diff options
author | skyleo <skyleo@skyleo.de> | 2019-10-10 03:13:14 +0200 |
---|---|---|
committer | skyleo <skyleo@skyleo.de> | 2019-10-10 03:34:02 +0200 |
commit | b2e1879cc22faeda1511108e912d915c90d30b6e (patch) | |
tree | d32e795807833167b6d7d5c16f8c505f4bb8faee /src/map | |
parent | 6209e88b2e14f67f9b3fd47084382c7b071ed4ed (diff) | |
download | hercules-b2e1879cc22faeda1511108e912d915c90d30b6e.tar.gz hercules-b2e1879cc22faeda1511108e912d915c90d30b6e.tar.bz2 hercules-b2e1879cc22faeda1511108e912d915c90d30b6e.tar.xz hercules-b2e1879cc22faeda1511108e912d915c90d30b6e.zip |
Fix Chaotic Blessings never healing the enemy
It has a chance to roll for enemy and heal the enemy,
While calculating the chance was correct,
it was getting the enemy with battle->check_target.
But unit->stop_attack has been called before in
unit->skilluse_id2, making battle->check_target return NULL at that
point, since it has no attack target anymore.
So it defaulted to heal the Homunculus itself, instead of the
enemy.
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/skill.c | 16 | ||||
-rw-r--r-- | src/map/unit.c | 6 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/map/skill.c b/src/map/skill.c index b5f84679e..fc5fc013e 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -8758,12 +8758,20 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * int r = rnd()%100; int target = (skill_lv-1)%5; int hp; - if(r<per[target][0]) //Self + if (r < per[target][0]) { //Self bl = src; - else if(r<per[target][1]) //Master + } else if (r < per[target][1]) { //Master bl = battle->get_master(src); - else //Enemy - bl = map->id2bl(battle->get_target(src)); + } else if ((per[target][1] - per[target][0]) < per[target][0] + && bl == battle->get_master(src)) { + /** + * Skill rolled for enemy, but there's nothing the Homunculus is attacking. + * So bl has been set to its master in unit->skilluse_id2. + * If it's more likely that it will heal itself, + * we let it heal itself. + */ + bl = src; + } if (!bl) bl = src; hp = skill->calc_heal(src, bl, skill_id, 1+rnd()%skill_lv, true); diff --git a/src/map/unit.c b/src/map/unit.c index 9cbef3091..1e9433eaf 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1328,6 +1328,12 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill if (src->type==BL_HOM) switch(skill_id) { //Homun-auto-target skills. + case HVAN_CHAOTIC: + target_id = ud->target; // Choose attack target for now + target = map->id2bl(target_id); + if (target != NULL) + break; + FALLTHROUGH // Attacking nothing, choose master as default target instead case HLIF_HEAL: case HLIF_AVOID: case HAMI_DEFENCE: |