aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRat <none@none>2010-09-25 18:47:03 +0200
committerRat <none@none>2010-09-25 18:47:03 +0200
commit28e90bbb605ce95ec51c2c5cea9980473a4dbb05 (patch)
tree0c19970109f4df03fa36f90f1d4b1f484e0cbf76 /src
parent562e3955a9a4e0f2643b1002005b5a6d3244084c (diff)
Core/Scripts/SmartAI: added SmartAI files
Core/DBLayer/Texts: added CreatureTextMgr files BuildSystem: added cmake for above files Note: these are still under development and NOT USABLE should not effect anything now --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CreatureAIRegistry.cpp2
-rw-r--r--src/server/game/AI/SmartAI/SmartAI.cpp190
-rw-r--r--src/server/game/AI/SmartAI/SmartAI.h369
-rw-r--r--src/server/game/CMakeLists.txt4
-rw-r--r--src/server/game/Texts/CreatureTextMgr.cpp109
-rw-r--r--src/server/game/Texts/CreatureTextMgr.h63
-rw-r--r--src/server/game/World/World.cpp4
-rw-r--r--src/server/shared/Database/Implementation/WorldDatabase.cpp1
-rw-r--r--src/server/shared/Database/Implementation/WorldDatabase.h1
9 files changed, 743 insertions, 0 deletions
diff --git a/src/server/game/AI/CreatureAIRegistry.cpp b/src/server/game/AI/CreatureAIRegistry.cpp
index 9db30a0a5c4..bccc3f23099 100644
--- a/src/server/game/AI/CreatureAIRegistry.cpp
+++ b/src/server/game/AI/CreatureAIRegistry.cpp
@@ -30,6 +30,7 @@
#include "CreatureAIRegistry.h"
#include "WaypointMovementGenerator.h"
#include "CreatureAIFactory.h"
+#include "SmartAI.h"
//#include "CreatureAIImpl.h"
namespace AIRegistry
@@ -51,6 +52,7 @@ namespace AIRegistry
(new CreatureAIFactory<CreatureEventAI>("EventAI"))->RegisterSelf();
(new CreatureAIFactory<AOEAI>("AOEAI"))->RegisterSelf();
(new CreatureAIFactory<VehicleAI>("VehicleAI"))->RegisterSelf();
+ (new CreatureAIFactory<SmartAI>("SmartAI"))->RegisterSelf();
(new MovementGeneratorFactory<RandomMovementGenerator<Creature> >(RANDOM_MOTION_TYPE))->RegisterSelf();
(new MovementGeneratorFactory<WaypointMovementGenerator<Creature> >(WAYPOINT_MOTION_TYPE))->RegisterSelf();
diff --git a/src/server/game/AI/SmartAI/SmartAI.cpp b/src/server/game/AI/SmartAI/SmartAI.cpp
new file mode 100644
index 00000000000..987cef83c39
--- /dev/null
+++ b/src/server/game/AI/SmartAI/SmartAI.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2008-2010 Trinity <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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "Common.h"
+#include "DatabaseEnv.h"
+#include "SQLStorage.h"
+#include "SmartAI.h"
+#include "ObjectMgr.h"
+#include "ProgressBar.h"
+#include "ObjectDefines.h"
+#include "GridDefines.h"
+#include "ConditionMgr.h"
+
+void SmartAIMgr::LoadSmartAIFromDB()
+{
+ //Drop Existing SmartAI List
+}
+
+SmartAI::SmartAI(Creature *c) : CreatureAI(c), me(c)
+{
+ // copy script to local (pretection for table reload)
+}
+
+int SmartAI::Permissible(const Creature *creature)
+{
+ if (creature->GetAIName() == "SmartAI")
+ return PERMIT_BASE_SPECIAL;
+ return PERMIT_BASE_NO;
+}
+
+void SmartAI::UpdateAI(const uint32 diff)
+{
+}
+
+void SmartAI::JustRespawned()
+{
+}
+
+void SmartAI::Reset()
+{
+}
+
+void SmartAI::JustReachedHome()
+{
+}
+
+void SmartAI::EnterCombat(Unit *enemy)
+{
+}
+
+void SmartAI::EnterEvadeMode()
+{
+}
+
+void SmartAI::JustDied(Unit* killer)
+{
+}
+
+void SmartAI::KilledUnit(Unit* victim)
+{
+}
+
+void SmartAI::JustSummoned(Creature* pUnit)
+{
+}
+
+void SmartAI::AttackStart(Unit *who)
+{
+ if (who && me->Attack(who, true))
+ me->GetMotionMaster()->MoveChase(who);
+}
+
+void SmartAI::MoveInLineOfSight(Unit *who)
+{
+ //CanAIAttack
+}
+
+void SmartAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
+{
+}
+
+void SmartAI::SpellHitTarget(Unit* target, const SpellEntry*)
+{
+}
+
+void SmartAI::DamageTaken(Unit* done_by, uint32& damage)
+{
+}
+
+void SmartAI::HealReceived(Unit* done_by, uint32& addhealth)
+{
+}
+
+void SmartAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
+{
+}
+
+void SmartAI::MovementInform(uint32 MovementType, uint32 Data)
+{
+}
+
+void SmartAI::IsSummonedBy(Unit* summoner)
+{
+}
+
+void SmartAI::DamageDealt(Unit * done_to, uint32 & damage)
+{
+}
+
+void SmartAI::SummonedCreatureDespawn(Creature* unit)
+{
+}
+
+void SmartAI::UpdateAIWhileCharmed(const uint32 diff)
+{
+}
+
+void SmartAI::CorpseRemoved(uint32 & respawnDelay)
+{
+}
+
+void SmartAI::PassengerBoarded(Unit* who, int8 seatId, bool apply)
+{
+}
+
+void SmartAI::InitializeAI()
+{
+}
+
+void SmartAI::OnCharmed(bool apply)
+{
+}
+
+bool SmartAI::CanAIAttack(const Unit* who) const
+{
+ return true;
+}
+
+void SmartAI::DoAction(const int32 param)
+{
+}
+
+uint32 SmartAI::GetData(uint32 id)
+{
+ return 0;
+}
+
+void SmartAI::SetData(uint32 id, uint32 value)
+{
+}
+
+void SmartAI::SetGUID(const uint64 &guid, int32 id)
+{
+}
+
+uint64 SmartAI::GetGUID(int32 id)
+{
+ return 0;
+}
+
+void SmartAI::MovepointReached(uint32 id)
+{
+}
+
+void SmartAI::MovepointStart(uint32 id)
+{
+}
+
+void SmartAI::SetRun(bool run)
+{
+}
+
+void SmartAI::SetMovePathEndAction(SMARTAI_ACTION action)
+{
+} \ No newline at end of file
diff --git a/src/server/game/AI/SmartAI/SmartAI.h b/src/server/game/AI/SmartAI/SmartAI.h
new file mode 100644
index 00000000000..16d0966c931
--- /dev/null
+++ b/src/server/game/AI/SmartAI/SmartAI.h
@@ -0,0 +1,369 @@
+/*
+ * Copyright (C) 2008-2010 Trinity <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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef TRINITY_SMARTAI_H
+#define TRINITY_SMARTAI_H
+
+#include "Common.h"
+#include "Creature.h"
+#include "CreatureAI.h"
+#include "Unit.h"
+
+/*
+N O T E S
+
+
+movepoints:
+ create ingame commands
+
+commands:
+ smartai
+ smartai movepoints
+ smartai movepoints start (id)
+ smartai movepoints add
+ smartai movepoints end
+ smartai movepoints show (id)
+ smartai reload
+ smartai create [reload creature]
+
+
+void passenger removed
+void setcanrun
+void setcanfly
+void setcanswim
+void setinhabittype
+
+event change flags
+
+*/
+
+//temp copied from eai, will be modded
+enum SMARTAI_EVENT
+{
+ SMART_EVENT_TIMER_IC = 0, // InitialMin, InitialMax, RepeatMin, RepeatMax
+ SMART_EVENT_TIMER_OOC = 1, // InitialMin, InitialMax, RepeatMin, RepeatMax
+ SMART_EVENT_HP = 2, // HPMax%, HPMin%, RepeatMin, RepeatMax
+ SMART_EVENT_MANA = 3, // ManaMax%,ManaMin% RepeatMin, RepeatMax
+ SMART_EVENT_AGGRO = 4, // NONE
+ SMART_EVENT_KILL = 5, // RepeatMin, RepeatMax
+ SMART_EVENT_DEATH = 6, // NONE
+ SMART_EVENT_EVADE = 7, // NONE
+ SMART_EVENT_SPELLHIT = 8, // SpellID, School, RepeatMin, RepeatMax
+ SMART_EVENT_RANGE = 9, // MinDist, MaxDist, RepeatMin, RepeatMax
+ SMART_EVENT_OOC_LOS = 10, // NoHostile, MaxRnage, RepeatMin, RepeatMax
+ SMART_EVENT_SPAWNED = 11, // Condition, CondValue1
+ SMART_EVENT_TARGET_HP = 12, // HPMax%, HPMin%, RepeatMin, RepeatMax
+ SMART_EVENT_TARGET_CASTING = 13, // RepeatMin, RepeatMax
+ SMART_EVENT_FRIENDLY_HP = 14, // HPDeficit, Radius, RepeatMin, RepeatMax
+ SMART_EVENT_FRIENDLY_IS_CC = 15, // DispelType, Radius, RepeatMin, RepeatMax
+ SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax
+ SMART_EVENT_SUMMONED_UNIT = 17, // CreatureId, RepeatMin, RepeatMax
+ SMART_EVENT_TARGET_MANA = 18, // ManaMax%, ManaMin%, RepeatMin, RepeatMax
+ SMART_EVENT_QUEST_ACCEPT = 19, // QuestID
+ SMART_EVENT_QUEST_COMPLETE = 20, //
+ SMART_EVENT_REACHED_HOME = 21, // NONE
+ SMART_EVENT_RECEIVE_EMOTE = 22, // EmoteId, Condition, CondValue1, CondValue2
+ SMART_EVENT_BUFFED = 23, // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max
+ SMART_EVENT_TARGET_BUFFED = 24, // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 Repeat Min/Max
+ SMART_EVENT_RESET = 35, // Is it called after combat, when the creature respawn and spawn. -- TRINITY ONLY
+
+ SMART_EVENT_END = 36,
+};
+
+//temp copied from eai, will be modded
+enum SMARTAI_ACTION
+{
+ SMART_ACTION_NONE = 0, // No action
+ SMART_ACTION_TEXT = 1, // TextId1, optionally -TextId2, optionally -TextId3(if -TextId2 exist). If more than just -TextId1 is defined, randomize. Negative values.
+ SMART_ACTION_SET_FACTION = 2, // FactionId (or 0 for default)
+ SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL = 3, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to demorph)
+ SMART_ACTION_SOUND = 4, // SoundId
+ SMART_ACTION_EMOTE = 5, // EmoteId
+ SMART_ACTION_RANDOM_SAY = 6, // UNUSED
+ SMART_ACTION_RANDOM_YELL = 7, // UNUSED
+ SMART_ACTION_RANDOM_TEXTEMOTE = 8, // UNUSED
+ SMART_ACTION_RANDOM_SOUND = 9, // SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field)
+ SMART_ACTION_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field)
+ SMART_ACTION_CAST = 11, // SpellId, Target, CastFlags
+ SMART_ACTION_SUMMON = 12, // CreatureID, Target, Duration in ms
+ SMART_ACTION_THREAT_SINGLE_PCT = 13, // Threat%, Target
+ SMART_ACTION_THREAT_ALL_PCT = 14, // Threat%
+ SMART_ACTION_QUEST_EVENT = 15, // QuestID, Target
+ SMART_ACTION_CAST_EVENT = 16, // QuestID, SpellId, Target - must be removed as hack?
+ SMART_ACTION_SET_UNIT_FIELD = 17, // Field_Number, Value, Target
+ SMART_ACTION_SET_UNIT_FLAG = 18, // Flags (may be more than one field OR'd together), Target
+ SMART_ACTION_REMOVE_UNIT_FLAG = 19, // Flags (may be more than one field OR'd together), Target
+ SMART_ACTION_AUTO_ATTACK = 20, // AllowAttackState (0 = stop attack, anything else means continue attacking)
+ SMART_ACTION_COMBAT_MOVEMENT = 21, // AllowCombatMovement (0 = stop combat based movement, anything else continue attacking)
+ SMART_ACTION_SET_PHASE = 22, // Phase
+ SMART_ACTION_INC_PHASE = 23, // Value (may be negative to decrement phase, should not be 0)
+ SMART_ACTION_EVADE = 24, // No Params
+ SMART_ACTION_FLEE_FOR_ASSIST = 25, // No Params
+ SMART_ACTION_QUEST_EVENT_ALL = 26, // QuestID
+ SMART_ACTION_CAST_EVENT_ALL = 27, // CreatureId, SpellId
+ SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Target, Spellid
+ SMART_ACTION_RANGED_MOVEMENT = 29, // Distance, Angle
+ SMART_ACTION_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3
+ SMART_ACTION_RANDOM_PHASE_RANGE = 31, // PhaseMin, PhaseMax
+ SMART_ACTION_SUMMON_ID = 32, // CreatureId, Target, SpawnId
+ SMART_ACTION_KILLED_MONSTER = 33, // CreatureId, Target
+ SMART_ACTION_SET_INST_DATA = 34, // Field, Data
+ SMART_ACTION_SET_INST_DATA64 = 35, // Field, Target
+ SMART_ACTION_UPDATE_TEMPLATE = 36, // Entry, Team
+ SMART_ACTION_DIE = 37, // No Params
+ SMART_ACTION_ZONE_COMBAT_PULSE = 38, // No Params
+ SMART_ACTION_CALL_FOR_HELP = 39, // Radius
+ SMART_ACTION_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged)
+ SMART_ACTION_FORCE_DESPAWN = 41, // No Params
+ SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL = 42, // MinHpValue, format(0-flat,1-percent from max health)
+ SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL = 43, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to unmount)
+
+ SMART_ACTION_SET_PHASE_MASK = 97,
+ SMART_ACTION_SET_STAND_STATE = 98,
+ SMART_ACTION_MOVE_RANDOM_POINT = 99,
+ SMART_ACTION_SET_VISIBILITY = 100,
+ SMART_ACTION_SET_ACTIVE = 101, //Apply
+ SMART_ACTION_SET_AGGRESSIVE = 102, //Apply
+ SMART_ACTION_ATTACK_START_PULSE = 103, //Distance
+ SMART_ACTION_SUMMON_GO = 104, //GameObjectID, DespawnTime in ms
+
+ SMART_ACTION_END = 105,
+};
+
+//temp copied from eai, will be modded
+enum SMARTAI_TARGETS
+{
+ SMART_TARGET_SELF = 0, //Self cast
+
+ //Hostile targets (if pet then returns pet owner)
+ SMART_TARGET_VICTIM = 1, //Our current target (ie: highest aggro)
+ SMART_TARGET_HOSTILE_SECOND_AGGRO = 2, //Second highest aggro (generaly used for cleaves and some special attacks)
+ SMART_TARGET_HOSTILE_LAST_AGGRO = 3, //Dead last on aggro (no idea what this could be used for)
+ SMART_TARGET_HOSTILE_RANDOM = 4, //Just any random target on our threat list
+ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP = 5, //Any random target except top threat
+
+ //Invoker targets (if pet then returns pet owner)
+ SMART_TARGET_ACTION_INVOKER = 6, //Unit who caused this Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF)
+
+ //Hostile targets (including pets)
+ SMART_TARGET_HOSTILE_WPET = 7, //Current target (can be a pet)
+ SMART_TARGET_HOSTILE_WPET_SECOND_AGGRO = 8, //Second highest aggro (generaly used for cleaves and some special attacks)
+ SMART_TARGET_HOSTILE_WPET_LAST_AGGRO = 9, //Dead last on aggro (no idea what this could be used for)
+ SMART_TARGET_HOSTILE_WPET_RANDOM = 10, //Just any random target on our threat list
+ SMART_TARGET_HOSTILE_WPET_RANDOM_NOT_TOP = 11, //Any random target except top threat
+
+ SMART_TARGET_ACTION_INVOKER_WPET = 12,
+
+ SMART_TARGET_END = 13,
+};
+
+#define SMARTAI_EVENT_PARAM_COUNT 6
+#define SMARTAI_ACTION_PARAM_COUNT 6
+
+struct MovePoint
+{
+ MovePoint(uint32 _id, float _x, float _y, float _z)
+ {
+ id = _id;
+ x = _x;
+ y = _y;
+ z = _z;
+ }
+
+ uint32 id;
+ float x;
+ float y;
+ float z;
+};
+
+// one line in DB is one event
+struct SMARTAI_EVENT_HOLDER
+{
+ uint32 event_id;
+ SMARTAI_EVENT event_type;
+ uint32 event_phase_mask;
+ uint32 event_chance;
+ uint32 event_flags;
+ int32 event_param[SMARTAI_EVENT_PARAM_COUNT];
+
+ SMARTAI_ACTION action_type;
+ int32 action_param[SMARTAI_ACTION_PARAM_COUNT];
+
+ float param_x;
+ float param_y;
+ float param_z;
+ float param_o;
+};
+
+// all events for a single entry
+typedef std::vector<SMARTAI_EVENT_HOLDER> SmartAIEventList;
+
+// all events for all entries
+typedef UNORDERED_MAP<int32, SmartAIEventList> SmartAIEventMap;
+
+class SmartAIMgr
+{
+ SmartAIMgr(){};
+ public:
+ ~SmartAIMgr(){};
+
+ void LoadSmartAIFromDB();
+
+ // only use this after EntryExists() check
+ SmartAIEventList const& GetEventList(int32 entry) const
+ {
+ SmartAIEventMap::const_iterator sList = m_EventMap.find(entry);
+ return (*sList).second;
+ }
+ SmartAIEventMap const& GetEventMap() const { return m_EventMap; }
+
+ // do we have entry's eventList from DB?
+ bool EntryExists(int32 entry)
+ {
+ SmartAIEventMap::const_iterator sList = m_EventMap.find(entry);
+ if (sList != m_EventMap.end())
+ return true;
+ return false;
+ }
+
+ private:
+ SmartAIEventMap m_EventMap;
+};
+
+class SmartAI : public CreatureAI
+{
+ protected:
+ Creature * const me;
+
+ public:
+ ~SmartAI(){};
+ explicit SmartAI(Creature *c);
+
+ // Called when creature is spawned or respawned
+ void JustRespawned();
+
+ // Called after InitializeAI(), EnterEvadeMode() for resetting variables
+ void Reset();
+
+ // Called at reaching home after evade
+ void JustReachedHome();
+
+ // Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
+ void EnterCombat(Unit *enemy);
+
+ // Called for reaction at stopping attack at no attackers or targets
+ void EnterEvadeMode();
+
+ // Called when the creature is killed
+ void JustDied(Unit* killer);
+
+ // Called when the creature kills a unit
+ void KilledUnit(Unit* victim);
+
+ // Called when the creature summon successfully other creature
+ void JustSummoned(Creature* pUnit);
+
+ // Tell creature to attack and follow the victim
+ void AttackStart(Unit *who);
+
+ // Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter
+ void MoveInLineOfSight(Unit *who);
+
+ // Called when hit by a spell
+ void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
+
+ // Called when spell hits a target
+ void SpellHitTarget(Unit* target, const SpellEntry*);
+
+ // Called at any Damage from any attacker (before damage apply)
+ void DamageTaken(Unit* done_by, uint32& damage);
+
+ // Called when the creature receives heal
+ void HealReceived(Unit* done_by, uint32& addhealth);
+
+ // Called at World update tick
+ void UpdateAI(const uint32 diff);
+
+ // Called at text emote receive from player
+ void ReceiveEmote(Player* pPlayer, uint32 text_emote);
+
+ // Called at waypoint reached or point movement finished
+ void MovementInform(uint32 MovementType, uint32 Data);
+
+ // Called when creature is summoned by another unit
+ void IsSummonedBy(Unit* summoner);
+
+ // Called at any Damage to any victim (before damage apply)
+ void DamageDealt(Unit * done_to, uint32 & damage);
+
+ // Called when a summoned creature dissapears (UnSommoned)
+ void SummonedCreatureDespawn(Creature* unit);
+
+ // called when the corpse of this creature gets removed
+ void CorpseRemoved(uint32 & respawnDelay);
+
+ // Called at World update tick if creature is charmed
+ void UpdateAIWhileCharmed(const uint32 diff);
+
+ // Called when a Player/Creature enters the creature (vehicle)
+ void PassengerBoarded(Unit* who, int8 seatId, bool apply);
+
+ // Called when gets initialized, when creature is added to world
+ void InitializeAI();
+
+ // Called when creature gets charmed by another unit
+ void OnCharmed(bool apply);
+
+ // Called when victim is in line of sight
+ bool CanAIAttack(const Unit* who) const;
+
+ // Used in scripts to share variables
+ void DoAction(const int32 param = 0);
+
+ // Used in scripts to share variables
+ uint32 GetData(uint32 id = 0);
+
+ // Used in scripts to share variables
+ void SetData(uint32 id, uint32 value);
+
+ // Used in scripts to share variables
+ void SetGUID(const uint64 &guid, int32 id = 0);
+
+ // Used in scripts to share variables
+ uint64 GetGUID(int32 id = 0);
+
+ //core related
+ static int Permissible(const Creature *);
+
+ // Called at movepoint reached
+ void MovepointReached(uint32 id);
+
+ // Start moving to the desired MovePoint
+ void MovepointStart(uint32 id);
+
+ // Makes the creature run/walk
+ void SetRun(bool bRun = true);
+
+ // Sets the action that will be called when creature reaches the last movepoint
+ void SetMovePathEndAction(SMARTAI_ACTION action = SMART_ACTION_FORCE_DESPAWN);
+
+ private:
+};
+
+#define sSmartAIMgr (*ACE_Singleton<SmartAIMgr, ACE_Null_Mutex>::instance())
+#endif
diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt
index 37108c64e9e..cecd0bfc11e 100644
--- a/src/server/game/CMakeLists.txt
+++ b/src/server/game/CMakeLists.txt
@@ -44,6 +44,7 @@ file(GLOB_RECURSE sources_Scripting Scripting/*.cpp Scripting/*.h)
file(GLOB_RECURSE sources_Server Server/*.cpp Server/*.h)
file(GLOB_RECURSE sources_Skills Skills/*.cpp Skills/*.h)
file(GLOB_RECURSE sources_Spells Spells/*.cpp Spells/*.h)
+file(GLOB_RECURSE sources_Texts Texts/*.cpp Texts/*.h)
file(GLOB_RECURSE sources_Tools Tools/*.cpp Tools/*.h)
file(GLOB_RECURSE sources_Tickets Tickets/*.cpp Tickets/*.h)
file(GLOB_RECURSE sources_Weather Weather/*.cpp Weather/*.h)
@@ -92,6 +93,7 @@ set(game_STAT_SRCS
${sources_Server}
${sources_Skills}
${sources_Spells}
+ ${sources_Texts}
${sources_Tools}
${sources_Tickets}
${sources_Weather}
@@ -128,6 +130,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/AI/CoreAI
${CMAKE_CURRENT_SOURCE_DIR}/AI/EventAI
${CMAKE_CURRENT_SOURCE_DIR}/AI/ScriptedAI
+ ${CMAKE_CURRENT_SOURCE_DIR}/AI/SmartAI
${CMAKE_CURRENT_SOURCE_DIR}/AuctionHouse
${CMAKE_CURRENT_SOURCE_DIR}/Battlegrounds
${CMAKE_CURRENT_SOURCE_DIR}/Battlegrounds/Zones
@@ -182,6 +185,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Skills
${CMAKE_CURRENT_SOURCE_DIR}/Spells
${CMAKE_CURRENT_SOURCE_DIR}/Spells/Auras
+ ${CMAKE_CURRENT_SOURCE_DIR}/Texts
${CMAKE_CURRENT_SOURCE_DIR}/Tools
${CMAKE_CURRENT_SOURCE_DIR}/Tickets
${CMAKE_CURRENT_SOURCE_DIR}/Weather
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp
new file mode 100644
index 00000000000..037c37813ad
--- /dev/null
+++ b/src/server/game/Texts/CreatureTextMgr.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2008-2010 Trinity <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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "Common.h"
+#include "DatabaseEnv.h"
+#include "SQLStorage.h"
+#include "CreatureTextMgr.h"
+#include "ProgressBar.h"
+#include "ObjectMgr.h"
+
+void CreatureTextMgr::LoadCreatureTexts()
+{
+ mTextMap.clear(); // for reload case
+
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_CRETEXT);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+
+ if (!result)
+ {
+ barGoLink bar(1);
+ bar.step();
+ sLog.outString();
+ sLog.outString(">> Loaded 0 Creature Texts. DB table `creature_texts` is empty.");
+ return;
+ }
+
+ barGoLink bar(result->GetRowCount());
+ uint32 TextCount = 0;
+ uint32 CreatureCount = 0;
+
+ do
+ {
+ bar.step();
+ Field* fields = result->Fetch();
+ CreatureTextEntry temp;
+
+ temp.entry = fields[0].GetUInt32();
+ temp.group = fields[1].GetUInt8();
+ temp.id = fields[2].GetUInt8();
+ temp.text = fields[3].GetString();
+ temp.type = ChatType(fields[4].GetUInt8());
+ temp.lang = Language(fields[5].GetUInt8());
+ temp.probability = fields[6].GetFloat();
+ temp.emote = Emote(fields[7].GetUInt32());
+ temp.duration = fields[8].GetUInt32();
+ temp.sound = fields[9].GetUInt32();
+
+ if (temp.sound)
+ {
+ if (!sSoundEntriesStore.LookupEntry(temp.sound)){
+ sLog.outErrorDb("CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Sound %u but sound does not exist.", temp.entry, temp.group, temp.sound);
+ temp.sound = 0;
+ }
+ }
+ if (!GetLanguageDescByID(temp.lang))
+ {
+ sLog.outErrorDb("CreatureTextMgr: Entry %u, Group %u in table `creature_texts` using Language %u but Language does not exist.", temp.entry, temp.group, uint32(temp.lang));
+ temp.lang = LANG_UNIVERSAL;
+ }
+ if (temp.type > CHAT_TYPE_ZONE_YELL)
+ {
+ sLog.outErrorDb("CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Type %u but this Chat Type does not exist.", temp.entry, temp.group, uint32(temp.type));
+ temp.type = CHAT_TYPE_SAY;
+ }
+ if (temp.emote)
+ {
+ if (!sEmotesStore.LookupEntry(temp.emote))
+ {
+ sLog.outErrorDb("CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Emote %u but emote does not exist.", temp.entry, temp.group, uint32(temp.emote));
+ temp.emote = EMOTE_ONESHOT_NONE;
+ }
+ }
+ //entry not yet added, add empty TextHolder (list of groups)
+ if (mTextMap.find(temp.entry) == mTextMap.end())
+ {
+ ++CreatureCount;
+ CreatureTextHolder TextHolder;
+ mTextMap[temp.entry] = TextHolder;
+ }
+ //group not yet added, add empty TextGroup (list of texts)
+ if (mTextMap[temp.entry].find(temp.group) == mTextMap[temp.entry].end())
+ {
+ CreatureTextGroup TextGroup;
+ mTextMap[temp.entry][temp.group] = TextGroup;
+ }
+ //add the text into our entry's group
+ mTextMap[temp.entry][temp.group].push_back(temp);
+
+ ++TextCount;
+ } while (result->NextRow());
+
+ sLog.outString();
+ sLog.outString(">> Loaded %u Creature Texts for %u Creatures.", TextCount, CreatureCount);
+}
diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h
new file mode 100644
index 00000000000..b35beddd64a
--- /dev/null
+++ b/src/server/game/Texts/CreatureTextMgr.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008-2010 Trinity <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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef TRINITY_CREATURE_TEXT_MGR_H
+#define TRINITY_CREATURE_TEXT_MGR_H
+
+#include "Creature.h"
+#include "SharedDefines.h"
+
+/*
+N O T E S
+
+*/
+
+struct CreatureTextEntry
+{
+ uint32 entry;
+ uint8 group;
+ uint8 id;
+ std::string text;
+ ChatType type;
+ Language lang;
+ float probability;
+ Emote emote;
+ uint32 duration;
+ uint32 sound;
+};
+
+
+typedef std::vector<CreatureTextEntry> CreatureTextGroup; //texts in a group
+typedef UNORDERED_MAP<uint32, CreatureTextGroup> CreatureTextHolder; //groups for a creature
+typedef UNORDERED_MAP<uint32, CreatureTextHolder> CreatureTextMap; //all creatures
+
+class CreatureTextMgr
+{
+ friend class ACE_Singleton<CreatureTextMgr, ACE_Null_Mutex>;
+ CreatureTextMgr() {};
+ public:
+ ~CreatureTextMgr() {};
+ void LoadCreatureTexts();
+ CreatureTextMap const& GetTextMap() const { return mTextMap; }
+
+ private:
+ CreatureTextMap mTextMap;
+};
+
+#define sCreatureTextMgr (*ACE_Singleton<CreatureTextMgr, ACE_Null_Mutex>::instance())
+#endif
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index dc8797b717c..78572695c59 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -71,6 +71,7 @@
#include "CharacterDatabaseCleaner.h"
#include "ScriptMgr.h"
#include "WeatherMgr.h"
+#include "CreatureTextMgr.h"
volatile bool World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
@@ -1642,6 +1643,9 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading spell script names...");
sObjectMgr.LoadSpellScriptNames();
+ sLog.outString("Loading Creature Texts...");
+ sCreatureTextMgr.LoadCreatureTexts();
+
sLog.outString("Initializing Scripts...");
sScriptMgr.Initialize();
diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp
index 2db9e3d9dc4..019473cee89 100644
--- a/src/server/shared/Database/Implementation/WorldDatabase.cpp
+++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp
@@ -36,6 +36,7 @@ bool WorldDatabaseConnection::Open(const std::string& infoString)
PrepareStatement(WORLD_DEL_CRELINKED_RESPAWN, "DELETE FROM creature_linked_respawn WHERE guid = ?");
PrepareStatement(WORLD_REP_CRELINKED_RESPAWN, "REPLACE INTO creature_linked_respawn (guid,linkedGuid) VALUES (?, ?)");
PrepareStatement(WORLD_DEL_GAMEOBJECT_RESPAWN_TIMES, "DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
+ PrepareStatement(WORLD_LOAD_CRETEXT, "SELECT entry, groupid, id, text, type, language, probability, emote, duration, sound FROM creature_text");
return true;
}
diff --git a/src/server/shared/Database/Implementation/WorldDatabase.h b/src/server/shared/Database/Implementation/WorldDatabase.h
index 379cca0b517..c45fdd6eac6 100644
--- a/src/server/shared/Database/Implementation/WorldDatabase.h
+++ b/src/server/shared/Database/Implementation/WorldDatabase.h
@@ -49,6 +49,7 @@ enum WorldDatabaseStatements
WORLD_DEL_CRELINKED_RESPAWN,
WORLD_REP_CRELINKED_RESPAWN,
WORLD_DEL_GAMEOBJECT_RESPAWN_TIMES,
+ WORLD_LOAD_CRETEXT,
MAX_WORLDDATABASE_STATEMENTS,
};