Advertisement
MegoZ_

Buffer Jump in SMBX2

Jun 5th, 2022 (edited)
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. local bufferJump = {}
  2. --v1.3
  3.  
  4. function bufferJump.onInitAPI()
  5.     registerEvent(bufferJump, "onTick")
  6. end
  7.  
  8. bufferJump.always = false
  9. bufferJump.disableTanooki = true
  10. local alreadyJumped = {false,false}
  11. --                      ^^     ^^     < In order to make this work for two players independently I do this.
  12. --                                      I don't know if there's a better way of doing this but hey, it works, I'm proud, and I'm happy! ⌐■_■
  13.  
  14. local disableCharacters = {
  15.     3,  --PEACH
  16.     5,  --LINK
  17.     6,  --MEGAMAN
  18.     9,  --KLONOA
  19.     10, --NINJABOMBERMAN
  20.     11, --ROSALINA
  21.     16  --SAMUS
  22. }
  23.  
  24. function bufferJump.onTick()
  25.     for k, p in ipairs(Player.get()) do
  26.         local function isUnderwater()
  27.             return(
  28.                 p:mem(0x36,FIELD_BOOL)              -- In a liquid
  29.                 and p:mem(0x06,FIELD_WORD) == 0     -- In quicksand
  30.             )
  31.         end
  32.         if not isUnderwater() and
  33.         p.forcedState == 0 and
  34.         p.deathTimer == 0 and
  35.         Level.winState() == 0 and
  36.         not p:mem(0x50,FIELD_BOOL) and
  37.         not p:mem(0x44, FIELD_BOOL) and -- Riding a rainbow shell
  38.         not p:mem(0x13C, FIELD_BOOL) and
  39.         p.mount ~= MOUNT_CLOWNCAR then
  40.  
  41.  
  42.  
  43.             for _,name in ipairs(disableCharacters) do
  44.                 if p.character == name then return end
  45.                 if bufferJump.disableTanooki then
  46.                     if p.powerup == 4 or p.powerup == 5 then return end
  47.                 end
  48.             end
  49.    
  50.             local function canDo()
  51.                 return (
  52.                     p:isOnGround()
  53.                     or (p.mount == MOUNT_BOOT and p:mem(0x10C,FIELD_BOOL))      -- Hopping in boot
  54.                     or p:mem(0x40,FIELD_WORD) > 0                               -- Climbing
  55.                 )
  56.             end
  57.    
  58.             p:mem(0x11E, FIELD_BOOL, false) -- Override Jumping
  59.    
  60.             if bufferJump.always then
  61.                 alreadyJumped[k] = false
  62.             else
  63.                 if not p.keys.jump then
  64.                     alreadyJumped[k] = false
  65.                 end
  66.             end
  67.            
  68.             if canDo() and p.keys.jump and alreadyJumped[k] == false then
  69.                 Audio.playSFX(1)
  70.                 p:mem(0x11C, FIELD_WORD, 20)
  71.                 alreadyJumped[k] = true
  72.             end
  73.  
  74.  
  75.  
  76.         end
  77.  
  78.  
  79.     end
  80. end
  81.  
  82. return bufferJump
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement