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
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user