Can any one rip ONLY the manual drifting code from this script??

mattisthebest

#1 Mystic Realm Enjoyer
Ive been trying to get the drifting code out of this script for a while now and i have no idea what i am doing since i have not learned lua yet, NOTE: The mod that the script comes from is Open Assets and im pretty sure im allowed to do this (any help or advice is VERY much appreciated :33)

--SCRIPT--
Lua:
//Unleashed Physics and Camera by DarknessStylus
//Originally named "Centered Camera"
//Based on my first script
//Now with counters xD

freeslot("S_PLAY_ALLDRIFT", "sfx_drft2")

states[S_PLAY_ALLDRIFT] = {SPR_PLAY, SPR2_SPIN|FF_ANIMATE, 4, nil, 4, 5, S_PLAY_WALK}

COM_AddCommand("analogsens", function(player, arg)
    if arg
        if arg == "1" or arg == "true" or arg == "gens" or arg == "unwiished" or arg == "on"
            if io and player == consoleplayer
                local file = io.openlocal("client/analogsens.dat", "w+")
                file:write(arg)
                file:close()
            end
            player.analogsens = true
            CONS_Printf(player, "Analog sensitivity now is Gens/Wii Unleashed type")
        elseif arg == "0" or arg == "false" or arg == "vanilla" or arg == "off"
            if io and player == consoleplayer
                local file = io.openlocal("client/analogsens.dat", "w+")
                file:write(arg)
                file:close()
            end  
            player.analogsens = false
            CONS_Printf(player, "Analog sensitivity now is Vanilla type")
        elseif player.analogsens
            CONS_Printf(player, "analogsens [1 or 0] - Changes the sensitivity for your analog. Currently Gens/Wii Unleashed type.")
        else
            CONS_Printf(player, "analogsens [1 or 0] - Changes the sensitivity for your analog. Currently Vanilla type.")
        end
    elseif player.analogsens
        CONS_Printf(player, "analogsens [1 or 0] - Changes the sensitivity for your analog. Currently Gens/Wii Unleashed type.")
    else
        CONS_Printf(player, "analogsens [1 or 0] - Changes the sensitivity for your analog. Currently Vanilla type.")
    end
end, 0)

local MomentumLimiter = function(mo,svr)

if (not (mo.skin == "adventuresonic"))
    svr = 77*mo.scale*1
else
    svr = 88*FRACUNIT
end

    if mo.eflags&MFE_UNDERWATER then
        svr = $/2
    end
   
    if mo.player.powers[pw_sneakers]
    or mo.player.powers[pw_super]
        svr = $*2
    end
   
    if mo.player.cmd.forwardmove < 0
    or mo.player.cmd.forwardmove == 0
    //or mo.player.cmd.sidemove ~= 0
    or mo.skin == "modernsonic" --silly failcheck
    or mo.player.isondriftvar == 1
    or mo.player.pflags & PF_SPINNING
    or (not (P_IsObjectOnGround(mo)))
        return
    end
   
    if mo.player.speed > svr then
        mo.movefactor = 1*FRACUNIT/4
        mo.friction = 30*FRACUNIT/32
        P_InstaThrust(mo, mo.angle, 77*mo.scale*1)
        mo.player.normalspeed = $ - FRACUNIT
        return true
    else
        return false
    end
end

//Better wall checker finally jajajajaja YES!!!!
addHook("MobjMoveBlocked", function(mo)
    mo.player.wallcounterc = true
end, MT_PLAYER)

addHook("MobjLineCollide", function(mo, line)
    if not(mo.player) then return end
    if not mo and mo.valid then return end
    if P_IsObjectOnGround(mo) then return end
    if mo.player.wallcounterc == false then return end
        mo.angle = mo.player.drawangle
    end, MT_PLAYER)

addHook("PlayerCanDamage", function(player, enemy)
    if player.isondriftvar == 1
    return true
    end
end)

addHook("PreThinkFrame", do
    for player in players.iterate
        if player.mo
       
        local mo = player.mo
       
        if player.cancelboostvar == nil
            player.cancelboostvar = 0
            end
        if player.angleholdervar == nil
            player.angleholdervar = 0
            end
        if player.momspeedvar == nil
            player.momspeedvar = 0
            end
           
            if player.mo.skin == "modernsonic"
                if player.cmd.buttons & BT_CUSTOM1
                and ((player.boosting == true) or (player.airboost == true))
                    player.cancelboostvar = $ + 1
                else
                    player.cancelboostvar = 0
                end
            end
            if player.mo.skin == "adventuresonic"
                if player.cmd.buttons & BT_SPIN
                //and player.mo.state ~= S_PLAY_SPINDASH
                and player.YuRushMode.boosting
                    player.cancelboostvar = $ + 1
                else
                    player.cancelboostvar = 0
                end
            end
            if player.mo.skin == "modernsonic"
                if player.cancelboostvar > 0
                and player.cancelboostvar < 2
                and P_IsObjectOnGround(player.mo)
                    if player.cmd.sidemove < -25
                        P_InstaThrust(player.mo, player.mo.angle - ANGLE_45, 60*FRACUNIT)
                    elseif player.cmd.sidemove > 25
                        P_InstaThrust(player.mo, player.mo.angle + ANGLE_45, 60*FRACUNIT)
                    elseif player.cmd.sidemove < 25
                    and player.cmd.sidemove > -25
                        return
                    end
                end
            end
            if player.mo.skin == "adventuresonic"
                if player.cancelboostvar > 0
                and player.cancelboostvar < 2
                and P_IsObjectOnGround(player.mo)
                    if player.cmd.sidemove < -25
                        P_InstaThrust(player.mo, player.mo.angle - ANGLE_90, 60*FRACUNIT)
                    elseif player.cmd.sidemove > 25
                        P_InstaThrust(player.mo, player.mo.angle + ANGLE_90, 60*FRACUNIT)
                    elseif player.cmd.sidemove < 25
                    and player.cmd.sidemove > -25
                        return
                    end
                end
            end
        end
    end
end)

//Main hook
addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo
       
        local mo = player.mo
        local movingfactor = 4*FRACUNIT/11
        local movingslowfactor = 0
        local momxyangle = R_PointToAngle2(player.mo.x, player.mo.y, (player.mo.x+player.mo.momx), (player.mo.y+player.mo.momy))
        local vnormalcamera = R_PointToAngle2(0, 0, mo.height - 7*FRACUNIT, mo.momz)
        local vspringcamera = R_PointToAngle2(0, 0, mo.height - 25*FRACUNIT, mo.momz)
       
        if player.wallcounterc == nil
            player.wallcounterc = false
            end
        if player.normalcamc == nil
            player.normalcamc = false
            end
        if player.hspringcamc == nil
            player.hspringcamc = 0
            end
        if player.speedturnvar == nil
            player.speedturnvar = 0
            end
        if player.isonairvar == nil
            player.isonairvar = 0
            end
        if player.beforeboostprevspd == nil
            player.beforeboostprevspd = 0
            end
        if player.isondriftvar == nil
            player.isondriftvar = 0
            end
        if player.prevpspeed2 == nil
            player.prevpspeed2 = 0
            end
        if player.isdriftingvar == nil
            player.isdriftingvar = 0
            end
        if player.isdriftdustvar == nil
            player.isdriftdustvar = 0
            end
        if player.aerealboostvar == nil
            player.aerealboostvar = 0
            end
        if player.boostanglechangervar == nil
            player.boostanglechanglervar = 0
            end
        if player.analogsens == nil
            player.analogsens = false
            end
        if player.localfriction2 == nil
            player.localfriction2 = 32*FRACUNIT/32
            end
   
    //Checks and counters
if (not (P_IsObjectOnGround(player.mo)))
    player.isonairvar = 10
else
    player.isonairvar = $ - 1
end

if not (player.driftmobj2 and player.driftmobj2.valid) then
    player.driftmobj2 = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_GFZFLOWER1)
    player.driftmobj2.flags2 = $1|MF2_DONTDRAW
    P_SetOrigin(player.driftmobj2, player.mo.x, player.mo.y, player.mo.z)
    player.driftmobj2.fuse = 65
elseif (player.driftmobj2 and player.driftmobj2.valid)
    P_SetOrigin(player.driftmobj2, player.mo.x, player.mo.y, player.mo.z)
end

    player.prevpspeed2 = 10

    //Special threat to EVERY character that breaks or have a weird function >:c
    if player.boosting == true
    //or DIDBOOST == true
        player.beforeboostprevspd = 18
        player.boostanglechangervar = $ + 1
    else
        player.beforeboostprevspd = $ - 1
        player.boostanglechangervar = 0
    end
        if player.beforeboostprevspd == 18
        or player.beforeboostprevspd == 0
            player.localfriction2 = 32*FRACUNIT/32
        elseif player.beforeboostprevspd < 17
        and player.beforeboostprevspd > 0
            player.localfriction2 = 29*FRACUNIT/32
        end
            if player.cmd.forwardmove == 0
            and ((player.beforeboostprevspd < 17) or (player.beforeboostprevspd > 0))
                player.localfriction2 = 29*FRACUNIT/32
            elseif ((player.cmd.forwardmove ~= 0) or (player.cmd.sidemove ~= 0))
            and ((player.beforeboostprevspd == 18) or (player.beforeboostprevspd <= 0))
                player.localfriction2 = 32*FRACUNIT/32
            end
           
    if player.mo.skin == "modernsonic"
        if player.boosting == false
            and player.speed > 42*FRACUNIT
            and P_IsObjectOnGround(player.mo)
                player.localfriction2 = 30*FRACUNIT/32
            //end
        end
    end
   
    if player.mo.skin == "adventuresonic"
        if mo.state == S_PLAY_ROLL
        or ((mo.state == S_PLAY_SPINDASH) and (player.isondriftvar == 0))
        and P_IsObjectOnGround(player.mo)
            player.hspringcamc = $ + 1
        else
            player.hspringcamc = 0
        end
    end
   
    if (not (P_IsObjectOnGround(player.mo)))
        if player.airboost == true
            player.aerealboostvar = $ + 1
        else
            player.aerealboostvar = 0
        end
        if player.aerealboostvar == 1
            mo.angle = momxyangle
            player.drawangle = mo.angle
        end
    end
   
    if player.noxmomchar
    and player.mo.skin == "modernsonic"
        player.noxmomchar = 2
    end
   
    //if player.normalcamc == false
if player.analogsens == true
    if P_IsObjectOnGround(player.mo)
        if player.speed < 25*FRACUNIT
        and player.cmd.forwardmove > 0
            if player.cmd.sidemove > -10
            and player.cmd.sidemove < 10
                mo.movefactor = movingslowfactor + 1*FRACUNIT/2
                player.localfriction2 = 32*FRACUNIT/32
                mo.friction = player.localfriction2
            end
        end
    end
