Scripts/Spells: Fix support for 'Teleport This!' (10857) (#26789)

Co-authored-by: offl <offl@users.noreply.github.com>
This commit is contained in:
offl
2021-08-10 11:18:28 +03:00
committed by GitHub
parent c7ae9d761a
commit 8186e6deca
2 changed files with 81 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
--
DELETE FROM `smart_scripts` WHERE `entryorguid` IN (16943,20928) AND `source_type` = 0 AND `id` IN (3,4,5);
DELETE FROM `smart_scripts` WHERE `entryorguid` IN (22348,22350,22351) AND `source_type` = 0;
UPDATE `creature_template` SET `AIName` = '' WHERE `entry` IN (22348,22350,22351);
DELETE FROM `spell_script_names` WHERE `spell_id` = 38920 AND `ScriptName` = 'spell_detonate_teleporter';
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(38920,'spell_detonate_teleporter');

View File

@@ -27,13 +27,11 @@ npc_commander_dawnforge
EndContentData */
#include "ScriptMgr.h"
#include "GameObject.h"
#include "GameObjectAI.h"
#include "Log.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "ScriptedEscortAI.h"
#include "ScriptedGossip.h"
#include "SpellScript.h"
/*######
## npc_commander_dawnforge
@@ -461,9 +459,81 @@ public:
};
};
/*######
## Quest 10857: Teleport This!
######*/
enum DetonateTeleporter
{
SPELL_TELEPORTER_KILL_CREDIT_1 = 38982, // 22348
SPELL_TELEPORTER_KILL_CREDIT_2 = 38983, // 22351
SPELL_TELEPORTER_KILL_CREDIT_3 = 38984, // 22350
NPC_WESTERN_TELEPORTER_CREDIT = 22348,
NPC_EASTERN_TELEPORTER_CREDIT = 22351,
NPC_CENTRAL_TELEPORTER_CREDIT = 22350
};
// 38920 - Detonate Teleporter
class spell_detonate_teleporter : public SpellScript
{
PrepareSpellScript(spell_detonate_teleporter);
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_UNIT;
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo(
{
SPELL_TELEPORTER_KILL_CREDIT_1,
SPELL_TELEPORTER_KILL_CREDIT_2,
SPELL_TELEPORTER_KILL_CREDIT_3
});
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
if (Unit* creature = GetHitCreature())
{
if (Unit* charmer = GetCaster()->GetCharmerOrOwner())
{
if (Player* player = charmer->ToPlayer())
{
uint32 spellId = 0;
switch (creature->GetEntry())
{
case NPC_WESTERN_TELEPORTER_CREDIT:
spellId = SPELL_TELEPORTER_KILL_CREDIT_1;
break;
case NPC_EASTERN_TELEPORTER_CREDIT:
spellId = SPELL_TELEPORTER_KILL_CREDIT_2;
break;
case NPC_CENTRAL_TELEPORTER_CREDIT:
spellId = SPELL_TELEPORTER_KILL_CREDIT_3;
break;
default:
return;
}
player->CastSpell(player, spellId);
}
}
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_detonate_teleporter::HandleScript, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
void AddSC_netherstorm()
{
new npc_commander_dawnforge();
new at_commander_dawnforge();
new npc_phase_hunter();
RegisterSpellScript(spell_detonate_teleporter);
}