1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* 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/>.
*/
#include "ScriptMgr.h"
#include "Containers.h"
#include "CreatureAIImpl.h"
#include "Player.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
enum Mistletoe
{
SPELL_CREATE_MISTLETOE = 26206,
SPELL_CREATE_HOLLY = 26207,
SPELL_CREATE_SNOWFLAKES = 45036
};
// 26218 - Mistletoe
class spell_winter_veil_mistletoe : public SpellScript
{
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);
GetCaster()->CastSpell(target, spellId, true);
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_mistletoe::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
enum PX238WinterWondervolt
{
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_1 = 26157,
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_2 = 26272,
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_3 = 26273,
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_4 = 26274
};
std::array<uint32, 4> const WonderboltTransformSpells =
{
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_1,
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_2,
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_3,
SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_4
};
// 26275 - PX-238 Winter Wondervolt TRAP
class spell_winter_veil_px_238_winter_wondervolt : public SpellScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo(WonderboltTransformSpells);
}
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit())
{
for (uint32 spell : WonderboltTransformSpells)
if (target->HasAura(spell))
return;
target->CastSpell(target, Trinity::Containers::SelectRandomContainerElement(WonderboltTransformSpells), true);
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_winter_veil_px_238_winter_wondervolt::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
enum ReindeerTransformation
{
SPELL_FLYING_REINDEER_310 = 44827,
SPELL_FLYING_REINDEER_280 = 44825,
SPELL_FLYING_REINDEER_60 = 44824,
SPELL_REINDEER_100 = 25859,
SPELL_REINDEER_60 = 25858,
};
// 25860 - Reindeer Transformation
class spell_winter_veil_reindeer_transformation : public SpellScript
{
bool Validate(SpellInfo const* /*spell*/) override
{
return ValidateSpellInfo(
{
SPELL_FLYING_REINDEER_310,
SPELL_FLYING_REINDEER_280,
SPELL_FLYING_REINDEER_60,
SPELL_REINDEER_100,
SPELL_REINDEER_60
});
}
void HandleDummy(SpellEffIndex /* effIndex */)
{
Unit* caster = GetCaster();
if (caster->HasAuraType(SPELL_AURA_MOUNTED))
{
float flyspeed = caster->GetSpeedRate(MOVE_FLIGHT);
float speed = caster->GetSpeedRate(MOVE_RUN);
caster->RemoveAurasByType(SPELL_AURA_MOUNTED);
//5 different spells used depending on mounted speed and if mount can fly or not
if (flyspeed >= 4.1f)
// Flying Reindeer
caster->CastSpell(caster, SPELL_FLYING_REINDEER_310, true); //310% flying Reindeer
else if (flyspeed >= 3.8f)
// Flying Reindeer
caster->CastSpell(caster, SPELL_FLYING_REINDEER_280, true); //280% flying Reindeer
else if (flyspeed >= 1.6f)
// Flying Reindeer
caster->CastSpell(caster, SPELL_FLYING_REINDEER_60, true); //60% flying Reindeer
else if (speed >= 2.0f)
// Reindeer
caster->CastSpell(caster, SPELL_REINDEER_100, true); //100% ground Reindeer
else
// Reindeer
caster->CastSpell(caster, SPELL_REINDEER_60, true); //60% ground Reindeer
}
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_winter_veil_reindeer_transformation::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
void AddSC_event_winter_veil()
{
RegisterSpellScript(spell_winter_veil_mistletoe);
RegisterSpellScript(spell_winter_veil_px_238_winter_wondervolt);
RegisterSpellScript(spell_winter_veil_reindeer_transformation);
}
|