summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index d2d8727e3..dce084a23 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1173,13 +1173,15 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl, va_list ap)
battle->check_range(&md->bl,bl,md->db->range2)
) { //Pick closest target?
#ifdef ACTIVEPATHSEARCH
- struct walkpath_data wpd;
- if (!path->search(&wpd, &md->bl, md->bl.m, md->bl.x, md->bl.y, bl->x, bl->y, 0, CELL_CHKNOPASS)) // Count walk path cells
- return 0;
- //Standing monsters use range2, walking monsters use range3
- if ((md->ud.walktimer == INVALID_TIMER && wpd.path_len > md->db->range2)
- || (md->ud.walktimer != INVALID_TIMER && wpd.path_len > md->db->range3))
- return 0;
+ struct walkpath_data wpd;
+ bool is_standing = (md->ud.walktimer == INVALID_TIMER);
+ if (!path->search(&wpd, &md->bl, md->bl.m, md->bl.x, md->bl.y, bl->x, bl->y, 0, CELL_CHKNOPASS) // Count walk path cells
+ || (is_standing && wpd.path_len > md->db->range2) //Standing monsters use range2, walking monsters use range3
+ || (!is_standing && wpd.path_len > md->db->range3)) {
+ if (!check_distance_bl(&md->bl, bl, md->status.rhw.range)
+ || !path->search_long(NULL, &md->bl, md->bl.m, md->bl.x, md->bl.y, bl->x, bl->y, CELL_CHKWALL))
+ return 0;
+ }
#endif
(*target) = bl;
md->target_id=bl->id;
@@ -1362,10 +1364,10 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick)
) {
short x = bl->x, y = bl->y;
mob_stop_attack(md);
- const struct mob_data *m_md = BL_CCAST(BL_MOB, bl);
- nullpo_retr(0, m_md);
- if (map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1)
- && (battle_config.slave_chase_masters_chasetarget == 0 || !mob->is_in_battle_state(m_md))
+ const struct mob_data *m_md = BL_CCAST(BL_MOB, bl); // Can be NULL due to master being BL_PC
+ // If master is BL_MOB and in battle, lock & chase to master's target instead, unless configured not to.
+ if ((battle_config.slave_chase_masters_chasetarget == 0 || (m_md != NULL && !mob->is_in_battle_state(m_md)))
+ && map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1)
&& unit->walktoxy(&md->bl, x, y, 0))
return 1;
}
@@ -1378,13 +1380,12 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick)
//Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex]
if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) {
struct unit_data *ud = unit->bl2ud(bl);
- struct mob_data *m_md = BL_CAST(BL_MOB, bl);
+ struct mob_data *m_md = BL_CAST(BL_MOB, bl); // Can be NULL due to master being BL_PC
nullpo_retr(0, ud);
- nullpo_retr(0, m_md);
md->last_linktime = tick;
struct block_list *tbl = NULL;
- if (battle_config.slave_chase_masters_chasetarget == 1 && m_md->target_id != 0) { // possibly chasing something
+ if (battle_config.slave_chase_masters_chasetarget == 1 && m_md != NULL && m_md->target_id != 0) { // possibly chasing something
tbl = map->id2bl(m_md->target_id);
} else if (ud->target != 0 && ud->state.attack_continue != 0) {
tbl = map->id2bl(ud->target);
@@ -2235,6 +2236,14 @@ static void mob_log_damage(struct mob_data *md, struct block_list *src, int dama
md->dmglog[minpos].flag= flag;
md->dmglog[minpos].dmg = damage;
}
+#if (PACKETVER >= 20120404 && PACKETVER < 20131223)
+ // Show HP bar to all chars who hit the mob (fixes TF_STEAL not showing HP bar right away but only when target leaves/re-enters sight range)
+ if (battle_config.show_monster_hp_bar != 0 && (md->status.mode & MD_BOSS) == 0) {
+ struct map_session_data *sd = map->charid2sd(char_id);
+ if (sd != NULL && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE)) // check if in range
+ clif->monster_hp_bar(md, sd);
+ }
+#endif
}
return;
}
@@ -4105,10 +4114,8 @@ static bool mob_read_optdrops_group(struct config_setting_t *group, int n)
*/
static bool mob_read_optdrops_db(void)
{
- const char *filename = "option_drop_groups.conf"; // FIXME hardcoded name
-
char filepath[256];
- safesnprintf(filepath, sizeof(filepath), "%s/%s", map->db_path, filename);
+ libconfig->format_db_path("option_drop_groups.conf", filepath, sizeof(filepath));
struct config_t option_groups;
if (libconfig->load_file(&option_groups, filepath) == CONFIG_FALSE) {