forked from ElunaLuaEngine/Eluna
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuraMethods.h
217 lines (204 loc) · 5.85 KB
/
AuraMethods.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
#ifndef AURAMETHODS_H
#define AURAMETHODS_H
/***
* The persistent effect of a [Spell] that remains on a [Unit] after the [Spell]
* has been cast.
*
* As an example, if you cast a damage-over-time spell on a target, an [Aura] is
* put on the target that deals damage continuously.
*
* [Aura]s on your player are displayed in-game as a series of icons to the left
* of the mini-map.
*
* Inherits all methods from: none
*/
namespace LuaAura
{
/**
* Returns the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
*
* @return [Unit] caster
*/
int GetCaster(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetCaster());
return 1;
}
/**
* Returns the GUID of the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
*
* @return string caster_guid : the GUID of the Unit as a decimal string
*/
int GetCasterGUID(lua_State* L, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetCasterGUID());
#else
Eluna::Push(L, aura->GetCasterGuid());
#endif
return 1;
}
/**
* Returns the level of the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
*
* @return uint32 caster_level
*/
int GetCasterLevel(lua_State* L, Aura* aura)
{
#if defined(TRINITY) || CMANGOS
Eluna::Push(L, aura->GetCaster()->GetLevel());
#else
Eluna::Push(L, aura->GetCaster()->getLevel());
#endif
return 1;
}
/**
* Returns the amount of time left until the [Aura] expires.
*
* @return int32 duration : amount of time left in milliseconds
*/
int GetDuration(lua_State* L, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetDuration());
#else
Eluna::Push(L, aura->GetAuraDuration());
#endif
return 1;
}
/**
* Returns the ID of the [Spell] that caused this [Aura] to be applied.
*
* @return uint32 aura_id
*/
int GetAuraId(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetId());
return 1;
}
/**
* Returns the amount of time this [Aura] lasts when applied.
*
* To determine how much time has passed since this Aura was applied,
* subtract the result of [Aura]:GetDuration from the result of this method.
*
* @return int32 max_duration : the maximum duration of the Aura, in milliseconds
*/
int GetMaxDuration(lua_State* L, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetMaxDuration());
#else
Eluna::Push(L, aura->GetAuraMaxDuration());
#endif
return 1;
}
/**
* Returns the number of times the [Aura] has "stacked".
*
* This is the same as the number displayed on the [Aura]'s icon in-game.
*
* @return uint32 stack_amount
*/
int GetStackAmount(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetStackAmount());
return 1;
}
/**
* Returns the [Unit] that the [Aura] has been applied to.
*
* @return [Unit] owner
*/
int GetOwner(lua_State* L, Aura* aura)
{
#if defined TRINITY || defined AZEROTHCORE
Eluna::Push(L, aura->GetOwner());
#else
Eluna::Push(L, aura->GetTarget());
#endif
return 1;
}
/**
* Change the amount of time before the [Aura] expires.
*
* @param int32 duration : the new duration of the Aura, in milliseconds
*/
int SetDuration(lua_State* L, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
#if defined TRINITY || defined AZEROTHCORE
aura->SetDuration(duration);
#else
aura->GetHolder()->SetAuraDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
#else
aura->GetHolder()->SendAuraUpdate(false);
#endif
#endif
return 0;
}
/**
* Change the maximum amount of time before the [Aura] expires.
*
* This does not affect the current duration of the [Aura], but if the [Aura]
* is reset to the maximum duration, it will instead change to `duration`.
*
* @param int32 duration : the new maximum duration of the Aura, in milliseconds
*/
int SetMaxDuration(lua_State* L, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
#if defined TRINITY || defined AZEROTHCORE
aura->SetMaxDuration(duration);
#else
aura->GetHolder()->SetAuraMaxDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
#else
aura->GetHolder()->SendAuraUpdate(false);
#endif
#endif
return 0;
}
/**
* Change the amount of times the [Aura] has "stacked" on the [Unit].
*
* If `amount` is greater than or equal to the current number of stacks,
* then the [Aura] has its duration reset to the maximum duration.
*
* @param uint32 amount
*/
int SetStackAmount(lua_State* L, Aura* aura)
{
uint8 amount = Eluna::CHECKVAL<uint8>(L, 2);
#if defined TRINITY || defined AZEROTHCORE
aura->SetStackAmount(amount);
#elif defined CMANGOS
aura->GetHolder()->SetStackAmount(amount, aura->GetTarget());
#else
aura->GetHolder()->SetStackAmount(amount);
#endif
return 0;
}
/**
* Remove this [Aura] from the [Unit] it is applied to.
*/
int Remove(lua_State* L, Aura* aura)
{
#if defined TRINITY || defined AZEROTHCORE
aura->Remove();
#else
aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL);
#endif
Eluna::CHECKOBJ<ElunaObject>(L, 1)->Invalidate();
return 0;
}
};
#endif