Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.67 KB | None | 0 0
  1. addHook("ThinkFrame", do
  2.     for player in players.iterate
  3.     if player.mo
  4. //setting up variables
  5.     //setting up prevz
  6.         if player.mo.prevz == nil
  7.             player.mo.prevz = 0
  8.         end
  9.    
  10.        
  11.     //setting up the check for our real speed
  12.         player.rspeed = R_PointToDist2(0, 0, player.rmomx, player.rmomy)
  13.         //print(player.rspeed/FRACUNIT, "speed", "", "")
  14.    
  15.     //setting up a check for conveyor speed
  16.         player.conveyorspeed = R_PointToDist2(0, 0, player.cmomx, player.cmomy)
  17.         //print(player.conveyorspeed/FRACUNIT, "CSPEED","","")
  18.        
  19.     //setting up default values for everyone to have
  20.         if (player.mo.skin == "sonic")
  21.         or (player.mo.skin == "fsonic")
  22.             player.charability = CA_NONE
  23.             if gametype ~= GT_COOP
  24.                 player.topspeed = 38*FRACUNIT
  25.             else
  26.                 player.topspeed = 34*FRACUNIT
  27.             end
  28.         elseif (player.mo.skin == "tsonic") //Toei breaks counter: 1
  29.             if (player.mo.toeipeel)
  30.                 player.thrustfactor = 0 //Just.... stop.
  31.                 player.jumpfactor = 0
  32.                 player.topspeed = 0
  33.                 player.normalspeed = 0
  34.                 player.mo.momx = 0
  35.                 player.mo.momy = 0
  36.                 player.accelstart = 0
  37.                 player.acceleration = 0
  38.             else
  39.                 player.topspeed = skins[player.mo.skin].normalspeed // LET'S GET MOVING!
  40.                 player.jumpfactor = skins[player.mo.skin].jumpfactor
  41.             end
  42.         else
  43.             player.topspeed = 34*FRACUNIT
  44.         end
  45.         player.maxspeed = 115*FRACUNIT //Because we can't just have Sonic zooming at an out-of-control speed
  46.        
  47.         /*      ~TO DO~
  48.         //Make an options screen to make certain aspects of this WAD togglable, akin to the level select in the Sonic 1/2 mobile ports.
  49.         //Add abilities from other classic games for Sonic such as the Insta-Shield, My version of the Drop Dash script, the Super PeelOut (needs running animations) and possibly with Saph's permission, normal shields replaced with elemental shields.
  50.         //Add support for Axis2D.
  51.         //Possibly add in the air drag mechanic.
  52.         //Possibly nerf slope acceleration in later versions when slopes become more widely used (I.E. closer to 2.2's release).
  53.         */
  54.         if not (player.mo.skin == "peach") //If you're not the exception, you're the rule
  55.         and not (player.mo.skin == "toad")
  56.         and not (player.mo.skin == "samus")
  57.         and not (player.mo.skin == "marisa")
  58.         and not (player.mo.skin == "alice")
  59.         and not (player.mo.skin == "sonicrefancy")
  60.         and not (player.mo.skin == "modernsonic")
  61.         and not (player.mo.skin == "sonicre")
  62.         and not (player.mo.skin == "tailsre")
  63.         and not (player.mo.skin == "knuxre")
  64.         and not (player.mo.skin == "silver")
  65.         and not (player.mo.skin == "kirby")
  66.         and not (player.isclassic == false)
  67.        
  68.     //Here's our base values for everyone, hopefully this is closer to Sonic 2/3's stats
  69.     //KNOWN BUG: Running down ramp sectors will cause them to act like slopes
  70.     //KNOWN BUG: Running on ice when changing sectors will sometimes cause the player to accelerate into infinity.
  71.     //This also happens when running down slopes in Axis2D, I'll have to look at Axis2D's source code to figure out why this happens.
  72.         //Breaking the vanilla speed cap
  73.             if player.rspeed > player.topspeed //If the player is running faster than they can normally
  74.             and not ((player.mo.eflags & MFE_JUSTHITFLOOR) and player.mo.friction != 59392)
  75.             and not (player.mo.eflags & MFE_JUSTHITFLOOR)
  76.             and (player.hasmomentum)
  77.             and not (player.isclassic == false)
  78.             and not (player.mo.skin == "dirk" and player.cmd.buttons & BT_USE)
  79.                 if not (player.powers[pw_sneakers])
  80.                 and not (player.powers[pw_super])
  81.                     if player.rspeed > player.normalspeed //If the player is going faster than their normalspeed
  82.                     and player.rspeed >= player.normalspeed - (6*FRACUNIT)
  83.                     and P_IsObjectOnGround(player.mo) //and the player is on the ground
  84.                         player.normalspeed = $1 + (player.rspeed - player.topspeed) + (6*FRACUNIT)
  85.                     elseif player.rspeed < player.normalspeed - 8*FRACUNIT
  86.                         player.normalspeed = $1 - 5*FRACUNIT
  87.                     end
  88.                 end
  89.             elseif not (player.dashmode)
  90.                 player.normalspeed = player.topspeed
  91.             end
  92.            
  93.         //Fixing slope physics slightly to play better with the new speed cap
  94.             if player.mo.prevz > player.mo.z //if the player is going downhill
  95.             and player.rspeed >= player.topspeed - 6*FRACUNIT //and the player is running as fast as they normally can
  96.             and P_IsObjectOnGround(player.mo) //And the player is on the ground (kinda important)
  97.             and player.rspeed < player.maxspeed //Don't accelerate if we're over max speed, this keeps control managable
  98.             and (player.hasmomentum) //gives us support for other characters to utilize this
  99.             and not (player.isclassic == false) //isclassic enables and disables the entire system
  100.                 player.normalspeed = player.prevnormspd + (((player.mo.prevz - player.mo.z)*2)/(player.normalspeed/FRACUNIT)) //MOAR SPED
  101.             end
  102.            
  103.         //Experimental camera option that adjusts the camera up or down intended to depend on if you're running up or down a slope
  104.         //Sadly, this also ends up messing with the camera when running up and down stairs which is unintended, thus why it defaults to off.
  105.             if (cv_camadjust.value)
  106.                 if not (player.mo.eflags & MFE_JUSTHITFLOOR)
  107.                 and not (maptol & TOL_2D)
  108.                 and P_IsObjectOnGround(player.mo)
  109.                     COM_BufInsertText(player, "cam_height "..20+(((player.mo.prevz-player.mo.z)/FRACUNIT)*3))
  110.                 else
  111.                     COM_BufInsertText(player, "cam_height 20")
  112.                 end
  113.             else
  114.             end
  115.            
  116.            
  117.             if (player.powers[pw_super]) //souped up acceleration for super players
  118.             or (player.mo.skin == "metal_sonic") //metal sonic flies so he should have a bit more acceleration
  119.                 player.thrustfactor = 5
  120.             else
  121.                 player.thrustfactor = 3
  122.             end
  123.            
  124.            
  125.             if not (player.mo.skin == "metal_sonic") //metal sonic does his own thing
  126.                 if not (player.mo.skin == "tsonic") //Toei breaks counter: 2
  127.                     player.runspeed = 24*FRACUNIT
  128.                 end
  129.                 player.accelstart = 178
  130.                 player.acceleration = 48
  131.             end
  132.            
  133.            
  134.             if player.spinitem == MT_THOK //unless you have a unique spintrail, you don't really need one
  135.                 player.spinitem = 0
  136.             end
  137.            
  138.            
  139.             if (player.classicanimations)
  140.                 player.revitem = 0
  141.             end
  142.            
  143.             player.mo.prevz = player.mo.z
  144.             player.prevnormspd = player.normalspeed
  145.            
  146.         //Buffing glide acceleration
  147.             if player.charability == CA_GLIDEANDCLIMB
  148.             and not P_IsObjectOnGround(player.mo)
  149.             and player.pflags & PF_THOKKED
  150.             and not (player.mo.state >= S_PLAY_CLIMB1 and player.mo.state <= S_PLAY_CLIMB5)
  151.                 if player.rspeed <= player.maxspeed/2
  152.                     player.actionspd = $+((player.glidetime^2)/20)
  153.                 end
  154.             elseif not (player.mo.skin == "tsonic") //Toei breaks counter: 3
  155.                 player.actionspd = skins[player.mo.skin].actionspd
  156.             end
  157.         end
  158.     end
  159.     end
  160. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement