修复4.机甲爆炸,需要对己方也产生伤害

This commit is contained in:
aozhiwei 2021-05-25 13:26:13 +08:00
parent 57e999aea9
commit 6e8de7d692
3 changed files with 19 additions and 4 deletions

View File

@ -318,7 +318,7 @@ void Car::Explosion(int team_id)
return; return;
} }
std::set<Creature*> objects; std::set<Creature*> objects;
TraverseProperTargets TraverseProperTargetsNoTeammate
( (
[this, &objects, team_id] (Creature* c, bool& stop) [this, &objects, team_id] (Creature* c, bool& stop)
{ {

View File

@ -1087,7 +1087,7 @@ void Creature::ResetAction()
need_sync_active_player = true; need_sync_active_player = true;
} }
bool Creature::IsProperTarget(Creature* target) bool Creature::IsProperTarget(Creature* target, bool no_teammate)
{ {
if (target->dead) { if (target->dead) {
return false; return false;
@ -1095,7 +1095,7 @@ bool Creature::IsProperTarget(Creature* target)
if (a8::HasBitFlag(target->status, HS_Disable)) { if (a8::HasBitFlag(target->status, HS_Disable)) {
return false; return false;
} }
if (team_id == target->team_id) { if (!no_teammate && team_id == target->team_id) {
return false; return false;
} }
if (room->GetRoomMode() == kZombieMode && GetRace() == target->GetRace()) { if (room->GetRoomMode() == kZombieMode && GetRace() == target->GetRace()) {
@ -1133,6 +1133,20 @@ void Creature::TraverseProperTargets(std::function<void (Creature*, bool&)> func
callback); callback);
} }
void Creature::TraverseProperTargetsNoTeammate(std::function<void (Creature*, bool&)> 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() void Creature::UpdatePoisoning()
{ {
if (dead) { if (dead) {

View File

@ -87,7 +87,7 @@ class Creature : public MoveableEntity
void ClearPassiveSkill(); void ClearPassiveSkill();
void UpdatePoisoning(); void UpdatePoisoning();
bool IsProperTarget(Creature* target); bool IsProperTarget(Creature* target, bool no_teammate = false);
bool IsEnemy(Creature* target); bool IsEnemy(Creature* target);
virtual void SelectSkillTargets(Skill* skill, virtual void SelectSkillTargets(Skill* skill,
const a8::Vec2& target_pos, const a8::Vec2& target_pos,
@ -125,6 +125,7 @@ class Creature : public MoveableEntity
int GetActionTargetId() { return action_target_id; } int GetActionTargetId() { return action_target_id; }
void TraverseProperTargets(std::function<void (Creature*, bool&)> func); void TraverseProperTargets(std::function<void (Creature*, bool&)> func);
void TraverseProperTargetsNoTeammate(std::function<void (Creature*, bool&)> func);
CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; }; CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; };
void Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance); void Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance);