diff --git a/server/gameserver/car.cc b/server/gameserver/car.cc index 6e26069..5d19b34 100644 --- a/server/gameserver/car.cc +++ b/server/gameserver/car.cc @@ -318,7 +318,7 @@ void Car::Explosion(int team_id) return; } std::set objects; - TraverseProperTargets + TraverseProperTargetsNoTeammate ( [this, &objects, team_id] (Creature* c, bool& stop) { diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index fbd6f5b..ba1c643 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1087,7 +1087,7 @@ void Creature::ResetAction() need_sync_active_player = true; } -bool Creature::IsProperTarget(Creature* target) +bool Creature::IsProperTarget(Creature* target, bool no_teammate) { if (target->dead) { return false; @@ -1095,7 +1095,7 @@ bool Creature::IsProperTarget(Creature* target) if (a8::HasBitFlag(target->status, HS_Disable)) { return false; } - if (team_id == target->team_id) { + if (!no_teammate && team_id == target->team_id) { return false; } if (room->GetRoomMode() == kZombieMode && GetRace() == target->GetRace()) { @@ -1133,6 +1133,20 @@ void Creature::TraverseProperTargets(std::function func callback); } +void Creature::TraverseProperTargetsNoTeammate(std::function func) +{ + auto callback = + [this, func] (Creature* c, bool& stop) + { + if (IsProperTarget(c, true)) { + func(c, stop); + } + }; + room->grid_service->TraverseCreatures(room->GetRoomIdx(), + GetGridList(), + callback); +} + void Creature::UpdatePoisoning() { if (dead) { diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 43680ee..ed2d3db 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -87,7 +87,7 @@ class Creature : public MoveableEntity void ClearPassiveSkill(); void UpdatePoisoning(); - bool IsProperTarget(Creature* target); + bool IsProperTarget(Creature* target, bool no_teammate = false); bool IsEnemy(Creature* target); virtual void SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, @@ -125,6 +125,7 @@ class Creature : public MoveableEntity int GetActionTargetId() { return action_target_id; } void TraverseProperTargets(std::function func); + void TraverseProperTargetsNoTeammate(std::function func); CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; }; void Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance);