Scripts/Spells: Cleanup in spell_generic

This commit is contained in:
Shauren
2011-03-04 20:20:06 +01:00
parent 7798474e74
commit 7ecaf1d816
+131 -111
View File
@@ -27,7 +27,7 @@
class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader
{
public:
public:
spell_gen_absorb0_hitlimit1() : SpellScriptLoader("spell_gen_absorb0_hitlimit1") { }
class spell_gen_absorb0_hitlimit1_AuraScript : public AuraScript
@@ -43,7 +43,7 @@ public:
return true;
}
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount)
void Absorb(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& absorbAmount)
{
absorbAmount = std::min(limit, absorbAmount);
}
@@ -54,7 +54,7 @@ public:
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_gen_absorb0_hitlimit1_AuraScript();
}
@@ -63,15 +63,16 @@ public:
// 41337 Aura of Anger
class spell_gen_aura_of_anger : public SpellScriptLoader
{
public:
public:
spell_gen_aura_of_anger() : SpellScriptLoader("spell_gen_aura_of_anger") { }
class spell_gen_aura_of_anger_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_aura_of_anger_AuraScript)
void HandleEffectPeriodicUpdate(AuraEffect * aurEff)
PrepareAuraScript(spell_gen_aura_of_anger_AuraScript);
void HandleEffectPeriodicUpdate(AuraEffect* aurEff)
{
if (AuraEffect * aurEff1 = aurEff->GetBase()->GetEffect(EFFECT_1))
if (AuraEffect* aurEff1 = aurEff->GetBase()->GetEffect(EFFECT_1))
aurEff1->ChangeAmount(aurEff1->GetAmount() + 5);
aurEff->SetAmount(100 * aurEff->GetTickNumber());
}
@@ -82,7 +83,7 @@ public:
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_gen_aura_of_anger_AuraScript();
}
@@ -91,13 +92,14 @@ public:
// 46394 Brutallus Burn
class spell_gen_burn_brutallus : public SpellScriptLoader
{
public:
public:
spell_gen_burn_brutallus() : SpellScriptLoader("spell_gen_burn_brutallus") { }
class spell_gen_burn_brutallus_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_burn_brutallus_AuraScript)
void HandleEffectPeriodicUpdate(AuraEffect * aurEff)
PrepareAuraScript(spell_gen_burn_brutallus_AuraScript);
void HandleEffectPeriodicUpdate(AuraEffect* aurEff)
{
if (aurEff->GetTickNumber() % 11 == 0)
aurEff->SetAmount(aurEff->GetAmount() * 2);
@@ -109,7 +111,7 @@ public:
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_gen_burn_brutallus_AuraScript();
}
@@ -124,13 +126,14 @@ enum eParachuteSpells
class spell_gen_parachute : public SpellScriptLoader
{
public:
public:
spell_gen_parachute() : SpellScriptLoader("spell_gen_parachute") { }
class spell_gen_parachute_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_parachute_AuraScript)
bool Validate(SpellEntry const * /*spellEntry*/)
PrepareAuraScript(spell_gen_parachute_AuraScript);
bool Validate(SpellEntry const* /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(SPELL_PARACHUTE))
return false;
@@ -139,14 +142,15 @@ public:
return true;
}
void HandleEffectPeriodic(AuraEffect const * /*aurEff*/)
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
{
Unit* pTarget = GetTarget();
if (Player* pPlayerTarget = pTarget->ToPlayer())
if (pPlayerTarget->IsFalling())
if (Player* target = GetTarget()->ToPlayer())
{
pPlayerTarget->RemoveAurasDueToSpell(SPELL_PARACHUTE);
pPlayerTarget->CastSpell(pPlayerTarget, SPELL_PARACHUTE_BUFF, true);
if (target->IsFalling())
{
target->RemoveAurasDueToSpell(SPELL_PARACHUTE);
target->CastSpell(target, SPELL_PARACHUTE_BUFF, true);
}
}
}
@@ -156,7 +160,7 @@ public:
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_gen_parachute_AuraScript();
}
@@ -171,72 +175,73 @@ enum NPCEntries
class spell_gen_pet_summoned : public SpellScriptLoader
{
public:
public:
spell_gen_pet_summoned() : SpellScriptLoader("spell_gen_pet_summoned") { }
class spell_gen_pet_summonedSpellScript : public SpellScript
class spell_gen_pet_summoned_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_pet_summonedSpellScript)
PrepareSpellScript(spell_gen_pet_summoned_SpellScript);
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit *caster = GetCaster();
Unit* caster = GetCaster();
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
Player* plr = caster->ToPlayer();
if (plr && plr->GetLastPetNumber())
if (plr->GetLastPetNumber())
{
PetType NewPetType = (plr->getClass() == CLASS_HUNTER) ? HUNTER_PET : SUMMON_PET;
if (Pet* NewPet = new Pet(plr, NewPetType))
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))
if (newPet->LoadPetFromDB(plr, 0, plr->GetLastPetNumber(), true))
{
// revive the pet if it is dead
if (NewPet->getDeathState() == DEAD)
NewPet->setDeathState(ALIVE);
if (newPet->getDeathState() == DEAD)
newPet->setDeathState(ALIVE);
NewPet->SetFullHealth();
NewPet->SetPower(NewPet->getPowerType(),NewPet->GetMaxPower(NewPet->getPowerType()));
newPet->SetFullHealth();
newPet->SetPower(newPet->getPowerType(), newPet->GetMaxPower(newPet->getPowerType()));
switch (NewPet->GetEntry())
switch (newPet->GetEntry())
{
case NPC_DOOMGUARD:
case NPC_INFERNAL:
NewPet->SetEntry(NPC_IMP);
newPet->SetEntry(NPC_IMP);
break;
default:
break;
}
}
else
delete NewPet;
delete newPet;
}
}
}
void Register()
{
OnEffect += SpellEffectFn(spell_gen_pet_summonedSpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffect += SpellEffectFn(spell_gen_pet_summoned_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_gen_pet_summonedSpellScript();
return new spell_gen_pet_summoned_SpellScript();
}
};
class spell_gen_remove_flight_auras : public SpellScriptLoader
{
public:
public:
spell_gen_remove_flight_auras() : SpellScriptLoader("spell_gen_remove_flight_auras") {}
class spell_gen_remove_flight_auras_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_remove_flight_auras_SpellScript)
void HandleScript(SpellEffIndex /*effIndex*/)
void HandleScript(SpellEffIndex /*effIndex*/);
{
Unit *target = GetHitUnit();
Unit* target = GetHitUnit();
if (!target)
return;
target->RemoveAurasByType(SPELL_AURA_FLY);
@@ -264,13 +269,14 @@ enum eLeechingSwarmSpells
class spell_gen_leeching_swarm : public SpellScriptLoader
{
public:
public:
spell_gen_leeching_swarm() : SpellScriptLoader("spell_gen_leeching_swarm") { }
class spell_gen_leeching_swarm_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_leeching_swarm_AuraScript)
bool Validate(SpellEntry const * /*spellEntry*/)
PrepareAuraScript(spell_gen_leeching_swarm_AuraScript);
bool Validate(SpellEntry const* /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(SPELL_LEECHING_SWARM_DMG))
return false;
@@ -279,18 +285,17 @@ public:
return true;
}
void HandleEffectPeriodic(AuraEffect const * aurEff)
void HandleEffectPeriodic(AuraEffect const* aurEff)
{
if (Unit* pTarget = GetTarget())
if (Unit* pCaster = GetCaster())
if (Unit* caster = GetCaster())
{
int32 lifeLeeched = pTarget->CountPctFromCurHealth(aurEff->GetAmount());
if (lifeLeeched < 250)
lifeLeeched = 250;
// Damage
pCaster->CastCustomSpell(pTarget, SPELL_LEECHING_SWARM_DMG, &lifeLeeched, 0, 0, false);
caster->CastCustomSpell(GetTarget(), SPELL_LEECHING_SWARM_DMG, &lifeLeeched, 0, 0, false);
// Heal
pCaster->CastCustomSpell(pCaster, SPELL_LEECHING_SWARM_HEAL, &lifeLeeched, 0, 0, false);
caster->CastCustomSpell(caster, SPELL_LEECHING_SWARM_HEAL, &lifeLeeched, 0, 0, false);
}
}
@@ -300,7 +305,7 @@ public:
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_gen_leeching_swarm_AuraScript();
}
@@ -323,13 +328,13 @@ enum eTrickSpells
class spell_gen_trick : public SpellScriptLoader
{
public:
public:
spell_gen_trick() : SpellScriptLoader("spell_gen_trick") {}
class spell_gen_trick_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_trick_SpellScript)
bool Validate(SpellEntry const * /*spellEntry*/)
PrepareSpellScript(spell_gen_trick_SpellScript);
bool Validate(SpellEntry const* /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(SPELL_PIRATE_COSTUME_MALE))
return false;
@@ -356,19 +361,32 @@ public:
void HandleScript(SpellEffIndex /*effIndex*/)
{
if (Player* pTarget = GetHitPlayer())
if (Player* target = GetHitPlayer())
{
uint8 gender = pTarget->getGender();
uint8 gender = target->getGender();
uint32 spellId = SPELL_TRICK_BUFF;
switch (urand(0, 5))
{
case 1: spellId = gender ? SPELL_LEPER_GNOME_COSTUME_FEMALE : SPELL_LEPER_GNOME_COSTUME_MALE; break;
case 2: spellId = gender ? SPELL_PIRATE_COSTUME_FEMALE : SPELL_PIRATE_COSTUME_MALE; break;
case 3: spellId = gender ? SPELL_GHOST_COSTUME_FEMALE : SPELL_GHOST_COSTUME_MALE; break;
case 4: spellId = gender ? SPELL_NINJA_COSTUME_FEMALE : SPELL_NINJA_COSTUME_MALE; break;
case 5: spellId = SPELL_SKELETON_COSTUME; break;
case 1:
spellId = gender ? SPELL_LEPER_GNOME_COSTUME_FEMALE : SPELL_LEPER_GNOME_COSTUME_MALE;
break;
case 2:
spellId = gender ? SPELL_PIRATE_COSTUME_FEMALE : SPELL_PIRATE_COSTUME_MALE;
break;
case 3:
spellId = gender ? SPELL_GHOST_COSTUME_FEMALE : SPELL_GHOST_COSTUME_MALE;
break;
case 4:
spellId = gender ? SPELL_NINJA_COSTUME_FEMALE : SPELL_NINJA_COSTUME_MALE;
break;
case 5:
spellId = SPELL_SKELETON_COSTUME;
break;
default:
break;
}
GetCaster()->CastSpell(pTarget, spellId, true, NULL);
GetCaster()->CastSpell(target, spellId, true, NULL);
}
}
@@ -394,13 +412,14 @@ enum eTrickOrTreatSpells
class spell_gen_trick_or_treat : public SpellScriptLoader
{
public:
public:
spell_gen_trick_or_treat() : SpellScriptLoader("spell_gen_trick_or_treat") {}
class spell_gen_trick_or_treat_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_trick_or_treat_SpellScript)
bool Validate(SpellEntry const * /*spellEntry*/)
PrepareSpellScript(spell_gen_trick_or_treat_SpellScript);
bool Validate(SpellEntry const* /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(SPELL_TRICK))
return false;
@@ -437,26 +456,26 @@ 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
class spell_creature_permanent_feign_death_AuraScript : public AuraScript
{
PrepareAuraScript(spell_creature_permanent_feign_deathAuraScript)
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* pTarget = GetTarget();
PrepareAuraScript(spell_creature_permanent_feign_death_AuraScript);
pTarget->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
pTarget->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
target->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);
OnEffectApply += AuraEffectApplyFn(spell_creature_permanent_feign_death_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_creature_permanent_feign_deathAuraScript();
return new spell_creature_permanent_feign_death_AuraScript();
}
};
@@ -468,13 +487,14 @@ enum PvPTrinketTriggeredSpells
class spell_pvp_trinket_wotf_shared_cd : public SpellScriptLoader
{
public:
public:
spell_pvp_trinket_wotf_shared_cd() : SpellScriptLoader("spell_pvp_trinket_wotf_shared_cd") {}
class spell_pvp_trinket_wotf_shared_cd_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pvp_trinket_wotf_shared_cd_SpellScript)
bool Validate(SpellEntry const * /*spellEntry*/)
PrepareSpellScript(spell_pvp_trinket_wotf_shared_cd_SpellScript);
bool Validate(SpellEntry const* /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER))
return false;
@@ -485,18 +505,18 @@ public:
void HandleScript(SpellEffIndex /*effIndex*/)
{
Player* pCaster = GetCaster()->ToPlayer();
if (!pCaster)
Player* caster = GetCaster()->ToPlayer();
if (!caster)
return;
const SpellEntry* m_spellInfo = GetSpellInfo();
SpellEntry const* spellInfo = GetSpellInfo();
pCaster->AddSpellCooldown(m_spellInfo->Id, NULL, time(NULL) + GetSpellRecoveryTime(sSpellStore.LookupEntry(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER)) / IN_MILLISECONDS);
caster->AddSpellCooldown(spellInfo->Id, NULL, time(NULL) + GetSpellRecoveryTime(sSpellStore.LookupEntry(SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER)) / IN_MILLISECONDS);
WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4);
data << uint64(pCaster->GetGUID());
data << uint64(caster->GetGUID());
data << uint8(0);
data << uint32(m_spellInfo->Id);
data << uint32(spellInfo->Id);
data << uint32(0);
pCaster->GetSession()->SendPacket(&data);
caster->GetSession()->SendPacket(&data);
}
void Register()
@@ -564,18 +584,18 @@ class spell_gen_shroud_of_death : public SpellScriptLoader
public:
spell_gen_shroud_of_death() : SpellScriptLoader("spell_gen_shroud_of_death") { }
class spell_gen_shroud_of_deathAuraScript : public AuraScript
class spell_gen_shroud_of_death_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_shroud_of_deathAuraScript)
PrepareAuraScript(spell_gen_shroud_of_death_AuraScript);
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
target->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
}
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
target->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
@@ -584,14 +604,14 @@ class spell_gen_shroud_of_death : public SpellScriptLoader
void Register()
{
OnEffectApply += AuraEffectApplyFn(spell_gen_shroud_of_deathAuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_shroud_of_deathAuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectApply += AuraEffectApplyFn(spell_gen_shroud_of_death_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_shroud_of_death_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_gen_shroud_of_deathAuraScript();
return new spell_gen_shroud_of_death_AuraScript();
}
};
@@ -603,13 +623,14 @@ enum DivineStormSpell
// 70769 Divine Storm!
class spell_gen_divine_storm_cd_reset : public SpellScriptLoader
{
public:
public:
spell_gen_divine_storm_cd_reset() : SpellScriptLoader("spell_gen_divine_storm_cd_reset") {}
class spell_gen_divine_storm_cd_reset_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_divine_storm_cd_reset_SpellScript)
bool Validate(SpellEntry const * /*spellEntry*/)
PrepareSpellScript(spell_gen_divine_storm_cd_reset_SpellScript);
bool Validate(SpellEntry const* /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(SPELL_DIVINE_STORM))
return false;
@@ -637,34 +658,33 @@ public:
class spell_gen_gunship_portal : public SpellScriptLoader
{
public:
public:
spell_gen_gunship_portal() : SpellScriptLoader("spell_gen_gunship_portal") { }
class spell_gen_gunship_portalSpellScript : public SpellScript
class spell_gen_gunship_portal_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_gunship_portalSpellScript)
PrepareSpellScript(spell_gen_gunship_portal_SpellScript);
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (!caster->ToPlayer())
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
if (Battleground *bg = caster->ToPlayer()->GetBattleground())
{
if (bg->GetTypeID(true) == BATTLEGROUND_IC)
bg->DoAction(1,caster->GetGUID());
}
bg->DoAction(1, caster->GetGUID());
}
void Register()
{
OnEffect += SpellEffectFn(spell_gen_gunship_portalSpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffect += SpellEffectFn(spell_gen_gunship_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_gen_gunship_portalSpellScript();
return new spell_gen_gunship_portal_SpellScript();
}
};
@@ -678,11 +698,11 @@ class spell_gen_parachute_ic : public SpellScriptLoader
public:
spell_gen_parachute_ic() : SpellScriptLoader("spell_gen_parachute_ic") { }
class spell_gen_parachute_icAuraScript : public AuraScript
class spell_gen_parachute_ic_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_parachute_icAuraScript)
PrepareAuraScript(spell_gen_parachute_ic_AuraScript)
void HandleTriggerSpell(AuraEffect const * /*aurEff*/)
void HandleTriggerSpell(AuraEffect const* /*aurEff*/)
{
Unit* target = GetTarget();
@@ -695,13 +715,13 @@ class spell_gen_parachute_ic : public SpellScriptLoader
void Register()
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_parachute_icAuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_parachute_ic_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
AuraScript *GetAuraScript() const
AuraScript* GetAuraScript() const
{
return new spell_gen_parachute_icAuraScript();
return new spell_gen_parachute_ic_AuraScript();
}
};