Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sm3dwNove = {}
- local trueCharacterID = player:mem(0xF0, FIELD_WORD);
- local trueCharacterID2 = nil;
- local textblox = API.load("textblox");
- function sm3dwNove.onInitAPI()
- registerEvent(sm3dwNove, "onTick", "onTick");
- registerEvent(sm3dwNove, "onStart", "onStart");
- registerEvent(sm3dwNove, "onInputUpdate");
- registerEvent(sm3dwNove, "onTickEnd", "onTickEnd");
- end
- if trueCharacterID == 1 or trueCharacterID == 2 or trueCharacterID == 4 then
- local footContact = false
- local isBannedCharacter = false
- local isInSomething = false
- local isDoingBannedStuff = false
- local allowCrawl = false
- local isHoldingSomething = false
- local isRunning = false
- local truePowerup = 1
- local currentPowerUp = nil
- local crouchWalkEntered = false
- currentPowerUp = player.powerUp
- --[[
- if allow2P then
- currentPowerUp = {currentPowerUp, player2.powerUp};
- end ]]
- local truePowerup = currentPowerUp
- local inputs = API.load("inputs2");
- local playeranim = API.load("playerAnim");
- inputs.locked[1].down = true;
- --[[
- if allow2P then
- inputs.locked[1][2].down = true;
- end]]
- local function sleep (a)
- local sec = tonumber(os.clock() + a);
- while (os.clock() < sec) do
- end
- end
- local function memRecognitionFunction()
- currentPowerUp = player:mem(0x112, FIELD_WORD)
- inGroundNow = player:mem(0x146, FIELD_BOOL)
- inSlopeNow = player:mem(0x48, FIELD_BOOL)
- inStandNPC = player:mem(0x176, FIELD_BOOL)
- isInVine = player:mem(0x40, FIELD_BOOL)
- pressedAltJump = player.altJumpKeyPressing
- isInMount =player:mem(0x108, FIELD_BOOL)
- isInWater = player:mem(0x44, FIELD_BOOL)
- spriteHeld = player:mem(0x154, FIELD_WORD)
- characterId = player:mem(0xF0, FIELD_WORD)
- isStatue = player:mem(0x4A, FIELD_BOOL)
- isInRainbowShell = player:mem(0x44, FIELD_BOOL)
- isLeft = player:mem(0x106, FIELD_WORD) < 0
- playerZoomFactor = player:mem(0xE0, FIELD_DFLOAT)
- isSpinning = player:mem(0x50, FIELD_BOOL)
- end
- local function memFusions()
- if math.abs(player.speedX) >= 5 then
- isRunning = true;
- else
- isRunning = false;
- end
- if not inSlopeNow and
- not inGroundNow and
- not inStandNPC then
- footContact = false;
- else
- footContact = true;
- end
- if characterId == 1 or
- characterId == 2 or
- characterId == 3 or
- characterId == 4 then
- isBannedCharacter = false
- else
- isBannedCharacter = true
- end
- if spriteHeld >= 1 then
- isHoldingSomething = true;
- else
- isHoldingSomething = false;
- end
- if isInVine or
- isInMount or
- isInWater or
- isInRainbowShell or
- isStatue then
- isInSomething = true;
- else
- isInSomething = false
- end
- end
- local function doingBannedStuff()
- if not footContact or
- isInSomething or
- isHoldingSomething then
- isDoingBannedStuff = true;
- else
- isDoingBannedStuff = false;
- end
- end
- local function longJump()
- if not isDoingBannedStuff and isRunning and
- inputs.state[1].altjump == 1 then
- if isLeft then
- player.runKeyPressing = false;
- addSpeed = player.speedX
- player.leftKeyPressing = false;
- player.speedX = 0
- Audio.playSFX(1);
- player.speedX = addSpeed - 10
- for k=1,5 do
- player.jumpKeyPressing = true
- end
- else
- player.runKeyPressing = false;
- addSpeed = player.speedX
- player.rightKeyPressing = false;
- player.speedX = 0
- Audio.playSFX(1);
- player.speedX = addSpeed + 10
- for m=1,5 do
- player.jumpKeyPressing = true
- end
- end
- end
- end
- local function crouchwalk()
- if not isDoingBannedStuff and
- currentPowerUp ~= 1 then
- Audio.playSFX(26);
- truePowerup = currentPowerUp;
- player:mem(0x112, FIELD_WORD, 1);
- end
- if truePowerup ~= currentPowerup and inputs.state[1].down == inputs.RELEASE then
- Audio.playSFX(71);
- player:mem(0x112, FIELD_WORD, truePowerup);
- end
- end
- function sm3dwNove.onTick()
- memRecognitionFunction();
- memFusions();
- doingBannedStuff();
- if inputs.state[1].down == inputs.PRESS or
- inputs.state[1].down == inputs.RELEASE then
- crouchwalk();
- end
- textblox.printExt ("X Speed = "..tostring(player.speedX), {x=5,y=050, font=textblox.defaultSpritefont[3][1], halign=textblox.HALIGN_LEFT, valign=textblox.VALIGN_MID})
- end
- function sm3dwNove.onInputUpdate()
- if inputs.state[1].down == inputs.PRESS and
- ((inSlopeNow and (characterId == 1 or characterId == 2)) or isInVine or isInMount or not footContact) then
- inputs.locked[1].down = false;
- end
- if inputs.locked[1].down == false and
- not((inSlopeNow and (characterId == 1 or characterId == 2)) or isInVine or isInMount or not footContact) then
- inputs.locked[1].down = true;
- end
- if(player.altJumpKeyPressing) and (player:mem(0x108,FIELD_WORD) < 1) and not player.jumpKeyPressing and isRunning then
- player.altJumpKeyPressing = false;
- longJump();
- end
- bugInput();
- end
- -- SMBX Crouching Bugfix --
- -- by Nat The Porcupine --
- --Further work by BulbyVR --
- local player_isCrouching = false;
- local player_lowCeiling = false;
- local player2_isCrouching = false;
- local player2_lowCeiling = false;
- local longJumpLeftAnim = playeranim.Anim({-2, -24, -24, -24, -24}, 5)
- local longJumpRightAnim = playeranim.Anim({2, 24, 24, 24, 24}, 5)
- local animationTimer = 0
- local animTimerLimit = 15
- function bugInput()
- -- Stores the player's crouching state in a variable --
- if player:mem(0x12E,FIELD_WORD) == -1 then
- player_isCrouching = true;
- else
- player_isCrouching = false;
- end
- -- Checks if the player is small or touching ground--
- if player:mem(0x112, FIELD_WORD) ~= 1 and footContact then
- -- Checks for blocks above the player while they're crouching --
- for k,v in pairs(Block.getIntersecting(player.x, player.y - 32, player.x + player.width, player.y)) do
- -- Checks for visible blocks only --
- if v:mem(0x1C,FIELD_WORD) == 0 then
- -- Block exception list: list of blocks that will not force the player to duck --
- local exception = {8, 25, 26, 27, 28, 30, 38, 69, 79, 108, 121, 122, 123,130, 161, 168, 172, 175, 178,
- 181, 240, 241, 242, 243, 244, 245, 259, 260, 261, 287, 288, 289, 290, 370, 371, 372, 373, 374, 375, 379, 380, 381, 382, 389, 391, 392, 404, 405, 406, 420, 437, 438, 439, 440 ,441, 442, 443, 444, 445, 446, 447, 448, 459, 460
- ,461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 506, 507, 508, 568, 572, 575, 579};
- if v.id == exception then player_lowCeiling = false else player_lowCeiling = true end
- end
- end
- end
- -- Forces the player to crouch --
- if player.downKeyPressing == false then
- if player_lowCeiling == true then
- player.downKeyPressing = true;
- elseif player:mem(0x146,FIELD_WORD) == 0 and player_isCrouching == true then
- player.downKeyPressing = true;
- else
- player.downKeyPressing = false;
- end
- end
- end
- function sm3dwNove.onTickEnd()
- -- Resets the player's low ceiling variable for technical reasons --
- player_lowCeiling = false;
- end
- end
- return sm3dwNove;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement