Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-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>
  • Loading branch information
cydh committed Mar 30, 2015
1 parent cbdc012 commit 3028c87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions conf/battle/monster.conf
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/map/battle.c
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/map/battle.h
Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion src/map/mob.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit 3028c87

Please sign in to comment.