Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SpellMethods.cpp
Go to the documentation of this file.
1/*
2* Copyright (C) 2010 - 2013 Eluna Lua Engine <http://emudevs.com/>
3* This program is free software licensed under GPL version 3
4* Please see the included DOCS/LICENSE.TXT for more information
5*/
6
7#include "SpellMethods.h"
8#include "Includes.h"
9
10namespace LuaSpell
11{
12 int GetCaster(lua_State* L, Spell* spell)
13 {
14 sEluna->Push(L, spell->GetCaster());
15 return 1;
16 }
17
18 int GetCastTime(lua_State* L, Spell* spell)
19 {
20 sEluna->Push(L, spell->GetCastTime());
21 return 1;
22 }
23
24 int GetId(lua_State* L, Spell* spell)
25 {
26 sEluna->Push(L, spell->m_spellInfo->Id);
27 return 1;
28 }
29
30 int GetPowerCost(lua_State* L, Spell* spell)
31 {
32 sEluna->Push(L, spell->GetPowerCost());
33 return 1;
34 }
35
36 int GetDuration(lua_State* L, Spell* spell)
37 {
38 sEluna->Push(L, spell->GetSpellInfo()->GetDuration());
39 return 1;
40 }
41
42 int Cast(lua_State* L, Spell* spell)
43 {
44 bool skipCheck = lua_toboolean(L, 1);
45 spell->cast(skipCheck);
46 return 0;
47 }
48
49 int IsAutoRepeat(lua_State* L, Spell* spell)
50 {
51 sEluna->Push(L, spell->IsAutoRepeat());
52 return 1;
53 }
54
55 int SetAutoRepeat(lua_State* L, Spell* spell)
56 {
57 bool repeat = luaL_checkbool(L, 1);
58 spell->SetAutoRepeat(repeat);
59 return 0;
60 }
61
62 int cancel(lua_State* L, Spell* spell)
63 {
64 spell->cancel();
65 return 0;
66 }
67
68 // Finish()
69 int Finish(lua_State* L, Spell* spell)
70 {
71 spell->finish();
72 return 0;
73 }
74
75 int GetTargetDest(lua_State* L, Spell* spell)
76 {
77 if (!spell->m_targets.HasDst())
78 return 0;
79
80 float x, y, z;
81 spell->m_targets.GetDstPos()->GetPosition(x, y, z);
82 sEluna->Push(L, x);
83 sEluna->Push(L, y);
84 sEluna->Push(L, z);
85 return 3;
86 }
87};
#define sEluna
Definition LuaEngine.h:710
bool HasDst() const
Definition Spell.h:217
WorldLocation const * GetDstPos() const
Definition Spell.cpp:383
Definition Spell.h:289
SpellInfo const * GetSpellInfo() const
Definition Spell.h:565
void cast(bool skipCheck=false)
Definition Spell.cpp:3266
SpellCastTargets m_targets
Definition Spell.h:535
Unit * GetCaster() const
Definition Spell.h:563
bool IsAutoRepeat() const
Definition Spell.h:543
int32 GetCastTime() const
Definition Spell.h:542
void cancel()
Definition Spell.cpp:3210
void SetAutoRepeat(bool rep)
Definition Spell.h:544
int32 GetPowerCost() const
Definition Spell.h:566
void finish(bool ok=true)
Definition Spell.cpp:3762
SpellInfo const *const m_spellInfo
Definition Spell.h:530
uint32 Id
Definition SpellInfo.h:160
int32 GetDuration() const
int GetDuration(lua_State *L, Spell *spell)
int SetAutoRepeat(lua_State *L, Spell *spell)
int GetPowerCost(lua_State *L, Spell *spell)
int Cast(lua_State *L, Spell *spell)
int cancel(lua_State *L, Spell *spell)
int GetCastTime(lua_State *L, Spell *spell)
int GetId(lua_State *L, Spell *spell)
int GetTargetDest(lua_State *L, Spell *spell)
int GetCaster(lua_State *L, Spell *spell)
int Finish(lua_State *L, Spell *spell)
int IsAutoRepeat(lua_State *L, Spell *spell)
void GetPosition(float &x, float &y) const
Definition Object.h:333