Unholy dk

This commit is contained in:
Yunfan Li
2024-09-06 20:29:56 +08:00
parent 593b30bbb0
commit f20d3aea6c
13 changed files with 98 additions and 50 deletions

View File

@@ -162,8 +162,14 @@ bool CastMeleeDebuffSpellAction::isUseful()
bool CastAuraSpellAction::isUseful()
{
return GetTarget() && (GetTarget() != nullptr) && CastSpellAction::isUseful() &&
!botAI->HasAura(spell, GetTarget(), false, isOwner);
if (!GetTarget() || !CastSpellAction::isUseful())
return false;
Aura* aura = botAI->GetAura(spell, GetTarget(), isOwner, checkDuration);
if (!aura)
return true;
if (beforeDuration && aura->GetDuration() < beforeDuration)
return true;
return false;
}
CastEnchantItemAction::CastEnchantItemAction(PlayerbotAI* botAI, std::string const spell)
@@ -251,8 +257,8 @@ Value<Unit*>* CastDebuffSpellOnMeleeAttackerAction::GetTargetValue()
return context->GetValue<Unit*>("melee attacker without aura", spell);
}
CastBuffSpellAction::CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner)
: CastAuraSpellAction(botAI, spell, checkIsOwner)
CastBuffSpellAction::CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner, uint32 beforeDuration)
: CastAuraSpellAction(botAI, spell, checkIsOwner, false, beforeDuration)
{
range = botAI->GetRange("spell");
}

View File

@@ -37,16 +37,20 @@ protected:
class CastAuraSpellAction : public CastSpellAction
{
public:
CastAuraSpellAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = false)
CastAuraSpellAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = false, bool checkDuration = false, uint32 beforeDuration = 0)
: CastSpellAction(botAI, spell)
{
this->isOwner = isOwner;
this->beforeDuration = beforeDuration;
this->checkDuration = checkDuration;
}
bool isUseful() override;
protected:
bool isOwner;
bool checkDuration;
uint32 beforeDuration;
};
class CastMeleeSpellAction : public CastSpellAction
@@ -107,7 +111,7 @@ public:
class CastBuffSpellAction : public CastAuraSpellAction
{
public:
CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = false);
CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = false, uint32 beforeDuration = 0);
std::string const GetTargetName() override { return "self target"; }
};