feat(Unit/Misc): HasAnyAuras() HasAllAuras() HasAuras() (#21040)
This commit is contained in:
@@ -2419,7 +2419,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate, bool isLFGReward)
|
||||
// Favored experience increase START
|
||||
uint32 zone = GetZoneId();
|
||||
float favored_exp_mult = 0;
|
||||
if ((zone == 3483 || zone == 3562 || zone == 3836 || zone == 3713 || zone == 3714) && (HasAura(32096) || HasAura(32098)))
|
||||
if ((zone == 3483 || zone == 3562 || zone == 3836 || zone == 3713 || zone == 3714) && HasAnyAuras(32096 /*Thrallmar's Favor*/, 32098 /*Honor Hold's Favor*/))
|
||||
favored_exp_mult = 0.05f; // Thrallmar's Favor and Honor Hold's Favor
|
||||
|
||||
xp = uint32(xp * (1 + favored_exp_mult));
|
||||
|
||||
@@ -5695,6 +5695,29 @@ uint32 Unit::GetAuraCount(uint32 spellId) const
|
||||
return count;
|
||||
}
|
||||
|
||||
bool Unit::HasAuras(SearchMethod sm, std::vector<uint32>& spellIds) const
|
||||
{
|
||||
if (sm == SearchMethod::MatchAll)
|
||||
{
|
||||
for (auto const& spellId : spellIds)
|
||||
if (!HasAura(spellId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
else if (sm == SearchMethod::MatchAny)
|
||||
{
|
||||
for (auto const& spellId : spellIds)
|
||||
if (HasAura(spellId))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("entities.unit", "Unit::HasAuras using non-supported SearchMethod {}", sm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::HasAura(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask) const
|
||||
{
|
||||
if (GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask))
|
||||
|
||||
@@ -558,6 +558,12 @@ enum CommandStates : uint8
|
||||
COMMAND_ABANDON = 3
|
||||
};
|
||||
|
||||
enum class SearchMethod
|
||||
{
|
||||
MatchAll,
|
||||
MatchAny
|
||||
};
|
||||
|
||||
typedef std::list<Player*> SharedVisionList;
|
||||
|
||||
struct AttackPosition {
|
||||
@@ -1367,6 +1373,50 @@ public:
|
||||
|
||||
[[nodiscard]] bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const;
|
||||
[[nodiscard]] uint32 GetAuraCount(uint32 spellId) const;
|
||||
|
||||
/**
|
||||
* @brief Check if unit has ANY or ALL specified auras.
|
||||
*
|
||||
* @param sm The search method to use
|
||||
* - SearchMethod::MatchAll : The function checks for all of the spell id's on the unit.
|
||||
* - SearchMethod::MatchAny : The function checks for any of the spell id's on the unit.
|
||||
*
|
||||
* @param spellIds List of spell id's to check for on the unit.
|
||||
*
|
||||
* @return Returns true if the search method condition is met. Otherwise false.
|
||||
*/
|
||||
bool HasAuras(SearchMethod sm, std::vector<uint32>& spellIds) const;
|
||||
|
||||
/**
|
||||
* @brief Checks if the unit has ANY specified auras.
|
||||
*
|
||||
* @tparam Auras Can be any type convertible to uint32.
|
||||
* @param spellIds List of spell id's to check for on the unit.
|
||||
*
|
||||
* @return Returns true if the unit has ANY of the specified auras. Otherwise false.
|
||||
*/
|
||||
template <typename... Auras>
|
||||
bool HasAnyAuras(Auras... spellIds) const
|
||||
{
|
||||
std::vector<uint32> spellList = { static_cast<uint32>(spellIds)... };
|
||||
return HasAuras(SearchMethod::MatchAny, spellList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if the unit has ALL specified auras.
|
||||
*
|
||||
* @tparam Auras Can be any type convertible to uint32.
|
||||
* @param spellIds List of spell id's to check for on the unit.
|
||||
*
|
||||
* @return Returns true if the unit has ALL of the specified auras. Otherwise false.
|
||||
*/
|
||||
template <typename... Auras>
|
||||
bool HasAllAuras(Auras... spellIds) const
|
||||
{
|
||||
std::vector<uint32> spellList = { static_cast<uint32>(spellIds)... };
|
||||
return HasAuras(SearchMethod::MatchAll, spellList);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool HasAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
|
||||
[[nodiscard]] bool HasAuraType(AuraType auraType) const;
|
||||
[[nodiscard]] bool HasAuraTypeWithCaster(AuraType auratype, ObjectGuid caster) const;
|
||||
|
||||
+1
-4
@@ -188,11 +188,8 @@ public:
|
||||
{
|
||||
DoCast(player, afflictionSpellID, true);
|
||||
|
||||
if (player->HasAura(SPELL_BROODAF_BLUE) && player->HasAura(SPELL_BROODAF_BLACK) && player->HasAura(SPELL_BROODAF_RED) &&
|
||||
player->HasAura(SPELL_BROODAF_BRONZE) && player->HasAura(SPELL_BROODAF_GREEN))
|
||||
{
|
||||
if (player->HasAllAuras(SPELL_BROODAF_BLUE, SPELL_BROODAF_BLACK, SPELL_BROODAF_RED, SPELL_BROODAF_BRONZE, SPELL_BROODAF_GREEN))
|
||||
DoCast(player, SPELL_CHROMATIC_MUT_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
events.ScheduleEvent(EVENT_AFFLICTION, 10s);
|
||||
|
||||
@@ -447,7 +447,7 @@ class spell_mutate_explode_bug : public SpellScript
|
||||
if (target->GetEntry() != NPC_QIRAJI_SCARAB && target->GetEntry() != NPC_QIRAJI_SCORPION)
|
||||
return true;
|
||||
if (Creature const* creature = target->ToCreature())
|
||||
if (creature->HasAura(SPELL_EXPLODE_BUG) || creature->HasAura(SPELL_MUTATE_BUG))
|
||||
if (creature->HasAnyAuras(SPELL_EXPLODE_BUG, SPELL_MUTATE_BUG))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -473,7 +473,7 @@ public:
|
||||
{
|
||||
if (spell->Id == SPELL_KODO_KOMBO_ITEM)
|
||||
{
|
||||
if (!(caster->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) || me->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
|
||||
if (!caster->HasAnyAuras(SPELL_KODO_KOMBO_PLAYER_BUFF, SPELL_KODO_KOMBO_DESPAWN_BUFF)
|
||||
&& (me->GetEntry() == NPC_AGED_KODO || me->GetEntry() == NPC_DYING_KODO || me->GetEntry() == NPC_ANCIENT_KODO))
|
||||
{
|
||||
me->UpdateEntry(NPC_TAMED_KODO, nullptr, false);
|
||||
@@ -494,7 +494,7 @@ public:
|
||||
|
||||
bool OnGossipHello(Player* player, Creature* creature) override
|
||||
{
|
||||
if (player->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) && creature->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
|
||||
if (player->HasAllAuras(SPELL_KODO_KOMBO_PLAYER_BUFF, SPELL_KODO_KOMBO_DESPAWN_BUFF))
|
||||
{
|
||||
player->TalkedToCreature(creature->GetEntry(), ObjectGuid::Empty);
|
||||
player->RemoveAurasDueToSpell(SPELL_KODO_KOMBO_PLAYER_BUFF);
|
||||
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
if (target->HasAura(SPELL_FROST_IMBUED_BLADE))
|
||||
return false;
|
||||
|
||||
if (target->IsImmunedToDamageOrSchool(SPELL_SCHOOL_MASK_ALL) || target->HasAura(SPELL_ICE_TOMB_UNTARGETABLE) || target->HasAura(SPELL_ICE_TOMB_DAMAGE) || target->HasAura(SPELL_TANK_MARKER_AURA) || target->HasSpiritOfRedemptionAura())
|
||||
if (target->IsImmunedToDamageOrSchool(SPELL_SCHOOL_MASK_ALL) || target->HasAnyAuras(SPELL_ICE_TOMB_UNTARGETABLE, SPELL_ICE_TOMB_DAMAGE, SPELL_TANK_MARKER_AURA) || target->HasSpiritOfRedemptionAura())
|
||||
return false;
|
||||
|
||||
return target != _source->GetVictim();
|
||||
|
||||
@@ -451,7 +451,7 @@ public:
|
||||
return false;
|
||||
if (_source->GetExactDist(target) > 100.0f)
|
||||
return false;
|
||||
if (target->HasAura(SPELL_HARVEST_SOUL_VALKYR) || target->HasAura(SPELL_VALKYR_TARGET_SEARCH))
|
||||
if (target->HasAnyAuras(SPELL_HARVEST_SOUL_VALKYR, SPELL_VALKYR_TARGET_SEARCH))
|
||||
return false;
|
||||
if (!_source->IsWithinLOSInMap(target))
|
||||
return false;
|
||||
@@ -603,7 +603,7 @@ public:
|
||||
{
|
||||
if (!unit || !unit->IsPlayer() || unit == _sourceObj || _sourceObj->GetVictim() == unit || !unit->isTargetableForAttack())
|
||||
return false;
|
||||
if (unit->HasAura(SPELL_PLAGUE_AVOIDANCE) || unit->HasAura(SPELL_BOSS_HITTIN_YA_AURA) || unit->HasAura(_notAura1) || unit->HasAura(_notAura2))
|
||||
if (unit->HasAnyAuras(SPELL_PLAGUE_AVOIDANCE, SPELL_BOSS_HITTIN_YA_AURA, _notAura1, _notAura2))
|
||||
return false;
|
||||
if (!_sourceObj->IsWithinLOSInMap(unit))
|
||||
return false;
|
||||
|
||||
@@ -1835,7 +1835,7 @@ public:
|
||||
{
|
||||
if (InstanceScript* instance = creature->GetInstanceScript())
|
||||
if (instance->GetBossState(DATA_ROTFACE) == DONE && instance->GetBossState(DATA_FESTERGUT) == DONE && !creature->FindCurrentSpellBySpellId(SPELL_HARVEST_BLIGHT_SPECIMEN) && !creature->FindCurrentSpellBySpellId(SPELL_HARVEST_BLIGHT_SPECIMEN25))
|
||||
if (player->HasAura(SPELL_ORANGE_BLIGHT_RESIDUE) && player->HasAura(SPELL_GREEN_BLIGHT_RESIDUE))
|
||||
if (player->HasAllAuras(SPELL_ORANGE_BLIGHT_RESIDUE, SPELL_GREEN_BLIGHT_RESIDUE))
|
||||
creature->CastSpell(creature, SPELL_HARVEST_BLIGHT_SPECIMEN, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
if (me->HasAura(SPELL_PLANAR_SHIFT) || me->HasAura(SPELL_DRAKE_STOP_TIME))
|
||||
if (me->HasAnyAuras(SPELL_PLANAR_SHIFT, SPELL_DRAKE_STOP_TIME))
|
||||
return;
|
||||
|
||||
events.Update(diff);
|
||||
|
||||
@@ -1527,7 +1527,7 @@ public:
|
||||
|
||||
bool OnCheck(Player* player, Unit* /*target*/, uint32 /*criteria_id*/) override
|
||||
{
|
||||
return player && player->HasAura(SPELL_MAGE_TOASTY_FIRE_AURA) && player->HasAura(SPELL_DRUID_STARLIGHT_AREA_AURA) && player->HasAura(SPELL_SHAMAN_STORM_POWER_10);
|
||||
return player && player->HasAllAuras(SPELL_MAGE_TOASTY_FIRE_AURA, SPELL_DRUID_STARLIGHT_AREA_AURA, SPELL_SHAMAN_STORM_POWER_10);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1538,7 +1538,7 @@ public:
|
||||
|
||||
bool OnCheck(Player* player, Unit* /*target*/, uint32 /*criteria_id*/) override
|
||||
{
|
||||
return player && player->HasAura(SPELL_MAGE_TOASTY_FIRE_AURA) && player->HasAura(SPELL_DRUID_STARLIGHT_AREA_AURA) && player->HasAura(SPELL_SHAMAN_STORM_POWER_25);
|
||||
return player && player->HasAllAuras(SPELL_MAGE_TOASTY_FIRE_AURA, SPELL_DRUID_STARLIGHT_AREA_AURA, SPELL_SHAMAN_STORM_POWER_25);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -454,8 +454,7 @@ public:
|
||||
|
||||
if (!player || player->IsGameMaster() || player->IsBeingTeleported() || (player->GetPositionZ() > 670 && player->GetVehicle()) ||
|
||||
// If player has Disguise aura for quest A Meeting With The Magister or An Audience With The Arcanist, do not teleport it away but let it pass
|
||||
player->HasAura(SPELL_SUNREAVER_DISGUISE_FEMALE) || player->HasAura(SPELL_SUNREAVER_DISGUISE_MALE) ||
|
||||
player->HasAura(SPELL_SILVER_COVENANT_DISGUISE_FEMALE) || player->HasAura(SPELL_SILVER_COVENANT_DISGUISE_MALE))
|
||||
player->HasAnyAuras(SPELL_SUNREAVER_DISGUISE_FEMALE, SPELL_SUNREAVER_DISGUISE_MALE, SPELL_SILVER_COVENANT_DISGUISE_FEMALE, SPELL_SILVER_COVENANT_DISGUISE_MALE))
|
||||
return;
|
||||
|
||||
switch (me->GetEntry())
|
||||
|
||||
@@ -1496,7 +1496,7 @@ public:
|
||||
if (!who || !who->IsPlayer() || !me->IsHostileTo(who) || !me->isInBackInMap(who, 5.0f))
|
||||
return;
|
||||
|
||||
if (who->HasAura(SPELL_TRESPASSER_H) || who->HasAura(SPELL_TRESPASSER_A))
|
||||
if (who->HasAnyAuras(SPELL_TRESPASSER_H, SPELL_TRESPASSER_A))
|
||||
return;
|
||||
|
||||
if (who->ToPlayer()->GetTeamId() == TEAM_ALLIANCE)
|
||||
|
||||
@@ -416,7 +416,7 @@ public:
|
||||
|
||||
bool OnGossipHello(Player* player, GameObject* /*go*/) override
|
||||
{
|
||||
if (player->HasAura(SPELL_MIND_EXHAUSTION) || player->HasAura(SPELL_SHADOW_GRASP))
|
||||
if (player->HasAnyAuras(SPELL_MIND_EXHAUSTION, SPELL_SHADOW_GRASP))
|
||||
return true;
|
||||
|
||||
if (Creature* trigger = player->FindNearestCreature(NPC_HELLFIRE_RAID_TRIGGER, 10.0f))
|
||||
|
||||
@@ -1618,7 +1618,7 @@ class spell_dk_improved_blood_presence : public AuraScript
|
||||
void HandleEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
if ((target->HasAura(SPELL_DK_FROST_PRESENCE) || target->HasAura(SPELL_DK_UNHOLY_PRESENCE)) && !target->HasAura(SPELL_DK_IMPROVED_BLOOD_PRESENCE_TRIGGERED))
|
||||
if (target->HasAnyAuras(SPELL_DK_FROST_PRESENCE, SPELL_DK_UNHOLY_PRESENCE) && !target->HasAura(SPELL_DK_IMPROVED_BLOOD_PRESENCE_TRIGGERED))
|
||||
target->CastCustomSpell(SPELL_DK_IMPROVED_BLOOD_PRESENCE_TRIGGERED, SPELLVALUE_BASE_POINT1, aurEff->GetAmount(), target, true, nullptr, aurEff);
|
||||
}
|
||||
|
||||
@@ -1655,7 +1655,7 @@ class spell_dk_improved_frost_presence : public AuraScript
|
||||
void HandleEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
if ((target->HasAura(SPELL_DK_BLOOD_PRESENCE) || target->HasAura(SPELL_DK_UNHOLY_PRESENCE)) && !target->HasAura(SPELL_DK_FROST_PRESENCE_TRIGGERED))
|
||||
if (target->HasAnyAuras(SPELL_DK_BLOOD_PRESENCE, SPELL_DK_UNHOLY_PRESENCE) && !target->HasAura(SPELL_DK_FROST_PRESENCE_TRIGGERED))
|
||||
target->CastCustomSpell(SPELL_DK_FROST_PRESENCE_TRIGGERED, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), target, true, nullptr, aurEff);
|
||||
}
|
||||
|
||||
@@ -1700,7 +1700,7 @@ class spell_dk_improved_unholy_presence : public AuraScript
|
||||
target->CastCustomSpell(target, SPELL_DK_IMPROVED_UNHOLY_PRESENCE_TRIGGERED, &basePoints, &basePoints, &basePoints, true, nullptr, aurEff);
|
||||
}
|
||||
|
||||
if ((target->HasAura(SPELL_DK_BLOOD_PRESENCE) || target->HasAura(SPELL_DK_FROST_PRESENCE)) && !target->HasAura(SPELL_DK_UNHOLY_PRESENCE_TRIGGERED))
|
||||
if (target->HasAnyAuras(SPELL_DK_BLOOD_PRESENCE, SPELL_DK_FROST_PRESENCE) && !target->HasAura(SPELL_DK_UNHOLY_PRESENCE_TRIGGERED))
|
||||
target->CastCustomSpell(SPELL_DK_UNHOLY_PRESENCE_TRIGGERED, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), target, true, nullptr, aurEff);
|
||||
}
|
||||
|
||||
|
||||
@@ -969,7 +969,7 @@ class spell_pal_lay_on_hands : public SpellScript
|
||||
Unit* caster = GetCaster();
|
||||
if (Unit* target = GetExplTargetUnit())
|
||||
if (caster == target)
|
||||
if (target->HasAura(SPELL_PALADIN_FORBEARANCE) || target->HasAura(SPELL_PALADIN_AVENGING_WRATH_MARKER) || target->HasAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER))
|
||||
if (target->HasAnyAuras(SPELL_PALADIN_FORBEARANCE, SPELL_PALADIN_AVENGING_WRATH_MARKER, SPELL_PALADIN_IMMUNE_SHIELD_MARKER))
|
||||
return SPELL_FAILED_TARGET_AURASTATE;
|
||||
|
||||
// Xinef: Glyph of Divinity
|
||||
|
||||
@@ -267,7 +267,7 @@ class achievement_flirt_with_disaster_perf_check : public AchievementCriteriaScr
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
if (player->HasAura(AURA_PERFUME_FOREVER) || player->HasAura(AURA_PERFUME_ENCHANTRESS) || player->HasAura(AURA_PERFUME_VICTORY))
|
||||
if (player->HasAnyAuras(AURA_PERFUME_FOREVER, AURA_PERFUME_ENCHANTRESS, AURA_PERFUME_VICTORY))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -774,7 +774,7 @@ public:
|
||||
{
|
||||
// return those not tagged or already under the influence of Aura of Nature
|
||||
if (Unit* unit = object->ToUnit())
|
||||
return !(unit->HasAura(SPELL_MARK_OF_NATURE) && !unit->HasAura(SPELL_AURA_OF_NATURE));
|
||||
return !unit->HasAllAuras(SPELL_MARK_OF_NATURE, SPELL_AURA_OF_NATURE);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -999,14 +999,10 @@ public:
|
||||
void SpellHit(Unit* /*Caster*/, SpellInfo const* Spell) override
|
||||
{
|
||||
if (InNormalForm())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (me->HasAura(NELSON_SPELL_SOUL_FLAME) && me->HasAura(NELSON_WEAKNESS_FROST_TRAP))
|
||||
{
|
||||
if (me->HasAllAuras(NELSON_SPELL_SOUL_FLAME, NELSON_WEAKNESS_FROST_TRAP))
|
||||
me->RemoveAura(NELSON_SPELL_SOUL_FLAME);
|
||||
}
|
||||
|
||||
if (!me->HasAura(NELSON_SPELL_CRIPPLING_CLIP) && Spell->Id == NELSON_WEAKNESS_WING_CLIP)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user