Check debuff owner on target

This commit is contained in:
郑佩茹
2023-03-21 13:25:41 -06:00
parent ab2420d89a
commit 5d17dfb2fe
5 changed files with 42 additions and 9 deletions

View File

@@ -1520,7 +1520,7 @@ bool IsRealAura(Player* bot, AuraEffect const* aurEff, Unit const* unit)
return false;
}
bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack)
bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, bool checkIsOwner, int maxAuraAmount)
{
if (!unit)
return false;
@@ -1531,6 +1531,8 @@ bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack)
wstrToLower(wnamepart);
int auraAmount = 0;
for (uint32 auraType = SPELL_AURA_BIND_SIGHT; auraType < TOTAL_AURAS; auraType++)
{
Unit::AuraEffectList const& auras = unit->GetAuraEffectsByType((AuraType)auraType);
@@ -1547,12 +1549,37 @@ bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack)
if (IsRealAura(bot, aurEff, unit))
{
if (checkIsOwner && aurEff)
{
if (aurEff->GetCasterGUID() != bot->GetGUID())
continue;
}
uint32 maxStackAmount = spellInfo->StackAmount;
return maxStack && maxStackAmount ? aurEff->GetBase()->GetStackAmount() >= maxStackAmount : true;
uint32 maxProcCharges = spellInfo->ProcCharges;
if (maxStack)
{
if (maxStackAmount && aurEff->GetBase()->GetStackAmount() >= maxStackAmount)
auraAmount++;
if (maxProcCharges && aurEff->GetBase()->GetCharges() >= maxProcCharges)
auraAmount++;
}
auraAmount++;
if (maxAuraAmount < 0)
return auraAmount > 0;
}
}
}
if (maxAuraAmount >= 0)
{
return auraAmount == maxAuraAmount || (auraAmount > 0 && auraAmount <= maxAuraAmount);
}
return false;
}