aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Spells
diff options
context:
space:
mode:
authorOdyssey <odysseyhyd@gmail.com>2014-09-08 15:56:00 +0100
committerDDuarte <dnpd.dd@gmail.com>2014-09-08 15:56:32 +0100
commit54e201b8b97912b45f5ae942c5b71abb1cf58640 (patch)
treefedaab04089811e63a9d77bd519efe6eed5985dc /src/server/scripts/Spells
parent5e745f3fbba4956c9ed732c74016e6ed8a6e1143 (diff)
Scripts/Commands: Allow to set a custom duration to the Freeze command applied Aura
- Allow to set a default duration for the Freeze Aura in worldserver.conf - Handle the .freeze and .unfreeze command custom effects through the Freeze AuraScript - Make players able to eventually unfreeze by themselves since the aura will expire without someone having to use .unfreeze - Make .freeze command usable with the following syntax: * .freeze (with a targeted player) * .freeze duration_in_seconds (with a targeted player) * .freeze playername duration (if duration is an invalid value it will be defaulted to the config one) * .freeze playername (in this case, duration will be defaulted to the config value) - Make .listfreeze command able to show the remaining freeze duration on all affected players Closes #12972
Diffstat (limited to 'src/server/scripts/Spells')
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 84e36b55c2c..e198a6a0c61 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -3609,6 +3609,79 @@ class spell_gen_eject_all_passengers : public SpellScriptLoader
}
};
+enum GMFreeze
+{
+ SPELL_GM_FREEZE = 9454
+};
+
+class spell_gen_gm_freeze : public SpellScriptLoader
+{
+ public:
+ spell_gen_gm_freeze() : SpellScriptLoader("spell_gen_gm_freeze") { }
+
+ class spell_gen_gm_freeze_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_gen_gm_freeze_AuraScript);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_GM_FREEZE))
+ return false;
+ return true;
+ }
+
+ void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ // Do what was done before to the target in HandleFreezeCommand
+ if (Player* player = GetTarget()->ToPlayer())
+ {
+ // stop combat + make player unattackable + duel stop + stop some spells
+ player->setFaction(35);
+ player->CombatStop();
+ if (player->IsNonMeleeSpellCast(true))
+ player->InterruptNonMeleeSpells(true);
+ player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+
+ // if player class = hunter || warlock remove pet if alive
+ if ((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK))
+ {
+ if (Pet* pet = player->GetPet())
+ {
+ pet->SavePetToDB(PET_SAVE_AS_CURRENT);
+ // not let dismiss dead pet
+ if (pet->IsAlive())
+ player->RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
+ }
+ }
+ }
+ }
+
+ void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ // Do what was done before to the target in HandleUnfreezeCommand
+ if (Player* player = GetTarget()->ToPlayer())
+ {
+ // Reset player faction + allow combat + allow duels
+ player->setFactionForRace(player->getRace());
+ player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ // save player
+ player->SaveToDB();
+ }
+ }
+
+ void Register() override
+ {
+ OnEffectApply += AuraEffectApplyFn(spell_gen_gm_freeze_AuraScript::OnApply, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL);
+ OnEffectRemove += AuraEffectRemoveFn(spell_gen_gm_freeze_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_gen_gm_freeze_AuraScript();
+ }
+};
+
void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
@@ -3689,4 +3762,5 @@ void AddSC_generic_spell_scripts()
new spell_gen_wg_water();
new spell_gen_whisper_gulch_yogg_saron_whisper();
new spell_gen_eject_all_passengers();
+ new spell_gen_gm_freeze();
}