OregonCore  revision fb2a440-git
Your Favourite TBC server
ScriptMgr.h File Reference
#include "Common.h"
#include "DBCStores.h"
#include "QuestDef.h"
#include "SharedDefines.h"
#include "World.h"
#include "Weather.h"
#include "Platform/CompilerDefs.h"

Go to the source code of this file.

Classes

struct  Script
 
class  ScriptMgr
 

Macros

#define MAX_SCRIPTS   5000
 
#define VISIBLE_RANGE   (166.0f)
 
#define DEFAULT_TEXT   "<Oregon Script Text Entry Missing!>"
 
#define FUNC_PTR(name, callconvention, returntype, parameters)    typedef returntype(*name)parameters __attribute__ ((callconvention));
 
#define sScriptMgr   Oregon::Singleton<ScriptMgr>::Instance()
 

Functions

void DoScriptText (int32 textEntry, WorldObject *pSource, Unit *pTarget=NULL)
 

Macro Definition Documentation

#define DEFAULT_TEXT   "<Oregon Script Text Entry Missing!>"

Definition at line 46 of file ScriptMgr.h.

#define FUNC_PTR (   name,
  callconvention,
  returntype,
  parameters 
)    typedef returntype(*name)parameters __attribute__ ((callconvention));

Definition at line 159 of file ScriptMgr.h.

#define MAX_SCRIPTS   5000

Definition at line 44 of file ScriptMgr.h.

Referenced by Script::RegisterSelf(), ScriptMgr::ScriptsInit(), and ScriptMgr::~ScriptMgr().

#define sScriptMgr   Oregon::Singleton<ScriptMgr>::Instance()

Definition at line 164 of file ScriptMgr.h.

#define VISIBLE_RANGE   (166.0f)

Definition at line 45 of file ScriptMgr.h.

Function Documentation

void DoScriptText ( int32  textEntry,
WorldObject pSource,
Unit pTarget = NULL 
)

Definition at line 98 of file ScriptMgr.cpp.

References CHAT_TYPE_BOSS_EMOTE, CHAT_TYPE_BOSS_WHISPER, CHAT_TYPE_SAY, CHAT_TYPE_TEXT_EMOTE, CHAT_TYPE_WHISPER, CHAT_TYPE_YELL, CHAT_TYPE_ZONE_YELL, debug_log, error_log, Object::GetEntry(), Object::GetGUID(), Object::GetGUIDLow(), GetSoundEntriesStore(), Object::GetTypeId(), WorldObject::MonsterSay(), WorldObject::MonsterTextEmote(), WorldObject::MonsterWhisper(), WorldObject::MonsterYell(), WorldObject::MonsterYellToZone(), pSystemMgr, WorldObject::SendPlaySound(), TYPEID_PLAYER, TYPEID_UNIT, StringTextData::uiEmote, StringTextData::uiLanguage, StringTextData::uiSoundId, and StringTextData::uiType.

Referenced by SimpleAI::DamageTaken(), guardAI::EnterCombat(), SimpleAI::EnterCombat(), SimpleAI::KilledUnit(), SimpleAI::UpdateAI(), and CreatureEventAI::~CreatureEventAI().

99 {
100  if (!pSource)
101  {
102  error_log("OSCR: DoScriptText entry %i, invalid Source pointer.", iTextEntry);
103  return;
104  }
105 
106  if (iTextEntry >= 0)
107  {
108  error_log("OSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
109  return;
110  }
111 
112  const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
113 
114  if (!pData)
115  {
116  error_log("OSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
117  return;
118  }
119 
120  debug_log("OSCR: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);
121 
122  if (pData->uiSoundId)
123  {
124  if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
125  pSource->SendPlaySound(pData->uiSoundId, false);
126  else
127  error_log("OSCR: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
128  }
129 
130  if (pData->uiEmote)
131  {
132  if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
133  ((Unit*)pSource)->HandleEmoteCommand(pData->uiEmote);
134  else
135  error_log("OSCR: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", iTextEntry, pSource->GetTypeId());
136  }
137 
138  switch (pData->uiType)
139  {
140  case CHAT_TYPE_SAY:
141  pSource->MonsterSay(iTextEntry, pData->uiLanguage, pTarget ? pTarget->GetGUID() : 0);
142  break;
143  case CHAT_TYPE_YELL:
144  pSource->MonsterYell(iTextEntry, pData->uiLanguage, pTarget ? pTarget->GetGUID() : 0);
145  break;
147  pSource->MonsterTextEmote(iTextEntry, pTarget ? pTarget->GetGUID() : 0);
148  break;
150  pSource->MonsterTextEmote(iTextEntry, pTarget ? pTarget->GetGUID() : 0, true);
151  break;
152  case CHAT_TYPE_WHISPER:
153  {
154  if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
155  pSource->MonsterWhisper(iTextEntry, pTarget->GetGUID());
156  else
157  error_log("OSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry);
158  }
159  break;
161  {
162  if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
163  pSource->MonsterWhisper(iTextEntry, pTarget->GetGUID(), true);
164  else
165  error_log("OSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry);
166  }
167  break;
168  case CHAT_TYPE_ZONE_YELL:
169  pSource->MonsterYellToZone(iTextEntry, pData->uiLanguage, pTarget ? pTarget->GetGUID() : 0);
170  break;
171  }
172 }
void SendPlaySound(uint32 Sound, bool OnlySelf)
Definition: Object.cpp:1790
uint32 uiLanguage
Definition: ScriptSystem.h:63
void MonsterTextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Object.cpp:1504
void MonsterSay(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1490
uint32 GetGUIDLow() const
Definition: Object.h:166
void MonsterYell(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1497
#define debug_log
Definition: Log.h:201
void MonsterWhisper(const char *text, uint64 receiver, bool IsBossWhisper=false)
Definition: Object.cpp:1511
uint8 GetTypeId() const
Definition: Object.h:210
DBCStorage< SoundEntriesEntry > const * GetSoundEntriesStore()
Definition: DBCStores.cpp:772
#define pSystemMgr
Definition: ScriptSystem.h:67
void MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1865
#define error_log
Definition: Log.h:202
uint32 uiSoundId
Definition: ScriptSystem.h:61
uint32 GetEntry() const
Definition: Object.h:192
Definition: Unit.h:908
const uint64 & GetGUID() const
Definition: Object.h:162