Skip to content

Commit e5070fb

Browse files
committed
Add spell script for using bg banners.
1 parent a102c96 commit e5070fb

3 files changed

Lines changed: 53 additions & 16 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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`='20250523175837');
7+
IF v = 0 THEN
8+
INSERT INTO `migrations` VALUES ('20250523175837');
9+
-- Add your query below.
10+
11+
12+
UPDATE `spell_template` SET `script_name`='spell_opening_battleground_banner' WHERE `entry`=21651;
13+
14+
15+
-- End of migration.
16+
END IF;
17+
END??
18+
DELIMITER ;
19+
CALL add_migration();
20+
DROP PROCEDURE IF EXISTS add_migration;

src/game/Spells/Spell.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8707,24 +8707,9 @@ void Spell::SetClientStarted(bool bisClientStarted)
87078707

87088708
void Spell::OnSpellLaunch()
87098709
{
8710-
if (!m_casterUnit || !m_caster->IsInWorld())
8710+
if (!m_casterUnit || !m_casterUnit->IsInWorld())
87118711
return;
87128712

8713-
// Make sure the player is sending a valid GO target and lock ID. SPELL_EFFECT_OPEN_LOCK
8714-
// can succeed with a lockId of 0
8715-
if (m_spellInfo->Id == 21651)
8716-
{
8717-
if (GameObject* go = m_targets.getGOTarget())
8718-
{
8719-
LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->GetLockId());
8720-
if (lockInfo && lockInfo->Index[1] == LOCKTYPE_SLOW_OPEN)
8721-
{
8722-
Spell* visual = new Spell(m_casterUnit, sSpellMgr.GetSpellEntry(24390), true);
8723-
visual->prepare();
8724-
}
8725-
}
8726-
}
8727-
87288713
unitTarget = m_targets.getUnitTarget();
87298714

87308715
// Charge handled here instead of in effect handler

src/scripts/spells/spell_special.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,33 @@ SpellScript* GetScript_ClearAllCooldowns(SpellEntry const*)
246246
return new ClearAllCooldownsScript();
247247
}
248248

249+
// 21651 - Opening
250+
struct OpeningBattlegroundBannerScript : public SpellScript
251+
{
252+
void OnSuccessfulStart(Spell* spell) const final
253+
{
254+
if (!spell->m_casterUnit)
255+
return;
256+
257+
if (GameObject* go = spell->m_targets.getGOTarget())
258+
{
259+
// Make sure the player is sending a valid GO target and lock ID.
260+
// SPELL_EFFECT_OPEN_LOCK can succeed with a lockId of 0.
261+
LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->GetLockId());
262+
if (lockInfo && lockInfo->Index[1] == LOCKTYPE_SLOW_OPEN)
263+
{
264+
Spell* visual = new Spell(spell->m_casterUnit, sSpellMgr.GetSpellEntry(24390), true);
265+
visual->prepare();
266+
}
267+
}
268+
}
269+
};
270+
271+
SpellScript* GetScript_OpeningBattlegroundBanner(SpellEntry const*)
272+
{
273+
return new OpeningBattlegroundBannerScript();
274+
}
275+
249276
void AddSC_special_spell_scripts()
250277
{
251278
Script* newscript;
@@ -309,4 +336,9 @@ void AddSC_special_spell_scripts()
309336
newscript->Name = "spell_clear_all_cooldowns";
310337
newscript->GetSpellScript = &GetScript_ClearAllCooldowns;
311338
newscript->RegisterSelf();
339+
340+
newscript = new Script;
341+
newscript->Name = "spell_opening_battleground_banner";
342+
newscript->GetSpellScript = &GetScript_OpeningBattlegroundBanner;
343+
newscript->RegisterSelf();
312344
}

0 commit comments

Comments
 (0)