瀏覽代碼

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 <house.bad@gmail.com>

Cydh Ramdh 10 年之前
父節點
當前提交
3028c871e3
共有 4 個文件被更改,包括 15 次插入1 次删除
  1. 5 0
      conf/battle/monster.conf
  2. 1 0
      src/map/battle.c
  3. 1 0
      src/map/battle.h
  4. 8 1
      src/map/mob.c

+ 5 - 0
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.

+ 1 - 0
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

+ 1 - 0
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);

+ 8 - 1
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;
 }