Advertisement
bulbyVR

Super Mario 3D world Moveset

Aug 10th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.03 KB | None | 0 0
  1. --[[
  2.     Super Mario 3D World moveset
  3.     Allows player to crawl and long jump.
  4.     sm3dwMove is api name. overwriteSpinJump will overwrite Spin Jump with Long Jump
  5.     ]]
  6.  
  7. local footContact = false;
  8. local isBannedCharacter = false;
  9. local isInSomething = false;
  10. local allowLongJump = false;
  11. local isDoingBannedStuff = false;
  12. local allowCrawl = false;
  13. local isHoldingSomething = false;
  14. local playeranim = API.load("playerAnim");
  15. local inputs = API.load("inputs2");
  16. local sm3dwMove = {}
  17. sm3dwMove.overwriteSpinJump = false;
  18. if sm3dwMove.overwriteSpinJump then
  19.     inputs.lock(1, "altjump")
  20. end
  21. function sm3dwMove.onInitAPI()
  22.     registerEvent(sm3dwMove, "onTick", "onTick")
  23.     registerEvent(sm3dwMove, "onStart", "onStart")
  24. end
  25. local function memRecognitionFunction()
  26.     currentPowerUp = player:mem(0x112, FIELD_WORD);
  27.     inGroundNow = player:mem(0x146, FIELD_BOOL);
  28.     inSlopeNow = player:mem(0x48, FIELD_BOOL);
  29.     inStandNPC = player:mem(0x176, FIELD_BOOL);
  30.     pressedAltJump = player.altJumpKeyPressing;
  31.     pressedJump = player.jumpKeyPressing;
  32.     pressedRun = player.runKeyPressing;
  33.     isInVine = player:mem(0x40, FIELD_BOOL);
  34.     isInMount = player:mem(0x108, FIELD_BOOL);
  35.     isInWater = player:mem(0x44, FIELD_BOOL);
  36.     spriteHeld = player:mem(0x154, FIELD_WORD);
  37.     characterId = player:mem(0xF0, FIELD_WORD);
  38.     pressedDown = player.downKeyPressing
  39.     isLeft = player.mem(0x114, FIELD_WORD) < 0;
  40.     isStatue = player.mem(0x4A, FIELD_BOOL)
  41.     isInRainbowShell = player:mem(0x44, FIELD_BOOL)
  42. end
  43. local function memFusions()
  44.     if not inSlopeNow and
  45.     not inGroundNow and
  46.     not inStandNPC then
  47.         footContact = false;
  48.     else
  49.         footContact = true;
  50.     end
  51.     if characterId == 1 or
  52.     characterId == 2 then
  53.         isBannedCharacter = false
  54.     else
  55.         isBannedCharacter = true
  56.     end
  57.     if spriteHeld >= 1 then
  58.         isHoldingSomething = true;
  59.     else
  60.         isHoldingSomething = false;
  61.     end
  62.     if isInVine or
  63.     isInMount or
  64.     isInWater or
  65.     isInRainbowShell then
  66.         isInSomething = true;
  67.     else
  68.         isInSomething = false
  69.     end
  70. end
  71. local function doingBannedStuff()
  72.     if  not footContact or
  73.     isBannedCharacter or
  74.     isInSomething or
  75.     isHoldingSomething then
  76.         isDoingBannedStuff = true;
  77.     else
  78.         isDoingBannedStuff = false;
  79.     end
  80. end
  81. local longJumpLeftAnim = playeranim.Anim({-2, -24, -24, -24, -24}, 5)
  82. local longJumpRightAnim = playeranim.Anim({2, 24, 24, 24, 24}, 5)
  83. local animationTimer = 0
  84. local animTimerLimit = 15
  85.  
  86. local function longJump()
  87.     if overwriteSpinJump and
  88.     inputs.state(1, "altjump") == inputs.PRESS and
  89.     not isDoingBannedStuff then
  90.         if isLeft then
  91.         longJumpLeftAnim:play(player);
  92.         Audio.playSFX(getSMBXPath().."\\sound\\player-jump.ogg");
  93.         player.speedX = -40
  94.         player.speedY = -10
  95.         else
  96.         longJumpRightAnim:play(player);
  97.         Audio.playSFX(getSMBXPath().."\\sound\\player-jump.ogg");
  98.         player.speedX = 40
  99.         player.speedY = -10
  100.         end
  101.     elseif not overwriteSpinJump and
  102.     (inputs.state(1, "jump") == inputs.PRESS and inputs.state(1, "run") == inputs.HOLD) and
  103.     not isDoingBannedStuff then
  104.         if isLeft then
  105.         longJumpLeftAnim:play(player);
  106.         Audio.playSFX(getSMBXPath().."\\sound\\player-jump.ogg");
  107.         player.speedX = -40
  108.         player.speedY = -10
  109.         else
  110.         longJumpRightAnim:play(player);
  111.         Audio.playSFX(getSMBXPath().."\\sound\\player-jump.ogg");
  112.         player.speedX = 40
  113.         player.speedY = -10
  114.         end
  115.     end
  116. end
  117. local function animTimeReload()
  118.     if not isDoingBannedStuff then
  119.         animationTimer = animationTimer + 1;
  120.     else
  121.         animationTimer = 0
  122.     end
  123. end
  124. local function animation()
  125.     if animationTimer >= animTimerLimit or
  126.     usingBannedPowerUps or
  127.     isInSomething or
  128.     isHoldingSomething or
  129.     footContact then
  130.         longJumpLeftAnim:stop(player);
  131.         longJumpRightAnim:stop(player);
  132.     end
  133. end
  134. local function crouchwalk()
  135.     if player.downKeyPressing and
  136.     not doingBannedStuff then
  137.         if player.rightKeyPressing then
  138.             player.speedX = 5
  139.         elseif player.leftKeyPressing then
  140.             player.speedX = -5
  141.         end
  142.     end
  143. end
  144.  
  145. function sm3dwMove.onTick()
  146.     memRecognitionFunction();
  147.     memFusions();
  148.     doingBannedStuff();
  149.     animation();
  150.     animTimeReload();
  151.     longJump();
  152.     crouchwalk();
  153. end
  154. return sm3dwMove;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement