mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-09 00:08:01 +00:00
refactor(Script/Spells): convert winter_veil into new system (#9606)
This commit is contained in:
@@ -34,43 +34,32 @@ enum Mistletoe
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 26218 - Mistletoe
|
// 26218 - Mistletoe
|
||||||
class spell_winter_veil_mistletoe : public SpellScriptLoader
|
class spell_winter_veil_mistletoe : public SpellScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareSpellScript(spell_winter_veil_mistletoe);
|
||||||
spell_winter_veil_mistletoe() : SpellScriptLoader("spell_winter_veil_mistletoe") { }
|
|
||||||
|
|
||||||
class spell_winter_veil_mistletoe_SpellScript : public SpellScript
|
bool Validate(SpellInfo const* /*spell*/) override
|
||||||
{
|
{
|
||||||
PrepareSpellScript(spell_winter_veil_mistletoe_SpellScript);
|
return ValidateSpellInfo(
|
||||||
|
|
||||||
bool Validate(SpellInfo const* /*spell*/) override
|
|
||||||
{
|
|
||||||
return ValidateSpellInfo(
|
|
||||||
{
|
|
||||||
SPELL_CREATE_MISTLETOE,
|
|
||||||
SPELL_CREATE_HOLLY,
|
|
||||||
SPELL_CREATE_SNOWFLAKES
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
|
||||||
{
|
|
||||||
if (Player* target = GetHitPlayer())
|
|
||||||
{
|
{
|
||||||
uint32 spellId = RAND(SPELL_CREATE_HOLLY, SPELL_CREATE_MISTLETOE, SPELL_CREATE_SNOWFLAKES);
|
SPELL_CREATE_MISTLETOE,
|
||||||
GetCaster()->CastSpell(target, spellId, true);
|
SPELL_CREATE_HOLLY,
|
||||||
}
|
SPELL_CREATE_SNOWFLAKES
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Register() override
|
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||||
{
|
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_mistletoe_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SpellScript* GetSpellScript() const override
|
|
||||||
{
|
{
|
||||||
return new spell_winter_veil_mistletoe_SpellScript();
|
if (Player* target = GetHitPlayer())
|
||||||
|
{
|
||||||
|
uint32 spellId = RAND(SPELL_CREATE_HOLLY, SPELL_CREATE_MISTLETOE, SPELL_CREATE_SNOWFLAKES);
|
||||||
|
GetCaster()->CastSpell(target, spellId, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Register() override
|
||||||
|
{
|
||||||
|
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_mistletoe::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,48 +72,37 @@ enum winterWondervoltTrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 26275 - PX-238 Winter Wondervolt TRAP
|
// 26275 - PX-238 Winter Wondervolt TRAP
|
||||||
class spell_winter_wondervolt_trap : public SpellScriptLoader
|
class spell_winter_wondervolt_trap : public SpellScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareSpellScript(spell_winter_wondervolt_trap);
|
||||||
spell_winter_wondervolt_trap() : SpellScriptLoader("spell_winter_wondervolt_trap") {}
|
|
||||||
|
|
||||||
class spell_winter_wondervolt_trap_SpellScript : public SpellScript
|
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
||||||
{
|
{
|
||||||
PrepareSpellScript(spell_winter_wondervolt_trap_SpellScript);
|
if (Player* target = GetHitPlayer())
|
||||||
|
|
||||||
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
|
||||||
{
|
{
|
||||||
if (Player* target = GetHitPlayer())
|
// check presence
|
||||||
{
|
if (target->HasAuraType(SPELL_AURA_TRANSFORM))
|
||||||
// check presence
|
|
||||||
if (target->HasAuraType(SPELL_AURA_TRANSFORM))
|
|
||||||
return;
|
|
||||||
|
|
||||||
uint32 spellId = 0;
|
|
||||||
if (target->getGender() == GENDER_MALE)
|
|
||||||
{
|
|
||||||
spellId = target->GetTeamId() == TEAM_ALLIANCE ? SPELL_WINTER_WONDERVOLT_GREEN_MAN : SPELL_WINTER_WONDERVOLT_RED_MAN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
spellId = target->GetTeamId() == TEAM_ALLIANCE ? SPELL_WINTER_WONDERVOLT_GREEN_WOMEN : SPELL_WINTER_WONDERVOLT_RED_WOMEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cast
|
|
||||||
target->CastSpell(target, spellId, true);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
uint32 spellId = 0;
|
||||||
|
if (target->getGender() == GENDER_MALE)
|
||||||
|
{
|
||||||
|
spellId = target->GetTeamId() == TEAM_ALLIANCE ? SPELL_WINTER_WONDERVOLT_GREEN_MAN : SPELL_WINTER_WONDERVOLT_RED_MAN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spellId = target->GetTeamId() == TEAM_ALLIANCE ? SPELL_WINTER_WONDERVOLT_GREEN_WOMEN : SPELL_WINTER_WONDERVOLT_RED_WOMEN;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Register() override
|
// cast
|
||||||
{
|
target->CastSpell(target, spellId, true);
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_winter_wondervolt_trap_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
return;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
SpellScript* GetSpellScript() const override
|
void Register() override
|
||||||
{
|
{
|
||||||
return new spell_winter_wondervolt_trap_SpellScript();
|
OnEffectHitTarget += SpellEffectFn(spell_winter_wondervolt_trap::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,24 +123,30 @@ enum crashinTrashin
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 49297 - Racer Rocket Slam
|
// 49297 - Racer Rocket Slam
|
||||||
class spell_winter_veil_racer_rocket_slam : public SpellScriptLoader
|
class spell_winter_veil_racer_rocket_slam : public SpellScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareSpellScript(spell_winter_veil_racer_rocket_slam);
|
||||||
spell_winter_veil_racer_rocket_slam() : SpellScriptLoader("spell_winter_veil_racer_rocket_slam") {}
|
|
||||||
|
|
||||||
class spell_winter_veil_racer_rocket_slam_SpellScript : public SpellScript
|
void HandleTriggerSpell(SpellEffIndex /*effIndex*/)
|
||||||
{
|
{
|
||||||
PrepareSpellScript(spell_winter_veil_racer_rocket_slam_SpellScript);
|
Unit* caster = GetCaster();
|
||||||
|
PreventHitEffect(EFFECT_0);
|
||||||
|
PreventHitEffect(EFFECT_1);
|
||||||
|
|
||||||
void HandleTriggerSpell(SpellEffIndex /*effIndex*/)
|
std::list<Creature*> unitList;
|
||||||
|
Unit* target = nullptr;
|
||||||
|
caster->GetCreaturesWithEntryInRange(unitList, 30.0f, NPC_BLUE_RACER);
|
||||||
|
if (!unitList.empty())
|
||||||
|
for (std::list<Creature*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
|
||||||
|
if (caster->HasInLine((*itr), 1.0f) && (*itr)->GetGUID() != caster->GetGUID())
|
||||||
|
{
|
||||||
|
target = (*itr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!target)
|
||||||
{
|
{
|
||||||
Unit* caster = GetCaster();
|
unitList.clear();
|
||||||
PreventHitEffect(EFFECT_0);
|
caster->GetCreaturesWithEntryInRange(unitList, 30.0f, NPC_RED_RACER);
|
||||||
PreventHitEffect(EFFECT_1);
|
|
||||||
|
|
||||||
std::list<Creature*> unitList;
|
|
||||||
Unit* target = nullptr;
|
|
||||||
caster->GetCreaturesWithEntryInRange(unitList, 30.0f, NPC_BLUE_RACER);
|
|
||||||
if (!unitList.empty())
|
if (!unitList.empty())
|
||||||
for (std::list<Creature*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
|
for (std::list<Creature*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
|
||||||
if (caster->HasInLine((*itr), 1.0f) && (*itr)->GetGUID() != caster->GetGUID())
|
if (caster->HasInLine((*itr), 1.0f) && (*itr)->GetGUID() != caster->GetGUID())
|
||||||
@@ -170,85 +154,57 @@ public:
|
|||||||
target = (*itr);
|
target = (*itr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!target)
|
|
||||||
{
|
|
||||||
unitList.clear();
|
|
||||||
caster->GetCreaturesWithEntryInRange(unitList, 30.0f, NPC_RED_RACER);
|
|
||||||
if (!unitList.empty())
|
|
||||||
for (std::list<Creature*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
|
|
||||||
if (caster->HasInLine((*itr), 1.0f) && (*itr)->GetGUID() != caster->GetGUID())
|
|
||||||
{
|
|
||||||
target = (*itr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target)
|
|
||||||
{
|
|
||||||
caster->CastSpell(target, SPELL_RACER_CHARGE_TO_OBJECT, true);
|
|
||||||
caster->CastSpell(target, SPELL_RACER_SLAM_HIT, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Position pos;
|
|
||||||
float x = caster->GetPositionX() + 30 * cos(caster->GetOrientation());
|
|
||||||
float y = caster->GetPositionY() + 30 * sin(caster->GetOrientation());
|
|
||||||
pos.Relocate(x, y, caster->GetMap()->GetHeight(x, y, MAX_HEIGHT) + 0.5f);
|
|
||||||
//caster->GetFirstCollisionPosition(pos, 30.0f, caster->GetOrientation());
|
|
||||||
caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_RACER_CHARGE_TO_OBJECT, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Register() override
|
if (target)
|
||||||
{
|
{
|
||||||
OnEffectLaunch += SpellEffectFn(spell_winter_veil_racer_rocket_slam_SpellScript::HandleTriggerSpell, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL);
|
caster->CastSpell(target, SPELL_RACER_CHARGE_TO_OBJECT, true);
|
||||||
|
caster->CastSpell(target, SPELL_RACER_SLAM_HIT, true);
|
||||||
}
|
}
|
||||||
};
|
else
|
||||||
|
{
|
||||||
|
Position pos;
|
||||||
|
float x = caster->GetPositionX() + 30 * cos(caster->GetOrientation());
|
||||||
|
float y = caster->GetPositionY() + 30 * sin(caster->GetOrientation());
|
||||||
|
pos.Relocate(x, y, caster->GetMap()->GetHeight(x, y, MAX_HEIGHT) + 0.5f);
|
||||||
|
//caster->GetFirstCollisionPosition(pos, 30.0f, caster->GetOrientation());
|
||||||
|
caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_RACER_CHARGE_TO_OBJECT, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SpellScript* GetSpellScript() const override
|
void Register() override
|
||||||
{
|
{
|
||||||
return new spell_winter_veil_racer_rocket_slam_SpellScript();
|
OnEffectLaunch += SpellEffectFn(spell_winter_veil_racer_rocket_slam::HandleTriggerSpell, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 49325 - Racer Slam, resolve
|
// 49325 - Racer Slam, resolve
|
||||||
class spell_winter_veil_racer_slam_hit : public SpellScriptLoader
|
class spell_winter_veil_racer_slam_hit : public SpellScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareSpellScript(spell_winter_veil_racer_slam_hit);
|
||||||
spell_winter_veil_racer_slam_hit() : SpellScriptLoader("spell_winter_veil_racer_slam_hit") {}
|
|
||||||
|
|
||||||
class spell_winter_veil_racer_slam_hit_SpellScript : public SpellScript
|
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
||||||
{
|
{
|
||||||
PrepareSpellScript(spell_winter_veil_racer_slam_hit_SpellScript);
|
Unit* caster = GetCaster();
|
||||||
|
Creature* target = GetHitCreature();
|
||||||
|
if (!target || caster == target)
|
||||||
|
return;
|
||||||
|
|
||||||
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
target->CastSpell(target->GetPositionX() + irand(-10, 10), target->GetPositionY() + irand(-10, 10), target->GetPositionZ(), SPELL_RACER_DEATH_VISUAL, true);
|
||||||
|
target->DespawnOrUnsummon(3000);
|
||||||
|
target->CastSpell(target, SPELL_RACER_FLAMES, true);
|
||||||
|
caster->CastSpell(caster, SPELL_RACER_KILL_COUNTER, true);
|
||||||
|
|
||||||
|
if (Player* targetSummoner = target->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||||
{
|
{
|
||||||
Unit* caster = GetCaster();
|
//targetSummoner->RemoveCriteriaProgress(sAchievementCriteriaStore.LookupEntry(RACER_ACHI_CRITERIA)); !ZOMG, ADD ACCESSOR
|
||||||
Creature* target = GetHitCreature();
|
targetSummoner->RemoveAurasDueToSpell(SPELL_RACER_KILL_COUNTER);
|
||||||
if (!target || caster == target)
|
|
||||||
return;
|
|
||||||
|
|
||||||
target->CastSpell(target->GetPositionX() + irand(-10, 10), target->GetPositionY() + irand(-10, 10), target->GetPositionZ(), SPELL_RACER_DEATH_VISUAL, true);
|
|
||||||
target->DespawnOrUnsummon(3000);
|
|
||||||
target->CastSpell(target, SPELL_RACER_FLAMES, true);
|
|
||||||
caster->CastSpell(caster, SPELL_RACER_KILL_COUNTER, true);
|
|
||||||
|
|
||||||
if (Player* targetSummoner = target->GetCharmerOrOwnerPlayerOrPlayerItself())
|
|
||||||
{
|
|
||||||
//targetSummoner->RemoveCriteriaProgress(sAchievementCriteriaStore.LookupEntry(RACER_ACHI_CRITERIA)); !ZOMG, ADD ACCESSOR
|
|
||||||
targetSummoner->RemoveAurasDueToSpell(SPELL_RACER_KILL_COUNTER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Register() override
|
void Register() override
|
||||||
{
|
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_racer_slam_hit_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SpellScript* GetSpellScript() const override
|
|
||||||
{
|
{
|
||||||
return new spell_winter_veil_racer_slam_hit_SpellScript();
|
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_racer_slam_hit::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -263,60 +219,49 @@ enum airRifle
|
|||||||
|
|
||||||
/* 65576 - Pelted!
|
/* 65576 - Pelted!
|
||||||
67533 - Shoot Air Rifle */
|
67533 - Shoot Air Rifle */
|
||||||
class spell_winter_veil_shoot_air_rifle : public SpellScriptLoader
|
class spell_winter_veil_shoot_air_rifle : public SpellScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareSpellScript(spell_winter_veil_shoot_air_rifle);
|
||||||
spell_winter_veil_shoot_air_rifle() : SpellScriptLoader("spell_winter_veil_shoot_air_rifle") {}
|
|
||||||
|
|
||||||
class spell_winter_veil_shoot_air_rifle_SpellScript : public SpellScript
|
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
||||||
{
|
{
|
||||||
PrepareSpellScript(spell_winter_veil_shoot_air_rifle_SpellScript);
|
Unit* caster = GetOriginalCaster();
|
||||||
|
Unit* target = GetHitUnit();
|
||||||
|
if (!target)
|
||||||
|
return;
|
||||||
|
|
||||||
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
if (GetSpellInfo()->Id == SPELL_AIR_RIFLE_HIT_TRIGGER)
|
||||||
{
|
{
|
||||||
Unit* caster = GetOriginalCaster();
|
if (!caster->IsFriendlyTo(target))
|
||||||
Unit* target = GetHitUnit();
|
caster->CastSpell(target, SPELL_AIR_RIFLE_PELTED_DAMAGE, true, nullptr, nullptr, caster->GetGUID());
|
||||||
if (!target)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (GetSpellInfo()->Id == SPELL_AIR_RIFLE_HIT_TRIGGER)
|
|
||||||
{
|
|
||||||
if (!caster->IsFriendlyTo(target))
|
|
||||||
caster->CastSpell(target, SPELL_AIR_RIFLE_PELTED_DAMAGE, true, nullptr, nullptr, caster->GetGUID());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint8 rand = urand(0, 99);
|
|
||||||
if (rand < 15)
|
|
||||||
caster->CastSpell(caster, SPELL_AIR_RIFLE_RIGHT_IN_THE_EYE, true, nullptr, nullptr, caster->GetGUID());
|
|
||||||
else if (rand < 35)
|
|
||||||
caster->CastSpell(target, SPELL_AIR_RIFLE_STARLED, true, nullptr, nullptr, caster->GetGUID());
|
|
||||||
else
|
|
||||||
caster->CastSpell(target, SPELL_AIR_RIFLE_HIT, true, nullptr, nullptr, caster->GetGUID());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
void Register() override
|
|
||||||
{
|
{
|
||||||
if (m_scriptSpellId == SPELL_AIR_RIFLE_HIT_TRIGGER)
|
uint8 rand = urand(0, 99);
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_shoot_air_rifle_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
|
if (rand < 15)
|
||||||
|
caster->CastSpell(caster, SPELL_AIR_RIFLE_RIGHT_IN_THE_EYE, true, nullptr, nullptr, caster->GetGUID());
|
||||||
|
else if (rand < 35)
|
||||||
|
caster->CastSpell(target, SPELL_AIR_RIFLE_STARLED, true, nullptr, nullptr, caster->GetGUID());
|
||||||
else
|
else
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_shoot_air_rifle_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
caster->CastSpell(target, SPELL_AIR_RIFLE_HIT, true, nullptr, nullptr, caster->GetGUID());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
SpellScript* GetSpellScript() const override
|
void Register() override
|
||||||
{
|
{
|
||||||
return new spell_winter_veil_shoot_air_rifle_SpellScript();
|
if (m_scriptSpellId == SPELL_AIR_RIFLE_HIT_TRIGGER)
|
||||||
|
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_shoot_air_rifle::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||||
|
else
|
||||||
|
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_shoot_air_rifle::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddSC_event_winter_veil_scripts()
|
void AddSC_event_winter_veil_scripts()
|
||||||
{
|
{
|
||||||
// Spells
|
// Spells
|
||||||
new spell_winter_veil_mistletoe();
|
RegisterSpellScript(spell_winter_veil_mistletoe);
|
||||||
new spell_winter_wondervolt_trap();
|
RegisterSpellScript(spell_winter_wondervolt_trap);
|
||||||
new spell_winter_veil_racer_rocket_slam();
|
RegisterSpellScript(spell_winter_veil_racer_rocket_slam);
|
||||||
new spell_winter_veil_racer_slam_hit();
|
RegisterSpellScript(spell_winter_veil_racer_slam_hit);
|
||||||
new spell_winter_veil_shoot_air_rifle();
|
RegisterSpellScript(spell_winter_veil_shoot_air_rifle);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user