From 897ee35b4e2558bf871f4445c13986c082811e48 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 17 Dec 2023 17:16:38 +0800 Subject: [PATCH] crash fix 4 --- src/strategy/actions/AttackAction.cpp | 5 ++++- src/strategy/values/EnemyPlayerValue.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/strategy/actions/AttackAction.cpp b/src/strategy/actions/AttackAction.cpp index 9c905f17..08ad2e2d 100644 --- a/src/strategy/actions/AttackAction.cpp +++ b/src/strategy/actions/AttackAction.cpp @@ -15,7 +15,10 @@ bool AttackAction::Execute(Event event) Unit* target = GetTarget(); if (!target) return false; - + + if (!target->IsInWorld()) { + return false; + } return Attack(target); } diff --git a/src/strategy/values/EnemyPlayerValue.h b/src/strategy/values/EnemyPlayerValue.h index bba9a0a4..058d7db8 100644 --- a/src/strategy/values/EnemyPlayerValue.h +++ b/src/strategy/values/EnemyPlayerValue.h @@ -24,7 +24,7 @@ class NearestEnemyPlayersValue : public PossibleTargetsValue class EnemyPlayerValue : public UnitCalculatedValue { public: - EnemyPlayerValue(PlayerbotAI* botAI, std::string const name = "enemy player") : UnitCalculatedValue(botAI, name, 5 * 1000) { } + EnemyPlayerValue(PlayerbotAI* botAI, std::string const name = "enemy player") : UnitCalculatedValue(botAI, name, 1 * 1000) { } Unit* Calculate() override;