forked from SpectralPack/Aura
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteractiveJokers.lua
More file actions
372 lines (342 loc) · 17.8 KB
/
InteractiveJokers.lua
File metadata and controls
372 lines (342 loc) · 17.8 KB
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
364
365
366
367
368
369
370
371
372
--FUNCTIONS FOR JOKERS THAT NEED TO DETECT CERTAIN EVENTS
--Detecting Egg price increase and triggering animation
local csc = Card.set_cost
function Card:set_cost()
if self.ability and self.ability.name == "Egg" then
if not self.animation then --Should only happen on creation
Aura.add_individual(self)
self.animation = { target = 0, egg_old_value = self.ability.extra_value }
elseif self.ability.extra_value > self.animation.egg_old_value then --When the price increases
Aura.add_individual(self)
self.animation = { target = 0, escape_target = true, egg_old_value = self.ability.extra_value }
end
end
csc(self) --Original Card:set_cost function call
end
--Detecting when the hand selected is already played to trigger Card Sharp animation
local uht = update_hand_text
function update_hand_text(config, vals)
uht(config, vals) --Original update_hand_text function call
--At least in vanilla, the only situation where the following conditions are met is when selecting a hand, not when playing it or leveling it up
if config.immediate and not config.volume and vals.handname ~= nil then
--Check if the selected hand has already been played this round and set Card Sharp animation target accordingly
if G.GAME.hands[vals.handname] and G.GAME.hands[vals.handname].played_this_round > 0 then
AnimatedJokers.j_card_sharp.target = 3
else
AnimatedJokers.j_card_sharp.target = 0
end
end
return true
end
--Detecting when interest is evaluated to trigger To The Moon animation.
local arer = add_round_eval_row
function add_round_eval_row(config)
--Original add_round_eval_row function call
local ret = arer(config)
--Trigger animation when the interest row is added
if config.name == "interest" then
--Only trigger if there is a To The Moon joker in play
local has_ttm = false
for _, jkr in ipairs(G.jokers.cards) do
if jkr.ability.name == "To the Moon" then
has_ttm = true
break
end
end
if has_ttm then
--Add animation inside an event
G.E_MANAGER:add_event(Event({
trigger = 'after',
blocking = false,
func = (function()
AnimatedJokers.j_to_the_moon.escape_target = true
return true
end)
}))
end
end
return ret
end
--Function for Oops All 6s. Called by Gros Michel, The Space Joker, 8 Ball, Business Card, Reserved Parking, Cavendish, Hallucination, Bloodstone, The Wheel of Fortune, Lucky Cards and Glass Cards
function Aura.Trigger_oops_all_6s()
--Add animation inside an event
G.E_MANAGER:add_event(Event({
func = (function()
AnimatedJokers.j_oops.extra.fps = 10*(G.SPEEDFACTOR/G.SETTINGS.GAMESPEED) --Adapt fps to game speed
AnimatedJokers.j_oops.extra.remaining_triggers = (AnimatedJokers.j_oops.extra.remaining_triggers or 0) + 1
return true
end)
}))
end
--FUNCTIONS FOR JOKERS THAT ANIMATE WHEN DRAGGED
--Detecting when certain jokers are grabbed to trigger their animations
local ccl = Node.set_offset
function Node:set_offset(x,y)
--Original Node:set_offset function call
ccl(self,x,y)
--Detecting Brainstorm grab
if y == "Click" and self.config and self.config.center_key == 'j_brainstorm' and (G.shop_jokers and self.area ~= G.shop_jokers or true) then
Aura.add_individual(self)
self.animation = {target = 5}
end
--Detecting Blueprint grab
if y == "Click" and self.config and self.config.center_key == 'j_blueprint' and (G.shop_jokers and self.area ~= G.shop_jokers or true) then
Aura.add_individual(self)
self.animation = {target = 11}
end
end
--Detecting when certain jokers are released to trigger their animations
local crl = Node.stop_drag
function Node:stop_drag()
--Original Node:stop_drag function call
crl(self)
--Detecting both Brainstorm and Blueprint release, as they share idle postion
if self.config and (self.config.center_key == 'j_brainstorm' or self.config.center_key == 'j_blueprint') then
Aura.add_individual(self)
self.animation = {target = 0}
end
end
--FUNCTIONS FOR JOKERS THAT ANIMATE ON CALCULATION
--Calculate_joker is called almost constantly after almost anything happens. What changes is the context. Lookout for context.blueprint to avoid triggering animation on the wrong card
local cj = Card.calculate_joker
function Card:calculate_joker(context)
--Detecting when Gros Michel is about to extinguish to trigger animation
if self.ability.name == "Gros Michel" and context.end_of_round and context.main_eval and not context.blueprint then
--Trigger Oops All 6s animation
Aura.Trigger_oops_all_6s()
--Use peek_pseudorandom to see the next value without altering it and know if it will extinguish
if peek_pseudorandom('gros_michel') < G.GAME.probabilities.normal/self.ability.extra.odds and not AnimatedJokers.j_gros_michel.IncorrectAtlas then
G.E_MANAGER:add_event(Event({
delay = 1*G.SPEEDFACTOR, --Delay to let the animation play before destroying the card
trigger = 'before',
func = (function()
Aura.add_individual(self)
self.animation = { extra = { target = 17 } }
return true
end)
}))
end
end
--Detecting when Sixth Sense is about to create a spectral card to trigger animation
if self.ability.name == "Sixth Sense" and
context.destroying_card and not context.blueprint and not self.debuff and
#context.full_hand == 1 and context.full_hand[1]:get_id() == 6 and G.GAME.current_round.hands_played == 0 and
#G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit and
not AnimatedJokers.j_sixth_sense.IncorrectAtlas then --It is important to not add delay if sixth sense is not animated
G.E_MANAGER:add_event(Event({ delay = 1.6*G.SETTINGS.GAMESPEED, --Delay the "+1 spectral" pop up to sync it with the flash
trigger = 'before',
func = (function()
Aura.add_individual(self)
self.animation = { target = 0, escape_target = true, fps = 10*(G.SPEEDFACTOR/G.SETTINGS.GAMESPEED) } --Adapt fps to SpeedFactor but not to Game Speed
return true
end)}))
end
--Detecting when Certificate is about to create a card with a seal to load animation
if self.ability.name == "Certificate" and not context.blueprint and context.first_hand_drawn then
Aura.add_individual(self)
self.animation.animation_loaded = true
end
--Original Card:calculate_joker function call
local ret = cj(self, context)
--Detecting when Flash Card is upgraded to trigger animation
if self.ability.name == "Flash Card" and context.reroll_shop and not context.blueprint and not AnimatedJokers.j_flash.IncorrectAtlas then
G.E_MANAGER:add_event(Event({
func = (function()
--Flip Flash Card away
self:flip()
play_sound('card1')
--Change to next letter once on back side
delay(0.075*G.SPEEDFACTOR)
Aura.add_individual(self)
self.animation.flash_index = self.animation.flash_index + 1
if self.animation.flash_index > 25 then self.animation.flash_index = 0 end --Wrap around
self.animation.target = self.animation.flash_order[self.animation.flash_index]
self:juice_up(0.3, 0.3) --Atract attention to the change
delay(0.075*G.SPEEDFACTOR)
--Flip Flash Card back
self:flip()
play_sound('tarot2', 1, 0.6)
return true
end)
}))
end
--Detecting when Trading Card activates to trigger animation
if self.ability.name == "Trading Card" and ret and ret.message and not context.blueprint and not AnimatedJokers.j_trading.IncorrectAtlas then --ret.message carrying info means will show the money pop up
G.E_MANAGER:add_event(Event({
func = (function()
--Flip Trading Card away
self:flip()
play_sound('card1')
delay(0.075*G.SPEEDFACTOR)
--Change to next card once on back side
Aura.add_individual(self)
self.animation.trading_index = self.animation.trading_index + 1
if self.animation.trading_index > #self.animation.trading_order then self.animation.trading_index = 0 end
local trading_target = self.animation.trading_order[self.animation.trading_index] and self.animation.trading_order[self.animation.trading_index] or 11
--Update atlas if needed
if (AuraTradingCards[trading_target].atlas or (Malverk and "alt_tex_" or "").."aura_j_trading") ~= self.config.center.atlas then
self.config.center.atlas = AuraTradingCards[trading_target].atlas or (Malverk and "alt_tex_" or "").."aura_j_trading"
self:set_sprites(self.config.center)
end
--Determine if EX or regular version is obtained
if AuraTradingCards[trading_target].EX and (pseudorandom("aura_trading_EX") < 1/10) then --10% chance for EX version only if EX version exists
trading_target = AuraTradingCards[trading_target].EX.pos
self.animation.EX = true
else
trading_target = AuraTradingCards[trading_target].pos and AuraTradingCards[trading_target].pos or trading_target
self.animation.EX = false
end
self.animation.target = trading_target - 1
self:juice_up(0.3, 0.3) --Atract attention to the change
delay(0.075*G.SPEEDFACTOR)
--Flip Trading Card back
self:flip()
play_sound('tarot2', 1, 0.6)
return true
end)
}))
end
--Update Loyalty Card animation according to remaining hands
if self.config.center_key == "j_loyalty_card" then
if self.animation then
if (5 - self.ability.loyalty_remaining) ~= self.animation.target then
Aura.add_individual(self)
self.animation = { target = 5 - (self.ability.loyalty_remaining or 0) }
self:juice_up(0.2,0.2)
play_sound("gold_seal") --This sounds can be interpreted as a hole being punched in the card
end
else
Aura.add_individual(self)
self.animation = { target = 5 - (self.ability.loyalty_remaining or 0) }
end
end
--Update Ice Cream animation according to remaining chips
if self.ability.name == "Ice Cream" and context.cardarea == G.jokers and context.after and not context.blueprint then
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = { target = math.floor((100 - self.ability.extra.chips) / 5) } --Divide frames for each 20 chips
return true
end)
}))
end
--Update Rocket animation according to dollars gained
if self.ability.name == "Rocket" and context.end_of_round and G.GAME.blind.boss and not context.blueprint then
Aura.add_individual(self)
self.animation = { fps = 10*self.ability.extra.dollars, extra = { target = 4 - math.min(4, math.floor(self.ability.extra.dollars / self.ability.extra.increase)) } } --Divide frames among the first 4 increments
end
--Update Popcorn animation according to remaining mult
if self.ability.name == "Popcorn" and context.end_of_round and not context.blueprint then
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = { target = 5 - self.ability.mult/4 } --Divide frames for each 4 mult
return true
end)
}))
end
--Update Seltzer animation according to remaining hands
if self.ability.name == "Seltzer" and context.cardarea == G.jokers and context.after and not context.blueprint then
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = { target = AnimatedJokers.j_selzer.frames-1 - math.floor(((self.ability.extra*(AnimatedJokers.j_selzer.frames-1)/10)) + 0.5 ) } --Automaticly divide frames (except first one) between al stages
return true
end)
}))
end
--Update Invisible Joker animation according to remaining rounds
if self.ability.name == "Invisible Joker" and context.end_of_round and not context.blueprint then
Aura.add_individual(self)
self.animation = { target = math.min( 10, math.floor((self.ability.invis_rounds * (AnimatedJokers.j_invisible.frames-1) / self.ability.extra) + 0.5)) } --Automaticly divide frames between al stages
end
--Detect when Space Joker activates to trigger animation
if self.ability.name == "Space Joker" and context.cardarea == G.jokers and context.before and not self.debuff then
--Trigger Oops All 6s animation
Aura.Trigger_oops_all_6s()
if not context.blueprint and ret and ret.level_up then -- ret.level_up means it is leveling up a hand
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = { target = 0, escape_target = true }
return true
end)
}))
end
end
--Detecting when Burglar activates to trigger animation
if self.ability.name == "Burglar" and not (context.blueprint_card or self.getting_sliced) and context.setting_blind and not self.debuff then
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = { target = 0, escape_target = true }
return true
end)
}))
end
--Detecting when Blackboard activates to trigger animation
if self.ability.name == "Blackboard" and ret and not context.blueprint then --ret carryng info means it is giving times mult
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = { target = 0, escape_target = true }
return true
end)
}))
end
--Detecting when Superposition activates to trigger animation
if self.ability.name == "Superposition" and ret and not context.blueprint then --ret carrying info means it is creating a tarot card
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
-- Toggle between frames 0 and 10
if self.config.center.animpos.x < 10 then
self.animation = {target = 10}
else
self.animation = {target = 0}
end
return true
end)
}))
end
--Detect when Lucky Cat upgrades to trigger animation
if self.ability.name == "Lucky Cat" and ret and ret.extra and not context.blueprint then
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = { target = 0, remaining_triggers = (self.animation and self.animation.remaining_triggers or 0) + 1, fps = 10*(G.SPEEDFACTOR/G.SETTINGS.GAMESPEED) } --Adapt fps to SpeedFactor but not to Game Speed
return true
end)
}))
end
--Detecting when Seeing Double activates to trigger animation
if self.ability.name == "Seeing Double" and ret and not context.blueprint then --ret carrying info means it is giving times mult
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
-- Toggle between idle frame 0 and 4
if self.config.center.animpos_extra.y == 0 then
self.animation = { extra = { target = 4 } }
else
self.animation = { extra = { target = 0 } }
end
return true
end)
}))
end
--Detecting when Hit the Road upgrades to trigger animation. The animation will last longer than the discards
if self.ability.name == "Hit the Road" and context.discard and not context.other_card.debuff and context.other_card:get_id() == 11 and not self.debuff and not context.blueprint then
Aura.add_individual(self)
self.animation = { target = 0, remaining_triggers = (self.animation and self.animation.remaining_triggers or 0) + 1 }
end
--Detect various jokers with probabilities that trigger Oops All 6s animation
if (self.ability.name == "8 Ball" and context.individual and context.cardarea == G.play and context.other_card and context.other_card:get_id() == 8) or
(self.ability.name == "Business Card" and context.individual and context.cardarea == G.play and context.other_card and context.other_card:is_face()) or
(self.ability.name == "Reserved Parking" and context.individual and context.cardarea == G.hand and context.other_card and context.other_card:is_face()) or
(self.ability.name == "Cavendish" and context.end_of_round and context.main_eval and not context.blueprint) or
(self.ability.name == "Hallucination" and context.open_booster) or
(self.ability.name == "Bloodstone" and context.individual and context.cardarea == G.play and context.other_card and context.other_card:is_suit("Hearts")) then
Aura.Trigger_oops_all_6s()
end
return ret
end