Created
October 5, 2016 19:58
-
-
Save Kittnz/acde9ea48eeb3cb7ddf588899ceb3036 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dark Iron Guzzler in the Brewfest achievement 'Down With The Dark Iron' | |
enum DarkIronGuzzler | |
{ | |
NPC_DARK_IRON_GUZZLER = 23709, | |
NPC_DARK_IRON_HERALD = 24536, | |
NPC_DARK_IRON_SPAWN_BUNNY = 23894, | |
NPC_FESTIVE_KEG_1 = 23702, // Thunderbrew Festive Keg | |
NPC_FESTIVE_KEG_2 = 23700, // Barleybrew Festive Keg | |
NPC_FESTIVE_KEG_3 = 23706, // Gordok Festive Keg | |
NPC_FESTIVE_KEG_4 = 24373, // T'chalis's Festive Keg | |
NPC_FESTIVE_KEG_5 = 24372, // Drohn's Festive Keg | |
SPELL_GO_TO_NEW_TARGET = 42498, | |
SPELL_ATTACK_KEG = 42393, | |
SPELL_RETREAT = 42341, | |
SPELL_DRINK = 42436, | |
SAY_RANDOM = 0, | |
}; | |
class npc_dark_iron_guzzler : public CreatureScript | |
{ | |
public: | |
npc_dark_iron_guzzler() : CreatureScript("npc_dark_iron_guzzler") { } | |
CreatureAI *GetAI(Creature* creature) const | |
{ | |
return new npc_dark_iron_guzzlerAI(creature); | |
} | |
struct npc_dark_iron_guzzlerAI : public ScriptedAI | |
{ | |
npc_dark_iron_guzzlerAI(Creature* creature) : ScriptedAI(creature) { } | |
bool atKeg; | |
bool playersLost; | |
bool barleyAlive; | |
bool thunderAlive; | |
bool gordokAlive; | |
bool drohnAlive; | |
bool tchaliAlive; | |
uint32 AttackKegTimer; | |
uint32 TalkTimer; | |
void Reset() | |
{ | |
AttackKegTimer = 5000; | |
TalkTimer = (urand(1000, 120000)); | |
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING); | |
} | |
void IsSummonedBy(Unit* summoner) | |
{ | |
// Only cast the spell on spawn | |
DoCast(me, SPELL_GO_TO_NEW_TARGET); | |
} | |
// These values are set through SAI - when a Festive Keg dies it will set data to all Dark Iron Guzzlers within 3 yards (the killers) | |
void SetData(uint32 type, uint32 data) | |
{ | |
if (type == 10 && data == 10) | |
{ | |
DoCast(me, SPELL_GO_TO_NEW_TARGET); | |
thunderAlive = false; | |
} | |
if (type == 11 && data == 11) | |
{ | |
DoCast(me, SPELL_GO_TO_NEW_TARGET); | |
barleyAlive = false; | |
} | |
if (type == 12 && data == 12) | |
{ | |
DoCast(me, SPELL_GO_TO_NEW_TARGET); | |
gordokAlive = false; | |
} | |
if (type == 13 && data == 13) | |
{ | |
DoCast(me, SPELL_GO_TO_NEW_TARGET); | |
drohnAlive = false; | |
} | |
if (type == 14 && data == 14) | |
{ | |
DoCast(me, SPELL_GO_TO_NEW_TARGET); | |
tchaliAlive = false; | |
} | |
} | |
// As you can see here we do not have to use a spellscript for this | |
void SpellHit(Unit* caster, const SpellInfo* spell) | |
{ | |
if (spell->Id == SPELL_DRINK) | |
{ | |
// Fake death - it's only visual! | |
me->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_DEAD); | |
me->StopMoving(); | |
// Time based on information from videos | |
me->ForcedDespawn(7000); | |
} | |
// Retreat - run back | |
if (spell->Id == SPELL_RETREAT) | |
{ | |
// Remove walking flag so we start running | |
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); | |
if (me->GetAreaId() == 1296) | |
{ | |
me->GetMotionMaster()->MovePoint(1, 1197.63f, -4293.571f, 21.243f); | |
} | |
else if (me->GetAreaId() == 1) | |
{ | |
me->GetMotionMaster()->MovePoint(2, -5152.3f, -603.529f, 398.356f); | |
} | |
} | |
if (spell->Id == SPELL_GO_TO_NEW_TARGET) | |
{ | |
// If we're at Durotar we target different kegs if we are at at Dun Morogh | |
if (me->GetAreaId() == 1296) | |
{ | |
if (drohnAlive && gordokAlive && tchaliAlive) | |
{ | |
switch (urand(0, 2)) | |
{ | |
case 0: // Gordok Festive Keg | |
me->GetMotionMaster()->MovePoint(4, 1220.86f, -4297.37f, 21.192f); | |
break; | |
case 1: // Drohn's Festive Keg | |
me->GetMotionMaster()->MovePoint(5, 1185.98f, -4312.98f, 21.294f); | |
break; | |
case 2: // Ti'chali's Festive Keg | |
me->GetMotionMaster()->MovePoint(6, 1184.12f, -4275.21f, 21.191f); | |
break; | |
} | |
} | |
else if (!drohnAlive) | |
{ | |
switch (urand(0, 1)) | |
{ | |
case 0: // Gordok Festive Keg | |
me->GetMotionMaster()->MovePoint(4, 1220.86f, -4297.37f, 21.192f); | |
break; | |
case 1: // Ti'chali's Festive Keg | |
me->GetMotionMaster()->MovePoint(6, 1184.12f, -4275.21f, 21.191f); | |
break; | |
} | |
} | |
else if (!gordokAlive) | |
{ | |
switch (urand(0, 1)) | |
{ | |
case 0: // Drohn's Festive Keg | |
me->GetMotionMaster()->MovePoint(5, 1185.98f, -4312.98f, 21.294f); | |
break; | |
case 1: // Ti'chali's Festive Keg | |
me->GetMotionMaster()->MovePoint(6, 1184.12f, -4275.21f, 21.191f); | |
break; | |
} | |
} | |
else if (!tchaliAlive) | |
{ | |
switch (urand(0, 1)) | |
{ | |
case 0: // Gordok Festive Keg | |
me->GetMotionMaster()->MovePoint(4, 1220.86f, -4297.37f, 21.192f); | |
break; | |
case 1: // Drohn's Festive Keg | |
me->GetMotionMaster()->MovePoint(5, 1185.98f, -4312.98f, 21.294f); | |
break; | |
} | |
} | |
} | |
// If we're at Dun Morogh we target different kegs if we are at Durotar | |
else if (me->GetAreaId() == 1) | |
{ | |
if (barleyAlive && gordokAlive && thunderAlive) | |
{ | |
switch (urand(0, 2)) | |
{ | |
case 0: // Barleybrew Festive Keg | |
me->GetMotionMaster()->MovePoint(7, -5183.67f, -599.58f, 397.177f); | |
break; | |
case 1: // Thunderbrew Festive Keg | |
me->GetMotionMaster()->MovePoint(8, -5159.53f, -629.52f, 397.213f); | |
break; | |
case 2: // Gordok Festive Keg | |
me->GetMotionMaster()->MovePoint(9, -5148.01f, -578.34f, 397.177f); | |
break; | |
} | |
} | |
else if (!barleyAlive) | |
{ | |
switch (urand(0, 1)) | |
{ | |
case 0: // Thunderbrew Festive Keg | |
me->GetMotionMaster()->MovePoint(8, -5159.53f, -629.52f, 397.213f); | |
break; | |
case 1: // Gordok Festive Keg | |
me->GetMotionMaster()->MovePoint(9, -5148.01f, -578.34f, 397.177f); | |
break; | |
} | |
} | |
else if (!gordokAlive) | |
{ | |
switch (urand(0, 1)) | |
{ | |
case 0: // Barleybrew Festive Keg | |
me->GetMotionMaster()->MovePoint(7, -5183.67f, -599.58f, 397.177f); | |
break; | |
case 1: // Thunderbrew Festive Keg | |
me->GetMotionMaster()->MovePoint(8, -5159.53f, -629.52f, 397.213f); | |
break; | |
} | |
} | |
else if (!thunderAlive) | |
{ | |
switch (urand(0, 1)) | |
{ | |
case 0: // Barleybrew Festive Keg | |
me->GetMotionMaster()->MovePoint(7, -5183.67f, -599.58f, 397.177f); | |
break; | |
case 1: // Gordok Festive Keg | |
me->GetMotionMaster()->MovePoint(9, -5148.01f, -578.34f, 397.177f); | |
break; | |
} | |
} | |
} | |
atKeg = false; | |
} | |
} | |
void MovementInform(uint32 Type, uint32 PointId) | |
{ | |
if (Type != POINT_MOTION_TYPE) | |
return; | |
// Arrived at the retreat spot, we should despawn | |
if (PointId == 1 || PointId == 2) | |
me->ForcedDespawn(1000); | |
// Arrived at the new keg - the spell has conditions in database | |
if (PointId == 4 || PointId == 5 || PointId == 6 || PointId == 7 || PointId == 8 || PointId == 9) | |
{ | |
DoCast(SPELL_ATTACK_KEG); | |
me->SetByteFlag(UNIT_FIELD_BYTES_1, 1, 0x01); // Sit down | |
atKeg = true; | |
} | |
} | |
void UpdateAI(const uint32 diff) | |
{ | |
if (!IsHolidayActive(HOLIDAY_BREWFEST)) | |
return; | |
// If all kegs are dead we should retreat because we have won | |
if ((!gordokAlive && !thunderAlive && !barleyAlive) || (!gordokAlive && !drohnAlive && !tchaliAlive)) | |
{ | |
DoCast(me, SPELL_RETREAT); | |
// We are doing this because we'll have to reset our scripts when we won | |
if (Creature* herald = me->FindNearestCreature(NPC_DARK_IRON_HERALD, 100.0f)) | |
herald->AI()->SetData(20, 20); | |
// Despawn all summon bunnies so they will stop summoning guzzlers | |
if (Creature* spawnbunny = me->FindNearestCreature(NPC_DARK_IRON_SPAWN_BUNNY, 100.0f)) | |
spawnbunny->ForcedDespawn(); | |
} | |
if (TalkTimer <= diff) | |
{ | |
me->AI()->Talk(SAY_RANDOM); | |
TalkTimer = (urand(44000, 120000)); | |
} else TalkTimer -= diff; | |
// Only happens if we're at keg | |
if (atKeg) | |
{ | |
if (AttackKegTimer <= diff) | |
{ | |
DoCast(SPELL_ATTACK_KEG); | |
AttackKegTimer = 5000; | |
} else AttackKegTimer -= diff; | |
} | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment