Skip to content

Commit d8034eb

Browse files
committed
Add more spell scripts.
1 parent b4efb11 commit d8034eb

File tree

7 files changed

+226
-74
lines changed

7 files changed

+226
-74
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
DROP PROCEDURE IF EXISTS add_migration;
2+
DELIMITER ??
3+
CREATE PROCEDURE `add_migration`()
4+
BEGIN
5+
DECLARE v INT DEFAULT 1;
6+
SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20250407022846');
7+
IF v = 0 THEN
8+
INSERT INTO `migrations` VALUES ('20250407022846');
9+
-- Add your query below.
10+
11+
12+
-- Add scripts for more spells.
13+
UPDATE `spell_template` SET `script_name`='spell_gnomeregan_collecting_fallout' WHERE `entry`=12709;
14+
DELETE FROM `spell_effect_mod` WHERE `Id`=12709;
15+
UPDATE `spell_template` SET `script_name`='spell_linkens_boomerang' WHERE `entry`=15712;
16+
UPDATE `spell_template` SET `script_name`='spell_scorpid_surprise' WHERE `entry`=6410;
17+
UPDATE `spell_template` SET `script_name`='spell_rogue_vanish' WHERE `entry` IN (1856, 1857, 27617);
18+
UPDATE `spell_template` SET `script_name`='spell_brittle_armor_dummy' WHERE `entry`=29284;
19+
UPDATE `spell_template` SET `script_name`='spell_mercurial_shield_dummy' WHERE `entry`=29286;
20+
UPDATE `spell_template` SET `script_name`='spell_everlook_transporter' WHERE `entry`=23442;
21+
22+
23+
-- End of migration.
24+
END IF;
25+
END??
26+
DELIMITER ;
27+
CALL add_migration();
28+
DROP PROCEDURE IF EXISTS add_migration;

src/game/ScriptMgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct SpellScript
140140
virtual ~SpellScript() = default;
141141

142142
// called on spell init
143-
virtual void OnInit(Spell* /*spell*/) const {}
143+
virtual void OnInit(Spell* /*spell*/) {}
144144
// called on success during Spell::Prepare
145145
virtual void OnSuccessfulStart(Spell* /*spell*/) const {}
146146
// called on success inside Spell::finish - for channels this only happens if whole channel went through

src/game/Spells/SpellEffects.cpp

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,64 +1472,6 @@ void Spell::EffectTriggerSpell(SpellEffectIndex effIdx)
14721472

14731473
uint32 triggeredSpellId = m_spellInfo->EffectTriggerSpell[effIdx];
14741474

