-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathelementcatlatro.lua
More file actions
585 lines (558 loc) · 15.7 KB
/
elementcatlatro.lua
File metadata and controls
585 lines (558 loc) · 15.7 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
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
577
578
579
580
581
582
583
584
585
-- so uhhh yeah
-- this is cattos!
local mod = SMODS.current_mod
local config = mod.config
--anticheat? okay
local legitimate = topuplib.debug and {titin = true, titin_recipe = {}} or nil
elementcattos = {
loc_txt = function(d)
d.text = d.text and topuplib.asub(d.text) or nil
local xline = {}
--TODO: localize these currently english-only strings
if d.anum then xline[1] = "Atomic number: " .. tostring(d.anum) end
if d.sym then xline[#xline + 1] = "Symbol: " .. d.sym end
if d.compound then
xline[#xline + 1] = "Formula: " .. (elementcattos.compounds[d.compound] and elementcattos.formatFormula(elementcattos.compounds[d.compound][1]) or ("INVALID ("..tostring(d.compound)..")"))
--todo: why does this crash?
--d.unlock = d.unlock or localize("ecattos_unlock_compound")
end
if d.extra then
if type(d.extra) == "table" then
for k,v in ipairs(d.extra) do
xline[#xline + 1] = v
end
else
xline[#xline + 1] = d.extra
end
end
if #xline ~= 0 then
d.text = d.text or {}
d.text[#d.text + 1] = "{C:inactive}" .. table.concat(xline, ", ")
end
return {
name = d.name,
text = d.text,
unlock = d.unlock
}
end,
loc_txt_planet = function(d)
return {name = d.name}
end,
doExplosion = function(src, joker_fract, joker_add, deck_fract, deck_add, shake_int)
local debuff_jokers = G.jokers and ((G.jokers.config.card_limit * (joker_fract or 0.3)) + (joker_add or 2))
local debuff_cards = G.playing_cards and ((#G.playing_cards * (deck_fract or 0.05)) + (deck_add or 2))
local area = src and src.area
local validate_tb = {}
G.ROOM.jiggle = G.ROOM.jiggle + ((300 - (G.SETTINGS.screenshake * 1.5)) * (shake_int or 1))
SMODS.calculate_context({ecattos_explosion_validate = true, src = src, cardarea = area}, validate_tb)
print("Validate table")
--todo: why is this empty
print(validate_tb)
SMODS.calculate_context({ecattos_explosion = true, src = src, cardarea = area})
--todo: debuffings
end,
loadGraphic = function(path)
return love.graphics.newImage(NFS.read('data', mod.path .. "assets/gfx/"..path..".png"), nil)
end,
enums = {
"S", "F", "D", "P",
S = 1, F = 2, D = 3, P = 4
},
--Radioactive
isRadioactive = function(card)
return elementcattos.radioactive[card.config.center_key]
end,
fromyears = function(n) return n * 315570000 end,
fromminutes = function(n) return n * 60 end,
fromhours = function(n) return n * 3600 end,
fromdays = function(n) return n * 86400 end,
halflife = function(n) return math.max(math.ceil((math.log(n) * 0.999) + (n * 0.001)) + 1, 0) end,
--Cards
defaultJokerCalculate = function(self, card, context)
if context.joker_main and card.ability.extra then
return {
mult = card.ability.extra.mult,
chips = card.ability.extra.chips,
Xmult = card.ability.extra.xmult,
Xchips = card.ability.extra.xchips
}
end
end,
simpleLocVars = function(properties)
local prop_vars = ""
for k,v in ipairs(properties) do
prop_vars = prop_vars .. "c.ability.extra." .. v .. ","
end
return assert(loadstring([[
return function(a,b,c) if not c.ability.extra then return end return {vars = {]]..prop_vars..[[}} end
]]), "simpleLocTxt failed")()
end,
atomicnumber = {},
tools = {},
cardFromMod = function(card)
return card.config.center and card.config.center.original_mod and card.config.center.original_mod.id == SMODS.Mods.ElementCatlatro.id
end,
modsupported = { -- Keys of jokers to consider "part of Element Catlatro" for Element Cattos deck
j_ecattos_element1 = true
},
othercattos = { -- Keys of jokers that are cattos
},
getNeutrons = function(card)
if not card.config.center.ecattos_conf then
return nil
end
return (card.ability.extra and card.ability.extra.neutrons) or card.config.center.ecattos_conf.neutrons
end,
pronoun = function(n)
if not CardPronouns or not n then return end
if CardPronouns.badge_types[n] then return n end
return "ecatto_" .. n
end,
fallbacks = {
"j_ecattos_element1", "j_ecattos_element2", "j_ecattos_element6", "j_ecattos_element8"
},
countJokers = function(key, isotope)
--TODO: implement isotope lol
-- (to, if specified, check if the joker is the right isotope)
if not G.jokers then return 0 end
local result = 0
for k,v in pairs(G.jokers.cards) do
if key == v.config.center_key then
result = result + 1
end
end
return result
end,
--Destroys a card. If eternal, card becomes Garbage instead.
basicDestroy = function(card)
(SMODS.is_eternal(card) and elementcattos.becomeGarbage or Card.start_dissolve)(card)
end,
--Compounds
compounds = {},
formatFormula = function(formula, method)
local result = ""
for k,v in ipairs(formula) do
if type(v) == "table" then
if #v == 1 or v[2] == 1 then
local c = elementcattos.compounds[v[1]]
if not c then error("Compound subpart "..v[1].." does not exist") end
result = result .. elementcattos.formatFormula(c[1], method)
elseif #v == 2 then
local subnum = ""
local ns = tostring(v[2])
result = result .. v[1] .. (method and ("("..ns..")") or topuplib.formatText({{ns, "small"}, {"", "inactive"}}))
elseif #v == 3 then
local subnum = ""
local ns = tostring(v[2])
result = result .. v[1] .. "-" .. v[2] .. (method and ("("..ns..")") or topuplib.formatText({{ns, "small"}, {"", "inactive"}}))
end
else
if type(v) == "string" and string.sub(v, 1, 1) == "_" then
v = string.sub(v, 2)
end
result = result .. v
end
end
return result
end,
hasFormula = function(formula, source)
local inputs = {}
local source = source or G.jokers.cards
formula = topuplib.tableShallowCopy(formula)
local count, element, iscompound, ntr
for k,v in pairs(formula) do
iscompound = false
ntr = nil
if type(v) == "table" then
if #v == 1 then
count = 1
element = v[1]
iscompound = true
else
count, element, ntr = v[2], v[1], v[3]
end
else
local firstlet = string.sub(v, 1, 1)
if firstlet == "_" then
count = 0
else
count, element = 1, v
end
end
if count ~= 0 then
for k,v in ipairs(source) do
if count ~= 0 and v.config.center.element_symbol == element and not inputs[k] and ((not ntr) or ntr == elementcattos.getNeutrons(v)) then
inputs[k] = v
count = count - 1
end
end
if count ~= 0 then
if iscompound then
for _,v2 in ipairs(elementcattos.compounds[element][1]) do
table.insert(formula, v2)
end
else
return
end
end
end
end
return inputs
end
}
SMODS.current_mod.custom_collection_tabs = function()
return { UIBox_button {
button = 'your_collection_ecattos_compounds', label = {localize("ecattos_compounds_recipes")}, minw = 5, id = 'your_collection_ecattos_compounds'
}}
end
--todo: element decaying and isotopes are gonna be a thing to figure out
--[[elementcattos.radioactive = {
ecatto_element82_214 = { --lead 214
hands = elementcattos.halflife(elementcattos.fromminutes(27.06)),
result = "ecatto_element83_214"
},
ecatto_element84 = { --polonium
hands = elementcattos.halflife(elementcattos.fromdays(138.38)),
result = "ecatto_element82_214"
},
ecatto_element86 = { --radium
hands = elementcattos.halflife(elementcattos.fromdays(3.8)),
result = "ecatto_element84"
},
ecatto_element88 = { --radium
hands = elementcattos.halflife(elementcattos.fromdays(11.43)),
result = "ecatto_element86"
},
ecatto_element118 = { --oganesson
hands = 0
},
ecatto_element118 = { --oganesson
hands = 0
},
ecatto_element118 = { --oganesson
hands = 0
},
ecatto_element118 = { --oganesson
hands = 0
},
ecatto_element118 = { --oganesson
hands = 0
},
ecatto_element118 = { --oganesson
hands = 0
},
ecatto_element118 = { --oganesson
hands = 0
},
ecatto_element118 = { --oganesson
explode = true,
hands = 0
}
}]]
elementcattos.badges = {
--Empty (INTENTIONAL)
}
mod.config_tab = function()
return {n = G.UIT.ROOT, config = {r = 0.1, minw = 8, minh = 6, align = "tl", padding = 0.2, colour = G.C.BLACK}, nodes = {
{n = G.UIT.C, config = {minw=1, minh=1, align = "tl", colour = G.C.CLEAR, padding = 0.15}, nodes = {
create_toggle({
label = "Disable Nonfunctional Cattos",
ref_table = config,
ref_value = 'disable_nonfunctional_cattos',
}),
create_toggle({
label = "Classic PlanetCattos Sprites (Requires restart)",
ref_table = config,
ref_value = 'old_planet_sprites',
})
}}
}}
end
local rq = {
"rarities",
"radioactive",
"jokers/elements",
"compoundcreator",
"consumables",
"jokers/compounds",
"compounds_extra_recipes",
"compounds_collection",
"levels/decks",
"levels/challenges",
"boosters",
"levels/sleeves",
"jokers/special",
"suits",
"modifiers/sticker_stabilized",
"modifiers/sticker_placeholder",
"modifiers/edition_pcb",
"drawstep_radioglow",
"patches",
"worldend",
"isotopes",
"achievements",
"main_collection",
BLINDSIDE and "blindside/bs_main" or nil
}
--Pronouns
if CardPronouns then
local in_pool = topuplib.returnFalse
CardPronouns.Pronoun {
colour = HEX("F0FF9F"),
text_colour = G.C.BLACK,
pronoun_table = { "Hse", "Ehr" },
in_pool = in_pool,
key = "ecatto_hse_ehr"
}
CardPronouns.Pronoun {
colour = HEX("8823FF"),
text_colour = G.C.WHITE,
pronoun_table = { "They", "It", "Xe" },
in_pool = in_pool,
key = "ecatto_they_it_xe"
}
CardPronouns.Pronoun {
colour = G.C.BLACK,
text_colour = G.C.WHITE,
pronoun_table = { "Unknown" },
in_pool = in_pool,
key = "ecatto_unknown"
}
CardPronouns.Pronoun {
colour = CardPronouns.badge_types.they_them.colour,
text_colour = G.C.WHITE,
pronoun_table = { "They", "Any" },
in_pool = in_pool,
key = "ecatto_they_any"
}
CardPronouns.Pronoun {
colour = HEX("C492FE"),
text_colour = G.C.WHITE,
pronoun_table = { "She", "He" },
in_pool = in_pool,
key = "ecatto_she_he"
}
CardPronouns.Pronoun {
colour = HEX("89A0FE"),
text_colour = G.C.WHITE,
pronoun_table = { "He", "She" },
in_pool = in_pool,
key = "ecatto_he_she"
}
CardPronouns.Pronoun {
colour = CardPronouns.badge_types.he_him.colour,
text_colour = G.C.WHITE,
pronoun_table = { "He", "Any" },
in_pool = in_pool,
key = "ecatto_he_any"
}
CardPronouns.Pronoun {
colour = HEX("9137E6"),
text_colour = G.C.WHITE,
pronoun_table = { "Xe", "Xem" },
in_pool = in_pool,
key = "ecatto_xe_xem"
}
CardPronouns.Pronoun {
colour = G.C.GREEN,
text_colour = G.C.WHITE,
pronoun_table = { "Tree", "Trim" },
in_pool = in_pool,
key = "ecatto_tree_trim"
}
CardPronouns.Pronoun {
colour = G.C.RED,
text_colour = G.C.WHITE,
pronoun_table = { "*Eagle noise*", "Any" },
in_pool = in_pool,
key = "ecatto_eaglenoise_any"
}
CardPronouns.Pronoun {
colour = G.C.DARK_EDITION,
text_colour = G.C.WHITE,
pronoun_table = { "None", "All" },
in_pool = in_pool,
key = "ecatto_na"
}
elementcattos.usa_flag = love.graphics.newImage(NFS.read('data', SMODS.current_mod.path .. "assets/gfx/usa.png"), nil)
end
if Yahimod then
local explode_hook = explodeCard
function explodeCard(card, ...)
elementcattos.doExplosion(src, 0, 0, 0, 0, 0)
return explode_hook(card, ...)
end
end
topuplib.addFontOption("Century Schoolbook", "lua/fonts/centuryschoolbook")
topuplib.addFontOption("Chemical Formula", "lua/fonts/chemicalformula")
topuplib.addDebugCollectionItem("c_ecattos_stabilizer")
local meme = topuplib.createFallbackPoolItem
topuplib.createFallbackPoolItem = function(type, pool)
if type == "Joker" and G.GAME.starting_params.ecattos_deck then
return pseudorandom_element(elementcattos.fallbacks, "ecattos_fallback_pool")
end
return meme(type, pool)
end
local oldfunc = Game.main_menu
Game.main_menu = function(change_context)
local ret = oldfunc(change_context)
if BLINDSIDE then
G.E_MANAGER:add_event(Event({
trigger = "after",
delay = 0,
blockable = false,
blocking = false,
func = function()
local planet = Card(
G.blindside_title_top.T.x,
G.blindside_title_top.T.y,
G.CARD_W,
G.CARD_H,
G.P_CARDS.empty,
G.P_CENTERS["j_ecattos_planet_earth"],
{ bypass_discovery_center = true }
)
G.blindside_title_top:emplace(planet)
planet.no_ui = true
planet:start_materialize()
G.blindside_title_top.T.w = G.blindside_title_top.T.w * 1.7675
G.blindside_title_top.T.x = G.blindside_title_top.T.x - 0.8
local iron = Card(
G.title_top.T.x,
G.title_top.T.y,
G.CARD_W,
G.CARD_H,
G.P_CARDS.empty,
G.P_CENTERS["j_ecattos_element26"],
{ bypass_discovery_center = true }
)
G.title_top:emplace(iron)
iron.no_ui = true
iron:start_materialize()
iron.T.w = iron.T.w * 1.1 * 1.2
iron.T.h = iron.T.h * 1.1 * 1.2
G.title_top.T.w = G.title_top.T.w * 1.7675
G.title_top.T.x = G.title_top.T.x - 0.8
return true
end,
}))
return ret
end
elementcattos.title_cardarea = CardArea(
0, 0,
G.CARD_W * 7,G.CARD_H,
{card_limit = 4, type = 'title', lr_padding = 1})
elementcattos.title_cardarea:set_alignment({
major = G.title_top,
bond = "Strong",
type = "cm",
offset = {x=0, y=3.5}
})
local candidates = {}
while #candidates < 118 do
candidates[#candidates+1] = #candidates+1
end
-- adds a Cryptid spectral to the main menu
while #elementcattos.title_cardarea.cards < 5 do
local n = table.remove(candidates, math.random(#candidates))
local newcard = Card(
G.title_top.T.x,
G.title_top.T.y,
G.CARD_W,
G.CARD_H,
G.P_CARDS.empty,
G.P_CENTERS["j_ecattos_element"..n],
{ bypass_discovery_center = true }
)
-- recenter the title
elementcattos.title_cardarea:emplace(newcard)
-- make the card look the same way as the title screen Ace of Spades
--newcard.T.w = newcard.T.w * 1.1 * 1.2
--newcard.T.h = newcard.T.h * 1.1 * 1.2
newcard.no_ui = true
newcard.states.visible = false
local delay = 3 - (#elementcattos.title_cardarea.cards * 0.3)
G.E_MANAGER:add_event(Event({
trigger = "after",
delay = delay,
blockable = false,
blocking = false,
func = function()
newcard.states.visible = true
newcard:start_materialize({ G.C.WHITE, G.C.WHITE }, false, 2)
return true
end,
}))
end
elementcattos.title_cardarea:sort('order')
elementcattos.title_cardarea:set_ranks()
elementcattos.title_cardarea:align_cards()
elementcattos.title_cardarea:hard_set_cards()
elementcattos.title_cardarea:hard_set_VT()
return ret
end
SMODS.Sound {
--This song is a WIP
key = "music_ecattos",
path = "balatro-elementcatto.ogg",
pitch = 1,
select_music_track = function(self)
return G.OVERLAY_MENU and topuplib.music == "ecattos"
end
}
--[[SMODS.Sound {
--This song is a WIP
key = "music_masterwork",
path = "balatro-masterworkcatto.ogg",
pitch = 1,
select_music_track = function(self)
if not G.jokers then return end
for k,v in pairs(G.jokers.cards) do
if v.config.center.rarity == "ecattos_masterwork" then
return 101
end
end
end
}]]
SMODS.Sound {
key = "explode",
path = "explode.ogg"
}
SMODS.Atlas({
key = "modifiers",
path = "modifiers.png",
px = 71,
py = 95
})
for i, v in ipairs(rq) do
if v then
local a = assert(SMODS.load_file("lua/"..v..".lua"))()
if type(a) == "function" then
a({
legitimate = legitimate
})
end
end
end
elementcattos.booster_pools = {
[1] = {},
[2] = {},
[3] = {},
[4] = {},
tool = {},
["ecattos_handmade"] = {}, --don't think is needed
["ecattos_safari"] = {}, --but just in case
["ecattos_masterwork"] = {},
["ecattos_strange"] = {},
}
for k,v in pairs(SMODS.Centers) do
if v.original_mod and v.original_mod.id == SMODS.current_mod.id then
if (not v.not_in_booster and v.rarity ~= "ecattos_handmade") then
if v.set == "Joker" then
table.insert(elementcattos.booster_pools[v.rarity], v.key)
elseif v.set == "Tarot" then
table.insert(elementcattos.booster_pools.tool, v.key)
end
end
end
end