Scripts/Stratholme: spawn Timmy the Cruel if conditions are met (#20750)

* Timmy the cruel
* Rename some variables and use sniffed spawn position
* codestyle
* Use areaboundary instead
* include order
* aokromes request
* remove static
* never cp on tc
This commit is contained in:
Riztazz
2017-11-11 12:31:40 +01:00
committed by jackpoz
parent 3e74ef1528
commit c69825d96d
2 changed files with 52 additions and 5 deletions

View File

@@ -24,6 +24,7 @@ SDCategory: Stratholme
EndScriptData */
#include "ScriptMgr.h"
#include "AreaBoundary.h"
#include "Creature.h"
#include "EventMap.h"
#include "GameObject.h"
@@ -33,17 +34,15 @@ EndScriptData */
#include "Player.h"
#include "stratholme.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:
@@ -54,16 +53,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;
@@ -82,6 +87,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

@@ -57,6 +57,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
@@ -84,6 +92,13 @@ 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
};
template <class AI, class T>
inline AI* GetStratholmeAI(T* obj)
{