end
   
    /*if player.boostanglechangervar == 1
        player.drawangle = mo.angle
        if mo.msbaang
            mo.msbaang = player.drawangle
        end
    end*/
   
    //The camera part
    //if (not (player.cmd.buttons & BT_CUSTOM3))
        if P_IsObjectOnGround(player.mo)
        and ((player.quickstep1 == 0) or (player.quickstep1 == nil) or (player.quickstep1 ~= 1))
        and player.isondriftvar == 0
        and player.hspringcamc == 0
            if player.speed > 25*FRACUNIT
                mo.angle = momxyangle
                player.drawangle = mo.angle
                if player.analogsens == true
                    if player.cmd.sidemove > -14
                    and player.cmd.sidemove < 14
                        mo.movefactor = movingslowfactor
                    else
                        mo.movefactor = movingfactor
                    end
                else
                    mo.movefactor = movingfactor
                end
                mo.friction = player.localfriction2
            end
            player.normalcamc = true
        else
            player.normalcamc = false
        end
       
        if player.isonairvar == 10
            if mo.state == S_PLAY_SPRING
                player.aiming = vspringcamera
            else
                player.aiming = vnormalcamera
            end
            if player.stomping == true
                player.aiming = vspringcamera
            end
        elseif player.isonairvar == 9
            player.aiming = 0
        end
           
            //Drift part
    if player.mo and player.mo.valid
    and (not (player.pflags & PF_STASIS))
        if ((player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL) or (player.cmd.buttons & BT_SPIN))
        and ((((player.cmd.sidemove > 25) or (player.cmd.sidemove < -25)) and (player.analogsens == true)) or (((player.cmd.sidemove > 20) or (player.cmd.sidemove < -20)) and (player.analogsens == false)) or (((player.cmd.sidemove > 20) or (player.cmd.sidemove < -20)) and (player.analogsens == nil)))
        and P_IsObjectOnGround(player.mo)
        and player.speed > 20*FRACUNIT
            if player.mo.skin == "modernsonic"
            and (not (player.cmd.buttons & BT_SPIN))
                if player.boosting == true
                    mo.angle = momxyangle
                    mo.movefactor = 6*FRACUNIT/8
                    player.localfriction2 = 23*FRACUNIT/32
                    player.isondriftvar = 1
                elseif player.boosting == false
                    mo.angle = momxyangle
                    mo.movefactor = 3*FRACUNIT/5
                    player.localfriction2 = 32*FRACUNIT/32
                    P_InstaThrust(player.mo, mo.angle,  (FixedMul(42*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
                    player.isondriftvar = 1
                end
            else
                mo.state = S_PLAY_ALLDRIFT
                player.isdriftingvar = $ + 1
                player.isdriftdustvar = $ + 1
                    if player.isdriftingvar > 6
                        S_StartSound(player.driftmobj2, sfx_drft2)
                    end
                    if player.isdriftdustvar == 2
                        local dust1 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust1.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust1.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust1.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust1.destscale = FRACUNIT/2
                           
                        local dust2 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust2.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust2.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust2.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust2.destscale = FRACUNIT/2
                           
                        local dust3 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust3.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust3.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust3.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust3.destscale = FRACUNIT/2
                           
                        local dust4 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust4.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust4.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust4.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust4.destscale = FRACUNIT/2
                           
                        local dust5 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust5.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust5.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust5.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust5.destscale = FRACUNIT/2
                    end
                    if player.isdriftingvar >= 7
                        player.isdriftingvar = 0
                    end
                    if player.isdriftdustvar > 2
                        player.isdriftdustvar = 0
                    end
                mo.angle = momxyangle
                player.drawangle = momxyangle
                if player.cmd.buttons & BT_SPIN
                    if player.speed < 55*FRACUNIT
                    and player.mo.skin ~= "adventuresonic"
                        P_Thrust(player.mo, mo.angle, (FixedMul(1*FRACUNIT, player.mo.scale)+3*FRACUNIT)+cos(player.aiming))
                        mo.movefactor = 3*FRACUNIT/5
                        player.localfriction2 = 32*FRACUNIT/32
                    else
                        P_InstaThrust(player.mo, mo.angle, (FixedMul(50*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
                        mo.movefactor = 6*FRACUNIT/8
                        player.localfriction2 = 23*FRACUNIT/32
                    end
                else
                    mo.movefactor = 3*FRACUNIT/5
                    player.localfriction2 = 32*FRACUNIT/32
                    if player.speed > 70*FRACUNIT
                        P_InstaThrust(player.mo, mo.angle, (FixedMul(70*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
                    else
                        P_InstaThrust(player.mo, mo.angle, (FixedMul(42*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
                    end
                end
                player.isondriftvar = 1
                if player.pflags & ~PF_SPINNING
                    player.pflags = $1 & ~PF_SPINNING
                end
            end
            mo.friction = player.localfriction2
        else
            player.isondriftvar = 0
            S_StopSound(player.driftmobj2)
        end
    end
       
        //Insert here rail grind special threat to make it more functional lol
        /*if mo.state == S_PLAYER_GRINDING
            mo.angle = momxyangle
            player.drawangle = momxyangle
            player.localfriction2 = 29*FRACUNIT/32
            end*/
           
        if player.isonairvar > 10
            player.isonairvar = 10
            end
        if player.cancelboostvar > 10
            player.cancelboostvar = 10
            end
        if player.angleholdervar < 0
            player.angleholdervar = 0
            end
        if player.aerealboostvar > 10
            player.aerealboostvar = 10
            end
        end
    end
end)

addHook("PlayerSpawn", function(p)
    if io and p == consoleplayer and p.analogsens == nil
        local file = io.openlocal("client/analogsens.dat")
        if file
            local string = file:read("*a")
            if string == "1" or string == "true" or string == "gens" or string == "on"
                COM_BufInsertText(p, "analogsens on")
            elseif string == "0" or string == "false" or string == "vanilla" or string == "off"
                COM_BufInsertText(p, "analogsens off")
            elseif string == nil
                COM_BufInsertText(p, "analogsens off")
            end
            file:close()
        end
    end
end)

addHook("PostThinkFrame", do
    for player in players.iterate
        if player.mo
       
    local mo = player.mo
    local fixedmove = R_PointToAngle2(0, 0, mo.player.cmd.forwardmove*FRACUNIT, -mo.player.cmd.sidemove*FRACUNIT)
    local angle = R_PointToAngle2(mo.x, mo.y, (mo.x+mo.momx), (mo.y+mo.momy))
    local inputangle = angle + fixedmove
    local angleo50 = ANG64h - ANG10 - ANG1
    local angleo51 = ANG64h - ANG10 - ANG2 - ANG1 - ANG1 - ANG1
    local diparate = 1 + 1/4
   
    if player.momentumkillercounter == nil
        player.momentumkillercounter = 0
        end
    if player.momentumkillercounter2 == nil
        player.momentumkillercounter2 = 0
        end
    if player.momentumkillervar == nil
        player.momentumkillervar = 0
        end
   
        if (not (P_IsObjectOnGround(player.mo)))
            player.wallcounterc = false
        end
            if player.mo.skin ~= "adventuresonic"
            or player.mo.skin ~= "modernsonic"
                MomentumLimiter(mo,svr)
            end
            /*if MomentumLimiter(mo,svr) == true
                player.momentumkillercounter = $ + 1
            else
                player.momentumkillercounter = 0
            end
            if player.momentumkillercounter == 1
                player.momentumkillercounter2 = 18
            else
                player.momentumkillercounter2 = $ - 1
            end*/
               
                //Momentum killer
                //I hate mom mods -_-
                /*insert momentum actual killer here*/
               
            if ((player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL) or (player.cmd.buttons & BT_SPIN))
            and player.mo.state == S_PLAY_ALLDRIFT
                if player.cmd.sidemove < 0
                    player.drawangle = $ + ANG30
                elseif player.cmd.sidemove > 0
                    player.drawangle = $ - ANG30
                end
            end
        end
    end
end)
 
Last edited:
Ive been trying to get the drifting code out of this script for a while now and i have no idea what i am doing since i have not learned lua yet, NOTE: The mod that the script comes from is Open Assets and im pretty sure im allowed to do this (any help or advice is VERY much appreciated :33)
As a person that also doesn't know anything about lua I somehow made it work while being this whole script being held by duct tape. I deleted enough stuff so the main features of the original are gone, but drifting works as it should.
Lua:
//Unleashed Physics and Camera by DarknessStylus

freeslot("S_PLAY_ALLDRIFT", "S_PLAY_DRIFTJUMP", "sfx_drft2")

states[S_PLAY_ALLDRIFT] = {SPR_PLAY, SPR2_SPIN|FF_ANIMATE, 4, nil, 4, 5, S_PLAY_WALK}
states[S_PLAY_DRIFTJUMP] = {SPR_PLAY, SPR2_ROLL|FF_ANIMATE, 8, nil, 3, 2, S_PLAY_SPINDASH}

local UnleashedDrift = function(mo)

local player = mo.player

    if player.cmd.forwardmove < -25
    or player.isondriftvar == 0
    or (not (P_IsObjectOnGround(mo)))
    or not (player.mo.flags2 & MF2_TWOD)
        return
    end
       
    if player.isondriftvar == 1
    and P_PlayerInPain(player) == false
        if player.speed < 39*FRACUNIT
        and player.speed > 1*FRACUNIT
            //P_InstaThrust(player.mo, mo.angle, 38*FRACUNIT)
            P_Thrust(player.mo, mo.angle, 5*FRACUNIT)
            //mo.momx = $1*5/4
            //mo.momy = $1*5/4
            //mo.friction = 34*FRACUNIT/32
        end
        if player.speed < 46*FRACUNIT
        and player.speed > 39*FRACUNIT
            P_InstaThrust(player.mo, mo.angle, 41*FRACUNIT)
            //mo.friction = 32*FRACUNIT/32
        end
        if player.speed < 70*FRACUNIT
        and player.speed > 46*FRACUNIT
            //mo.momx = $1*5/6
            //mo.momy = $1*5/6
            if player.driftmodealt
                P_InstaThrust(player.mo, mo.angle, player.modspeed - 3*FRACUNIT)
            end
        end
        if player.speed > 70*FRACUNIT
            if player.driftmodealt
                P_InstaThrust(player.mo, mo.angle, (FixedMul(74*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
            else
                P_Thrust(player.mo, mo.angle, (FixedMul(3*FRACUNIT, player.mo.scale)+3*FRACUNIT)+cos(player.aiming))
            end
        end
        if player.speed > 119*mo.scale*1
            P_InstaThrust(player.mo, mo.angle, 119*mo.scale*1)
        end
    end
end

local SimpleDrift = function(mo)

local player = mo.player

    if player.cmd.forwardmove < 0
    or player.isondriftvar == 0
    or (not (P_IsObjectOnGround(mo)))
        return
    end
       
    if player.isondriftvar == 1
        if player.cmd.buttons & BT_SPIN
            if player.speed < 55*FRACUNIT
            and player.mo.skin ~= "adventuresonic"
                P_Thrust(player.mo, mo.angle, (FixedMul(5*FRACUNIT, player.mo.scale)+3*FRACUNIT)+cos(player.aiming))
            else
                P_InstaThrust(player.mo, mo.angle, (FixedMul(50*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
            end
        else
            if player.speed > 70*FRACUNIT
                P_InstaThrust(player.mo, mo.angle, (FixedMul(70*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
            else
                P_InstaThrust(player.mo, mo.angle, (FixedMul(42*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
            end
        end
        if player.mo.skin == "modernsonic"
            if player.boosting == true
                P_InstaThrust(player.mo, mo.angle, (FixedMul(70*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
            elseif player.boosting == false
                P_InstaThrust(player.mo, mo.angle, (FixedMul(42*FRACUNIT, player.mo.scale)+5*FRACUNIT)+cos(player.aiming))
            end
        end
    end
end

//Better wall checker finally jajajajaja YES!!!!
addHook("MobjMoveBlocked", function(mo)
    mo.player.wallcounterc = true
end, MT_PLAYER)

addHook("MobjLineCollide", function(mo, line)
    if not(mo.player) then return end
    if not mo and mo.valid then return end
    if P_IsObjectOnGround(mo) then return end
    if mo.player.wallcounterc == false then return end
        mo.angle = mo.player.drawangle
    end, MT_PLAYER)

addHook("PlayerCanDamage", function(player, enemy)
    if player.isondriftvar == 1
    or player.driftjumpvar > 0
    and P_PlayerInPain(player) == false
    return true
    end
end)

addHook("PreThinkFrame", do
    for player in players.iterate
        if player.mo //and player.pflags & ~PF_FULLSTASIS
       
        local mo = player.mo
       
        if player.cancelboostvar == nil
            player.cancelboostvar = 0
            end
        if player.driftboostcountervar == nil
            player.driftboostcountvar = 0
            end
        if player.modspeed == nil
            player.modspeed = 0
            end
        if player.momspeedvar == nil
            player.momspeedvar = 0
            end
           
        if player.pflags & ~PF_FULLSTASIS
            if player.mo.skin == "modernsonic"
                //if player.cmd.buttons & BT_CUSTOM1
                if ((player.boosting == true) or (player.airboost == true))
                    player.cancelboostvar = $ + 1
                    player.driftboostcountervar = $ + 1
                else
                    player.cancelboostvar = 0
                    player.driftboostcountervar = 0
                end
            end
            if player.mo.skin == "adventuresonic"
            and player.YuRushMode ~= nil
                if player.cmd.buttons & BT_SPIN
                //and player.mo.state ~= S_PLAY_SPINDASH
                and player.YuRushMode.boosting
                    player.cancelboostvar = $ + 1
                    player.driftboostcountervar = $ + 1
                else
                    player.cancelboostvar = 0
                    player.driftboostcountervar = 0
                end
            end
            if player.mo.skin == "modernsonic"
                if player.cancelboostvar > 0
                and player.cancelboostvar < 2
                and P_IsObjectOnGround(player.mo)
                and (not (player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL))
                    if player.cmd.sidemove < -25
                        P_InstaThrust(player.mo, player.mo.angle - ANGLE_45, 60*FRACUNIT)
                    elseif player.cmd.sidemove > 25
                        P_InstaThrust(player.mo, player.mo.angle + ANGLE_45, 60*FRACUNIT)
                    elseif player.cmd.sidemove < 25
                    and player.cmd.sidemove > -25
                        return
                    end
                end
                if player.driftboostcountervar > 0
                and player.driftboostcountervar < 2
                and player.driftmodealt
                    if player.cmd.sidemove < -25
                        P_InstaThrust(player.mo, player.mo.angle + ANG20, 60*FRACUNIT)
                    elseif player.cmd.sidemove > 25
                        P_InstaThrust(player.mo, player.mo.angle - ANG20, 60*FRACUNIT)
                    elseif player.cmd.sidemove < 25
                    and player.cmd.sidemove > -25
                        return
                    end
                end
            end
            if player.mo.skin == "adventuresonic"
                if player.cancelboostvar > 0
                and player.cancelboostvar < 2
                and P_IsObjectOnGround(player.mo)
                and (not (player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL))
                    if player.cmd.sidemove < -25
                        P_InstaThrust(player.mo, player.mo.angle - ANGLE_90, 60*FRACUNIT)
                    elseif player.cmd.sidemove > 25
                        P_InstaThrust(player.mo, player.mo.angle + ANGLE_90, 60*FRACUNIT)
                    elseif player.cmd.sidemove < 25
                    and player.cmd.sidemove > -25
                        return
                    end
                end
            end
               
            end
        end
    end
end)

//Main hook
addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo //and player.pflags & ~PF_FULLSTASIS
       
        local mo = player.mo
        local movingfactor = 4*FRACUNIT/11
        local movingfactor2 = 4*FRACUNIT/16
        local movingslowfactor = 0
        local momxyangle = R_PointToAngle2(player.mo.x, player.mo.y, (player.mo.x+player.mo.momx), (player.mo.y+player.mo.momy))
        local fixedmoveang = R_PointToAngle2(0, 0, mo.player.cmd.forwardmove*FRACUNIT, -mo.player.cmd.sidemove*FRACUNIT)
        local vnormalcamera = R_PointToAngle2(0, 0, mo.height - 7*FRACUNIT, mo.momz)
        local vnormalrotcamera = R_PointToAngle2(0, 0, mo.height - 1*FRACUNIT, mo.momz)
        local vspringcamera = R_PointToAngle2(0, 0, mo.height - 25*FRACUNIT, mo.momz)
        local vspringrotcamera = R_PointToAngle2(0, 0, mo.height - 8*FRACUNIT, mo.momz)
        local actualangleturnvar = player.cmd.angleturn<<16
       
        if player.wallcounterc == nil
            player.wallcounterc = false
            end
        if player.normalcamc == nil
            player.normalcamc = false
            end
        if player.hspringcamc == nil
            player.hspringcamc = 0
            end
        if player.speedturnvar == nil
            player.speedturnvar = 0
            end
        if player.isonairvar == nil
            player.isonairvar = 0
            end
        if player.isonairupvar == nil
            player.isonairupvar = 0
            end
        if player.beforeboostprevspd == nil
            player.beforeboostprevspd = 0
            end
        if player.isondriftvar == nil
            player.isondriftvar = 0
            end
        if player.prevpspeed2 == nil
            player.prevpspeed2 = 0
            end
        if player.isdriftingvar == nil
            player.isdriftingvar = 0
            end
        if player.isdriftdustvar == nil
            player.isdriftdustvar = 0
            end
        if player.unldriftcounter == nil
            player.unldriftcounter = 0
            end
        if player.driftjumpvar == nil
            player.driftjumpvar = 0
            end
        if player.driftstomper == nil
            player.driftstomper = 0
            end
        if player.jumperfixer == nil
            player.jumperfixer = 0
            end
        if player.jumperfixer2 == nil
            player.jumperfixer2 = 0
            end
        if player.moveallfactor == nil
            player.moveallfactor = 4*FRACUNIT/9
            end
        if player.aerealboostvar == nil
            player.aerealboostvar = 0
            end
        if player.acceleratorvar == nil
            player.acceleratorvar = 0
            end
        if player.boostanglechangervar == nil
            player.boostanglechanglervar = 0
            end
        if player.analogsens == nil
            player.analogsens = false
            end
        if player.sprungcounter == nil
            player.sprungcounter = 0
            end
        if player.driftmode == nil
            player.driftmode = false
            end
        if player.angleholdervar == nil
            player.angleholdervar = 0
            end
        if player.angleholdercounter == nil
            player.angleholdercounter = 0
            end
        if player.driftmodealt == nil
            player.driftmodealt = false
            end
        if player.airchanges == nil
            player.airchanges = false
            end
        if player.localfriction2 == nil
            player.localfriction2 = 32*FRACUNIT/32
            end
   
    //Checks and counters
if (not (P_IsObjectOnGround(player.mo)))
    player.isonairvar = 10
    player.isonairupvar = $ + 1
else
    player.isonairvar = $ - 1
    player.isonairupvar = 0
end

if not (player.driftmobj2 and player.driftmobj2.valid) then
    player.driftmobj2 = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_GFZFLOWER1)
    player.driftmobj2.flags2 = $1|MF2_DONTDRAW
    P_SetOrigin(player.driftmobj2, player.mo.x, player.mo.y, player.mo.z)
    player.driftmobj2.fuse = 65
elseif (player.driftmobj2 and player.driftmobj2.valid)
    P_SetOrigin(player.driftmobj2, player.mo.x, player.mo.y, player.mo.z)
end

    player.prevpspeed2 = 10

if player.pflags & ~PF_FULLSTASIS
    //Special threat to EVERY character that breaks or have a weird function >:c
    if player.boosting == true
    //or DIDBOOST == true
    or ((player.isondriftvar == 1) and (player.speed > 77*FRACUNIT))
        player.beforeboostprevspd = 11
        player.boostanglechangervar = $ + 1
    else
        player.beforeboostprevspd = $ - 1
        player.boostanglechangervar = 0
    end
        if player.beforeboostprevspd == 11
        or player.beforeboostprevspd == 0
            player.localfriction2 = 32*FRACUNIT/32
        elseif player.beforeboostprevspd < 10
        and player.beforeboostprevspd > 0
            if player.driftmode
                if player.speed > 40*FRACUNIT
                    player.localfriction2 = 28*FRACUNIT/32
                else
                    player.localfriction2 = 32*FRACUNIT/32
                    player.beforeboostprevspd = 0
                end
            else
                player.localfriction2 = 29*FRACUNIT/32
            end
        end
            if player.cmd.forwardmove == 0
            and ((player.beforeboostprevspd < 10) or (player.beforeboostprevspd > 0))
                player.localfriction2 = 29*FRACUNIT/32
            elseif ((player.cmd.forwardmove ~= 0) or (player.cmd.sidemove ~= 0))
            and ((player.beforeboostprevspd == 11) or (player.beforeboostprevspd <= 0))
                player.localfriction2 = 32*FRACUNIT/32
            end
           
    if player.mo.skin == "modernsonic"
        if player.boosting == false
            and player.speed > 42*FRACUNIT
            and P_IsObjectOnGround(player.mo)
            and player.beforeboostprevspd <= 0
            and not ((player.powers[pw_sneakers]) or (player.powers[pw_super]))
                player.localfriction2 = 29*FRACUNIT/32
            //end
        end
    end
   
    if player.mo.skin == "adventuresonic"
        if mo.state == S_PLAY_ROLL
        or ((mo.state == S_PLAY_SPINDASH) and (player.isondriftvar == 0))
        and P_IsObjectOnGround(player.mo)
            player.hspringcamc = $ + 1
        else
            player.hspringcamc = 0
        end
    end
   
    if (not (P_IsObjectOnGround(player.mo)))
        if player.airboost == true
            player.aerealboostvar = $ + 1
        else
            player.aerealboostvar = 0
        end
        if player.aerealboostvar == 1
            mo.angle = momxyangle
            player.drawangle = mo.angle
        end
    end
   
    if player.noxmomchar
    and player.mo.skin == "modernsonic"
        player.noxmomchar = 2
    end
   
    if player.cmd.forwardmove < -47
        mo.friction = 30*FRACUNIT/32
    end
end  

   
    //Drift part
    if player.mo and player.mo.valid
    and player.pflags & ~PF_FULLSTASIS
    and player.pflags & ~PF_SLIDING
    and not (player.mo.flags2 & MF2_TWOD)
        if ((player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL) or ((player.cmd.buttons & BT_SPIN) and player.mo.skin ~= "adventuresonic" and player.driftmode))
        //and ((((player.cmd.sidemove > 20) or (player.cmd.sidemove < -20)) and (player.analogsens == true)) or (((player.cmd.sidemove > 15) or (player.cmd.sidemove < -15)) and (player.analogsens == false)) or (((player.cmd.sidemove > 15) or (player.cmd.sidemove < -15)) and (player.analogsens == nil)))
        and P_IsObjectOnGround(player.mo)
        and ((player.cmd.sidemove > 10) or (player.cmd.sidemove < -10))
        and P_PlayerInPain(player) == false
        and player.speed > 15*FRACUNIT
            if player.mo.skin == "modernsonic"
            //and (not (player.cmd.buttons & BT_SPIN))
                if player.boosting == true
                    mo.angle = momxyangle
                    if player.driftmodealt
                        mo.movefactor = 6*FRACUNIT/8
                    end
                    //player.localfriction2 = 23*FRACUNIT/32
                    player.isondriftvar = 1
                    player.unldriftcounter = $ + 1
                elseif player.boosting == false
                    mo.angle = momxyangle
                    mo.movefactor = 3*FRACUNIT/5
                    //player.localfriction2 = 32*FRACUNIT/32
                    player.isondriftvar = 1
                    player.unldriftcounter = $ + 1
                end
            else
                mo.state = S_PLAY_ALLDRIFT
                player.isdriftingvar = $ + 1
                player.isdriftdustvar = $ + 1
                player.unldriftcounter = $ + 1
                    if player.isdriftingvar > 6
                        S_StartSound(player.driftmobj2, sfx_drft2)
                    end
                    if player.isdriftdustvar == 2
                        local dust1 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust1.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust1.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust1.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust1.destscale = FRACUNIT/2
                           
                        local dust2 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust2.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust2.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust2.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust2.destscale = FRACUNIT/2
                           
                        local dust3 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust3.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust3.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust3.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust3.destscale = FRACUNIT/2
                           
                        local dust4 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust4.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust4.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust4.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust4.destscale = FRACUNIT/2
                           
                        local dust5 = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-10, 10) * FRACUNIT, P_RandomRange(-10, 10) * FRACUNIT, 0, MT_SPINDUST)                          
                        dust5.momx = P_RandomRange(-4, 4)*FRACUNIT
                        dust5.momy = P_RandomRange(-4, 4)*FRACUNIT
                        dust5.momz = P_RandomRange(0, 4)*FRACUNIT
                        dust5.destscale = FRACUNIT/2
                    end
                    if player.isdriftingvar >= 7
                        player.isdriftingvar = 0
                    end
                    if player.isdriftdustvar > 2
                        player.isdriftdustvar = 0
                    end
                mo.angle = momxyangle
                player.drawangle = momxyangle
                //player.localfriction2 = 32*FRACUNIT/32
                if player.speed < 70*FRACUNIT
                    mo.movefactor = 3*FRACUNIT/5
                end
                player.isondriftvar = 1
                if player.pflags & ~PF_SPINNING
                    player.pflags = $1 & ~PF_SPINNING
                end
            end
            mo.friction = player.localfriction2
        else
            player.isondriftvar = 0
            S_StopSound(player.driftmobj2)
        end
    end
   
    if player.driftmode
        if player.isondriftvar == 1
            UnleashedDrift(mo)
            if player.speed < 39*FRACUNIT
            and player.speed > 1*FRACUNIT
                mo.friction = 34*FRACUNIT/32
            end
            if player.speed < 46*FRACUNIT
            and player.speed > 39*FRACUNIT
                mo.movefactor = 3*FRACUNIT/7
                mo.friction = 32*FRACUNIT/32
            end
            if player.speed < 70*FRACUNIT
            and player.speed > 46*FRACUNIT
                mo.movefactor = 3*FRACUNIT/9
                mo.friction = 31*FRACUNIT/32
            end
            if player.speed > 70*FRACUNIT
            and player.speed < 86*FRACUNIT
                mo.movefactor = 0
            elseif player.speed > 86*FRACUNIT
            and player.speed < 96*FRACUNIT
                mo.movefactor = 0
            elseif player.speed > 96*FRACUNIT
                mo.movefactor = 0
            elseif player.mo.skin == "modernsonic"
            and player.boosting == true
                mo.movefactor = 0
                P_Thrust(player.mo, mo.angle, 12*FRACUNIT)
            end
            if player.speed > 119*mo.scale*1
                mo.friction = 32*FRACUNIT/32
            end
        end
    elseif player.driftmodealt
        if (not ((player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL)))
            player.driftjumpvar = 0
            player.jumperfixer = 0
        else
            player.jumperfixer = $ + 1
        end
        if player.jumperfixer == 1
            player.jumperfixer2 = 10
        else
            player.jumperfixer2 = $ - 1
        end
        if player.jumperfixer2 > 0
            player.driftstomper = $ + 1
        else
            player.driftstomper = 0
        end
        if player.cmd.buttons & BT_JUMP
        or player.lastbuttons & BT_JUMP
            player.driftstomper = 0
        end
        if player.isondriftvar == 1
            UnleashedDrift(mo)
            if player.speed < 39*FRACUNIT
            and player.speed > 1*FRACUNIT
                mo.friction = 34*FRACUNIT/32
            end
            if player.speed > 39*FRACUNIT
            and player.speed < 70*FRACUNIT
                mo.friction = 30*FRACUNIT/32
            end
            player.driftjumpvar = $ + 1
            if player.driftjumpvar == 1
                //P_DoJump(player, (true))
                P_SetObjectMomZ(player.mo, 3*FRACUNIT)
                mo.state = S_PLAY_DRIFTJUMP
                if player.mo.skin == "modernsonic"
                    S_StartSound(player.mo, sfx_mjump)
                else
                    S_StartSound(player.mo, sfx_jump)
                end
            end
        end
        //if player.cmd.buttons & BT_CUSTOM2
        if player.driftstomper == 8
        and player.isonairupvar < 12
        and P_PlayerInPain(player) == false
        and mo.state ~= S_PLAY_SPRING
            //player.mo.momz = FixedMul(-50*FRACUNIT, mo.scale)
            P_SetObjectMomZ(player.mo, FixedMul(-30*FRACUNIT, mo.scale), true)
            //mo.movefactor = 1*FRACUNIT/12
        end
        if ((P_IsObjectOnGround(player.mo)) and (player.driftstomper > 9))
            player.driftstomper = 11
        end
        if player.driftstomper == 9
            player.isdriftingvar = 7
            player.driftsens = 7
        end
    else
        if player.isondriftvar == 1
            SimpleDrift(mo)
            if player.cmd.buttons & BT_SPIN
                if player.speed < 55*FRACUNIT
                and player.mo.skin ~= "adventuresonic"
                    mo.movefactor = 3*FRACUNIT/5
                    player.localfriction2 = 32*FRACUNIT/32
                else
                    mo.movefactor = 6*FRACUNIT/8
                    player.localfriction2 = 23*FRACUNIT/32
                end
            else
                mo.movefactor = 3*FRACUNIT/5
                player.localfriction2 = 32*FRACUNIT/32
            end
        end
    end
   
    //Air Drag
    //For characters who doesn't have it
    if player.airchanges == true
    and player.pflags & ~PF_FULLSTASIS
        //if (not (P_IsObjectOnGround(player.mo)))
        if player.pflags & PF_JUMPED
        //and player.mo.eflags & ~MFE_ONGROUND
            //if player.mo.skin ~= "modernsonic"
            if player.mo.skin ~= "adventuresonic"
                if player.speed > 30*FRACUNIT
                and player.speed < 62*FRACUNIT
                    mo.momx = FixedDiv(FixedMul($, 96), 99)
                    mo.momy = FixedDiv(FixedMul($, 96), 99)
                elseif player.speed > 62*FRACUNIT
                    mo.momx = FixedDiv(FixedMul($, 96), 100)
                    mo.momy = FixedDiv(FixedMul($, 96), 100)
                end
                if player.stomping == true
                    if player.speed > 0
                        mo.momx = FixedDiv(FixedMul($, 96), 102)
                        mo.momy = FixedDiv(FixedMul($, 96), 102)
                    end
                end
            end
        end
       
        //SRB2 needs better checks for things like this
        if mo.eflags & MFE_SPRUNG
            player.sprungcounter = 45
        else
            player.sprungcounter = $ - 1
        end
   
        //Higher gravity and higher jumps
        //Only for specific things
        if player.mo.flags & ~MF_NOGRAVITY
        and player.pflags & ~PF_FULLSTASIS
        and player.pflags & PF_JUMPED
        //and player.pflags & PF_JUMPDOWN
        and mo.eflags & ~MFE_UNDERWATER
        and player.sprungcounter <= 0    --SRB2 really needs better checks for things like this -_-
        and P_PlayerInPain(player) == false
        and abs(mo.momz)
            player.mo.momz = $ + FixedMul(P_GetMobjGravity(player.mo), 6*FRACUNIT/12)
        end
        if player.jumpfactor == skins[player.mo.skin].jumpfactor
            player.jumpfactor = FixedMul($, 7*FRACUNIT / 5)
        end
    end
   
        //Insert here rail grind special threat to make it more functional lol
        //if mo.state == S_PLAYER_GRINDING
        if player.railthistic ~= nil
        and player.rail ~= nil
        and player.railthistic == true
        and player.rail == line
        and player.speed > 4*FRACUNIT
        and player.pflags & ~PF_FULLSTASIS
            mo.angle = momxyangle
            player.drawangle = momxyangle
            player.localfriction2 = 29*FRACUNIT/32
        end
           
        if player.isonairvar > 10
            player.isonairvar = 10
            end
        if player.sprungcounter < 0
            player.sprungcounter = 0
            end
        if player.jumperfixer2 < 0
            player.jumperfixer2 = 0
            end
        if player.driftjumpvar > 15
            player.driftjumpvar = 15
            end
        if player.cancelboostvar > 10
            player.cancelboostvar = 10
            end
        if player.aerealboostvar > 10
            player.aerealboostvar = 10
            end
        end
    end
end)

addHook("PlayerSpawn", function(p)
    if io and p == consoleplayer and p.analogsens == nil
        local file = io.openlocal("client/analogsens.dat")
        if file
            local string = file:read("*a")
            if string == "1" or string == "true" or string == "gens" or string == "unwiished" or string == "on"
                COM_BufInsertText(p, "analogsens on")
            elseif string == "0" or string == "false" or string == "vanilla" or string == "off"
                COM_BufInsertText(p, "analogsens off")
            elseif string == nil
                COM_BufInsertText(p, "analogsens off")
            end
            file:close()
        else
            COM_BufInsertText(p, "analogsens on")
        end
    end
end)

addHook("PlayerSpawn", function(p)
    if io and p == consoleplayer and p.driftmode == nil
        local file = io.openlocal("client/driftmode.dat")
        if file
            local string = file:read("*a")
            if string == "1" or string == "true" or string == "unleashed" or string == "unwiished" or string == "on"
                COM_BufInsertText(p, "driftmode on")
            elseif string == "0" or string == "false" or string == "off"
                COM_BufInsertText(p, "driftmode off")
            elseif string == "2" or string == "alt" or string == "fixed" or string == "gens"
                COM_BufInsertText(p, "driftmode alt")
            elseif string == nil
                COM_BufInsertText(p, "driftmode on")
            end
            file:close()
        else
            COM_BufInsertText(p, "driftmode on")
        end
    end
end)

addHook("PlayerSpawn", function(p)
    if io and p == consoleplayer and p.airchanges == nil
        local file = io.openlocal("client/airchanges.dat")
        if file
            local string = file:read("*a")
            if string == "1" or string == "true" or string == "on"
                COM_BufInsertText(p, "airchanges on")
            elseif string == "0" or string == "false" or string == "off"
                COM_BufInsertText(p, "airchanges off")
            elseif string == nil
                COM_BufInsertText(p, "airchanges off")
            end
            file:close()
        else
            COM_BufInsertText(p, "airchanges on")
        end
    end
end)

addHook("PostThinkFrame", do
    for player in players.iterate
        if player.mo //and player.pflags & ~PF_FULLSTASIS
       
    local mo = player.mo
    local fixedmove = R_PointToAngle2(0, 0, mo.player.cmd.forwardmove*FRACUNIT, -mo.player.cmd.sidemove*FRACUNIT)
    local angle = R_PointToAngle2(mo.x, mo.y, (mo.x+mo.momx), (mo.y+mo.momy))
    local inputangle = angle + fixedmove
    local angleo50 = ANG64h - ANG10 - ANG1
    local angleo51 = ANG64h - ANG10 - ANG2 - ANG1 - ANG1 - ANG1
    local diparate = 1 + 1/4
   
    if player.momentumkillercounter == nil
        player.momentumkillercounter = 0
        end
    if player.momentumkillercounter2 == nil
        player.momentumkillercounter2 = 0
        end
    if player.momentumkillervar == nil
        player.momentumkillervar = 0
        end
   
        if (not (P_IsObjectOnGround(player.mo)))
        and player.pflags & ~PF_FULLSTASIS
            player.wallcounterc = false
        end
            if player.mo.skin ~= "adventuresonic"
            and player.mo.skin ~= "modernsonic"
            and player.pflags & ~PF_FULLSTASIS
                MomentumLimiter(mo,svr)
                if player.speed > 77*mo.scale*1
                    if player.isondriftvar == 0
                    and player.mo.skin ~= "modernsonic" --Stupid fail fix
                    and player.pflags & ~PF_FULLSTASIS
                        if player.cmd.sidemove > 14
                        or player.cmd.sidemove < -14
                            mo.friction = 30*FRACUNIT/32
                            mo.movefactor = 1*FRACUNIT/4
                        else
                            mo.friction = 32*FRACUNIT/32
                            mo.movefactor = 0
                        end
                    end
                end
            end
           
        if player.mo.skin == "modernsonic"
        and player.pflags & ~PF_FULLSTASIS
            if player.driftjumpvar > 0
            and (not (P_IsObjectOnGround(player.mo)))
            and (not (P_PlayerInPain(player)))
                if player.boosting == true
                    if player.mo.state ~= S_PLAY_DRIFTJUMP
                        mo.state = S_PLAY_DRIFTJUMP
                    end
                end
            end
        end
       
            /*if MomentumLimiter(mo,svr) == true
                player.momentumkillercounter = $ + 1
            else
                player.momentumkillercounter = 0
            end
            if player.momentumkillercounter == 1
                player.momentumkillercounter2 = 18
            else
                player.momentumkillercounter2 = $ - 1
            end*/
               
                //Momentum killer
                //I hate mom mods -_-
                /*insert momentum actual killer here*/
               
            //if ((player.cmd.buttons & BT_ATTACK) or (player.cmd.buttons & BT_FIRENORMAL) or (player.cmd.buttons & BT_SPIN))
            if player.mo.state == S_PLAY_ALLDRIFT and player.pflags & ~PF_FULLSTASIS
            or ((player.isondriftvar == 1) and (player.mo.state == S_PLAY_SPINDASH) and (player.mo.skin == "modernsonic"))
                if player.cmd.sidemove < 0
                    player.drawangle = $ + ANG30
                elseif player.cmd.sidemove > 0
                    player.drawangle = $ - ANG30
                end
            end
        end
    end
end)
It works, if you don't mind the error message that pops up in the console. :oh: I also like how this drift works so I decided to try and rip it out without the unleashed gameplay changes.
 

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

Back
Top