2010-07-24 22:41:42 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
2010-08-08 19:45:53 +02:00
|
|
|
* Scripts for spells with SPELLFAMILY_GENERIC which cannot be included in AI script file
|
2010-07-24 22:41:42 +02:00
|
|
|
* of creature using it or can't be bound to any player class.
|
|
|
|
|
* Ordered alphabetically using scriptname.
|
|
|
|
|
* Scriptnames of files in this file should be prefixed with "spell_gen_"
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScriptPCH.h"
|
|
|
|
|
|
2010-08-22 21:07:18 -07:00
|
|
|
enum NPCEntries
|
|
|
|
|
{
|
|
|
|
|
NPC_DOOMGUARD = 11859,
|
|
|
|
|
NPC_INFERNAL = 89,
|
|
|
|
|
NPC_IMP = 416,
|
|
|
|
|
};
|
|
|
|
|
|
2010-08-24 00:10:49 +02:00
|
|
|
class spell_gen_pet_summoned : public SpellScriptLoader
|
2010-08-22 21:07:18 -07:00
|
|
|
{
|
|
|
|
|
public:
|
2010-08-24 00:10:49 +02:00
|
|
|
spell_gen_pet_summoned() : SpellScriptLoader("spell_gen_pet_summoned") { }
|
2010-08-22 21:07:18 -07:00
|
|
|
|
|
|
|
|
class spell_gen_pet_summonedSpellScript : public SpellScript
|
|
|
|
|
{
|
2010-08-23 14:10:24 +02:00
|
|
|
void HandleScript(SpellEffIndex /*effIndex*/)
|
2010-08-22 21:07:18 -07:00
|
|
|
{
|
|
|
|
|
Unit *caster = GetCaster();
|
|
|
|
|
if (caster->GetTypeId() != TYPEID_PLAYER)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Player* plr = caster->ToPlayer();
|
|
|
|
|
if (plr && plr->GetLastPetNumber())
|
2010-08-06 20:09:23 +02:00
|
|
|
{
|
2010-08-22 21:07:18 -07:00
|
|
|
PetType NewPetType = (plr->getClass() == CLASS_HUNTER) ? HUNTER_PET : SUMMON_PET;
|
|
|
|
|
if (Pet* NewPet = new Pet(plr, NewPetType))
|
|
|
|
|
{
|
|
|
|
|
if (NewPet->LoadPetFromDB(plr, 0, plr->GetLastPetNumber(), true))
|
|
|
|
|
{
|
|
|
|
|
// revive the pet if it is dead
|
|
|
|
|
if (NewPet->getDeathState() == DEAD)
|
|
|
|
|
NewPet->setDeathState(ALIVE);
|
|
|
|
|
|
2010-08-26 01:20:57 +06:00
|
|
|
NewPet->SetFullHealth();
|
2010-08-22 21:07:18 -07:00
|
|
|
NewPet->SetPower(NewPet->getPowerType(),NewPet->GetMaxPower(NewPet->getPowerType()));
|
|
|
|
|
|
|
|
|
|
switch (NewPet->GetEntry())
|
|
|
|
|
{
|
|
|
|
|
case NPC_DOOMGUARD:
|
|
|
|
|
case NPC_INFERNAL:
|
|
|
|
|
NewPet->SetEntry(NPC_IMP);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
delete NewPet;
|
|
|
|
|
}
|
2010-08-06 20:09:23 +02:00
|
|
|
}
|
2010-08-22 21:07:18 -07:00
|
|
|
}
|
2010-08-06 20:09:23 +02:00
|
|
|
|
2010-08-22 21:07:18 -07:00
|
|
|
void Register()
|
2010-08-06 20:09:23 +02:00
|
|
|
{
|
2010-08-24 00:10:49 +02:00
|
|
|
OnEffect += SpellEffectFn(spell_gen_pet_summonedSpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
2010-08-06 20:09:23 +02:00
|
|
|
}
|
2010-08-22 21:07:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SpellScript* GetSpellScript() const
|
|
|
|
|
{
|
2010-08-29 22:40:23 +06:00
|
|
|
return new spell_gen_pet_summonedSpellScript();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class spell_gen_remove_flight_auras : public SpellScriptLoader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
spell_gen_remove_flight_auras() : SpellScriptLoader("spell_gen_remove_flight_auras") {}
|
|
|
|
|
|
|
|
|
|
class spell_gen_remove_flight_auras_SpellScript : public SpellScript
|
|
|
|
|
{
|
|
|
|
|
void HandleScript(SpellEffIndex /*effIndex*/)
|
|
|
|
|
{
|
|
|
|
|
Unit *target = GetHitUnit();
|
|
|
|
|
if (!target)
|
|
|
|
|
return;
|
|
|
|
|
target->RemoveAurasByType(SPELL_AURA_FLY);
|
|
|
|
|
target->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Register()
|
|
|
|
|
{
|
|
|
|
|
OnEffect += SpellEffectFn(spell_gen_remove_flight_auras_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SpellScript* GetSpellScript() const
|
|
|
|
|
{
|
|
|
|
|
return new spell_gen_remove_flight_auras_SpellScript();
|
2010-08-22 21:07:18 -07:00
|
|
|
}
|
2010-08-07 01:02:09 +06:00
|
|
|
};
|
2010-08-06 20:09:23 +02:00
|
|
|
|
2010-09-08 14:57:44 +03:00
|
|
|
class spell_creature_permanent_feign_death : public SpellScriptLoader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
spell_creature_permanent_feign_death() : SpellScriptLoader("spell_creature_permanent_feign_death") { }
|
|
|
|
|
|
|
|
|
|
class spell_creature_permanent_feign_deathAuraScript : public AuraScript
|
|
|
|
|
{
|
|
|
|
|
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraApplication const * aurApp, AuraEffectHandleModes /*mode*/)
|
|
|
|
|
{
|
|
|
|
|
Unit* pTarget = aurApp->GetTarget();
|
|
|
|
|
if (!pTarget)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pTarget->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
|
|
|
|
|
pTarget->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Register()
|
|
|
|
|
{
|
|
|
|
|
OnEffectApply += AuraEffectApplyFn(spell_creature_permanent_feign_deathAuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AuraScript *GetAuraScript() const
|
|
|
|
|
{
|
|
|
|
|
return new spell_creature_permanent_feign_deathAuraScript();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2010-07-24 22:41:42 +02:00
|
|
|
void AddSC_generic_spell_scripts()
|
|
|
|
|
{
|
2010-08-29 22:40:23 +06:00
|
|
|
new spell_gen_pet_summoned();
|
|
|
|
|
new spell_gen_remove_flight_auras();
|
2010-09-08 14:57:44 +03:00
|
|
|
new spell_creature_permanent_feign_death();
|
2010-08-06 19:46:02 +02:00
|
|
|
}
|