From 3028c871e306ac2c137585f1afd84e2b0518b9a1 Mon Sep 17 00:00:00 2001 From: Cydh Ramdh Date: Mon, 30 Mar 2015 12:54:09 +0700 Subject: [PATCH] Added monster config as https://rathena.org/board/topic/101136-toggle-for-loot-search-type-closest-vs-random/ * `monster_loot_search_type` default is `1` for official behavior in e6caa95, and `0` for old Athena style -closest- item. Signed-off-by: Cydh Ramdh --- conf/battle/monster.conf | 5 +++++ src/map/battle.c | 1 + src/map/battle.h | 1 + src/map/mob.c | 9 ++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/conf/battle/monster.conf b/conf/battle/monster.conf index def1d63ee8..edc893f463 100644 --- a/conf/battle/monster.conf +++ b/conf/battle/monster.conf @@ -99,6 +99,11 @@ monster_damage_delay_rate: 100 // 1 = Monster will not consume the item. monster_loot_type: 0 +// How does monster search floor item to loot? +// 0: Closest (old Athena style) +// 1: Oldest in range (Official) +monster_loot_search_type: 1 + // Chance of mob casting a skill (Note 2) // Higher rates lead to 100% mob skill usage with no/few normal attacks. // Set to 0 to disable mob skills. diff --git a/src/map/battle.c b/src/map/battle.c index 99d0d8ce03..6532959907 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7982,6 +7982,7 @@ static const struct _battle_data { { "pet_ignore_infinite_def", &battle_config.pet_ignore_infinite_def, 0, 0, 1, }, { "homunculus_evo_intimacy_need", &battle_config.homunculus_evo_intimacy_need, 91100, 0, INT_MAX, }, { "homunculus_evo_intimacy_reset", &battle_config.homunculus_evo_intimacy_reset, 1000, 0, INT_MAX, }, + { "monster_loot_search_type", &battle_config.monster_loot_search_type, 1, 0, 1, }, }; #ifndef STATS_OPT_OUT diff --git a/src/map/battle.h b/src/map/battle.h index 859cdcfb42..eb1fd17eb1 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -587,6 +587,7 @@ extern struct Battle_Config int pet_ignore_infinite_def; // Makes fixed damage of petskillattack2 ignores infinite defense int homunculus_evo_intimacy_need; int homunculus_evo_intimacy_reset; + int monster_loot_search_type; } battle_config; void do_init_battle(void); diff --git a/src/map/mob.c b/src/map/mob.c index 36d7c3397d..2604654535 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1175,11 +1175,18 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) target = va_arg(ap,struct block_list**); dist = distance_bl(&md->bl, bl); - if (mob_can_reach(md,bl,dist+1, MSS_LOOT) && ((*target) == NULL || md->target_id > bl->id)) { + if (mob_can_reach(md,bl,dist+1, MSS_LOOT) && ( + (*target) == NULL || + (battle_config.monster_loot_search_type && md->target_id > bl->id) || + (!battle_config.monster_loot_search_type && !check_distance_bl(&md->bl, *target, dist)) // New target closer than previous one. + )) + { (*target) = bl; md->target_id = bl->id; md->min_chase = md->db->range3; } + else if (!battle_config.monster_loot_search_type) + mob_stop_walking(md, 1); // Stop walking immediately if item is no longer on the ground. return 0; }