diff --git a/assets/1x/blind.png b/assets/1x/blind.png index 6cca466..972d694 100644 Binary files a/assets/1x/blind.png and b/assets/1x/blind.png differ diff --git a/assets/2x/blind.png b/assets/2x/blind.png index 95cda64..9054f18 100644 Binary files a/assets/2x/blind.png and b/assets/2x/blind.png differ diff --git a/src/blind.lua b/src/blind.lua index ac78084..ecac19f 100644 --- a/src/blind.lua +++ b/src/blind.lua @@ -7,12 +7,73 @@ SMODS.Atlas { atlas_table = "ANIMATION_ATLAS", } +local function disable_improbable() + G.GAME.improbable = nil + local orig = (getmetatable(G.GAME.probabilities) or {}).orig + + if orig then + G.GAME.probabilities = orig + end +end + +if cry_prob then + local orig_prob = cry_prob + + ---@diagnostic disable-next-line: lowercase-global + cry_prob = function(owned, den, rigged) + return G.GAME.improbable and 0 or orig_prob(owned, den, rigged) + end +end + +local orig_update = Game.update + +---@diagnostic disable-next-line: duplicate-set-field +function Game:update(dt) + orig_update(self, dt) + local orig = G.GAME.probabilities + + if not G.GAME.improbable or not getmetatable(orig) then + return + end + + local mt = { + orig = orig, + __index = function (_, k) + return k == "normal" and 0 or orig[k] + end, + __newindex = function (_, k, v) + if k ~= "normal" or v ~= 0 then + orig[k] = v + end + end, + } + + local proxy = {} + setmetatable(proxy, mt) + G.GAME.probabilities = proxy +end + +SMODS.Blind { + key = "improbable", + boss = {min = 1, max = 10}, + boss_colour = HEX("009966"), + atlas = "blind", + pos = {x = 0, y = 0}, + mult = 2, + dollars = 5, + defeat = disable_improbable, + disable = disable_improbable, + set_blind = function(_) + G.GAME.improbable = true + end, +} + SMODS.Blind { key = "nimble", boss = {min = 1, max = 10}, boss_colour = HEX("0291fb"), atlas = "blind", - pos = {x = 0, y = 0}, + pos = {x = 0, y = 1}, mult = 2, dollars = 5, defeat = function(self) @@ -38,7 +99,7 @@ SMODS.Blind { if not self.disabled then self.disabled = true G.E_MANAGER:add_event(Event({ - delay = 0.1, + delay = 1, trigger = "after", func = force_hand, })) @@ -48,49 +109,3 @@ SMODS.Blind { self.disabled = false end, } - -local function disable() - local orig = (getmetatable(G.GAME.probabilities) or {}).orig - - if orig then - G.GAME.probabilities = orig - end -end - -local orig_pseudorandom = pseudorandom - ----@diagnostic disable-next-line: lowercase-global -function pseudorandom(seed, min, max) - return getmetatable(G.GAME.probabilities) and 0 / 0 or orig_pseudorandom(seed, min, max) -end - -SMODS.Blind { - key = "improbable", - boss = {min = 1, max = 10}, - boss_colour = HEX("aaaaaa"), - atlas = "blind", - pos = {x = 0, y = 0}, - mult = 2, - dollars = 5, - defeat = disable, - disable = disable, - set_blind = function(_) - local orig = G.GAME.probabilities - - local mt = { - orig = orig, - __index = function (_, k) - return k == "normal" and 0 or orig[k] - end, - __newindex = function (_, k, v) - if k ~= "normal" or v ~= 0 then - orig[k] = v - end - end, - } - - local proxy = {} - setmetatable(proxy, mt) - G.GAME.probabilities = proxy - end, -}