balatro-mods/Cryptid/lovely/Voucher.toml

212 lines
6.5 KiB
TOML

[manifest]
version = "1.0.0"
dump_lua = true
priority = 0
# first we need to fix what on earth is going on with card.shop_voucher
# for some reason it's not saved/loaded so... that's what's gonna happen
# also adding another variable here that will be useful later
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = '''ability = self.ability,'''
position = "before"
payload = '''
shop_voucher = self.shop_voucher,
shop_cry_bonusvoucher = self.shop_cry_bonusvoucher,
'''
match_indent = true
# water is wet
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = '''self.ability = cardTable.ability'''
position = "before"
payload = '''
self.shop_voucher = cardTable.shop_voucher
self.shop_cry_bonusvoucher = cardTable.shop_cry_bonusvoucher
'''
match_indent = true
# get rid of this dumb hackfix in :redeem()
# also track vouchers redeemed
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = '''--G.GAME.current_round.voucher = nil'''
position = "after"
payload = '''
if self.shop_cry_bonusvoucher then G.GAME.cry_bonusvouchersused[self.shop_cry_bonusvoucher] = true end
'''
match_indent = true
# create the table
[[patches]]
[patches.pattern]
target = "game.lua"
pattern = '''used_packs = {},'''
position = "after"
payload = '''
cry_bonusvouchers = {},
cry_voucher_stickers = {eternal = false, perishable = false, rental = false, pinned = false, banana = false},
cry_voucher_edition = {},
'''
match_indent = true
# initialise the other helpful variables
# tarot/planet percrates appear here too because why not
# [[patches]]
# [patches.pattern]
# target = "game.lua"
# pattern = '''ecto_minus = 1,'''
# position = "after"
# payload = '''
# cry_bonusvouchercount = 0,
# cry_bonusvouchersused = {},
# cry_percrate = {tarot = 100, planet = 100},
# '''
# match_indent = true
# populate the table with keys
[[patches]]
[patches.pattern]
target = "functions/state_events.lua"
pattern = '''G.GAME.current_round.voucher = SMODS.get_next_vouchers()'''
position = "after"
payload = '''
G.GAME.current_round.cry_voucher_stickers = Cryptid.next_voucher_stickers()
G.GAME.current_round.cry_voucher_edition = cry_get_next_voucher_edition() or {}
G.GAME.current_round.cry_bonusvouchers = {}
G.GAME.cry_bonusvouchersused = {} -- i'm not sure why i'm putting these in two separate tables but it doesn't matter much
for i = 1, G.GAME.cry_bonusvouchercount do
G.GAME.current_round.cry_bonusvouchers[i] = SMODS.get_next_vouchers()
end
'''
match_indent = true
# fire is hot
[[patches]]
[patches.pattern]
target = "game.lua"
pattern = '''self.GAME.current_round.voucher = forced_voucher and {forced_voucher, spawn = {[forced_voucher] = true }} or SMODS.get_next_vouchers()'''
position = "after"
payload = '''
G.GAME.current_round.cry_voucher_stickers = Cryptid.next_voucher_stickers()
G.GAME.current_round.cry_voucher_edition = cry_get_next_voucher_edition() or {}
for i = 1, self.GAME.cry_bonusvouchercount do
self.GAME.current_round.cry_bonusvouchers[i] = get_next_voucher_key()
end
'''
match_indent = true
# add the vouchers to the shop. couldn't be more simple
# use a simple regex to snipe the correct position
[[patches]]
[patches.regex]
target = "game.lua"
pattern = '''card\:start_materialize\(\)\n\s+G\.shop_vouchers\:emplace\(card\)\n\s+end'''
position = "at"
payload = '''
for k, v in pairs(G.GAME.current_round.cry_voucher_stickers) do
card.ability[k] = v
card:set_cost()
end
if G.GAME.current_round.cry_voucher_edition then
card:set_edition(G.GAME.current_round.cry_voucher_edition, true, true)
end
card:start_materialize()
G.shop_vouchers:emplace(card)
end
for i = 1, #G.GAME.current_round.cry_bonusvouchers do
if not G.GAME.cry_bonusvouchersused[i] then
local card = Card(G.shop_vouchers.T.x + G.shop_vouchers.T.w/2,
G.shop_vouchers.T.y, G.CARD_W, G.CARD_H, G.P_CARDS.empty, G.P_CENTERS[G.GAME.current_round.cry_bonusvouchers[i]],{bypass_discovery_center = true, bypass_discovery_ui = true})
card.shop_cry_bonusvoucher = i
Cryptid.manipulate(card)
if G.GAME.events.ev_cry_choco2 then
card.misprint_cost_fac = (card.misprint_cost_fac or 1) * 2
card:set_cost()
end
if G.GAME.modifiers.cry_enable_flipped_in_shop and pseudorandom('cry_flip_vouch'..G.GAME.round_resets.ante) > 0.7 then
card.cry_flipped = true
end
create_shop_card_ui(card, 'Voucher', G.shop_vouchers)
card:start_materialize()
if G.GAME.current_round.cry_voucher_edition then -- eh why not
card:set_edition(G.GAME.current_round.cry_voucher_edition, true, true)
end
G.shop_vouchers.config.card_limit = G.shop_vouchers.config.card_limit + 1 -- does this actually matter/even get reset??? i'm confused but whatever
G.shop_vouchers:emplace(card)
end
end
'''
# control the planet/tarot rates (This needs to be left in to maintain vanilla RNG
[[patches]]
[patches.pattern]
target = "functions/UI_definitions.lua"
pattern = '''
{type = 'Tarot', val = G.GAME.tarot_rate},
{type = 'Planet', val = G.GAME.planet_rate},
'''
position = "at"
payload = '''
{type = 'Tarot', val = G.GAME.tarot_rate*(G.GAME.cry_percrate.tarot/100)},
{type = 'Planet', val = G.GAME.planet_rate*(G.GAME.cry_percrate.planet/100)},
'''
match_indent = true
# Adds adjustability to every other consumable type
[[patches]]
[patches.pattern]
target = "functions/UI_definitions.lua"
pattern = '''
table.insert(rates, { type = v, val = G.GAME[v:lower()..'_rate'] })
'''
position = "at"
payload = '''
local num = G.GAME.cry_percrate and G.GAME.cry_percrate[v:lower()] or 100
table.insert(rates, { type = v, val = G.GAME[v:lower()..'_rate'] * ((num or 100) / 100) })
'''
match_indent = true
# fix total rate (Current Cryptid implementation)
# [[patches]]
# [patches.pattern]
# target = "functions/UI_definitions.lua"
# pattern = '''
# total_rate = total_rate + G.GAME[v:lower()..'_rate']
# '''
# position = "at"
# payload = '''
# if not (v:lower() == 'tarot' or v:lower() == 'planet') then
# total_rate = total_rate + G.GAME[v:lower()..'_rate']
# else
# total_rate = total_rate + ( G.GAME[v:lower()..'_rate'] * (G.GAME.cry_percrate[v:lower()]/100) )
# end
# '''
# match_indent = true
# fix total rate (IcyEthics Refactor)
[[patches]]
[patches.pattern]
target = "functions/UI_definitions.lua"
pattern = '''
total_rate = total_rate + G.GAME[v:lower()..'_rate']
'''
position = "at"
payload = '''
total_rate = total_rate + ( G.GAME[v:lower()..'_rate'] * (G.GAME.cry_percrate[v:lower()]/100) )
'''
match_indent = true
# don't check voucher requirements for forced tier 3 voucher pool
[[patches]]
[patches.pattern]
target = "functions/common_events.lua"
pattern = "if v.requires then"
position = "at"
payload = "if v.requires and _type ~= 'Tier3' then"
match_indent = true