summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwushin <pasekei@gmail.com>2015-09-22 22:44:24 -0500
committerwushin <pasekei@gmail.com>2015-09-22 22:44:24 -0500
commita75c3f0fb3fd71dbe587e0ee079cc419e68e435f (patch)
treea52aba67e67984fd987496af83c9f78e8736854b /src
parent5dac6c5ff0f1e2883ce923dfe2f70b638c2a4118 (diff)
downloadtmwa-a75c3f0fb3fd71dbe587e0ee079cc419e68e435f.tar.gz
tmwa-a75c3f0fb3fd71dbe587e0ee079cc419e68e435f.tar.bz2
tmwa-a75c3f0fb3fd71dbe587e0ee079cc419e68e435f.tar.xz
tmwa-a75c3f0fb3fd71dbe587e0ee079cc419e68e435f.zip
Fix how attacked summons behave when master leaves
closes #143
Diffstat (limited to 'src')
-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 d037972..4fd682d 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;