R.I.P SimpleAI

- Convert SimpleAI to (DB) SmartAI
- Spell ids corrected (and completed some of the scripts)
- Random cleanup (code style) in some scripts
This commit is contained in:
Nay
2012-03-11 16:59:17 +00:00
parent 036dae5a36
commit 2b2d054f64
10 changed files with 373 additions and 938 deletions
File diff suppressed because it is too large Load Diff
@@ -25,7 +25,6 @@ EndScriptData */
#include "ScriptPCH.h"
#include "serpent_shrine.h"
#include "ScriptedSimpleAI.h"
#include "Spell.h"
#define SPELL_SPOUT 37433
@@ -55,15 +54,16 @@ EndScriptData */
float AddPos[9][3] =
{
{2.8553810f, -459.823914f, -19.182686f}, //MOVE_AMBUSHER_1 X, Y, Z
{12.400000f, -466.042267f, -19.182686f}, //MOVE_AMBUSHER_2 X, Y, Z
{51.366653f, -460.836060f, -19.182686f}, //MOVE_AMBUSHER_3 X, Y, Z
{62.597980f, -457.433044f, -19.182686f}, //MOVE_AMBUSHER_4 X, Y, Z
{77.607452f, -384.302765f, -19.182686f}, //MOVE_AMBUSHER_5 X, Y, Z
{63.897900f, -378.984924f, -19.182686f}, //MOVE_AMBUSHER_6 X, Y, Z
{34.447250f, -387.333618f, -19.182686f}, //MOVE_GUARDIAN_1 X, Y, Z
{14.388216f, -423.468018f, -19.625271f}, //MOVE_GUARDIAN_2 X, Y, Z
{42.471519f, -445.115295f, -19.769423f} //MOVE_GUARDIAN_3 X, Y, Z
// MOVE_AMBUSHER_1 X, Y, Z
{2.8553810f, -459.823914f, -19.182686f},
{12.400000f, -466.042267f, -19.182686f},
{51.366653f, -460.836060f, -19.182686f},
{62.597980f, -457.433044f, -19.182686f},
{77.607452f, -384.302765f, -19.182686f},
{63.897900f, -378.984924f, -19.182686f},
{34.447250f, -387.333618f, -19.182686f},
{14.388216f, -423.468018f, -19.625271f},
{42.471519f, -445.115295f, -19.769423f}
};
class boss_the_lurker_below : public CreatureScript
@@ -80,10 +80,10 @@ public:
{
boss_the_lurker_belowAI(Creature* c) : Scripted_NoMovementAI(c), Summons(me)
{
instance = c->GetInstanceScript();
Instance = c->GetInstanceScript();
}
InstanceScript* instance;
InstanceScript* Instance;
SummonList Summons;
bool Spawned;
@@ -103,7 +103,7 @@ public:
bool CheckCanStart()//check if players fished
{
if (instance && instance->GetData(DATA_STRANGE_POOL) == NOT_STARTED)
if (Instance && Instance->GetData(DATA_STRANGE_POOL) == NOT_STARTED)
return false;
return true;
}
@@ -112,39 +112,39 @@ public:
me->AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_LEVITATING);
SpoutAnimTimer = 1000;
RotTimer = 0;
WaterboltTimer = 15000;//give time to get in range when fight starts
WaterboltTimer = 15000; // give time to get in range when fight starts
SpoutTimer = 45000;
WhirlTimer = 18000;//after avery spout
WhirlTimer = 18000; // after avery spout
PhaseTimer = 120000;
GeyserTimer = rand()%5000 + 15000;
CheckTimer = 15000;//give time to get in range when fight starts
WaitTimer = 60000;//never reached
WaitTimer2 = 60000;//never reached
CheckTimer = 15000; // give time to get in range when fight starts
WaitTimer = 60000; // never reached
WaitTimer2 = 60000; // never reached
Submerged = true;//will be false at combat start
Submerged = true; // will be false at combat start
Spawned = false;
InRange = false;
CanStartEvent = false;
Summons.DespawnAll();
if (instance)
if (Instance)
{
instance->SetData(DATA_THELURKERBELOWEVENT, NOT_STARTED);
instance->SetData(DATA_STRANGE_POOL, NOT_STARTED);
Instance->SetData(DATA_THELURKERBELOWEVENT, NOT_STARTED);
Instance->SetData(DATA_STRANGE_POOL, NOT_STARTED);
}
DoCast(me, SPELL_SUBMERGE);//submerge anim
me->SetVisible(false);//we start invis under water, submerged
DoCast(me, SPELL_SUBMERGE); // submerge anim
me->SetVisible(false); // we start invis under water, submerged
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* /*killer*/)
{
if (instance)
if (Instance)
{
instance->SetData(DATA_THELURKERBELOWEVENT, DONE);
instance->SetData(DATA_STRANGE_POOL, IN_PROGRESS);
Instance->SetData(DATA_THELURKERBELOWEVENT, DONE);
Instance->SetData(DATA_STRANGE_POOL, IN_PROGRESS);
}
Summons.DespawnAll();
@@ -152,22 +152,20 @@ public:
void EnterCombat(Unit* who)
{
if (instance)
instance->SetData(DATA_THELURKERBELOWEVENT, IN_PROGRESS);
if (Instance)
Instance->SetData(DATA_THELURKERBELOWEVENT, IN_PROGRESS);
Scripted_NoMovementAI::EnterCombat(who);
}
void MoveInLineOfSight(Unit* who)
{
if (!CanStartEvent)//boss is invisible, don't attack
if (!CanStartEvent) // boss is invisible, don't attack
return;
if (!me->getVictim() && who->IsValidAttackTarget(me))
{
float attackRadius = me->GetAttackDistance(who);
if (me->IsWithinDistInMap(who, attackRadius))
{
AttackStart(who);
}
}
}
@@ -179,7 +177,7 @@ public:
void UpdateAI(const uint32 diff)
{
if (!CanStartEvent)//boss is invisible, don't attack
if (!CanStartEvent) // boss is invisible, don't attack
{
if (CheckCanStart())
{
@@ -190,21 +188,21 @@ public:
WaitTimer2 = 500;
}
if (!Submerged && WaitTimer2 <= diff)//wait 500ms before emerge anim
if (!Submerged && WaitTimer2 <= diff) // wait 500ms before emerge anim
{
me->RemoveAllAuras();
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
DoCast(me, SPELL_EMERGE, false);
WaitTimer2 = 60000;//never reached
WaitTimer2 = 60000; // never reached
WaitTimer = 3000;
}
else
WaitTimer2 -= diff;
if (WaitTimer <= diff)//wait 3secs for emerge anim, then attack
if (WaitTimer <= diff) // wait 3secs for emerge anim, then attack
{
WaitTimer = 3000;
CanStartEvent = true;//fresh fished from pool
CanStartEvent = true; // fresh fished from pool
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
}
@@ -214,7 +212,7 @@ public:
return;
}
if (me->getThreatManager().getThreatList().empty())//check if should evade
if (me->getThreatManager().getThreatList().empty()) // check if should evade
{
if (me->isInCombat())
EnterEvadeMode();
@@ -226,7 +224,7 @@ public:
{
me->InterruptNonMeleeSpells(false);
DoCast(me, SPELL_SUBMERGE);
PhaseTimer = 60000;//60secs submerged
PhaseTimer = 60000; // 60secs submerged
Submerged = true;
} else PhaseTimer-=diff;
@@ -236,12 +234,12 @@ public:
me->SetReactState(REACT_PASSIVE);
me->GetMotionMaster()->MoveRotate(20000, urand(0, 1) ? ROTATE_DIRECTION_LEFT : ROTATE_DIRECTION_RIGHT);
SpoutTimer = 45000;
WhirlTimer = 20000;//whirl directly after spout
WhirlTimer = 20000; // whirl directly after spout
RotTimer = 20000;
return;
} else SpoutTimer -= diff;
//Whirl directly after a Spout and at random times
// Whirl directly after a Spout and at random times
if (WhirlTimer <= diff)
{
WhirlTimer = 18000;
@@ -273,7 +271,7 @@ public:
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if (i->getSource() && i->getSource()->isAlive() && me->HasInArc(float(diff/20000*M_PI*2), i->getSource()) && me->IsWithinDist(i->getSource(), SPOUT_DIST) && !i->getSource()->IsInWater())
DoCast(i->getSource(), SPELL_SPOUT, true);//only knock back palyers in arc, in 100yards, not in water
DoCast(i->getSource(), SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water
}
}
@@ -300,7 +298,7 @@ public:
GeyserTimer = rand()%5000 + 15000;
} else GeyserTimer -= diff;
if (!InRange)//if on players in melee range cast Waterbolt
if (!InRange) // if on players in melee range cast Waterbolt
{
if (WaterboltTimer <= diff)
{
@@ -318,12 +316,13 @@ public:
DoMeleeAttackIfReady();
}else//submerged
}
else // submerged
{
if (PhaseTimer <= diff)
{
Submerged = false;
me->InterruptNonMeleeSpells(false);//shouldn't be any
me->InterruptNonMeleeSpells(false); // shouldn't be any
me->RemoveAllAuras();
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
me->RemoveFlag(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED);
@@ -334,28 +333,22 @@ public:
return;
} else PhaseTimer-=diff;
if (me->getThreatManager().getThreatList().empty())//check if should evade
if (me->getThreatManager().getThreatList().empty()) // check if should evade
{
EnterEvadeMode();
return;
}
if (!me->isInCombat())
DoZoneInCombat();
if (!Spawned)
{
me->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
//spawn adds
// spawn adds
for (uint8 i = 0; i < 9; ++i)
{
Creature* Summoned;
if (i < 6)
Summoned = me->SummonCreature(MOB_COILFANG_AMBUSHER, AddPos[i][0], AddPos[i][1], AddPos[i][2], 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
else Summoned = me->SummonCreature(MOB_COILFANG_GUARDIAN, AddPos[i][0], AddPos[i][1], AddPos[i][2], 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
if (Summoned)
Summons.Summon(Summoned);
}
if (Creature* summoned = me->SummonCreature(i < 6 ? MOB_COILFANG_AMBUSHER : MOB_COILFANG_GUARDIAN, AddPos[i][0], AddPos[i][1], AddPos[i][2], 0, TEMPSUMMON_CORPSE_DESPAWN, 0))
Summons.Summon(summoned);
Spawned = true;
}
}
@@ -363,32 +356,6 @@ public:
};
};
class mob_coilfang_guardian : public CreatureScript
{
public:
mob_coilfang_guardian() : CreatureScript("mob_coilfang_guardian") { }
CreatureAI* GetAI(Creature* creature) const
{
SimpleAI* ai = new SimpleAI (creature);
ai->Spell[0].Enabled = true;
ai->Spell[0].Spell_Id = SPELL_ARCINGSMASH;
ai->Spell[0].Cooldown = 15000;
ai->Spell[0].First_Cast = 5000;
ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET;
ai->Spell[1].Enabled = true;
ai->Spell[1].Spell_Id = SPELL_HAMSTRING;
ai->Spell[1].Cooldown = 10000;
ai->Spell[1].First_Cast = 2000;
ai->Spell[1].Cast_Target_Type = CAST_HOSTILE_TARGET;
return ai;
}
};
class mob_coilfang_ambusher : public CreatureScript
{
public:
@@ -412,12 +379,6 @@ public:
{
MultiShotTimer = 10000;
ShootBowTimer = 4000;
}
void EnterCombat(Unit* /*who*/)
{
}
void MoveInLineOfSight(Unit* who)
@@ -438,18 +399,16 @@ public:
DoCast(me->getVictim(), SPELL_SPREAD_SHOT, true);
MultiShotTimer = 10000+rand()%10000;
ShootBowTimer += 1500;//add global cooldown
ShootBowTimer += 1500; // add global cooldown
} else MultiShotTimer -= diff;
if (ShootBowTimer <= diff)
{
Unit* target = NULL;
target = SelectTarget(SELECT_TARGET_RANDOM, 0);
int bp0 = 1100;
if (target)
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
me->CastCustomSpell(target, SPELL_SHOOT, &bp0, NULL, NULL, true);
ShootBowTimer = 4000+rand()%5000;
MultiShotTimer += 1500;//add global cooldown
MultiShotTimer += 1500; // add global cooldown
} else ShootBowTimer -= diff;
}
};
@@ -482,7 +441,6 @@ class go_strange_pool : public GameObjectScript
void AddSC_boss_the_lurker_below()
{
new boss_the_lurker_below();
new mob_coilfang_guardian();
new mob_coilfang_ambusher();
new go_strange_pool();
}