1475-
// special cases
1476-
switch (m_spellInfo->Id)
1477-
{
1478-
// The Only Cure is More Green Glow quest 2962
1479-
case 12709:
1480-
m_caster->CastSpell(unitTarget, (urand(0, 2) ? 11638 : 11637), true, m_CastItem, nullptr, m_originalCasterGUID);
1481-
return;
1482-
// Linken's Boomerang: 10% chance to proc stun, 3% chance to proc disarm (dubious numbers)
1483-
case 15712:
1484-
if (triggeredSpellId == 15753)
1485-
{
1486-
if (urand(0, 10))
1487-
return;
1488-
}
1489-
else if (triggeredSpellId == 15752)
1490-
{
1491-
if (urand(0, 30))
1492-
return;
1493-
}
1494-
1495-
break;
1496-
}
1497-
switch (triggeredSpellId)
1498-
{
1499-
// Item [Scorpid Surprise] - Heals 294 damage over 21 sec, assuming you don't bite down on a poison sac.
1500-
// 10% proc rate (no source !)
1501-
case 6411:
1502-
if (urand(0, 10))
1503-
return;
1504-
break;
1505-
// Vanish
1506-
case 18461:
1507-
{
1508-
unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
1509-
unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
1510-
1511-
// World of Warcraft Client Patch 1.12.0 (2006-08-22)
1512-
// - Vanish now removes effects that allow the caster to always remain
1513-
// aware of their target(currently Hunter's Mark and Mind Vision).
1514-
#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_11_2
1515-
unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED);
1516-
#endif
1517-
1518-
if (Player* pPlayer = unitTarget->ToPlayer())
1519-
pPlayer->CastHighestStealthRank();
1520-
1521-
return;
1522-
}
1523-
// Brittle Armor - (need add max stack of 24575 Brittle Armor)
1524-
case 29284:
1525-
m_caster->CastSpell(unitTarget, 24575, true, m_CastItem, nullptr, m_originalCasterGUID);
1526-
return;
1527-
// Mercurial Shield - (need add max stack of 26464 Mercurial Shield)
1528-
case 29286:
1529-
m_caster->CastSpell(unitTarget, 26464, true, m_CastItem, nullptr, m_originalCasterGUID);
1530-
return;
1531-
}
1532-
15331475
// normal case
15341476
SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(triggeredSpellId);
15351477
if (!spellInfo)
@@ -1632,7 +1574,7 @@ void Spell::EffectTeleportUnits(SpellEffectIndex effIdx)
16321574
unitTarget->NearTeleportTo(*st, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget == m_caster ? TELE_TO_SPELL : 0));
16331575
else if (unitTarget->GetTypeId() == TYPEID_PLAYER)
16341576
((Player*)unitTarget)->TeleportTo(*st, unitTarget == m_caster ? TELE_TO_SPELL : 0);
1635-
break;
1577+
return;
16361578
}
16371579
case TARGET_LOCATION_CASTER_DEST:
16381580
{
@@ -1666,19 +1608,6 @@ void Spell::EffectTeleportUnits(SpellEffectIndex effIdx)
16661608
return;
16671609
}
16681610
}
1669-
1670-
// post effects for TARGET_LOCATION_DATABASE
1671-
if (m_spellInfo->Id == 23442 && m_casterUnit)
1672-
{
1673-
int32 r = irand(0, 119);
1674-
if (r >= 70) // 7/12 success
1675-
{
1676-
if (r < 100) // 4/12 evil twin
1677-
m_casterUnit->CastSpell(m_casterUnit, 23445, true);
1678-
else // 1/12 fire
1679-
m_casterUnit->CastSpell(m_casterUnit, 23449, true);
1680-
}
1681-
}
16821611
}
16831612

16841613
void Spell::EffectApplyAura(SpellEffectIndex effIdx)

src/scripts/eastern_kingdoms/dun_morogh/gnomeregan/gnomeregan.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,27 @@ bool QuestAccept_npc_kernobee(Player* pPlayer, Creature* pCreature, Quest const*
885885
return true;
886886
}
887887

888+
// 12709 - Collecting Fallout (Heavy Leaden Collection Phial)
889+
struct GnomereganCollectingFalloutScript : public SpellScript
890+
{
891+
uint32 chosenEffect = 0;
892+
893+
void OnInit(Spell* /*spell*/) final
894+
{
895+
chosenEffect = urand(EFFECT_INDEX_0, EFFECT_INDEX_1);
896+
}
888897

898+
bool OnEffectExecute(Spell* spell, SpellEffectIndex effIdx) const final
899+
{
900+
// only execute one of the trigger spell effects
901+
return effIdx == chosenEffect;
902+
}
903+
};
904+
905+
SpellScript* GetScript_GnomereganCollectingFallout(SpellEntry const*)
906+
{
907+
return new GnomereganCollectingFalloutScript();
908+
}
889909

890910
void AddSC_gnomeregan()
891911
{
@@ -903,4 +923,9 @@ void AddSC_gnomeregan()
903923
pNewScript->GetAI = &GetAI_npc_kernobee;
904924
pNewScript->pQuestAcceptNPC = &QuestAccept_npc_kernobee;
905925
pNewScript->RegisterSelf();
926+
927+
pNewScript = new Script;
928+
pNewScript->Name = "spell_gnomeregan_collecting_fallout";
929+
pNewScript->GetSpellScript = &GetScript_GnomereganCollectingFallout;
930+
pNewScript->RegisterSelf();
906931
}

src/scripts/spells/spell_item.cpp

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ struct NoggenfoggerElixirScript : public SpellScript
133133

134134
pPlayer->CastSpell(pPlayer, randomSpellId, true, nullptr);
135135
}
136+
return true;
136137
}
137138
};
138139

@@ -141,6 +142,113 @@ SpellScript* GetScript_NoggenfoggerElixir(SpellEntry const*)
141142
return new NoggenfoggerElixirScript();
142143
}
143144

145+
// 15712 - Linken's Boomerang
146+
struct LinkensBoomerangScript : public SpellScript
147+
{
148+
bool OnEffectExecute(Spell* spell, SpellEffectIndex effIdx) const final
149+
{
150+
// 10% chance to proc stun, 3% chance to proc disarm (dubious numbers)
151+
if (effIdx == EFFECT_INDEX_1)
152+
{
153+
if (urand(0, 30))
154+
return false;
155+
}
156+
else if (effIdx == EFFECT_INDEX_2)
157+
{
158+
if (urand(0, 10))
159+
return false;
160+
}
161+
return true;
162+
}
163+
};
164+
165+
SpellScript* GetScript_LinkensBoomerang(SpellEntry const*)
166+
{
167+
return new LinkensBoomerangScript();
168+
}
169+
170+
// 6410 - Food (Scorpid Surprise)
171+
struct ScorpidSurpriseScript : public SpellScript
172+
{
173+
bool OnEffectExecute(Spell* spell, SpellEffectIndex effIdx) const final
174+
{
175+
if (effIdx == EFFECT_INDEX_1)
176+
{
177+
// Heals 294 damage over 21 sec, assuming you don't bite down on a poison sac.
178+
// 10% proc rate (no source !)
179+
if (urand(0, 10))
180+
return false;
181+
}
182+
return true;
183+
}
184+
};
185+
186+
SpellScript* GetScript_ScorpidSurprise(SpellEntry const*)
187+
{
188+
return new ScorpidSurpriseScript();
189+
}
190+
191+
// 29284 - Brittle Armor (Zandalarian Hero Badge)
192+
struct BrittleArmorDummyScript : public SpellScript
193+
{
194+
bool OnEffectExecute(Spell* spell, SpellEffectIndex effIdx) const final
195+
{
196+
if (effIdx == EFFECT_INDEX_0 && spell->GetUnitTarget())
197+
{
198+
spell->m_caster->CastSpell(spell->GetUnitTarget(), 24575, true);
199+
}
200+
return true;
201+
}
202+
};
203+
204+
SpellScript* GetScript_BrittleArmorDummy(SpellEntry const*)
205+
{
206+
return new BrittleArmorDummyScript();
207+
}
208+
209+
// 29286 - Mercurial Shield (Petrified Scarab)
210+
struct MercurialShieldDummyScript : public SpellScript
211+
{
212+
bool OnEffectExecute(Spell* spell, SpellEffectIndex effIdx) const final
213+
{
214+
if (effIdx == EFFECT_INDEX_0 && spell->GetUnitTarget())
215+
{
216+
spell->m_caster->CastSpell(spell->GetUnitTarget(), 26464, true);
217+
}
218+
return true;
219+
}
220+
};
221+
222+
SpellScript* GetScript_MercurialShieldDummy(SpellEntry const*)
223+
{
224+
return new MercurialShieldDummyScript();
225+
}
226+
227+
// 23442 - Everlook Transporter (Dimensional Ripper - Everlook)
228+
struct EverlookTransporterScript : public SpellScript
229+
{
230+
bool OnEffectExecute(Spell* spell, SpellEffectIndex effIdx) const final
231+
{
232+
if (effIdx == EFFECT_INDEX_0 && spell->m_casterUnit)
233+
{
234+
int32 r = irand(0, 119);
235+
if (r >= 70) // 7/12 success
236+
{
237+
if (r < 100) // 4/12 evil twin
238+
spell->m_casterUnit->CastSpell(spell->m_casterUnit, 23445, true);
239+
else // 1/12 fire
240+
spell->m_casterUnit->CastSpell(spell->m_casterUnit, 23449, true);
241+
}
242+
}
243+
return true;
244+
}
245+
};
246+
247+
SpellScript* GetScript_EverlookTransporter(SpellEntry const*)
248+
{
249+
return new EverlookTransporterScript();
250+
}
251+
144252
void AddSC_item_spell_scripts()
145253
{
146254
Script* newscript;
@@ -164,4 +272,29 @@ void AddSC_item_spell_scripts()
164272
newscript->Name = "spell_noggenfogger_elixir";
165273
newscript->GetSpellScript = &GetScript_NoggenfoggerElixir;
166274
newscript->RegisterSelf();
275+
276+
newscript = new Script;
277+
newscript->Name = "spell_linkens_boomerang";
278+
newscript->GetSpellScript = &GetScript_LinkensBoomerang;
279+
newscript->RegisterSelf();
280+
281+
newscript = new Script;
282+
newscript->Name = "spell_scorpid_surprise";
283+
newscript->GetSpellScript = &GetScript_ScorpidSurprise;
284+
newscript->RegisterSelf();
285+
286+
newscript = new Script;
287+
newscript->Name = "spell_brittle_armor_dummy";
288+
newscript->GetSpellScript = &GetScript_BrittleArmorDummy;
289+
newscript->RegisterSelf();
290+
291+
newscript = new Script;
292+
newscript->Name = "spell_mercurial_shield_dummy";
293+
newscript->GetSpellScript = &GetScript_MercurialShieldDummy;
294+
newscript->RegisterSelf();
295+
296+
newscript = new Script;
297+
newscript->Name = "spell_everlook_transporter";
298+
newscript->GetSpellScript = &GetScript_EverlookTransporter;
299+
newscript->RegisterSelf();
167300
}

