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

View File

@@ -34,7 +34,6 @@ set(scripts_STAT_SRCS
../game/AI/ScriptedAI/ScriptedEscortAI.cpp
../game/AI/ScriptedAI/ScriptedCreature.cpp
../game/AI/ScriptedAI/ScriptedFollowerAI.cpp
../game/AI/ScriptedAI/ScriptedSimpleAI.cpp
)
if(SCRIPTS)

View File

@@ -84,7 +84,6 @@ set(scripts_STAT_SRCS
EasternKingdoms/MoltenCore/instance_molten_core.cpp
EasternKingdoms/MoltenCore/boss_sulfuron_harbinger.cpp
EasternKingdoms/MoltenCore/boss_magmadar.cpp
EasternKingdoms/MoltenCore/molten_core.cpp
EasternKingdoms/MoltenCore/boss_shazzrah.cpp
EasternKingdoms/Stratholme/boss_baroness_anastari.cpp
EasternKingdoms/Stratholme/boss_nerubenkan.cpp

View File

@@ -24,7 +24,6 @@ SDCategory: Karazhan
EndScriptData */
#include "ScriptPCH.h"
#include "ScriptedSimpleAI.h"
#include "karazhan.h"
#include "GameObject.h"
@@ -549,33 +548,8 @@ public:
};
// CONVERT TO ACID
class mob_shadow_of_aran : public CreatureScript
{
public:
mob_shadow_of_aran() : CreatureScript("mob_shadow_of_aran") { }
CreatureAI* GetAI(Creature* creature) const
{
sLog->outString("TSCR: Convert simpleAI script for Creature Entry %u to ACID", creature->GetEntry());
SimpleAI* ai = new SimpleAI (creature);
ai->Spell[0].Enabled = true;
ai->Spell[0].Spell_Id = SPELL_SHADOW_PYRO;
ai->Spell[0].Cooldown = 5000;
ai->Spell[0].First_Cast = 1000;
ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET;
ai->EnterEvadeMode();
return ai;
}
};
void AddSC_boss_shade_of_aran()
{
new boss_shade_of_aran();
new mob_shadow_of_aran();
new mob_aran_elemental();
}

View File

@@ -1,86 +0,0 @@
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* 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/>.
*/
/* ScriptData
SDName: Molten_Core
SD%Complete: 100
SDComment:
SDCategory: Molten Core
EndScriptData */
/* ContentData
mob_ancient_core_hound
EndContentData */
#include "ScriptPCH.h"
#include "ScriptedSimpleAI.h"
enum Spells
{
SPELL_CONE_OF_FIRE = 19630,
SPELL_BITE = 19771,
//Random Debuff (each hound has only one of these)
SPELL_GROUND_STOMP = 19364,
SPELL_ANCIENT_DREAD = 19365,
SPELL_CAUTERIZING_FLAMES = 19366,
SPELL_WITHERING_HEAT = 19367,
SPELL_ANCIENT_DESPAIR = 19369,
SPELL_ANCIENT_HYSTERIA = 19372
};
class mob_ancient_core_hound : public CreatureScript
{
public:
mob_ancient_core_hound() : CreatureScript("mob_ancient_core_hound") { }
CreatureAI* GetAI(Creature* creature) const
{
SimpleAI* ai = new SimpleAI(creature);
ai->Spell[0].Enabled = true;
ai->Spell[0].Spell_Id = SPELL_CONE_OF_FIRE;
ai->Spell[0].Cooldown = 7000;
ai->Spell[0].First_Cast = 10000;
ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET;
uint32 RandDebuff = RAND(SPELL_GROUND_STOMP, SPELL_ANCIENT_DREAD, SPELL_CAUTERIZING_FLAMES,
SPELL_WITHERING_HEAT, SPELL_ANCIENT_DESPAIR, SPELL_ANCIENT_HYSTERIA);
ai->Spell[1].Enabled = true;
ai->Spell[1].Spell_Id = RandDebuff;
ai->Spell[1].Cooldown = 24000;
ai->Spell[1].First_Cast = 15000;
ai->Spell[1].Cast_Target_Type = CAST_HOSTILE_TARGET;
ai->Spell[2].Enabled = true;
ai->Spell[2].Spell_Id = SPELL_BITE;
ai->Spell[2].Cooldown = 6000;
ai->Spell[2].First_Cast = 4000;
ai->Spell[2].Cast_Target_Type = CAST_HOSTILE_TARGET;
ai->EnterEvadeMode();
return ai;
}
};
void AddSC_molten_core()
{
new mob_ancient_core_hound();
}

View File

@@ -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();
}