From a75c3f0fb3fd71dbe587e0ee079cc419e68e435f Mon Sep 17 00:00:00 2001 From: wushin Date: Tue, 22 Sep 2015 22:44:24 -0500 Subject: Fix how attacked summons behave when master leaves closes #143 --- src/map/map.hpp | 1 + src/map/mob.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/map/map.hpp b/src/map/map.hpp index aea35b7..a247bb6 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -472,6 +472,7 @@ struct mob_data : block_list std::unique_ptr skilldelayup; // [MAX_MOBSKILL]; LevelElement def_ele; BlockId master_id; + BlockId last_master_id; int master_dist; int exclusion_src, exclusion_party; NpcEvent npc_event; diff --git a/src/map/mob.cpp b/src/map/mob.cpp index d037972..4fd682d 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -1845,6 +1845,18 @@ void mob_ai_sub_hard(dumb_ptr bl, tick_t tick) } md->state.master_check = 0; + // Processing of summoned monster attacked by owner + if (md->last_master_id && md->state.special_mob_ai) + { + if (((bl = map_id2bl(md->last_master_id)) != nullptr && md->bl_m != bl->bl_m) || (bl = map_id2bl(md->last_master_id)) == nullptr) + { + md->last_master_id = BlockId(); + md->state.special_mob_ai = 0; + md->mode = get_mob_db(md->mob_class).mode; + md->target_id = BlockId(); + md->attacked_id = BlockId(); + } + } // Processing of slave monster if (md->master_id && md->state.special_mob_ai == 0) mob_ai_sub_hard_slavemob(md, tick); @@ -2358,6 +2370,7 @@ int mob_damage(dumb_ptr src, dumb_ptr md, int damage, && bool(md->mode & MobMode::TURNS_AGAINST_BAD_MASTER)) { /* If the master hits a monster, have the monster turn against him */ + md->last_master_id = md->master_id; md->master_id = BlockId(); md->mode = MobMode::war; /* Regular war mode */ md->target_id = src->bl_id; -- cgit v1.2.3-60-g2f50