Skip to content

Instantly share code, notes, and snippets.

@twilight-sparkle-irl
Last active February 4, 2019 15:46
Show Gist options
  • Save twilight-sparkle-irl/9fead1f73489d4465f106d02ca0d6efc to your computer and use it in GitHub Desktop.
Save twilight-sparkle-irl/9fead1f73489d4465f106d02ca0d6efc to your computer and use it in GitHub Desktop.
makes mario oof randomly. a really, really simple test of lua stuff. probably glitchy.
memory.usememorydomain("RDRAM")
math.randomseed(os.time())
local oof = 0
local dew_it = 0
while true do
if math.random() > (0.994 - dew_it) and oof < 1 then
console.log(oof)
memory.write_u32_be(0x33b17c,0x00020460+math.random(0,5))
oof = 200
dew_it = 0
else
oof = oof - 1
end
-- since the next 4 lines of actual code are confusing lemme lay it out
-- basically this is based on a whole ton of messing around and seeing what jumping actions look like
-- so that whenever you're jumping your chance of being oofed goes up
-- remove these next four lines for ez bby mode
if dew_it < 0 and memory.read_u8(0x33b17c) == 0x03 or (memory.read_u32_be(0x33b17c) > 0x00800800) and (memory.read_u32_be(0x33b17c) < 0x008008ff) then
oof = 0
dew_it = dew_it + 0.02
end
emu.frameadvance();
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment