-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAura.lua
576 lines (557 loc) · 20.1 KB
/
Aura.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
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
--- STEAMODDED HEADER
--- MOD_NAME: Aura
--- MOD_ID: Aura
--- MOD_AUTHOR: [MathIsFun_, ChromaPIE, Bard, Grassy311, RattlingSnow353, Solace, RadicaAprils, chloe_cromslor]
--- MOD_DESCRIPTION: Adds animations to Jokers.
--- BADGE_COLOUR: 3469ab
--- VERSION: 0.023
AnimatedJokers = {
j_joker = { frames_per_row = 11, frames = 22 },
j_greedy_joker = { frames = 12 },
j_lusty_joker = { frames_per_row = 5, frames = 20 },
j_wrathful_joker = { frames_per_row = 1, frames = 18 },
j_gluttenous_joker = { frames = 12 },
j_jolly = {},
j_zany = {},
j_mad = {},
j_crazy = {},
j_droll = {},
j_sly = {},
j_wily = {},
j_clever = {},
j_devious = {},
j_crafty = {},
j_half = {},
j_stencil = {},
j_four_fingers = {},
j_mime = {},
j_credit_card = {},
j_ceremonial = {},
j_banner = {},
j_mystic_summit = {},
j_marble = {},
j_loyalty_cfard = {},
j_8_ball = {},
j_misprint = {},
j_dusk = { frames_per_row = 13, frames = 78, fps = 5 },
j_raised_fist = { frames_per_row = 4, frames = 14 },
j_chaos = {},
j_fibonacci = {},
j_steel_joker = {},
j_scary_face = {},
j_abstract = {},
j_delayed_grat = {},
j_hack = { frames_per_row = 8, frames = 64 },
j_pareidolia = {},
j_gros_michel = {},
j_even_steven = {},
j_odd_todd = {},
j_scholar = { frames_per_row = 9, frames = 45 },
j_business = {},
j_supernova = {},
j_ride_the_bus = {},
j_space = {},
j_egg = {},
j_burglar = {},
j_blackboard = { frames_per_row = 9, frames = 59, individual = true },
j_runner = {},
j_ice_cream = {},
j_dna = {},
j_splash = {},
j_blue_joker = {},
j_sixth_sense = { frames = 13, extra = { frames = 20 } }, --todo: card destroy animation
j_constellation = { frames_per_row = 6, frames = 60},
j_hiker = {},
j_faceless = { frames_per_row = 4, frames = 24 },
j_green_joker = {},
j_superposition = {},
j_todo_list = { frames_per_row = 12, frames = 96}, --todo: animate on trigger
j_cavendish = {},
j_card_sharp = {},
j_red_card = { frames_per_row = 19, frames = 349 },
j_madness = {},
j_square = { frames_per_row = 11, frames = 22 },
j_seance = {},
j_riff_raff = { frames_per_row = 14, frames = 490 },
j_vampire = {},
j_shortcut = {},
j_hologram = {},
j_vagabond = { frames = 30, fps = 5 },
j_baron = {},
j_cloud_9 = {},
j_rocket = {},
j_obelisk = {},
j_midas_mask = {},
j_luchador = {},
j_photograph = { frames = 48 },
j_gift = {},
j_turtle_bean = {},
j_erosion = {},
j_reserved_parking = {},
j_mail = {},
j_to_the_moon = { frames_per_row = 10, frames = 50},
j_hallucination = {},
j_fortune_teller = {},
j_juggler = {},
j_drunkard = {},
j_stone = {},
j_golden = {},
j_lucky_cat = {},
j_baseball = {},
j_bull = {},
j_diet_cola = {},
j_trading = {},
j_flash = { frames_per_row = 13, frames = 26, individual = true, immediate = true },
j_popcorn = {},
j_trousers = { frames = 48 },
j_ancient = {},
j_ramen = {},
j_walkie_talkie = {},
j_selzer = {},
j_castle = { frames_per_row = 9, frames = 69, start_frame = 0, extra = { frames_per_row = 5, frames = 5, fps = 5, start_frame = 0 } },
j_smiley = {},
j_campfire = {},
j_ticket = {},
j_mr_bones = {},
j_acrobat = {},
j_sock_and_buskin = {},
j_swashbuckler = {},
j_troubadour = {},
j_certificate = {},
j_smeared = {},
j_throwback = {},
j_hanging_chad = {},
j_rough_gem = {},
j_bloodstone = {},
j_arrowhead = {},
j_onyx_agate = {},
j_glass = {},
j_ring_master = {},
j_flower_pot = { frames = 24 },
j_blueprint = { frames_per_row = 8, frames = 44, individual = true },
j_wee = { frames_per_row = 11, frames = 22 },
j_merry_andy = {},
j_oops = {},
j_idol = {},
j_seeing_double = {},
j_matador = {},
j_hit_the_road = {},
j_duo = {},
j_trio = {},
j_family = {},
j_order = {},
j_tribe = {},
j_stuntman = {},
j_invisible = {},
j_brainstorm = { frames_per_row = 8, frames = 39, individual = true },
j_satellite = {},
j_shoot_the_moon = {},
j_drivers_license = {},
j_cartomancer = {},
j_astronomer = {frames = 29},
j_burnt = {},
j_bootstraps = {},
j_caino = {},
j_triboulet = {},
j_yorick = {},
j_chicot = {},
j_perkeo = {}
}
AnimatedIndividuals = {}
Aura = {}
Aura.LayeredCards = {}
function Aura.add_individual(card)
if not card.animated then
AnimatedIndividuals[#AnimatedIndividuals+1] = card
card.animated = true
local center_copy = {}
for k, v in pairs(card.config.center) do
center_copy[k] = v
end
center_copy.pos = {x = card.config.center.pos.x, y = card.config.center.pos.y}
card.config.center = center_copy
card:set_sprites(card.config.center)
end
end
if SMODS.Atlas then
--Register all Jokers/Sprites
for i = 1, 150 do
local k = G.P_CENTER_POOLS.Joker[i].key
local v = AnimatedJokers[k]
if v and v.frames then
--sprite
SMODS.Atlas {
key = k,
path = k .. ".png",
px = v.px or 71,
py = v.py or 95
}
if v.extra then
SMODS.Atlas {
key = k.."_extra",
path = k .. "_extra.png",
px = v.px or 71,
py = v.py or 95
}
end
--joker override
SMODS[v.set or "Joker"]:take_ownership(k, {
atlas = k,
pos = { x = 0, y = 0, extra = v.extra and {x = 0, y = 0, atlas = "aura_"..k.."_extra"} },
})
else
SMODS[v and v.set or "Joker"]:take_ownership(k,{},true)
end
end
else
local init = SMODS["INIT"]
function init.Aura()
--0.9.8 compat by @ChromaPIE
--Register all Jokers/Sprites
for i = 1, 150 do
local k = G.P_CENTER_POOLS.Joker[i].key
local v = AnimatedJokers[k]
if v then
--joker override
SMODS[v.set or "Joker"]:take_ownership(k):register()
--sprite
--todo: add extra layer, waiting unitl 0.9.8 compat is fixed
if v.frames then
SMODS.Sprite:new(
k,
SMODS.findModByID('Aura').path,
k .. ".png",
v.px or 71,
v.py or 95,
"asset_atli"
):register()
SMODS.Jokers[k].atlas = k
SMODS.Jokers[k].pos = { x = 0, y = 0 }
if v.extra then
SMODS.Sprite:new(
k .. "_extra",
SMODS.findModByID('Aura').path,
k .. "_extra.png",
v.px or 71,
v.py or 95,
"asset_atli"
):register()
SMODS.Jokers[k].pos.extra = { x = 0, y = 0, atlas = k .. "_extra"}
end
end end
end
end
end
--Update animated sprites
local upd = Game.update
function Aura.update_frame(dt, k, obj, jkr)
if AnimatedJokers[k] and obj and (AnimatedJokers[k].frames or AnimatedJokers[k].individual) then
local next_frame = false
local next_frame_extra = false
local anim = AnimatedJokers[k]
if anim.individual then
if jkr then
if not jkr.animation then jkr.animation = {} end
if not jkr.animation.t then jkr.animation.t = 0 end
jkr.animation.t = jkr.animation.t + dt
if jkr.animation.t > 1/(jkr.animation.fps or 10) then
jkr.animation.t = jkr.animation.t - 1/(jkr.animation.fps or 10)
next_frame = true
end
if jkr.animation.extra then
if not jkr.animation.extra.t then jkr.animation.extra.t = 0 end
jkr.animation.extra.t = jkr.animation.extra.t + dt
if jkr.animation.extra.t > 1/(jkr.animation.extra.fps or 10) then
jkr.animation.extra.t = jkr.animation.extra.t - 1/(jkr.animation.extra.fps or 10)
next_frame_extra = true
end
end
end
else
if not anim.t then anim.t = 0 end
anim.t = anim.t + dt
if anim.t > 1/(anim.fps or 10) then
anim.t = anim.t - 1/(anim.fps or 10)
next_frame = true
end
if anim.extra then
if not anim.extra.t then anim.extra.t = 0 end
anim.extra.t = anim.extra.t + dt
if anim.extra.t > 1/(anim.extra.fps or 10) then
anim.extra.t = anim.extra.t - 1/(anim.extra.fps or 10)
next_frame_extra = true
end
end
end
if next_frame then
local loc = obj.pos.y*(anim.frames_per_row or anim.frames)+obj.pos.x
if (not anim.individual) or (jkr and jkr.animation.target and loc ~= jkr.animation.target) then
loc = loc + 1
if anim.immediate and jkr and jkr.animation.target then
loc = jkr.animation.target
end
end
if loc >= anim.frames then loc = anim.start_frame or 0 end
obj.pos.x = loc%(anim.frames_per_row or anim.frames)
obj.pos.y = math.floor(loc/(anim.frames_per_row or anim.frames))
end
if next_frame_extra then
local loc = obj.pos.extra.y*(anim.extra.frames_per_row or anim.extra.frames)+obj.pos.extra.x
if (not anim.individual) or (jkr and jkr.animation.extra and jkr.animation.extra.target and loc ~= jkr.animation.extra.target) then
loc = loc + 1
if anim.extra.immediate and jkr and jkr.animation.extra and jkr.animation.extra.target then
loc = jkr.animation.extra.target
end
end
if loc >= anim.extra.frames then loc = anim.extra.start_frame or 0 end
obj.pos.extra.x = loc%(anim.extra.frames_per_row or anim.extra.frames)
obj.pos.extra.y = math.floor(loc/(anim.extra.frames_per_row or anim.extra.frames))
end
end
end
function Game:update(dt)
upd(self,dt)
for k, v in pairs(AnimatedJokers) do
Aura.update_frame(dt, k, G.P_CENTERS[k])
end
for _, v in pairs(AnimatedIndividuals) do
Aura.update_frame(dt, v.config.center_key, v.config.center, v)
end
end
--On Click/Release Animations
local ccl = Node.set_offset
function Node:set_offset(x,y)
ccl(self,x,y)
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
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 = 16}
end
end
local crl = Node.stop_drag
function Node:stop_drag()
crl(self)
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
--On Creation Effects
local ci = Card.init
function Card:init(x,y,w,h,card,center,params)
ci(self,x,y,w,h,card,center,params)
if self.config.center_key == 'j_flash' then
if not self.animation then
Aura.add_individual(self)
local anim_order = {}
for i = 1, 26 do
anim_order[i] = i-1
end
pseudoshuffle(anim_order, pseudoseed("aura_flash"))
--force J to be first
for i = 1, 26 do
if anim_order[i] == 9 then
anim_order[1], anim_order[i] = anim_order[i], anim_order[1]
end
end
self.animation = {target = anim_order[1], config = {index = 1, order = anim_order}}
--instantly update animation
Aura.update_frame(0, self.config.center_key, self.config.center, self)
end
end
end
--Sprite setting for multiple layers
local css = Card.set_sprites
function Card:set_sprites(c, f)
css(self, c,f)
if self.config.center and self.config.center.pos and self.config.center.pos.extra and self.config.center.pos.extra.atlas then
if not self.children.front then
self.children.front = Sprite(self.T.x, self.T.y, self.T.w, self.T.h, G.ASSET_ATLAS[self.config.center.pos.extra.atlas], self.config.center.pos)
self.children.front.states.hover = self.states.hover
self.children.front.states.click = self.states.click
self.children.front.states.drag = self.states.drag
self.children.front.states.collide.can = false
self.children.front:set_role({major = self, role_type = 'Glued', draw_major = self})
else
self.children.front:set_sprite_pos(self.config.center.pos.extra)
end
end
end
local cd = Card.draw
function Card:draw(layer)
if self.config and self.config.center and self.config.center.pos and self.config.center.pos.extra and self.config.center.pos.extra.atlas then self:set_sprites() end
cd(self,layer)
end
--Castle
function Aura.castle_suit_num(suit)
if (suit == "Spades") then return 0 end
if (suit == "Hearts") then return 5 end
if (suit == "Clubs") then return 10 end
if (suit == "Diamonds") then return 15 end
if (suit == "Moons") then return 25 end
if (suit == "Stars") then return 30 end
return 20
end
local rcc = reset_castle_card
function reset_castle_card(dont_reset)
if not dont_reset then rcc() end
local new_suit = G.GAME.current_round.castle_card.suit or 'Spades'
local anim_offset = Aura.castle_suit_num(new_suit)
AnimatedJokers.j_castle.extra.frames = anim_offset+5
AnimatedJokers.j_castle.extra.start_frame = anim_offset
G.P_CENTERS["j_castle"].pos.extra.y = anim_offset/5
if (new_suit == "Moons" or new_suit == "Stars") then
if AnimatedJokers.j_castle.start_frame == 0 then
AnimatedJokers.j_castle.start_frame = 72
AnimatedJokers.j_castle.frames = 94
G.P_CENTERS["j_castle"].pos.y = 8
end
else
if AnimatedJokers.j_castle.start_frame == 72 then
AnimatedJokers.j_castle.start_frame = 0
AnimatedJokers.j_castle.frames = 69
G.P_CENTERS["j_castle"].pos.y = 0
end
end
end
local gsr = Game.start_run
function Game:start_run(args)
--don't mess up on save load
gsr(self,args)
reset_castle_card(true)
end
--On trigger effects
local cj = Card.calculate_joker
function Card:calculate_joker(context)
--Flash Card (pre-calculation)
if self.ability.name == "Flash Card" and context.reroll_shop and not context.blueprint then
G.E_MANAGER:add_event(Event({
func = (function()
self:flip()
play_sound('card1')
return true
end)
}))
end
local ret1, ret2 = cj(self, context)
--Blackboard
if self.ability.name == "Blackboard" and context.cardarea == G.jokers and context.joker_main then
local black_suits, all_cards = 0, 0
for k, v in ipairs(G.hand.cards) do
all_cards = all_cards + 1
if v:is_suit('Clubs', nil, true) or v:is_suit('Spades', nil, true) then
black_suits = black_suits + 1
end
end
if black_suits == all_cards then
--triggered
G.E_MANAGER:add_event(Event({
func = (function()
Aura.add_individual(self)
self.animation = {target = 0}
self.config.center.pos.x = 1 --start on second frame
return true
end)
}))
end
end
--Flash Card
if self.ability.name == "Flash Card" and context.reroll_shop and not context.blueprint then
G.E_MANAGER:add_event(Event({
func = (function()
self.animation.config.index = self.animation.config.index + 1
if self.animation.config.index > 26 then self.animation.config.index = 1 end
self.animation.target = self.animation.config.order[self.animation.config.index]
self:juice_up(0.3, 0.3)
return true
end)
}))
delay(0.075*G.SETTINGS.GAMESPEED)
G.E_MANAGER:add_event(Event({
func = (function()
self:flip()
play_sound('tarot2', 1, 0.6)
return true
end)
}))
end
return ret1, ret2
end
--There's a bug with this function in 0.9.8 that screws up the joker pool
--So we just override it to fix our problems
if SMODS.injectJokers then
function SMODS.injectJokers()
local minId = table_length(G.P_CENTER_POOLS['Joker']) + 1
local id = 0
local i = 0
local joker = nil
for k, slug in ipairs(SMODS.BUFFERS.Jokers) do
joker = SMODS.Jokers[slug]
if joker.order then
id = joker.order
else
i = i + 1
id = i + minId
end
local joker_obj = {
discovered = joker.discovered,
name = joker.name,
set = "Joker",
unlocked = joker.unlocked,
order = id,
key = joker.slug,
pos = joker.pos,
config = joker.config,
rarity = joker.rarity,
blueprint_compat = joker.blueprint_compat,
eternal_compat = joker.eternal_compat,
effect = joker.effect,
cost = joker.cost,
cost_mult = 1.0,
atlas = joker.atlas or nil,
mod_name = joker.mod_name,
badge_colour = joker.badge_colour,
soul_pos = joker.soul_pos,
-- * currently unsupported
no_pool_flag = joker.no_pool_flag,
yes_pool_flag = joker.yes_pool_flag,
unlock_condition = joker.unlock_condition,
enhancement_gate = joker.enhancement_gate,
start_alerted = joker.start_alerted
}
for _i, sprite in ipairs(SMODS.Sprites) do
if sprite.name == joker_obj.key then
joker_obj.atlas = sprite.name
end
end
-- Now we replace the others
G.P_CENTERS[slug] = joker_obj
if not joker.taken_ownership then
table.insert(G.P_CENTER_POOLS['Joker'], joker_obj)
table.insert(G.P_JOKER_RARITY_POOLS[joker_obj.rarity], joker_obj)
else
for kk, v in ipairs(G.P_CENTER_POOLS['Joker']) do
if v.key == slug then G.P_CENTER_POOLS['Joker'][kk] = joker_obj end
end
if joker_obj.rarity == joker.rarity_original then
for kk, v in ipairs(G.P_JOKER_RARITY_POOLS[joker_obj.rarity]) do
if v.key == slug then G.P_JOKER_RARITY_POOLS[joker_obj.rarity][kk] = joker_obj end
end
else
table.insert(G.P_JOKER_RARITY_POOLS[joker_obj.rarity], joker_obj)
local j
for kk, v in ipairs(G.P_JOKER_RARITY_POOLS[joker.rarity_original]) do
if v.key == slug then j = kk end
end
table.remove(G.P_JOKER_RARITY_POOLS[joker.rarity_original], j)
end
end
-- Setup Localize text
G.localization.descriptions["Joker"][slug] = joker.loc_txt
sendInfoMessage("Registered Joker " .. joker.name .. " with the slug " .. joker.slug .. " at ID " .. id .. ".")
end
end
end