Scripts/Spells: Feign Death & 'prevent emotes flag' spell scripts

Port From (https://github.com/TrinityCore/TrinityCore/commit/43f63d76315ec251cc04d70ec6ee811aef9d1176)
This commit is contained in:
hondacrx
2022-05-26 16:08:46 -04:00
parent a4c27e574a
commit 36bc8e6d31
+133 -33
View File
@@ -1300,38 +1300,6 @@ namespace Scripts.Spells.Generic
} }
} }
[Script]
class spell_gen_creature_permanent_feign_death : AuraScript
{
void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.AddDynamicFlag(UnitDynFlags.Dead);
target.AddUnitFlag2(UnitFlags2.FeignDeath);
Creature creature = target.ToCreature();
if (creature != null)
creature.SetReactState(ReactStates.Passive);
}
void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.RemoveDynamicFlag(UnitDynFlags.Dead);
target.RemoveUnitFlag2(UnitFlags2.FeignDeath);
Creature creature = target.ToCreature();
if (creature != null)
creature.InitializeReactState();
}
public override void Register()
{
OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
}
}
[Script("spell_gen_sunreaver_disguise")] [Script("spell_gen_sunreaver_disguise")]
[Script("spell_gen_silver_covenant_disguise")] [Script("spell_gen_silver_covenant_disguise")]
class spell_gen_dalaran_disguise : SpellScript class spell_gen_dalaran_disguise : SpellScript
@@ -1700,6 +1668,116 @@ namespace Scripts.Spells.Generic
} }
} }
/*
* There are only 3 possible flags Feign Death auras can apply: UNIT_DYNFLAG_DEAD, UnitFlags2.FeignDeath
* and UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT. Some auras can apply only 2 flags
*
* spell_gen_feign_death_all_flags applies all 3 flags
* spell_gen_feign_death_no_dyn_flag applies no UNIT_DYNFLAG_DEAD (does not make the creature appear dead)
* spell_gen_feign_death_no_prevent_emotes applies no UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT
*
* REACT_PASSIVE should be handled directly in scripts since not all creatures should be passive. Otherwise
* creature will be not able to aggro or execute MoveInLineOfSight events. Removing may cause more issues
* than already exists
*/
[Script]
class spell_gen_feign_death_all_flags : AuraScript
{
void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.AddDynamicFlag(UnitDynFlags.Dead);
target.AddUnitFlag2(UnitFlags2.FeignDeath);
target.AddUnitFlag(UnitFlags.PreventEmotesFromChatText);
Creature creature = target.ToCreature();
if (creature != null)
creature.SetReactState(ReactStates.Passive);
}
void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.RemoveDynamicFlag(UnitDynFlags.Dead);
target.RemoveUnitFlag2(UnitFlags2.FeignDeath);
target.RemoveUnitFlag(UnitFlags.PreventEmotesFromChatText);
Creature creature = target.ToCreature();
if (creature != null)
creature.InitializeReactState();
}
public override void Register()
{
OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
}
}
// 35357 - Spawn Feign Death
[Script] // 51329 - Feign Death
class spell_gen_feign_death_no_dyn_flag : AuraScript
{
void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.AddUnitFlag2(UnitFlags2.FeignDeath);
target.AddUnitFlag(UnitFlags.PreventEmotesFromChatText);
Creature creature = target.ToCreature();
if (creature != null)
creature.SetReactState(ReactStates.Passive);
}
void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.RemoveUnitFlag2(UnitFlags2.FeignDeath);
target.RemoveUnitFlag(UnitFlags.PreventEmotesFromChatText);
Creature creature = target.ToCreature();
if (creature != null)
creature.InitializeReactState();
}
public override void Register()
{
OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
}
}
[Script] // 58951 - Permanent Feign Death
class spell_gen_feign_death_no_prevent_emotes : AuraScript
{
void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.AddDynamicFlag(UnitDynFlags.Dead);
target.AddUnitFlag2(UnitFlags2.FeignDeath);
Creature creature = target.ToCreature();
if (creature != null)
creature.SetReactState(ReactStates.Passive);
}
void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.RemoveDynamicFlag(UnitDynFlags.Dead);
target.RemoveUnitFlag2(UnitFlags2.FeignDeath);
Creature creature = target.ToCreature();
if (creature != null)
creature.InitializeReactState();
}
public override void Register()
{
OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
}
}
[Script] // 46642 - 5,000 Gold [Script] // 46642 - 5,000 Gold
class spell_gen_5000_gold : SpellScript class spell_gen_5000_gold : SpellScript
@@ -2279,6 +2357,28 @@ namespace Scripts.Spells.Generic
} }
} }
[Script]
class spell_gen_prevent_emotes : AuraScript
{
void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.AddUnitFlag(UnitFlags.PreventEmotesFromChatText);
}
void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{
Unit target = GetTarget();
target.RemoveUnitFlag(UnitFlags.PreventEmotesFromChatText);
}
public override void Register()
{
OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, SpellConst.EffectFirstFound, AuraType.Any, AuraEffectHandleModes.Real));
OnEffectRemove.Add(new EffectApplyHandler(OnRemove, SpellConst.EffectFirstFound, AuraType.Any, AuraEffectHandleModes.Real));
}
}
[Script("spell_item_soul_harvesters_charm")] [Script("spell_item_soul_harvesters_charm")]
[Script("spell_item_commendation_of_kaelthas")] [Script("spell_item_commendation_of_kaelthas")]
[Script("spell_item_corpse_tongue_coin")] [Script("spell_item_corpse_tongue_coin")]
@@ -3869,7 +3969,7 @@ namespace Scripts.Spells.Generic
{ {
void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{ {
GetTarget().RemoveAurasDueToSpell(SpellIds.SiegeTankControl); //aurEff->GetAmount() GetTarget().RemoveAurasDueToSpell(SpellIds.SiegeTankControl); //aurEff.GetAmount()
} }
public override void Register() public override void Register()