Scripts/Stratholme: spawn Timmy the Cruel if conditions are met

This commit is contained in:
Aokromes
2017-11-12 13:19:19 +01:00
parent 0760502ee3
commit fb0e0eb117
3 changed files with 125 additions and 5 deletions

View File

@@ -24,22 +24,21 @@ SDCategory: Stratholme
EndScriptData */
#include "ScriptMgr.h"
#include "AreaBoundary.h"
#include "ScriptedCreature.h"
#include "InstanceScript.h"
#include "stratholme.h"
#include "Player.h"
enum Misc
{
MAX_ENCOUNTER = 6
};
enum InstanceEvents
{
EVENT_BARON_RUN = 1,
EVENT_SLAUGHTER_SQUARE = 2
};
Position const timmyTheCruelSpawnPosition = { 3625.358f, -3188.108f, 130.3985f, 4.834562f };
EllipseBoundary const beforeScarletGate(Position(3671.158f, -3181.79f), 60.0f, 40.0f);
class instance_stratholme : public InstanceMapScript
{
public:
@@ -50,16 +49,22 @@ class instance_stratholme : public InstanceMapScript
instance_stratholme_InstanceMapScript(Map* map) : InstanceScript(map)
{
SetHeaders(DataHeader);
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
EncounterState[i] = NOT_STARTED;
for (uint8 i = 0; i < 5; ++i)
IsSilverHandDead[i] = false;
timmySpawned = false;
scarletsKilled = 0;
}
uint32 EncounterState[MAX_ENCOUNTER];
uint8 scarletsKilled;
bool IsSilverHandDead[5];
bool timmySpawned;
ObjectGuid serviceEntranceGUID;
ObjectGuid gauntletGate1GUID;
@@ -78,6 +83,33 @@ class instance_stratholme : public InstanceMapScript
GuidSet abomnationGUID;
EventMap events;
void OnUnitDeath(Unit* who) override
{
switch (who->GetEntry())
{
case NPC_CRIMSON_GUARDSMAN:
case NPC_CRIMSON_CONJUROR:
case NPC_CRIMSON_INITATE:
case NPC_CRIMSON_GALLANT:
{
if (!timmySpawned)
{
Position pos = who->ToCreature()->GetHomePosition();
// check if they're in front of the entrance
if (beforeScarletGate.IsWithinBoundary(pos))
{
if (++scarletsKilled >= TIMMY_THE_CRUEL_CRUSADERS_REQUIRED)
{
instance->SummonCreature(NPC_TIMMY_THE_CRUEL, timmyTheCruelSpawnPosition);
timmySpawned = true;
}
}
}
break;
}
}
}
bool StartSlaugtherSquare()
{
//change to DONE when crystals implemented

View File

@@ -54,6 +54,14 @@ enum STRCreatureIds
NPC_ABOM_VENOM = 10417,
NPC_BLACK_GUARD = 10394,
NPC_YSIDA = 16031,
// Scarlet side creatures
NPC_CRIMSON_GUARDSMAN = 10418,
NPC_CRIMSON_CONJUROR = 10419,
NPC_CRIMSON_INITATE = 10420,
NPC_CRIMSON_GALLANT = 10424,
NPC_TIMMY_THE_CRUEL = 10808
};
enum STRGameobjectIds
@@ -81,5 +89,12 @@ enum STRSpellIds
SPELL_BARON_ULTIMATUM = 27861
};
enum STRMisc
{
//! amount of crusade monsters required to be killed in order for timmy the cruel to spawn
TIMMY_THE_CRUEL_CRUSADERS_REQUIRED = 15,
MAX_ENCOUNTER = 6
};
#endif

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
*
* 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 "ScriptedCreature.h"
#include "SpellScript.h"
#include "Player.h"
enum TikiTarget
{
SPELL_TIKI_TARGET_VISUAL_1 = 71064,
SPELL_TIKI_TARGET_VISUAL_2 = 71065,
SPELL_TIKI_TARGET_VISUAL_3 = 71066
};
/*######
# npc_tiki_target "Used by entry 38038"
######*/
class npc_tiki_target : public CreatureScript
{
public:
npc_tiki_target() : CreatureScript("npc_tiki_target") { }
struct npc_tiki_targetAI : public ScriptedAI
{
npc_tiki_targetAI(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
DoCast(me, RAND(SPELL_TIKI_TARGET_VISUAL_1, SPELL_TIKI_TARGET_VISUAL_2, SPELL_TIKI_TARGET_VISUAL_3));
}
void DamageTaken(Unit* who, uint32& damage) override
{
if (who->GetTypeId() == TYPEID_UNIT && me->HealthBelowPct(85))
damage = 0;
}
void UpdateAI(uint32 diff) override
{
}
private:
TaskScheduler _scheduler;
};
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_tiki_targetAI(creature);
}
};
void AddSC_durotar_area_echo_isles()
{
new npc_tiki_target();
}