-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabilities.p8
363 lines (355 loc) · 9.05 KB
/
abilities.p8
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
effects = {
damage = function(ability)
bonus = ability.candy.attack_power - ability.opponent.defense_rating
bonus_multiplier = 1 + (bonus / 100)
-- don't allow an attack ability to give back health
bonus_multiplier = max(bonus_multiplier, 0)
-- always subtract whole numbers from the health
damage = flr(ability.power * bonus_multiplier)
ability.opponent.hp -= damage
-- don't let opponent hp fall below zero
if (ability.opponent.hp < 0) ability.opponent.hp = 0
end,
flat_damage = function(ability)
ability.opponent.hp -= ability.power
-- don't let opponent hp fall below zero
if (ability.opponent.hp < 0) ability.opponent.hp = 0
end,
apply_statuses = function(ability)
foreach(ability.status_effects, function(status_effect)
local status_name = status_effect.name
local status_already_exists = false
-- if the status effect already exists on the opponent,
-- increase the power and reset the duration
-- @todo -- add a max power for status effects?
foreach(ability.opponent.status_effects, function(o_status_effect)
if (o_status_effect.name == status_name) then
o_status_effect.power += status_effect.power
o_status_effect.duration = status_effect.duration
status_already_exists = true
end
end)
if (status_already_exists) then
dialog:queue("the effects of ".. status_effect.name .." on ".. ability.opponent.name .." worsened")
else
status_effect_ability = make_ability(ability.candy, status_effect)
add(ability.opponent.status_effects, status_effect_ability)
-- @todo this doesn't feel great here
current_scene:add(status_effect_ability)
dialog:queue(ability.opponent.name.." was inflicted with "..status_effect.name)
end
end)
end,
reduce_attack_power = function(ability)
-- ability.opponent.attack_power *= (1 - (ability.power / 100))
ability.opponent.attack_power -= ability.power
-- don't let attack power fall below 0
ability.opponent.attack_power = max(ability.opponent.attack_power, 0)
dialog:queue(ability.opponent.name.."'s attack was lowered")
end,
reduce_defense_rating = function(ability)
-- ability.opponent.defense_rating *= (1 - (ability.power / 100))
ability.opponent.defense_rating -= ability.power
-- don't let defense rating fall below 0
ability.opponent.defense_rating = max(ability.opponent.defense_rating, 0)
dialog:queue(ability.opponent.name.."'s defense was lowered")
end,
increase_defense_rating = function(ability)
-- ability.candy.defense_rating *= (1 + (ability.power / 100))
ability.candy.defense_rating += ability.power
dialog:queue(ability.candy.name.."'s defense was increased")
end,
heal = function(ability)
ability.candy.hp += ability.power
-- don't allow the heal to give more than max hp
ability.candy.hp = min(ability.candy.hp, ability.candy.max_hp)
dialog:queue(ability.candy.name.." healed")
end
}
status_effects = {
bleed = {
name = "bleed",
power = 7,
duration = 3,
is_status_effect = true,
animation = animations.bleed,
effects = {
effects.flat_damage
}
},
poison = {
name = "poison",
power = 5,
duration = 4,
is_status_effect = true,
animation = animations.poison,
effects = {
effects.flat_damage
}
},
rot = {
name = "rot",
power = 4,
duration = 5,
is_status_effect = true,
animation = animations.rot,
effects = {
effects.flat_damage
}
}
}
abilities = {
-- razor apple
throw_razor = {
name = "throw razor",
power = nil,
status_effects = {
status_effects.bleed
},
animation = animations.slice,
effects = {
effects.apply_statuses
}
},
bash = {
name = "bash",
power = 15,
status_effects = {},
animation = animations.basic_attack,
effects = {
effects.damage
}
},
rot_teeth = {
name = "rot teeth",
power = 15,
status_effects = {},
animation = animations.debuff,
effects = {
effects.reduce_defense_rating
}
},
caramelize = {
name = "caramelize",
power = 10,
status_effects = {},
animation = animations.buff,
effects = {
effects.increase_defense_rating
}
},
-- boom pops
pop = {
name = "pop",
power = 7,
status_effects = {},
animation = animations.basic_attack,
effects = {
effects.damage
}
},
acid_spit = {
name = "acid spit",
power = nil,
status_effects = {
status_effects.poison
},
animation = animations.poison,
effects = {
effects.apply_statuses
}
},
boom = {
name = "boom",
power = 20,
status_effects = {},
animation = animations.explosion,
effects = {
effects.damage
}
},
settle_down = {
name = "settle down",
power = 20,
status_effects = {},
animation = animations.debuff,
effects = {
effects.reduce_attack_power
}
},
-- criminal crunch
crunch = {
name = "crunch",
power = 20,
status_effects = nil,
animation = animations.basic_attack,
effects = {
effects.damage
}
},
rat_a_tat = {
name = "rat-a-tat",
power = nil,
status_effects = {
status_effects.bleed
},
animation = animations.bleed,
effects = {
effects.apply_statuses
}
},
cannibalize = {
name = "cannibalize",
power = 10,
status_effects = {},
animation = animations.heal,
effects = {
effects.heal
}
},
swack_swack = {
name = "swack swack",
power = 10,
status_effects = {},
animation = animations.debuff,
effects = {
effects.reduce_attack_power,
effects.reduce_defense_rating
}
},
-- jaw crusher
split_wig = {
name = "split wig",
power = 10,
status_effects = {},
animation = animations.basic_attack,
effects = {
effects.damage,
effects.reduce_defense_rating
}
},
break_jaw = {
name = "break jaw",
power = 20,
status_effects = {},
animation = animations.explosion,
effects = {
effects.damage
}
},
jab = {
name = "jab",
power = 10,
status_effects = {},
animation = animations.buff,
effects = {
effects.damage,
effects.increase_defense_rating
}
},
uppercut = {
name = "uppercut",
power = 5,
status_effects = {
status_effects.bleed
},
animation = animations.slice,
effects = {
effects.damage,
effects.apply_statuses
}
},
-- pb killer
stab_stab = {
name = "stab stab",
power = 5,
status_effects = {
status_effects.bleed
},
animation = animations.slice,
effects = {
effects.damage,
effects.apply_statuses
}
},
draw_blood = {
name = "draw blood",
power = 10,
status_effects = nil,
animation = animations.heal,
effects = {
effects.heal
}
},
slit_throat = {
name = "slit throat",
power = 20,
status_effects = nil,
animation = animations.slice,
effects = {
effects.damage
}
},
disembowel = {
name = "disembowel",
power = 20,
status_effects = nil,
animation = animations.debuff,
effects = {
effects.reduce_defense_rating
}
}
}
function make_ability(candy, ability)
return {
candy = candy,
name = ability.name,
power = ability.power,
status_effects = ability.status_effects,
duration = ability.duration,
animation = ability.animation,
is_status_effect = ability.is_status_effect,
opponent = nil,
animation_loops = {},
effects = ability.effects,
was_triggered = false,
trigger = function(self, opponent)
-- if the ability has duration, subtract from it
if (self.duration != nil and self.duration > 0) self.duration -= 1
-- if the ability has an animation, add it
if (self.animation) add(self.animation_loops, cocreate(self.animation))
if (opponent.is_player and not self.is_status_effect) then
-- if the opponent is the player, add the screen shake
add(self.animation_loops, cocreate(animations.screen_shake))
end
foreach(self.animation_loops, function(animation_loop)
add(animations, animation_loop)
end)
self.opponent = opponent
self.was_triggered = true
end,
update = function(self)
end,
draw = function(self)
foreach(self.animation_loops, function(animation_loop)
if (animation_loop and costatus(animation_loop) != 'dead') then
coresume(animation_loop, self)
else
del(self.animation_loops, animation_loop)
del(animations, animation_loop)
end
end)
-- if all animations have run, clean up
if (self.was_triggered and #self.animation_loops == 0) then
if (self.effects != nil and #self.effects > 0) then
foreach(self.effects, function(effect)
effect(self)
end)
end
-- no longer using ability so unset the opponent
self.opponent = nil
self.was_triggered = false
end
end
}
end