src/scripts/spells/spell_rogue.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,38 @@ SpellScript* GetScript_RogueEviscerate(SpellEntry const*)
4545
return new RogueEviscerateScript();
4646
}
4747

48+
// 1856, 1857, 27617 - Vanish
49+
struct RogueVanishScript : SpellScript
50+
{
51+
bool OnEffectExecute(Spell* spell, SpellEffectIndex effIdx) const final
52+
{
53+
if (effIdx == EFFECT_INDEX_1 && spell->GetUnitTarget())
54+
{
55+
spell->GetUnitTarget()->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
56+
spell->GetUnitTarget()->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
57+
58+
// World of Warcraft Client Patch 1.12.0 (2006-08-22)
59+
// - Vanish now removes effects that allow the caster to always remain
60+
// aware of their target(currently Hunter's Mark and Mind Vision).
61+
#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_11_2
62+
spell->GetUnitTarget()->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED);
63+
#endif
64+
65+
if (Player* pPlayer = spell->GetUnitTarget()->ToPlayer())
66+
pPlayer->CastHighestStealthRank();
67+
68+
return false;
69+
70+
}
71+
return true;
72+
}
73+
};
74+
75+
SpellScript* GetScript_RogueVanish(SpellEntry const*)
76+
{
77+
return new RogueVanishScript();
78+
}
79+
4880
void AddSC_rogue_spell_scripts()
4981
{
5082
Script* newscript;
@@ -53,4 +85,9 @@ void AddSC_rogue_spell_scripts()
5385
newscript->Name = "spell_rogue_eviscerate";
5486
newscript->GetSpellScript = &GetScript_RogueEviscerate;
5587
newscript->RegisterSelf();
88+
89+
newscript = new Script;
90+
newscript->Name = "spell_rogue_vanish";
91+
newscript->GetSpellScript = &GetScript_RogueVanish;
92+
newscript->RegisterSelf();
5693
}

src/scripts/spells/spell_special.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SpellScript* GetScript_Meteor(SpellEntry const*)
4343
// 24934 - Darkmoon Steam Tonk Control Console
4444
struct DarkmoonSteamTonkControlConsoleScript : public SpellScript
4545
{
46-
void OnInit(Spell* spell) const final
46+
void OnInit(Spell* spell) final
4747
{
4848
// Unsummon a potential Hunter or Warlock pet when using the Tonk Control Console.
4949
// Without this, the player will be unable to summon a Tonk but will still be

0 commit comments

Comments
 (0)