From 63048f24053270285f6b27fe4b2b320e175072e0 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 5 Sep 2023 09:58:21 +0800 Subject: [PATCH] fix debuff trigger --- src/strategy/actions/GenericSpellActions.cpp | 6 +++++- src/strategy/generic/CastTimeStrategy.cpp | 7 ++++++- src/strategy/triggers/GenericTriggers.cpp | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/strategy/actions/GenericSpellActions.cpp b/src/strategy/actions/GenericSpellActions.cpp index ec12a965..377f29d9 100644 --- a/src/strategy/actions/GenericSpellActions.cpp +++ b/src/strategy/actions/GenericSpellActions.cpp @@ -294,5 +294,9 @@ Value* BuffOnMainTankAction::GetTargetValue() bool CastDebuffSpellAction::isUseful() { - return CastAuraSpellAction::isUseful() && GetTarget() && (GetTarget()->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; + Unit* target = GetTarget(); + if (!target || !target->IsAlive() || !target->IsInWorld()) { + return false; + } + return CastAuraSpellAction::isUseful() && (target->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; } \ No newline at end of file diff --git a/src/strategy/generic/CastTimeStrategy.cpp b/src/strategy/generic/CastTimeStrategy.cpp index 9e362370..e7360731 100644 --- a/src/strategy/generic/CastTimeStrategy.cpp +++ b/src/strategy/generic/CastTimeStrategy.cpp @@ -38,7 +38,12 @@ float CastTimeMultiplier::GetValue(Action* action) castTime += duration; } - if (castTime > (1000 * action->GetTarget()->GetHealth() / AI_VALUE(float, "expected group dps"))) { + Unit* target = action->GetTarget(); + if (!target || !target->IsAlive() || !target->IsInWorld()) { + return false; + } + + if (castTime > (1000 * target->GetHealth() / AI_VALUE(float, "expected group dps"))) { return 0.0f; } } diff --git a/src/strategy/triggers/GenericTriggers.cpp b/src/strategy/triggers/GenericTriggers.cpp index d8290760..be35d17b 100644 --- a/src/strategy/triggers/GenericTriggers.cpp +++ b/src/strategy/triggers/GenericTriggers.cpp @@ -207,7 +207,11 @@ bool TargetInSightTrigger::IsActive() bool DebuffTrigger::IsActive() { - return BuffTrigger::IsActive() && GetTarget() && (GetTarget()->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; + Unit* target = GetTarget(); + if (!target || !target->IsAlive() || !target->IsInWorld()) { + return false; + } + return BuffTrigger::IsActive() && (target->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; } bool DebuffOnBossTrigger::IsActive()