--Air Acceleration --if you're adding this to a character, only include the playerthink code (preferably add it to your current playerthink function), and replace the aaamount variable --with any number around fracunit (65536) --default percentage, default max, default aa value local DEFP,DEFM = 100,655 local DEF = DEFP*DEFM local aaamount = FRACUNIT --network stuff, thanks luigi budd!! local ran = P_RandomFixed() addHook("NetVars",function(net) ran = net($) aaamount = net($) end) addHook("PlayerSpawn", function(player) local path = "client/airacceleration_amount.dat" if splitscreen and player == secondarydisplayplayer path = "client/airacceleration_amount_p2.dat" end player.aaamount = DEF local fi = io.openlocal(path,"r") if fi local data = fi:read("*a") --read whole file if netgame COM_BufInsertText(player,"_aaset "..ran.." "..(data or DEF)) else player.aaamount = tonumber(tonumber(data)~=nil and data or DEF) end --splitscreen fix fi:close() else --make it if it doesn't exist local fi = io.openlocal(path,"w+") if fi fi:write(tostring(DEF)) fi:close() end end end) --sync upon joining COM_AddCommand("_aaset",function(player,sig,value) if tonumber(sig) ~= ran return end if tonumber(value) ~= nil player.aaamount = tonumber(value) end end) addHook("PlayerThink", function(player) local mo = player.mo if player.aadisable player.aadisable = $-1 return end --you can set aadisable to 1 or 2 each tic for a custom character within your lua, in order to disable it --(you can also use this to make custom aa behavior) if not mo or not mo.valid or P_IsObjectOnGround(mo) or (mo.eflags & MFE_JUSTHITFLOOR) or player.powers[pw_tailsfly] or (mo.flags2 & MF2_TWOD) or (maptol & TOL_2D) or player.aaamount == 0 return end if player.exiting or (player.pflags & PF_STASIS) or player.powers[pw_nocontrol] or P_PlayerInPain(player) or player.playerstate ~= PST_LIVE or not (mo.momx or mo.momy) or player.powers[pw_carry] return end if mo.skin == "mario" or mo.skin == "luigi" or mo.skin == "s3sonic" or (mo.skin == "cdsonic" and player.physics) or mo.skin == "elfilin" return end --if you're adding aa to a character, you should remove this condition and add your own local amount = aaamount == -1 and player.aaamount or min(player.aaamount,aaamount) --P_3dMovement from p_user.c translated into lua local super = ((player.powers[pw_super] or player.powers[pw_sneakers]) and 2 or 1) local acceleration = player.accelstart/super + FixedDiv(player.speed,mo.scale)/FU * player.acceleration/super local normalspd = FixedMul(player.normalspeed,mo.scale) local topspeed = (player.powers[pw_super] or player.powers[pw_sneakers]) and 5*normalspd/3 or normalspd if (mo.eflags & (MFE_UNDERWATER|MFE_GOOWATER)) topspeed = $ >> 1 acceleration = $*2/3 end local shift = (player.pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING and 3 or 2 local om = R_PointToDist2(mo.momx,mo.momy,0,0) --old magnitude --now thrust! P_Thrust(mo,R_PointToAngle2(0,0,player.cmd.forwardmove*FU,-player.cmd.sidemove*FU) + (player.cmd.angleturn * FU), FixedMul((abs(player.cmd.forwardmove)+abs(player.cmd.sidemove))*(player.thrustfactor*super*acceleration),FixedMul(mo.scale,amount)) >> shift) local nm = R_PointToDist2(mo.momx,mo.momy,0,0) --new magnitude if nm > topspeed if om > topspeed and nm > om mo.momx, mo.momy = fixmul(fixdiv($1, nm), om), fixmul(fixdiv($2, nm), om) elseif om <= topspeed mo.momx, mo.momy = fixmul(fixdiv($1, nm), topspeed), fixmul(fixdiv($2, nm), topspeed) end end end) local function aaset(player,arg) if player.mo.valid if tonumber(arg)~=nil local a = tonumber(arg) player.aaamount = a*DEFM CONS_Printf(consoleplayer,"Your Air Acceleration value has been set to "+a+"%") if player.aaamount > aaamount CONS_Printf(consoleplayer,"Warning: Value is above airacceleration_limit, falling back to "+aaamount/DEFM+"%") end return true else CONS_Printf(consoleplayer,"airacceleration - Modify how much control you have midair.") CONS_Printf(consoleplayer,"Range: 0% (none) to 100% (full)") CONS_Printf(consoleplayer,"Currently "+player.aaamount/DEFM+"%") end end end COM_AddCommand( "airacceleration", function(player,arg) if aaset(player,arg) and player == consoleplayer local fi = io.openlocal("client/airacceleration_amount.dat","w+") if fi fi:write(player.aaamount) fi:close() end end end ) --player 2 version COM_AddCommand( "airacceleration2", function(player,arg) if aaset(player,arg) local fi = io.openlocal("client/airacceleration_amount_p2.dat","w+") if fi fi:write(player.aaamount) fi:close() end end end ,COM_SPLITSCREEN) COM_AddCommand( "airacceleration_limit", function(player,arg) if tonumber(arg)~=nil if multiplayer or usedCheats local a = tonumber(arg) aaamount = max(a*DEFM, -1) CONS_Printf(player,"Air Acceleration limit has been set to "+a+"%") if aaamount == -1 CONS_Printf(player,"Warning: The limit is now disabled, expect problems.") elseif aaamount > FRACUNIT CONS_Printf(player,"Warning: The limit is now above 100%, expect problems.") end else CONS_Printf(player,"Cheats must be enabled to set this in singleplayer.") end else CONS_Printf(player,"airacceleration_amount - Set the maximum Air Acceleration percentage any player can set.") CONS_Printf(player,"Range: 0% (none) to 100% (full) or more, -1 to disable limit") CONS_Printf(player,"Currently "+aaamount/DEFM+"%") end end ,COM_ADMIN)