summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormeko <mekolat@users.noreply.github.com>2015-09-29 12:22:46 -0400
committermeko <mekolat@users.noreply.github.com>2015-09-29 12:22:46 -0400
commit25941d0fc34a420726c5bfb88e8f3c02a072369c (patch)
tree00a6a7869f50d204f7a268f6a4bbc39d222b69ca
parent1deb35fc806cd4d9b7d3656448884491c5abb429 (diff)
parenta75c3f0fb3fd71dbe587e0ee079cc419e68e435f (diff)
downloadtmwa-25941d0fc34a420726c5bfb88e8f3c02a072369c.tar.gz
tmwa-25941d0fc34a420726c5bfb88e8f3c02a072369c.tar.bz2
tmwa-25941d0fc34a420726c5bfb88e8f3c02a072369c.tar.xz
tmwa-25941d0fc34a420726c5bfb88e8f3c02a072369c.zip
Merge pull request #152 from wushin/summoned-mobs
Fix how attacked summons behave when master leaves
-rw-r--r--src/map/map.hpp1
-rw-r--r--src/map/mob.cpp13
2 files changed, 14 insertions, 0 deletions
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<tick_t[]> 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 9fe6b2d..ddfdeb6 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -1845,6 +1845,18 @@ void mob_ai_sub_hard(dumb_ptr<block_list> 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<block_list> src, dumb_ptr<mob_data> 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;