Scripts/Quest: Improved script for Abduction (#28306)

(cherry picked from commit f7ebdd3631)
This commit is contained in:
Malcrom
2022-10-14 09:33:35 -03:00
committed by Shauren
parent d81db584b4
commit 0b948b758f
2 changed files with 158 additions and 81 deletions

View File

@@ -0,0 +1,21 @@
-- *** Quest 11590 "Abduction" ***
-- Condition for source Spell condition type Object entry guid
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=17 AND `SourceGroup`=0 AND `SourceEntry`=45611 AND `SourceId`=0;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES
(17, 0, 45611, 0, 0, 31, 1, 3, 25316, 0, 0, 12, 0, '', 'Spell Arcane Chains will hit the explicit target of the spell if target is unit Beryl Sorcerer.'),
(17, 0, 45611, 0, 0, 38, 1, 25, 4, 0, 0, 12, 0, '', 'Spell Arcane Chains will hit the explicit target of the spell if target health percentage must be equal or lower than 25% of max Health.');
DELETE FROM `spell_script_names` WHERE `spell_id`= 45625;
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(45625, 'spell_arcane_chains_character_force_cast');
-- Update creatures
UPDATE `creature_template` SET `minlevel`=69, `maxlevel`=70, `unit_flags`=32768, `unit_class`=2, `ScriptName`='npc_captured_beryl_sorcerer' WHERE `entry`=25474;
UPDATE `creature_template` SET `AIName`='' WHERE `entry`=25316;
DELETE FROM `smart_scripts` WHERE `entryorguid`=25316;
-- Condition for source Spell implicit target condition type Object entry guid
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceGroup`=1 AND `SourceEntry`=45735 AND `SourceId`=0;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES
(13, 1, 45735, 0, 0, 31, 0, 3, 25474, 0, 0, 0, 0, '', 'Spell Arcane Chains: Chain Channel II (effect 0) will hit the target of the spell if target is unit Captured Beryl Sorcerer.');

View File

@@ -36,6 +36,140 @@
#include "TemporarySummon.h"
#include "WorldSession.h"
/*######
## Quest 11590: Abduction
######*/
// NPC 25316: Beryl Sorcerer
enum BerylSorcerer
{
EVENT_FROSTBOLT = 1,
EVENT_ARCANE_CHAINS,
NPC_LIBRARIAN_DONATHAN = 25262,
NPC_CAPTURED_BERLY_SORCERER = 25474,
SPELL_FROSTBOLT = 9672,
SPELL_ARCANE_CHAINS = 45611,
SPELL_ARCANE_CHAINS_CHARACTER_FORCE_CAST = 45625,
SPELL_ARCANE_CHAINS_SUMMON_CHAINED_MAGE_HUNTER = 45626,
SPELL_COSMETIC_ENSLAVE_CHAINS_SELF = 45631,
SPELL_ARCANE_CHAINS_CHANNEL_II = 45735
};
struct npc_beryl_sorcerer : public ScriptedAI
{
npc_beryl_sorcerer(Creature* creature) : ScriptedAI(creature), _chainsCast(false) { }
void JustAppeared() override
{
me->SetReactState(REACT_AGGRESSIVE);
}
void JustEngagedWith(Unit* who) override
{
if (me->IsValidAttackTarget(who))
AttackStart(who);
_events.ScheduleEvent(EVENT_FROSTBOLT, 3s, 4s);
}
void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
{
if (_chainsCast)
return;
if (spellInfo->Id == SPELL_ARCANE_CHAINS && caster->IsPlayer())
{
_playerGUID = caster->GetGUID();
_chainsCast = true;
_events.ScheduleEvent(EVENT_ARCANE_CHAINS, 4s);
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
_events.Update(diff);
if (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_FROSTBOLT:
DoCastVictim(SPELL_FROSTBOLT);
_events.ScheduleEvent(EVENT_FROSTBOLT, 3s, 4s);
break;
case EVENT_ARCANE_CHAINS:
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
{
me->CastSpell(player, SPELL_ARCANE_CHAINS_CHARACTER_FORCE_CAST);
player->KilledMonsterCredit(NPC_CAPTURED_BERLY_SORCERER);
}
me->DespawnOrUnsummon();
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
private:
EventMap _events;
bool _chainsCast;
ObjectGuid _playerGUID;
};
// NPC 25474: Captured Beryl Sorcerer
struct npc_captured_beryl_sorcerer : public FollowerAI
{
npc_captured_beryl_sorcerer(Creature* creature) : FollowerAI(creature) { }
void JustAppeared() override
{
me->SetReactState(REACT_DEFENSIVE);
me->SetImmuneToAll(true);
if (TempSummon const* tempSummon = me->ToTempSummon())
{
if (Player* summoner = Object::ToPlayer(tempSummon->GetSummoner()))
{
summoner->CastSpell(summoner, SPELL_ARCANE_CHAINS_CHANNEL_II);
StartFollow(summoner);
}
}
}
void MoveInLineOfSight(Unit* who) override
{
FollowerAI::MoveInLineOfSight(who);
if (who->GetEntry() == NPC_LIBRARIAN_DONATHAN && me->IsWithinDistInMap(who, INTERACTION_DISTANCE))
{
SetFollowComplete();
me->DespawnOrUnsummon();
}
}
};
// Spell 45625: - Arcane Chains: Character Force Cast
class spell_arcane_chains_character_force_cast : public SpellScript
{
PrepareSpellScript(spell_arcane_chains_character_force_cast);
void HandleScriptEffect(SpellEffIndex /* effIndex */)
{
GetHitUnit()->CastSpell(GetCaster(), SPELL_ARCANE_CHAINS_SUMMON_CHAINED_MAGE_HUNTER); // Player cast back 45626 on npc
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_arcane_chains_character_force_cast::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
/*######
## Quest 11865: Unfit for Death
######*/
@@ -997,86 +1131,6 @@ public:
}
};
/*######
## npc_beryl_sorcerer
######*/
enum BerylSorcerer
{
NPC_CAPTURED_BERLY_SORCERER = 25474,
NPC_LIBRARIAN_DONATHAN = 25262,
SPELL_ARCANE_CHAINS = 45611,
SPELL_COSMETIC_CHAINS = 54324,
SPELL_COSMETIC_ENSLAVE_CHAINS_SELF = 45631
};
struct npc_beryl_sorcerer : public FollowerAI
{
npc_beryl_sorcerer(Creature* creature) : FollowerAI(creature)
{
Initialize();
}
void Initialize()
{
bEnslaved = false;
}
bool bEnslaved;
void Reset() override
{
me->SetReactState(REACT_AGGRESSIVE);
Initialize();
}
void JustEngagedWith(Unit* who) override
{
if (me->IsValidAttackTarget(who))
AttackStart(who);
}
void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
{
Player* playerCaster = caster->ToPlayer();
if (!playerCaster)
return;
if (spellInfo->Id == SPELL_ARCANE_CHAINS && !HealthAbovePct(50) && !bEnslaved)
{
EnterEvadeMode(); //We make sure that the npc is not attacking the player!
me->SetReactState(REACT_PASSIVE);
StartFollow(playerCaster);
me->UpdateEntry(NPC_CAPTURED_BERLY_SORCERER);
DoCast(me, SPELL_COSMETIC_ENSLAVE_CHAINS_SELF, true);
playerCaster->KilledMonsterCredit(NPC_CAPTURED_BERLY_SORCERER);
bEnslaved = true;
}
}
void MoveInLineOfSight(Unit* who) override
{
FollowerAI::MoveInLineOfSight(who);
if (who->GetEntry() == NPC_LIBRARIAN_DONATHAN && me->IsWithinDistInMap(who, INTERACTION_DISTANCE))
{
SetFollowComplete();
me->DisappearAndDie();
}
}
void UpdateAI(uint32 /*diff*/) override
{
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
};
/*######
## Valiance Keep Cannoneer script to activate cannons
######*/
@@ -1814,6 +1868,9 @@ class spell_borean_tundra_arcane_prisoner_rescue : public SpellScript
void AddSC_borean_tundra()
{
RegisterCreatureAI(npc_beryl_sorcerer);
RegisterCreatureAI(npc_captured_beryl_sorcerer);
RegisterSpellScript(spell_arcane_chains_character_force_cast);
RegisterGameObjectAI(go_caribou_trap);
RegisterGameObjectAI(go_mammoth_trap);
RegisterSpellScript(spell_red_dragonblood);
@@ -1822,7 +1879,6 @@ void AddSC_borean_tundra()
new npc_counselor_talbot();
new npc_leryssa();
new npc_general_arlos();
RegisterCreatureAI(npc_beryl_sorcerer);
RegisterCreatureAI(npc_valiance_keep_cannoneer);
RegisterCreatureAI(npc_hidden_cultist);
RegisterSpellScript(spell_windsoul_totem_aura);