I Need help turning this code into a wallrun

addHook("PlayerThink", function(player)
if not player and player.valid and player.mo.skin == "sonic" and and player.playerstate == PST_LIVE return end
if player.mo.collidewall == nil
player.mo.collidewall = false
end
if player.mo.collidewall == true
player.mo.collidewall = false
end
end)

// this is for checking if your blocked from moving by say, a wall? also checks if your moving towards it as well as a character check.
addHook("MobjMoveBlocked", function(mo)
if mo.player and mo.skin == "sonic" and mo.valid and mo.player.playerstate == PST_LIVE
if not P_IsObjectOnGround(mo)
if not (mo.player.pflags & PF_ANALOGMODE)
if mo.player.cmd.forwardmove > 0
mo.collidewall = true
end
else
if not (mo.player.cmd.forwardmove == 0)
or not (mo.player.cmd.sidemove == 0)
mo.collidewall = true
end
end
end
end
end, MT_PLAYER)

// this is for when your on the wall and you hit jump, another character check as pre usaual.
addHook("JumpSpecial", function(player)
if player.mo and player.mo.skin == "sonic" and player.mo.valid and player.playerstate == PST_LIVE
if player.mo.collidewall
P_DoJump(player)
S_StartSound(player.mo, sfx_zoom)
P_InstaThrust(player.mo, player.mo.angle, -5*FRACUNIT)
P_SetObjectMomZ(player.mo, 15*FRACUNIT)
player.pflags = $1 & ~(PF_THOKKED)
player.mo.collidewall = false
return true
end
end
end
 
her
addHook("PlayerThink", function(player)
if not player and player.valid and player.mo.skin == "sonic" and and player.playerstate == PST_LIVE return end
if player.mo.collidewall == nil
player.mo.collidewall = false
end
if player.mo.collidewall == true
player.mo.collidewall = false
end
end)

// this is for checking if your blocked from moving by say, a wall? also checks if your moving towards it as well as a character check.
addHook("MobjMoveBlocked", function(mo)
if mo.player and mo.skin == "sonic" and mo.valid and mo.player.playerstate == PST_LIVE
if not P_IsObjectOnGround(mo)
if not (mo.player.pflags & PF_ANALOGMODE)
if mo.player.cmd.forwardmove > 0
mo.collidewall = true
end
else
if not (mo.player.cmd.forwardmove == 0)
or not (mo.player.cmd.sidemove == 0)
mo.collidewall = true
end
end
end
end
end, MT_PLAYER)

// this is for when your on the wall and you hit jump, another character check as pre usaual.
addHook("JumpSpecial", function(player)
if player.mo and player.mo.skin == "sonic" and player.mo.valid and player.playerstate == PST_LIVE
if player.mo.collidewall
P_DoJump(player)
S_StartSound(player.mo, sfx_zoom)
P_InstaThrust(player.mo, player.mo.angle, -5*FRACUNIT)
P_SetObjectMomZ(player.mo, 15*FRACUNIT)
player.pflags = $1 & ~(PF_THOKKED)
player.mo.collidewall = false
return true
end
end
end
code fixed:
addHook("PlayerThink", function(player)
    if not (player and player.valid and player.mo and player.mo.skin == "sonic" and player.playerstate == PST_LIVE) then return end

    if player.mo.collidewall == nil then
        player.mo.collidewall = false
    elseif player.mo.collidewall == true then
        player.mo.collidewall = false
    end
end)

addHook("MobjMoveBlocked", function(mo)
    if mo and mo.valid and mo.player and mo.player.valid and mo.skin == "sonic" and mo.player.playerstate == PST_LIVE then
        if not P_IsObjectOnGround(mo) then
            if not (mo.player.pflags & PF_ANALOGMODE) then
                if mo.player.cmd.forwardmove > 0 then
                    mo.collidewall = true
                end
            else
                if mo.player.cmd.forwardmove ~= 0 or mo.player.cmd.sidemove ~= 0 then
                    mo.collidewall = true
                end
            end
        end
    end
end, MT_PLAYER)

addHook("JumpSpecial", function(player)
    if player and player.valid and player.mo and player.mo.valid and player.mo.skin == "sonic" and player.playerstate == PST_LIVE then
        if player.mo.collidewall then
            P_DoJump(player)
            S_StartSound(player.mo, sfx_zoom)
            P_InstaThrust(player.mo, player.mo.angle, -5*FRACUNIT)
            P_SetObjectMomZ(player.mo, 15*FRACUNIT)
            player.pflags = $ & ~PF_THOKKED
            player.mo.collidewall = false
            return true
        end
    end
end)
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top