refactor(Core/Unit): PC&NPC Immunity (#11986)

* initial

* refactor(Core/Unit): PC & NPC Immunities

Cherry-pick TC: 74af880217

Co-authored-by: Treeston <treeston.nmoc@gmail.com>

* fix builds error

Cherry-pick TC: 74af880217

Co-authored-by: Treeston <treeston.nmoc@gmail.com>

* Fix nef combat, and replace SetFlag by SetUnitFlag

* fix combat with jedoga

Co-authored-by: Treeston <treeston.nmoc@gmail.com>
This commit is contained in:
Maelthyr
2022-06-18 14:16:45 +02:00
committed by GitHub
parent 4bc99f8070
commit d928d8d96a
88 changed files with 450 additions and 328 deletions

View File

@@ -1773,7 +1773,7 @@ class spell_gen_creature_permanent_feign_death : public AuraScript
Unit* target = GetTarget();
target->SetDynamicFlag(UNIT_DYNFLAG_DEAD);
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
target->SetImmuneToAll(true);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_PASSIVE);
@@ -1784,7 +1784,7 @@ class spell_gen_creature_permanent_feign_death : public AuraScript
Unit* target = GetTarget();
target->RemoveDynamicFlag(UNIT_DYNFLAG_DEAD);
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
target->SetImmuneToAll(false);
if (target->GetTypeId() == TYPEID_UNIT)
target->ToCreature()->SetReactState(REACT_AGGRESSIVE);

View File

@@ -1100,7 +1100,7 @@ class spell_item_draenic_pale_ale : public SpellScript
summon->SetOwnerGUID(GetCaster()->GetGUID());
summon->SetFaction(GetCaster()->GetFaction());
summon->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
summon->SetImmuneToAll(true);
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->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC))
if (unit->IsImmuneToPC())
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->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
target->SetImmuneToPC(true);
target->SetControlled(true, UNIT_STATE_STUNNED);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
GetTarget()->SetImmuneToPC(false);
}
void Register() override