TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cast_commandscript Class Reference

Public Member Functions

 cast_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool CheckSpellExistsAndIsValid (ChatHandler *handler, uint32 spellId)
 
static bool HandleCastCommand (ChatHandler *handler, char const *args)
 
static bool HandleCastBackCommand (ChatHandler *handler, char const *args)
 
static bool HandleCastDistCommand (ChatHandler *handler, char const *args)
 
static bool HandleCastSelfCommand (ChatHandler *handler, char const *args)
 
static bool HandleCastTargetCommad (ChatHandler *handler, char const *args)
 
static bool HandleCastDestCommand (ChatHandler *handler, char const *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

cast_commandscript::cast_commandscript ( )
inline
34 : CommandScript("cast_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

static bool cast_commandscript::CheckSpellExistsAndIsValid ( ChatHandler handler,
uint32  spellId 
)
inlinestatic
55  {
56  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
57  if (!spellInfo)
58  {
60  handler->SetSentErrorMessage(true);
61  return false;
62  }
63 
64  if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer()))
65  {
66  handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
67  handler->SetSentErrorMessage(true);
68  return false;
69  }
70  return true;
71  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:490
Definition: SpellInfo.h:326
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:447
#define sSpellMgr
Definition: SpellMgr.h:756
static bool IsSpellValid(SpellInfo const *spellInfo, Player *player=NULL, bool msg=true)
Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book...
Definition: SpellMgr.cpp:482
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<ChatCommand> cast_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

37  {
38  static std::vector<ChatCommand> castCommandTable =
39  {
46  };
47  static std::vector<ChatCommand> commandTable =
48  {
49  { "cast", rbac::RBAC_PERM_COMMAND_CAST, false, NULL, "", castCommandTable },
50  };
51  return commandTable;
52  }
static bool HandleCastCommand(ChatHandler *handler, char const *args)
Definition: cs_cast.cpp:73
static bool HandleCastSelfCommand(ChatHandler *handler, char const *args)
Definition: cs_cast.cpp:180
static bool HandleCastTargetCommad(ChatHandler *handler, char const *args)
Definition: cs_cast.cpp:200
Definition: RBAC.h:177
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleCastDistCommand(ChatHandler *handler, char const *args)
Definition: cs_cast.cpp:142
Definition: RBAC.h:175
Definition: RBAC.h:176
static bool HandleCastBackCommand(ChatHandler *handler, char const *args)
Definition: cs_cast.cpp:109
Definition: RBAC.h:174
Definition: RBAC.h:179
static bool HandleCastDestCommand(ChatHandler *handler, char const *args)
Definition: cs_cast.cpp:240

+ Here is the call graph for this function:

static bool cast_commandscript::HandleCastBackCommand ( ChatHandler handler,
char const args 
)
inlinestatic
110  {
111  Creature* caster = handler->getSelectedCreature();
112  if (!caster)
113  {
115  handler->SetSentErrorMessage(true);
116  return false;
117  }
118 
119  // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
120  uint32 spellId = handler->extractSpellIdFromLink((char*)args);
121  if (!spellId)
122  return false;
123 
124  if (!CheckSpellExistsAndIsValid(handler, spellId))
125  return false;
126 
127  char* triggeredStr = strtok(NULL, " ");
128  if (triggeredStr)
129  {
130  int l = strlen(triggeredStr);
131  if (strncmp(triggeredStr, "triggered", l) != 0)
132  return false;
133  }
134 
135  bool triggered = (triggeredStr != NULL);
136 
137  caster->CastSpell(handler->GetSession()->GetPlayer(), spellId, triggered);
138 
139  return true;
140  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Language.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32_t uint32
Definition: Define.h:150
uint32 extractSpellIdFromLink(char *text)
Definition: Chat.cpp:806
WorldSession * GetSession()
Definition: Chat.h:59
static bool CheckSpellExistsAndIsValid(ChatHandler *handler, uint32 spellId)
Definition: cs_cast.cpp:54
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool cast_commandscript::HandleCastCommand ( ChatHandler handler,
char const args 
)
inlinestatic
74  {
75  if (!*args)
76  return false;
77 
78  Unit* target = handler->getSelectedUnit();
79  if (!target)
80  {
82  handler->SetSentErrorMessage(true);
83  return false;
84  }
85 
86  // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
87  uint32 spellId = handler->extractSpellIdFromLink((char*)args);
88  if (!spellId)
89  return false;
90 
91  if (!CheckSpellExistsAndIsValid(handler, spellId))
92  return false;
93 
94  char* triggeredStr = strtok(NULL, " ");
95  if (triggeredStr)
96  {
97  int l = strlen(triggeredStr);
98  if (strncmp(triggeredStr, "triggered", l) != 0)
99  return false;
100  }
101 
102  bool triggered = (triggeredStr != NULL);
103 
104  handler->GetSession()->GetPlayer()->CastSpell(target, spellId, triggered);
105 
106  return true;
107  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Unit * getSelectedUnit()
Definition: Chat.cpp:591
Definition: Language.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32_t uint32
Definition: Define.h:150
uint32 extractSpellIdFromLink(char *text)
Definition: Chat.cpp:806
WorldSession * GetSession()
Definition: Chat.h:59
static bool CheckSpellExistsAndIsValid(ChatHandler *handler, uint32 spellId)
Definition: cs_cast.cpp:54
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool cast_commandscript::HandleCastDestCommand ( ChatHandler handler,
char const args 
)
inlinestatic
241  {
242  Unit* caster = handler->getSelectedUnit();
243  if (!caster)
244  {
246  handler->SetSentErrorMessage(true);
247  return false;
248  }
249 
250  // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
251  uint32 spellId = handler->extractSpellIdFromLink((char*)args);
252  if (!spellId)
253  return false;
254 
255  if (!CheckSpellExistsAndIsValid(handler, spellId))
256  return false;
257 
258  char* posX = strtok(NULL, " ");
259  char* posY = strtok(NULL, " ");
260  char* posZ = strtok(NULL, " ");
261 
262  if (!posX || !posY || !posZ)
263  return false;
264 
265  float x = float(atof(posX));
266  float y = float(atof(posY));
267  float z = float(atof(posZ));
268 
269  char* triggeredStr = strtok(NULL, " ");
270  if (triggeredStr)
271  {
272  int l = strlen(triggeredStr);
273  if (strncmp(triggeredStr, "triggered", l) != 0)
274  return false;
275  }
276 
277  bool triggered = (triggeredStr != NULL);
278 
279  caster->CastSpell(x, y, z, spellId, triggered);
280 
281  return true;
282  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Unit * getSelectedUnit()
Definition: Chat.cpp:591
Definition: Language.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
uint32 extractSpellIdFromLink(char *text)
Definition: Chat.cpp:806
G3D::int16 x
Definition: Vector2int16.h:37
static bool CheckSpellExistsAndIsValid(ChatHandler *handler, uint32 spellId)
Definition: cs_cast.cpp:54
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Unit.h:1305
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool cast_commandscript::HandleCastDistCommand ( ChatHandler handler,
char const args 
)
inlinestatic
143  {
144  if (!*args)
145  return false;
146 
147  // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
148  uint32 spellId = handler->extractSpellIdFromLink((char*)args);
149  if (!spellId)
150  return false;
151 
152  if (!CheckSpellExistsAndIsValid(handler, spellId))
153  return false;
154 
155  char* distStr = strtok(NULL, " ");
156 
157  float dist = 0;
158 
159  if (distStr)
160  sscanf(distStr, "%f", &dist);
161 
162  char* triggeredStr = strtok(NULL, " ");
163  if (triggeredStr)
164  {
165  int l = strlen(triggeredStr);
166  if (strncmp(triggeredStr, "triggered", l) != 0)
167  return false;
168  }
169 
170  bool triggered = (triggeredStr != NULL);
171 
172  float x, y, z;
173  handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, dist);
174 
175  handler->GetSession()->GetPlayer()->CastSpell(x, y, z, spellId, triggered);
176 
177  return true;
178  }
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
uint32 extractSpellIdFromLink(char *text)
Definition: Chat.cpp:806
WorldSession * GetSession()
Definition: Chat.h:59
G3D::int16 x
Definition: Vector2int16.h:37
static bool CheckSpellExistsAndIsValid(ChatHandler *handler, uint32 spellId)
Definition: cs_cast.cpp:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool cast_commandscript::HandleCastSelfCommand ( ChatHandler handler,
char const args 
)
inlinestatic
181  {
182  if (!*args)
183  return false;
184 
185  Unit* target = handler->getSelectedUnit();
186 
187  // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
188  uint32 spellId = handler->extractSpellIdFromLink((char*)args);
189  if (!spellId)
190  return false;
191 
192  if (!CheckSpellExistsAndIsValid(handler, spellId))
193  return false;
194 
195  target->CastSpell(target, spellId, false);
196 
197  return true;
198  }
Unit * getSelectedUnit()
Definition: Chat.cpp:591
uint32_t uint32
Definition: Define.h:150
uint32 extractSpellIdFromLink(char *text)
Definition: Chat.cpp:806
static bool CheckSpellExistsAndIsValid(ChatHandler *handler, uint32 spellId)
Definition: cs_cast.cpp:54
Definition: Unit.h:1305
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool cast_commandscript::HandleCastTargetCommad ( ChatHandler handler,
char const args 
)
inlinestatic
201  {
202  Creature* caster = handler->getSelectedCreature();
203  if (!caster)
204  {
206  handler->SetSentErrorMessage(true);
207  return false;
208  }
209 
210  if (!caster->GetVictim())
211  {
213  handler->SetSentErrorMessage(true);
214  return false;
215  }
216 
217  // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
218  uint32 spellId = handler->extractSpellIdFromLink((char*)args);
219  if (!spellId)
220  return false;
221 
222  if (!CheckSpellExistsAndIsValid(handler, spellId))
223  return false;
224 
225  char* triggeredStr = strtok(NULL, " ");
226  if (triggeredStr)
227  {
228  int l = strlen(triggeredStr);
229  if (strncmp(triggeredStr, "triggered", l) != 0)
230  return false;
231  }
232 
233  bool triggered = (triggeredStr != NULL);
234 
235  caster->CastSpell(caster->GetVictim(), spellId, triggered);
236 
237  return true;
238  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Language.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Unit * GetVictim() const
Definition: Unit.h:1379
uint32_t uint32
Definition: Define.h:150
uint32 extractSpellIdFromLink(char *text)
Definition: Chat.cpp:806
static bool CheckSpellExistsAndIsValid(ChatHandler *handler, uint32 spellId)
Definition: cs_cast.cpp:54
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: Language.h:604

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: