diff options
Diffstat (limited to 'src/map/mob.cpp')
-rw-r--r-- | src/map/mob.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 0da946a..1614fe5 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -1152,6 +1152,7 @@ int mob_spawn(BlockId id) md->stats[mob_stat::SPEED] = get_mob_db(md->mob_class).speed.count(); md->def_ele = get_mob_db(md->mob_class).element; md->master_id = BlockId(); + md->parent_id = BlockId(); md->master_dist = 0; md->state.state = MS::IDLE; @@ -1573,13 +1574,13 @@ int mob_ai_sub_hard_slavemob(dumb_ptr<mob_data> md, tick_t tick) nullpo_retz(md); - if ((bl = map_id2bl(md->master_id)) != nullptr) + if ((bl = map_id2bl(md->parent_id)) != nullptr) mmd = bl->is_mob(); mode = get_mob_db(md->mob_class).mode; // It is not main monster/leader. - if (!mmd || mmd->bl_type != BL::MOB || mmd->bl_id != md->master_id) + if (!mmd || mmd->bl_type != BL::MOB || mmd->bl_id != md->parent_id) return 0; // Since it is in the map on which the master is not, teleport is carried out and it pursues. @@ -1861,6 +1862,7 @@ void mob_ai_sub_hard(dumb_ptr<block_list> bl, tick_t tick) 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->parent_id = BlockId(); md->state.special_mob_ai = 0; md->mode = get_mob_db(md->mob_class).mode; md->target_id = BlockId(); @@ -1868,7 +1870,7 @@ void mob_ai_sub_hard(dumb_ptr<block_list> bl, tick_t tick) } } // Processing of slave monster - if (md->master_id && md->state.special_mob_ai == 0) + if (md->parent_id && md->state.special_mob_ai == 0) mob_ai_sub_hard_slavemob(md, tick); // アクティヴモンスターの策敵 (?? of a bitter taste TIVU monster) @@ -2071,7 +2073,7 @@ void mob_ai_sub_hard(dumb_ptr<block_list> bl, tick_t tick) // mobs that are not slaves can random-walk if (bool(mode & MobMode::CAN_MOVE) && mob_can_move(md) - && (!md->master_id || md->state.special_mob_ai + && (!md->parent_id || md->state.special_mob_ai || md->master_dist > 10)) { // if walktime is more than 7 seconds in the future, @@ -2162,7 +2164,7 @@ void mob_ai_sub_lazy(dumb_ptr<block_list> bl, tick_t tick) // MOB which is not not the summons MOB but BOSS, either sometimes reboils. else if (random_::chance(MOB_LAZYWARPPERC) && md->spawn.x0 <= 0 - && md->master_id + && md->parent_id && !bool(get_mob_db(md->mob_class).mode & MobMode::BOSS)) mob_spawn(md->bl_id); @@ -2174,7 +2176,7 @@ void mob_ai_sub_lazy(dumb_ptr<block_list> bl, tick_t tick) // MOB which is not BOSS which is not Summons MOB, either -- a case -- sometimes -- leaping if (random_::chance(MOB_LAZYWARPPERC) && md->spawn.x0 <= 0 - && md->master_id + && md->parent_id && !bool(get_mob_db(md->mob_class).mode & MobMode::BOSS)) mob_warp(md, nullptr, -1, -1, BeingRemoveWhy::NEGATIVE1); } @@ -2334,7 +2336,7 @@ void mob_deleteslave_sub(dumb_ptr<block_list> bl, BlockId id) nullpo_retv(bl); md = bl->is_mob(); - if (md->master_id && md->master_id == id) + if (md->parent_id && md->parent_id == id) mob_damage(nullptr, md, md->hp, 1); } @@ -2381,6 +2383,7 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage, { /* If the master hits a monster, have the monster turn against him */ md->last_master_id = md->master_id; + //md->parent_id = BlockId(); md->master_id = BlockId(); md->mode = MobMode::war; /* Regular war mode */ md->target_id = src->bl_id; @@ -2757,7 +2760,7 @@ void mob_warpslave_sub(dumb_ptr<block_list> bl, BlockId id, int x, int y) { dumb_ptr<mob_data> md = bl->is_mob(); - if (md->master_id == id) + if (md->parent_id == id) { mob_warp(md, nullptr, x, y, BeingRemoveWhy::QUIT); } @@ -2873,7 +2876,7 @@ void mob_countslave_sub(dumb_ptr<block_list> bl, BlockId id, int *c) nullpo_retv(bl); md = bl->is_mob(); - if (md->master_id == id) + if (md->parent_id == id) (*c)++; } @@ -2969,8 +2972,10 @@ int mob_summonslave(dumb_ptr<mob_data> md2, int *value_, int amount, int flag) map_addiddb(md); mob_spawn(md->bl_id); - if (flag) - md->master_id = md2->bl_id; + if (flag) { + md->master_id = md2->master_id; // tell the subslave who actually owns them + md->parent_id = md2->bl_id; // tell the subslave who spawned them + } } } return 0; @@ -3292,7 +3297,7 @@ int mobskill_use(dumb_ptr<mob_data> md, tick_t tick, if (battle_config.mob_skill_use == 0 || md->skilltimer) return 0; - if (md->state.special_mob_ai) + if (md->state.special_mob_ai && md->parent_id) return 0; for (mob_skill& msii : ms) |