diff options
Diffstat (limited to 'src/map/mob.c')
-rw-r--r-- | src/map/mob.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 784bb5a07..ef47d6b70 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1620,7 +1620,16 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { if(tbl->type == BL_PC) mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus) - unit->attack(&md->bl,tbl->id,1); + + if(!(mode&MD_RANDOMTARGET)) + unit->attack(&md->bl,tbl->id,1); + else { // Attack once and find new random target + int search_size = (view_range < md->status.rhw.range) ? view_range : md->status.rhw.range; + unit->attack(&md->bl,tbl->id,0); + tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), search_size); + md->target_id = tbl->id; + md->min_chase = md->db->range3; + } return true; } @@ -3073,6 +3082,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { struct block_list *bl; struct mob_data *fmd = NULL; int i,j,n; + short skill_target; nullpo_ret(md); nullpo_ret(ms = md->db->skill); @@ -3171,10 +3181,12 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { if (!flag) continue; //Skill requisite failed to be fulfilled. + //Execute skill + skill_target = (md->db->status.mode&MD_RANDOMTARGET)? MST_RANDOM : ms[i].target; if (skill->get_casttype(ms[i].skill_id) == CAST_GROUND) {//Ground skill. short x, y; - switch (ms[i].target) { + switch (skill_target) { case MST_RANDOM: //Pick a random enemy within skill range. bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv)); @@ -3204,10 +3216,10 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { x = bl->x; y = bl->y; // Look for an area to cast the spell around... - if (ms[i].target >= MST_AROUND1 || ms[i].target >= MST_AROUND5) { - j = ms[i].target >= MST_AROUND1? - (ms[i].target-MST_AROUND1) +1: - (ms[i].target-MST_AROUND5) +1; + if (skill_target >= MST_AROUND1 || skill_target >= MST_AROUND5) { + j = skill_target >= MST_AROUND1? + (skill_target-MST_AROUND1) +1: + (skill_target-MST_AROUND5) +1; map->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3); } md->skill_idx = i; @@ -3220,7 +3232,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { } } else { //Targetted skill - switch (ms[i].target) { + switch (skill_target) { case MST_RANDOM: //Pick a random enemy within skill range. bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv)); |