-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathPetBuff.lua
287 lines (283 loc) · 8.61 KB
/
PetBuff.lua
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
function PetBuffSpell(spell)
local InBattleFlag = spell.being.battleGrid.InBattle()
local petlist = {}
local buffnumber
local morebuffs
local petidsnumber
local morepetids
local duration
local extra
local amount
local i
local j
local k
if InBattleFlag == false then --This checks if the spell is set to trigger while not in battle. If In Battle, checking is moot anyway.
if spell.HasParam("PetBuffInBattleOnly") then
if spell.Param("PetBuffInBattleOnly") == "False" or spell.Param("PetBuffInBattleOnly") == "false" or spell.Param("PetBuffInBattleOnly") == "FALSE" then
local InBattleFlag = true
else
if InBattleFlag == false then
spell.being.MustBeInBattleWarning()
end
end
end
end
if InBattleFlag then
if spell.HasParam("PetBuffTarget") then
if spell.Param("PetBuffTarget") == "OnlyMyPets" then
if #(spell.being.currentPets) > 0 then
for i = 0, #(spell.being.currentPets)-1, 1 do
petlist[#petlist+1] = spell.being.currentPets[i]
end
end
else
if spell.Param("PetBuffTarget") == "AllEnemyPets" then
if #(spell.being.battleGrid.currentEnemies) > 0 then
for i = 0, #(spell.being.battleGrid.currentEnemies)-1, 1 do
if #(spell.being.battleGrid.currentEnemies[i].currentPets) > 0 then
for j = 0, #(spell.being.battleGrid.currentEnemies[i].currentPets)-1, 1 do
petlist[#petlist+1] = spell.being.battleGrid.currentEnemies[i].currentPets[j]
end
end
end
end
else
if spell.Param("PetBuffTarget") == "AllPlayerPets" then
for i = 1, #(spell.ctrl.currentPlayers), 1 do
for j = 0, #(spell.ctrl.currentPlayers[i].currentPets)-1, 1 do
petlist[#petlist+1] = spell.ctrl.currentPlayers[i].currentPets[j]
end
end
else
if spell.Param("PetBuffTarget") == "TargetsPets" then
for _, target in ipairs(GetTarget(spell)) do
if #(target.currentPets) > 0 then
for i = 0, #(target.currentPets)-1, 1 do
petlist[#petlist+1] = target.currentPets[i]
end
end
end
else
if spell.Param("PetBuffTarget") == "NamedPetID" then
petidsnumber = 0
morepetids = true
while morepetids do
if spell.HasParam("PetID"..tostring(petidsnumber+1)) then
petidsnumber = petidsnumber +1
else
morepetids = false
end
end
for i = 1, #(spell.ctrl.currentPlayers), 1 do
for j = 0, #(spell.ctrl.currentPlayers[i].currentPets)-1, 1 do
for k = 1, petidsnumber ,1 do
if spell.ctrl.currentPlayers[i].currentPets[j].beingObj.get_beingID() == spell.Param("PetID"..tostring(k)) then
petlist[#petlist+1] = spell.ctrl.currentPlayers[i].currentPets[j]
end
end
end
end
if #(spell.being.battleGrid.currentEnemies) > 0 then
for i = 0, #(spell.being.battleGrid.currentEnemies)-1, 1 do
if #(spell.being.battleGrid.currentEnemies[i].currentPets) > 0 then
for j = 0, #(spell.being.battleGrid.currentEnemies[i].currentPets)-1, 1 do
for k = 1, petidsnumber ,1 do
if spell.being.battleGrid.currentEnemies[i].currentPets[j].beingObj.get_beingID() == spell.Param("PetID"..tostring(k)) then
petlist[#petlist+1] = spell.being.battleGrid.currentEnemies[i].currentPets[j]
end
end
end
end
end
end
end
end
end
end
end
end
if #petlist > 0 then
buffnumber = 0
morebuffs = true
while morebuffs do
if spell.HasParam("PetBuffStatus"..tostring(buffnumber+1)) then
buffnumber = buffnumber +1
else
morebuffs = false
end
end
if buffnumber > 0 then
for i = 1, #petlist, 1 do
for j = 1, buffnumber, 1 do
if spell.HasParam("PetBuffAmount"..tostring(j)) then
amount = tonumber(spell.Param("PetBuffAmount"..tostring(j)))
else
amount = 0
end
if spell.HasParam("PetBuffDuration"..tostring(j)) then
duration = tonumber(spell.Param("PetBuffDuration"..tostring(j)))
else
duration = 9999
end
if spell.HasParam("PetBuffExtra"..tostring(j)) then
extra = spell.Param("PetBuffExtra"..tostring(j))
else
extra = "None"
end
BuffTarget(petlist[i], spell.Param("PetBuffStatus"..tostring(j)),amount,duration,extra)
end
end
end
end
end
end
function BuffTarget(being, status, amount, duration, extra)
local spell
if status == "Heal" then
being.Heal(math.floor(amount))
else
if status == "DamageNorm" then
being.Damage(amount)
else
if status == "Damage" then
being.Damage(amount, true)
else
if status == "DamageTrue" then
being.Damage(amount, true, true)
else
if status == "Invincibility" then
being.AddInvince(duration)
else
if status == "CastSpell" then
if extra ~= "None" then
spell = being.deCtrl.CreateSpellBase(extra, being, false)
spell.interrupt = false
spell.StartCast(false, 0, false)
end
else
if extra == "Cleanse" then
being.RemoveStatus(status)
else
being.AddStatus(status, amount, duration)
end
end
end
end
end
end
end
end
function PetBuffArtifactFunction(item, target, status, amount, duration, extra)
local petlist = {}
local i
local j
local localamount
local localduration
local localextra
if target == "OnlyMyPets" then
if #(item.being.currentPets) > 0 then
for i = 0, #(item.being.currentPets)-1, 1 do
petlist[#petlist+1] = item.being.currentPets[i]
end
end
else
if target == "AllEnemyPets" then
if #(item.being.battleGrid.currentEnemies) > 0 then
for i = 0, #(item.being.battleGrid.currentEnemies)-1, 1 do
if #(item.being.battleGrid.currentEnemies[i].currentPets) > 0 then
for j = 0, #(item.being.battleGrid.currentEnemies[i].currentPets)-1, 1 do
petlist[#petlist+1] = item.being.battleGrid.currentEnemies[i].currentPets[j]
end
end
end
end
else
if target == "AllPlayerPets" then
for i = 1, #(item.ctrl.currentPlayers), 1 do
for j = 0, #(item.ctrl.currentPlayers[i].currentPets)-1, 1 do
petlist[#petlist+1] = item.ctrl.currentPlayers[i].currentPets[j]
end
end
else
if target== "TargetsPets" then
for _, target in ipairs(GetTarget(item)) do
if #(target.currentPets) > 0 then
for i = 0, #(target.currentPets)-1, 1 do
petlist[#petlist+1] = target.currentPets[i]
end
end
end
end
end
end
end
if #petlist > 0 then
for i = 1, #petlist, 1 do
if amount ~= nil then
localamount = amount
else
amount = 0
end
if duration ~= nil then
localduration = duration
else
localduration = 9999
end
if extra ~= nil then
localextra = extra
else
localextra = "None"
end
BuffTarget(petlist[i], status, localamount, localduration, localextra)
end
end
end
function PetBuffArtifactPetIDFunction(item, petid, status, amount, duration, extra)
local petlist = {}
local i
local j
local localamount
local localduration
local localextra
for i = 1, #(item.ctrl.currentPlayers), 1 do
for j = 0, #(item.ctrl.currentPlayers[i].currentPets)-1, 1 do
if item.ctrl.currentPlayers[i].currentPets[j].beingObj.get_beingID() == petid then
petlist[#petlist+1] = item.ctrl.currentPlayers[i].currentPets[j]
end
end
end
if #(item.being.battleGrid.currentEnemies) > 0 then
for i = 0, #(item.being.battleGrid.currentEnemies)-1, 1 do
if #(item.being.battleGrid.currentEnemies[i].currentPets) > 0 then
for j = 0, #(item.being.battleGrid.currentEnemies[i].currentPets)-1, 1 do
if item.being.battleGrid.currentEnemies[i].currentPets[j].beingObj.get_beingID() == petid then
petlist[#petlist+1] = item.being.battleGrid.currentEnemies[i].currentPets[j]
end
end
end
end
end
if #petlist > 0 then
for i = 1, #petlist, 1 do
if amount ~= nil then
localamount = amount
else
amount = 0
end
if duration ~= nil then
localduration = duration
else
localduration = 9999
end
if extra ~= nil then
localextra = extra
else
localextra = "None"
end
BuffTarget(petlist[i], status, localamount, localduration, localextra)
end
end
end
function MyPetBuffArtifact(item)
PetBuffArtifactFunction(item, "OnlyMyPets", "Defense", 10, 10, "None")
end