feat(Core/Unit): New helpers for UnitFlag and UnitFlag2 (#11227)

This commit is contained in:
Kitzunu
2022-03-30 12:59:42 +02:00
committed by GitHub
parent 54c06eb72e
commit 856aed6fc6
243 changed files with 1205 additions and 1191 deletions

View File

@@ -682,7 +682,7 @@ class spell_dru_moonkin_form_passive : public AuraScript
void Absorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount)
{
// reduces all damage taken while Stunned in Moonkin Form
if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN))
if (GetTarget()->GetUnitFlags() & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN))
absorbAmount = CalculatePct(dmgInfo.GetDamage(), absorbPct);
}
@@ -749,7 +749,7 @@ class spell_dru_primal_tenacity : public AuraScript
void Absorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount)
{
// reduces all damage taken while Stunned in Cat Form
if (GetTarget()->GetShapeshiftForm() == FORM_CAT && GetTarget()->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN))
if (GetTarget()->GetShapeshiftForm() == FORM_CAT && GetTarget()->HasUnitFlag(UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN))
absorbAmount = CalculatePct(dmgInfo.GetDamage(), absorbPct);
}

View File

@@ -84,12 +84,12 @@ public:
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
_modelId = GetUnitOwner()->GetDisplayId();
_hasFlag = GetUnitOwner()->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
_hasFlag = GetUnitOwner()->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
for (uint8 i = 0; i < 3; ++i)
_itemId.at(i) = GetUnitOwner()->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i);
GetUnitOwner()->SetDisplayId(11686);
GetUnitOwner()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
GetUnitOwner()->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
for (uint8 i = 0; i < 3; ++i)
GetUnitOwner()->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, 0);
}
@@ -98,7 +98,7 @@ public:
{
GetUnitOwner()->SetDisplayId(_modelId);
if (!_hasFlag)
GetUnitOwner()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
GetUnitOwner()->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
for (uint8 i = 0; i < 3; ++i)
GetUnitOwner()->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, _itemId.at(i));
}
@@ -1803,8 +1803,8 @@ class spell_gen_creature_permanent_feign_death : public AuraScript
{
Unit* target = GetTarget();
target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_PASSIVE);
@@ -1814,8 +1814,8 @@ class spell_gen_creature_permanent_feign_death : public AuraScript
{
Unit* target = GetTarget();
target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_AGGRESSIVE);
@@ -2867,7 +2867,7 @@ class spell_gen_mounted_charge : public SpellScript
}
// If target isn't a training dummy there's a chance of failing the charge
if (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE) && roll_chance_f(12.5f))
if (!target->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE) && roll_chance_f(12.5f))
spellId = SPELL_CHARGE_MISS_EFFECT;
if (Unit* vehicle = GetCaster()->GetVehicleBase())

View File

@@ -593,7 +593,7 @@ class spell_hun_masters_call : public SpellScript
// Do a mini Spell::CheckCasterAuras on the pet, no other way of doing this
SpellCastResult result = SPELL_CAST_OK;
uint32 const unitflag = pet->GetUInt32Value(UNIT_FIELD_FLAGS);
uint32 const unitflag = pet->GetUnitFlags();
if (pet->GetCharmerGUID())
result = SPELL_FAILED_CHARMED;
else if (unitflag & UNIT_FLAG_STUNNED)

View File

@@ -1100,7 +1100,7 @@ class spell_item_draenic_pale_ale : public SpellScript
summon->SetOwnerGUID(GetCaster()->GetGUID());
summon->SetFaction(GetCaster()->GetFaction());
summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
summon->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
summon->SetReactState(REACT_PASSIVE);
summon->GetMotionMaster()->MoveFollow(GetCaster(), PET_FOLLOW_DIST, GetCaster()->GetAngle(summon), MOTION_SLOT_CONTROLLED);
GetSpell()->ExecuteLogEffectSummonObject(effIndex, summon);

View File

@@ -717,7 +717,7 @@ class spell_q11198_take_down_tethyr : public SpellScript
{
PreventHitDefaultEffect(effIndex);
if (Unit* unit = GetHitUnit())
if (unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
if (unit->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC))
return;
GetCaster()->CastCustomSpell(42576 /*SPELL_CANNON_BLAST*/, SPELLVALUE_BASE_POINT0, GetEffectValue(), GetCaster(), true);
}
@@ -1002,13 +1002,13 @@ class spell_q11396_11399_force_shield_arcane_purple_x3 : public AuraScript
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
target->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
target->SetControlled(true, UNIT_STATE_STUNNED);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
GetTarget()->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
}
void Register() override
@@ -1468,7 +1468,7 @@ class spell_symbol_of_life_dummy : public SpellScript
{
target->RemoveAurasDueToSpell(SPELL_PERMANENT_FEIGN_DEATH);
target->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
target->SetUInt32Value(UNIT_FIELD_FLAGS_2, 0);
target->ReplaceAllUnitFlags2(UNIT_FLAG2_NONE);
target->SetHealth(target->GetMaxHealth() / 2);
target->SetPower(POWER_MANA, uint32(target->GetMaxPower(POWER_MANA) * 0.75f));
}

View File

@@ -432,7 +432,7 @@ class spell_rog_nerves_of_steel : public AuraScript
void Absorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount)
{
// reduces all damage taken while stun or fear
if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_FLEEING) || (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN)))
if (GetTarget()->GetUnitFlags() & (UNIT_FLAG_FLEEING) || (GetTarget()->GetUnitFlags() & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN)))
absorbAmount = CalculatePct(dmgInfo.GetDamage(), absorbPct);
}

View File

@@ -413,7 +413,7 @@ class spell_sha_astral_shift : public AuraScript
void Absorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount)
{
// reduces all damage taken while stun, fear or silence
if (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_FLEEING | UNIT_FLAG_SILENCED) || (GetTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN)))
if (GetTarget()->GetUnitFlags() & (UNIT_FLAG_FLEEING | UNIT_FLAG_SILENCED) || (GetTarget()->GetUnitFlags() & (UNIT_FLAG_STUNNED) && GetTarget()->HasAuraWithMechanic(1 << MECHANIC_STUN)))
absorbAmount = CalculatePct(dmgInfo.GetDamage(), absorbPct);
}