Advertisement
Guest User

Oshtoby's Unfinished Wall Run Code

a guest
Jun 23rd, 2024
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.44 KB | Gaming | 0 0
  1. addHook("PreThinkFrame", function()
  2. for player in players.iterate
  3. if player.jointime < 1 then
  4. player.oshStoreX = player.mo.x
  5. player.oshStoreY = player.mo.y
  6. player.oshStoreZ = player.mo.floorz
  7. player.oshMomXY = FRACUNIT
  8. player.oshRunState = 0
  9. player.oshOnGround = 0
  10. else
  11. player.oshStoreX = player.mo.x
  12. player.oshStoreY = player.mo.y
  13. player.oshStoreZ = player.mo.floorz
  14. player.cmd.forwardmove = $*player.oshCeilingValue
  15. player.cmd.sidemove = $*player.oshCeilingValue
  16. player.oshStickForce = FixedSqrt(((player.cmd.forwardmove*player.cmd.forwardmove)+(player.cmd.sidemove*player.cmd.sidemove))*FRACUNIT)
  17. player.oshStickAngle = R_PointToAngle2(0,0,player.cmd.sidemove*FRACUNIT,player.cmd.forwardmove*FRACUNIT)
  18. player.oshCamStick=camera.angle + R_PointToAngle2(0,0,player.cmd.sidemove*FRACUNIT,player.cmd.forwardmove*FRACUNIT)-ANGLE_90
  19. end
  20. end
  21. end)
  22.  
  23. addHook("PlayerThink", function(player)
  24. if player.jointime < 1 then
  25. player.oshMoSlope = FixedAngle(0)
  26. //player.oshTotMom = FixedSqrt(FixedMul(player.mo.momx,player.mo.momx)+FixedMul(player.mo.momy,player.mo.momy)+FixedMul(player.mo.momz,player.mo.momz))
  27. player.oshMomXY = FixedSqrt(FixedMul(player.mo.momx,player.mo.momx)+FixedMul(player.mo.momy,player.mo.momy))
  28. player.oshWallAngle = FixedAngle(0)
  29. player.oshLineToStickTo=-1
  30. player.oshSideToStickTo=-1
  31. player.oshRunState = 0
  32. player.oshWallSpeed = FRACUNIT
  33. player.oshWallFriction = FRACUNIT
  34. player.oshTopSpeed = player.normalspeed
  35. player.oshWallMomX = FRACUNIT
  36. player.oshWallMomY = FRACUNIT
  37. player.oshWallMomZ = FRACUNIT
  38. player.oshCurrentState = 0
  39. player.oshDefaultGrav=P_MobjFlip(player.mo)
  40. player.oshHitGroundSpeed=FRACUNIT
  41. player.oshWallAngleCache=FixedAngle(0)
  42. player.oshGroundTimer = 2
  43. player.oshCeilingValue=1
  44. player.oshOnGroundC=0
  45. else
  46. --SET GENERAL VARIABLES--
  47. player.oshTotMom = FixedSqrt(FixedMul(player.mo.momx,player.mo.momx)+FixedMul(player.mo.momy,player.mo.momy)+FixedMul(player.mo.momz,player.mo.momz))
  48. player.oshMomXY = FixedSqrt(FixedMul(player.mo.momx,player.mo.momx)+FixedMul(player.mo.momy,player.mo.momy))
  49. player.oshAcceleration = ((FixedInt((player.thrustfactor * (player.accelstart+(player.oshWallSpeed>>FRACBITS)*player.acceleration))<<FRACBITS)*FixedInt(player.oshStickForce))/50)*2
  50. if player.powers[pw_sneakers] <= 0 and player.oshTopSpeed ~= player.oshNormSpeed then
  51. player.oshTopSpeed = player.normalspeed
  52. elseif player.powers[pw_sneakers] > 0 and player.oshTopSpeed ~= FixedDiv(FixedMul(player.oshNormSpeed,166*FRACUNIT),100*FRACUNIT) then
  53. player.oshTopSpeed = FixedDiv(FixedMul(player.normalspeed,166*FRACUNIT),100*FRACUNIT)
  54. end
  55. --END OF SET GENERAL VARIABLES--
  56. --DETECT IF SHOULD BE IN AIR--
  57. if player.oshRunState == 2 then
  58. player.oshOnGround = 1
  59. elseif P_MobjFlip(player.mo)==1 then --If Gravity is normal--
  60. if player.mo.momz > 0 and player.mo.standingslope == nil then
  61. player.oshOnGround = 0
  62. elseif FixedInt(player.mo.z)-FixedInt(player.mo.floorz) > 10 and player.mo.standingslope == nil then
  63. player.oshOnGround = 0
  64. elseif P_IsObjectOnGround(player.mo) then
  65. player.oshOnGround = 1
  66. elseif player.mo.standingslope ~= nil
  67. player.oshOnGround = 1
  68. end
  69. else --If Gravity is flipped--
  70. if player.mo.momz < 0 and player.mo.standingslope == nil then
  71. player.oshOnGround = 0
  72. elseif FixedInt(player.mo.ceilingz)-FixedInt(player.mo.height)-FixedInt(player.mo.z) > 10 and player.mo.standingslope == nil then
  73. player.oshOnGround = 0
  74. elseif P_IsObjectOnGround(player.mo) then
  75. player.oshOnGround = 1
  76. elseif player.mo.standingslope ~= nil
  77. player.oshOnGround = 1
  78. end
  79. end
  80. --END OF DETECT IF SHOULD BE IN AIR--
  81. --IGNORE GROUND UPHILL SLOPES PART 1--
  82. if P_MobjFlip(player.mo)==1 then --If Gravity is normal--
  83. print ("Down")
  84. if FixedInt(player.oshMomXY)>0 then
  85. player.oshMoAngle = R_PointToAngle2(0,0,player.mo.momx,player.mo.momy)
  86. player.oshMoSlope = R_PointToAngle2(0,P_FloorzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_FloorzAtPos(player.mo.x+FixedMul(player.mo.radius,cos(player.oshMoAngle)), player.mo.y+FixedMul(player.mo.radius,sin(player.oshMoAngle)), player.mo.z+player.mo.height, player.mo.height))
  87. else
  88. player.oshMoAngle = player.mo.angle
  89. player.oshMoSlope = R_PointToAngle2(0,P_FloorzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_FloorzAtPos(player.mo.x+FixedMul(player.mo.radius,cos(player.oshMoAngle)), player.mo.y+FixedMul(player.mo.radius,sin(player.oshMoAngle)), player.mo.z+player.mo.height, player.mo.height))
  90. end
  91. player.oshSlopeX = R_PointToAngle2(0,P_FloorzAtPos(player.mo.x-FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_FloorzAtPos(player.mo.x+FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.y,player.mo.z,player.mo.height))
  92. player.oshSlopeY = R_PointToAngle2(0,P_FloorzAtPos(player.mo.x,player.mo.y-FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.z,player.mo.height),player.mo.radius,P_FloorzAtPos(player.mo.x,player.mo.y+FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.z,player.mo.height))
  93. if player.oshOnGround == 1 and FixedInt(AngleFixed(player.oshMoSlope)) < 180 and player.oshRunState ~= 2 then
  94. player.mo.flags = $|MF_NOGRAVITY
  95. player.mo.z = player.mo.floorz
  96. elseif player.oshOnGround == 0 then
  97. player.mo.flags = $ & ~MF_NOGRAVITY
  98. end
  99. else --If Gravity is flipped--
  100. print ("Up")
  101. if FixedInt(player.oshMomXY)>0 then
  102. player.oshMoAngle = R_PointToAngle2(0,0,player.mo.momx,player.mo.momy)
  103. player.oshMoSlope = R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_CeilingzAtPos(player.mo.x+FixedMul(player.mo.radius,cos(player.oshMoAngle)), player.mo.y+FixedMul(player.mo.radius,sin(player.oshMoAngle)), player.mo.z, player.mo.height))
  104. else
  105. player.oshMoAngle = player.mo.angle
  106. player.oshMoSlope = R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_CeilingzAtPos(player.mo.x+FixedMul(player.mo.radius,cos(player.oshMoAngle)), player.mo.y+FixedMul(player.mo.radius,sin(player.oshMoAngle)), player.mo.z, player.mo.height))
  107. end
  108. player.oshSlopeX = R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x-FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_CeilingzAtPos(player.mo.x+FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.y,player.mo.z,player.mo.height))
  109. player.oshSlopeY = R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x,player.mo.y-FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.z,player.mo.height),player.mo.radius,P_CeilingzAtPos(player.mo.x,player.mo.y+FixedDiv(player.mo.radius, 2*FRACUNIT),player.mo.z,player.mo.height))
  110. if player.oshOnGround == 1 and FixedInt(AngleFixed(player.oshMoSlope)) > 180 and player.oshRunState ~= 2 then
  111. player.mo.flags = $|MF_NOGRAVITY
  112. player.mo.z = player.mo.ceilingz-player.mo.height
  113. elseif player.oshOnGround == 0 then
  114. player.mo.flags = $ & ~MF_NOGRAVITY
  115. end
  116. end
  117. --END OF IGNORE GROUND UPHILL SLOPES PART 1--
  118. --GETTING LINE TO STICK TO--
  119. if player.lastlinehit > -1 and player.climbing==0 then
  120. player.oshLineToStickTo=player.lastlinehit
  121. player.oshSideToStickTo=player.lastsidehit
  122. if lines[player.oshLineToStickTo].frontside == sides[player.oshSideToStickTo] then
  123. player.oshWallAngle = R_PointToAngle2(lines[player.oshLineToStickTo].v1.x,lines[player.oshLineToStickTo].v1.y,lines[player.oshLineToStickTo].v2.x,lines[player.oshLineToStickTo].v2.y)
  124. elseif lines[player.oshLineToStickTo].backside == sides[player.oshSideToStickTo] then
  125. player.oshWallAngle = R_PointToAngle2(lines[player.oshLineToStickTo].v2.x,lines[player.oshLineToStickTo].v2.y,lines[player.oshLineToStickTo].v1.x,lines[player.oshLineToStickTo].v1.y)
  126. end
  127. player.oshToWallSlope = ANGLE_180 - R_PointToAngle2(10*FRACUNIT,P_FloorzAtPos(player.mo.x-FixedMul(10*FRACUNIT,cos(player.oshWallAngle+ANGLE_90)), player.mo.y-FixedMul(10*FRACUNIT,sin(player.oshWallAngle+ANGLE_90)), player.mo.z+player.mo.height, player.mo.height),0,P_FloorzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height))
  128. player.oshCeilWallSlope = R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),10*FRACUNIT, P_CeilingzAtPos(player.mo.x-FixedMul(10*FRACUNIT,cos(player.oshWallAngle+ANGLE_90)),player.mo.y-FixedMul(10*FRACUNIT,sin(player.oshWallAngle+ANGLE_90)),player.mo.z, player.mo.height))
  129. player.lastlinehit, player.lastsidehit = -1, -1
  130. elseif player.lastlinehit == -1 then
  131. player.oshLineToStickTo=-1
  132. player.oshSideToStickTo=-1
  133. end
  134. if player.oshOnGround==1 and player.oshRunState ~= 2 and player.oshLineToStickTo==-1 then
  135. player.oshWallSpeed = player.oshMomXY
  136. elseif player.oshRunState == 2 then
  137. if FixedSqrt(FixedMul(player.oshWallMomX,player.oshWallMomX)+FixedMul(player.oshWallMomY,player.oshWallMomY)+FixedMul(player.oshWallMomZ, player.oshWallMomZ)) > 10*FRACUNIT then
  138. player.oshWallSpeed = FixedSqrt(FixedMul(player.oshWallMomX,player.oshWallMomX)+FixedMul(player.oshWallMomY,player.oshWallMomY)+FixedMul(player.oshWallMomZ,player.oshWallMomZ))
  139. else
  140. player.oshWallSpeed = 10*FRACUNIT
  141. end
  142. end
  143. --END OF GETTING LINE TO STICK TO--
  144. --GET DEFAULT GRAVITY--
  145. if player.oshRunState == 2 and player.oshDefaultGrav== -1 then
  146. player.oshDefaultGrav = -2
  147. elseif player.oshRunState == 2 and player.oshDefaultGrav== 1 then
  148. player.oshDefaultGrav = 2
  149. elseif player.oshRunState ~= 2 and player.oshDefaultGrav == 2*P_MobjFlip(player.mo) then
  150. player.oshDefaultGrav = P_MobjFlip(player.mo)
  151. elseif player.oshRunState ~= 2 and player.oshDefaultGrav == -1*P_MobjFlip(player.mo) then
  152. player.oshDefaultGrav = P_MobjFlip(player.mo)
  153. end
  154. --END OF GET DEFAULT GRAVITY--
  155. --INTO WALL RUN--
  156. if player.oshLineToStickTo ~= -1 and P_MobjFlip(player.mo)==1 and player.powers[pw_justlaunched]== 1 then
  157. P_TeleportMove(player.mo, player.mo.x-FixedMul(10*FRACUNIT,cos(player.oshWallAngle+ANGLE_90)), player.mo.y-FixedMul(10*FRACUNIT,sin(player.oshWallAngle+ANGLE_90)), player.mo.z+(5*FRACUNIT))
  158. player.oshRunState = 2
  159. player.oshWallMomX = FixedMul(cos(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  160. player.oshWallMomY = FixedMul(sin(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  161. player.oshWallMomZ = FixedMul(FixedMul(sin(player.oshWallAngle-player.mo.angle),player.oshWallSpeed),(P_MobjFlip(player.mo))*(-1*FRACUNIT))
  162. player.oshToWallSlope = FixedAngle(0)
  163. elseif player.oshLineToStickTo ~= -1 and P_MobjFlip(player.mo)==-1 and player.powers[pw_justlaunched]== 1 then
  164. P_TeleportMove(player.mo, player.mo.x-FixedMul(10*FRACUNIT,cos(player.oshWallAngle+ANGLE_90)), player.mo.y-FixedMul(10*FRACUNIT,sin(player.oshWallAngle+ANGLE_90)), player.mo.z-(5*FRACUNIT))
  165. player.oshRunState = 2
  166. player.oshWallMomX = FixedMul(cos(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  167. player.oshWallMomY = FixedMul(sin(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  168. player.oshWallMomZ = FixedMul(FixedMul(sin(player.oshWallAngle-player.mo.angle),player.oshWallSpeed),(P_MobjFlip(player.mo))*(-1*FRACUNIT))
  169. player.oshCeilWallSlope = FixedAngle(0)
  170. elseif FixedInt(AngleFixed(player.oshToWallSlope)) > 30 and FixedInt(AngleFixed(player.oshToWallSlope)) < 180 and player.oshLineToStickTo ~= -1 and player.oshRunState == 1 and P_MobjFlip(player.mo)==1 then
  171. P_TeleportMove(player.mo, player.mo.x-FixedMul(10*FRACUNIT,cos(player.oshWallAngle+ANGLE_90)), player.mo.y-FixedMul(10*FRACUNIT,sin(player.oshWallAngle+ANGLE_90)), player.mo.z+(5*FRACUNIT))
  172. player.oshRunState = 2
  173. player.oshWallMomX = FixedMul(cos(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  174. player.oshWallMomY = FixedMul(sin(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  175. player.oshWallMomZ = FixedMul(FixedMul(sin(player.oshWallAngle-player.mo.angle),player.oshWallSpeed),(P_MobjFlip(player.mo))*(-1*FRACUNIT))
  176. player.oshToWallSlope = FixedAngle(0)
  177. elseif FixedInt(AngleFixed(player.oshCeilWallSlope)) > 30 and FixedInt(AngleFixed(player.oshCeilWallSlope)) < 180 and player.oshLineToStickTo ~= -1 and player.oshRunState == 1 and P_MobjFlip(player.mo)==-1 then
  178. P_TeleportMove(player.mo, player.mo.x-FixedMul(10*FRACUNIT,cos(player.oshWallAngle+ANGLE_90)), player.mo.y-FixedMul(10*FRACUNIT,sin(player.oshWallAngle+ANGLE_90)), player.mo.z-(5*FRACUNIT))
  179. player.oshRunState = 2
  180. player.oshWallMomX = FixedMul(cos(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  181. player.oshWallMomY = FixedMul(sin(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.mo.angle),player.oshWallSpeed))
  182. player.oshWallMomZ = FixedMul(FixedMul(sin(player.oshWallAngle-player.mo.angle),player.oshWallSpeed),(P_MobjFlip(player.mo))*(-1*FRACUNIT))
  183. player.oshCeilWallSlope = FixedAngle(0)
  184. elseif player.oshOnGround == 0 and player.oshRunState ~= 2 then
  185. if player.oshDefaultGrav < 0 then
  186. A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,0)
  187. elseif player.oshDefaultGrav > 0 then
  188. A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,1)
  189. end
  190. elseif FixedInt(player.oshTotMom)>=10 and player.oshOnGround == 1 and player.oshRunState ~= 2 then
  191. player.oshWallFriction = player.mo.friction
  192. player.oshRunState = 1
  193. elseif FixedInt(player.oshTotMom)<10 and player.oshRunState ~= 0 and player.oshRunState ~= 2 then
  194. player.oshRunState = 1
  195. elseif player.oshRunState == 2 and P_IsObjectOnGround(player.mo) and P_MobjFlip(player.mo) == 1 and FixedInt(player.oshWallMomZ)<=0 then
  196. player.oshRunState = 1
  197. player.mo.z = P_FloorzAtPos(player.mo.x, player.mo.y, player.mo.z, player.mo.height)
  198. player.oshOnGround = 1
  199. player.mo.momy=FixedMul(cos(R_PointToAngle2(0,P_FloorzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_FloorzAtPos(player.mo.x+FixedMul(player.mo.radius,cos(player.mo.angle)), player.mo.y+FixedMul(player.mo.radius,sin(player.mo.angle)), player.mo.z+player.mo.height, player.mo.height))),FixedMul(sin(player.mo.angle),player.oshWallSpeed))
  200. player.mo.momx=FixedMul(cos(R_PointToAngle2(0,P_FloorzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_FloorzAtPos(player.mo.x+FixedMul(player.mo.radius,cos(player.mo.angle)), player.mo.y+FixedMul(player.mo.radius,sin(player.mo.angle)), player.mo.z+player.mo.height, player.mo.height))),FixedMul(cos(player.mo.angle),player.oshWallSpeed))
  201. player.mo.momz=FixedMul(sin(R_PointToAngle2(0,P_FloorzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_FloorzAtPos(player.mo.x+FixedMul(player.mo.radius,cos(player.mo.angle)), player.mo.y+FixedMul(player.mo.radius,sin(player.mo.angle)), player.mo.z+player.mo.height, player.mo.height))),player.oshWallSpeed)
  202. elseif player.oshRunState == 2 and P_IsObjectOnGround(player.mo) and P_MobjFlip(player.mo) == -1 and FixedInt(player.oshWallMomZ)>=0 then
  203. player.oshOnGround = 1
  204. player.oshRunState = 1
  205. player.mo.z = P_CeilingzAtPos(player.mo.x, player.mo.y, player.mo.z, player.mo.height)-player.mo.height
  206. player.mo.momy=FixedMul(cos(R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_CeilingzAtPos(player.mo.x-FixedMul(player.mo.radius,cos(player.mo.angle)), player.mo.y-FixedMul(player.mo.radius,sin(player.mo.angle)), player.mo.z+player.mo.height, player.mo.height))),FixedMul(sin(player.mo.angle),FixedMul(-1*FRACUNIT,player.oshWallSpeed)))
  207. player.mo.momx=FixedMul(cos(R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_CeilingzAtPos(player.mo.x-FixedMul(player.mo.radius,cos(player.mo.angle)), player.mo.y-FixedMul(player.mo.radius,sin(player.mo.angle)), player.mo.z+player.mo.height, player.mo.height))),FixedMul(cos(player.mo.angle),FixedMul(-1*FRACUNIT,player.oshWallSpeed)))
  208. player.mo.momz=FixedMul(sin(R_PointToAngle2(0,P_CeilingzAtPos(player.mo.x,player.mo.y,player.mo.z,player.mo.height),player.mo.radius,P_CeilingzAtPos(player.mo.x-FixedMul(player.mo.radius,cos(player.mo.angle)), player.mo.y-FixedMul(player.mo.radius,sin(player.mo.angle)), player.mo.z+player.mo.height, player.mo.height))),player.oshWallSpeed)
  209. elseif player.oshRunState ~= 2 and player.oshOnGround == 0 and player.oshRunState ~= 0 then
  210. player.oshRunState = 3
  211. elseif player.oshLineToStickTo==-1 and player.oshRunState == 2 then
  212. player.oshRunState = 3
  213. elseif FixedInt(player.oshTotMom)<10 and player.oshRunState == 2 then
  214. player.oshRunState = 3
  215. A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,(oshDefaultGrav+2)/4)
  216. player.mo.momy=player.oshWallMomY--+FixedMul(sin(player.oshWallAngle+FixedAngle(90*FRACUNIT)),70*FRACUNIT)
  217. player.mo.momx=player.oshWallMomX--+FixedMul(cos(player.oshWallAngle+FixedAngle(90*FRACUNIT)),70*FRACUNIT)
  218. player.mo.momz=player.oshWallMomZ
  219. end
  220. if player.oshRunState == 2 then
  221. player.oshCeilingValue=1
  222. else
  223. player.oshCeilingValue=P_MobjFlip(player.mo)
  224. end
  225. if player.oshRunState == 3 then
  226. if player.oshDefaultGrav < 0 then
  227. A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,0)
  228. elseif player.oshDefaultGrav > 0 then
  229. A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,1)
  230. end
  231. player.oshRunState = 0
  232. end
  233. if player.oshRunState == 0 then
  234. player.oshDefaultGrav=P_MobjFlip(player.mo)
  235. end
  236. --END OF INTO WALL RUN--
  237. --THE WALL CRAWL--
  238. if player.mo and player.mo.valid and player.oshRunState == 2 and player.oshLineToStickTo >= 0 then
  239. print ("--ON THE WALL--")
  240. if player.oshRunState == 2 and player.mo.momz > 0 then
  241. A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,0)
  242. elseif player.oshRunState == 2 and player.mo.momz < 0 then
  243. A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,1)
  244. end
  245. if not P_IsObjectOnGround(player.mo) then
  246. player.oshHitGroundSpeed=player.oshWallSpeed
  247. player.oshWallAngleCache=player.oshWallAngle
  248. end
  249. --SPRITE ROTATION--
  250. if FixedInt(AngleFixed(R_PointToAngle(player.mo.x, player.mo.y)-player.oshWallAngle-FixedAngle(90*FRACUNIT)))>90 and FixedInt(AngleFixed(R_PointToAngle(player.mo.x,player.mo.y)-player.oshWallAngle-FixedAngle(90*FRACUNIT)))<=180 then
  251. player.mo.rollangle = FixedAngle(90*FRACUNIT)
  252. elseif FixedInt(AngleFixed(R_PointToAngle(player.mo.x, player.mo.y)-player.oshWallAngle-FixedAngle(90*FRACUNIT)))<270 and FixedInt(AngleFixed(R_PointToAngle(player.mo.x, player.mo.y)-player.oshWallAngle-FixedAngle(90*FRACUNIT)))>180 then
  253. player.mo.rollangle = ANGLE_270
  254. else
  255. player.mo.rollangle = R_PointToAngle(player.mo.x, player.mo.y)-player.oshWallAngle-FixedAngle(90*FRACUNIT)
  256. end
  257. --END OF SPRITE ROTATION--
  258. player.oshWallMomX = FixedDiv(FixedMul(player.oshWallMomX,29*FRACUNIT),32*FRACUNIT)
  259. player.oshWallMomY = FixedDiv(FixedMul(player.oshWallMomY,29*FRACUNIT),32*FRACUNIT)
  260. player.oshWallMomZ = FixedDiv(FixedMul(player.oshWallMomZ,29*FRACUNIT),32*FRACUNIT)
  261. if player.oshWallSpeed < player.oshTopSpeed and player.oshWallSpeed+FixedDiv(player.oshAcceleration*FRACUNIT,1000*FRACUNIT) < player.oshTopSpeed then
  262. player.oshWallMomX = player.oshWallMomX+FixedMul(cos(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.oshCamStick),FixedDiv(player.oshAcceleration*FRACUNIT,1000*FRACUNIT)))
  263. player.oshWallMomY = player.oshWallMomY+FixedMul(sin(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.oshCamStick),FixedDiv(player.oshAcceleration*FRACUNIT,1000*FRACUNIT)))
  264. player.oshWallMomZ = player.oshWallMomZ-FixedMul(sin(player.oshWallAngle-player.oshCamStick),FixedDiv(player.oshAcceleration*FRACUNIT,1000*FRACUNIT))
  265. elseif player.oshWallSpeed < player.oshTopSpeed and player.oshWallSpeed+FixedDiv(player.oshAcceleration*FRACUNIT,1000*FRACUNIT) == player.oshTopSpeed then
  266. player.oshWallMomX = player.oshWallMomX+FixedMul(cos(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.oshCamStick),player.oshTopSpeed-player.oshWallSpeed))
  267. player.oshWallMomY = player.oshWallMomY+FixedMul(sin(player.oshWallAngle),FixedMul(cos(player.oshWallAngle-player.oshCamStick),player.oshTopSpeed-player.oshWallSpeed))
  268. player.oshWallMomZ = player.oshWallMomZ-FixedMul(sin(player.oshWallAngle-player.oshCamStick),player.oshTopSpeed-player.oshWallSpeed)
  269. end
  270. --SET THE ACTUAL MOMENTUMS--
  271. player.mo.momy=player.oshWallMomY--+FixedMul(sin(player.oshWallAngle+FixedAngle(90*FRACUNIT)),70*FRACUNIT)
  272. player.mo.momx=player.oshWallMomX--+FixedMul(cos(player.oshWallAngle+FixedAngle(90*FRACUNIT)),70*FRACUNIT)
  273. player.mo.momz=player.oshWallMomZ
  274. --END OF SET THE ACTUAL MOMENTUMS--
  275. --STICK TO THE WALL--
  276. player.mo.momx = player.mo.momx+FixedMul(75*FRACUNIT,cos(player.oshWallAngle+ANGLE_90))
  277. player.mo.momy = player.mo.momy+FixedMul(75*FRACUNIT,sin(player.oshWallAngle+ANGLE_90))
  278. --END OF STICK TO THE WALL--
  279. --CHANGING THE STATE--
  280. if player.mo.state ~= 21 and FixedInt(player.runspeed)>player.oshWallSpeed and player.dashmode <= 3*TICRATE then
  281. player.oshCurrentState = 13
  282. end
  283. if player.mo.state ~= 21 and FixedInt(player.runspeed)<=player.oshWallSpeed and player.dashmode <= 3*TICRATE then
  284. player.oshCurrentState = 15
  285. end
  286. if player.mo.state ~= 21 and player.dashmode > 3*TICRATE then
  287. player.oshCurrentState = 16
  288. end
  289. if player.mo.state == 21 then
  290. player.oshCurrentState = 21
  291. end
  292. if player.mo.state ~= 21 and player.oshCurrentState == 21 then
  293. player.oshCurrentState = 13
  294. end
  295. if player.oshRunState == 2 then
  296. player.mo.state = player.oshCurrentState
  297. end
  298. --END OF CHANGING THE STATE
  299. elseif player.oshGroundTimer > 0 then
  300. player.oshGroundTimer = player.oshGroundTimer -1
  301. end
  302. //if player.oshRunState == 2 and player.momz>0 then
  303. // A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,0)
  304. //elseif player.oshRunState == 2 and player.momz<0 then
  305. // A_SetObjectFlags2(player.mo,MF2_OBJECTFLIP,1)
  306. //end
  307. if not P_IsObjectOnGround(player.mo) and player.oshOnGround == 1 and player.oshRunState ~= 0 and player.oshRunState ~= 2 then
  308. if player.mo.state ~= 21 and FixedInt(player.runspeed)>player.oshWallSpeed and player.dashmode <= 3*TICRATE then
  309. player.oshCurrentState = 13
  310. end
  311. if player.mo.state ~= 21 and FixedInt(player.runspeed)<=player.oshWallSpeed and player.dashmode <= 3*TICRATE then
  312. player.oshCurrentState = 15
  313. end
  314. if player.mo.state ~= 21 and player.dashmode > 3*TICRATE then
  315. player.oshCurrentState = 16
  316. end
  317. if player.mo.state == 21 then
  318. player.oshCurrentState = 21
  319. end
  320. if player.mo.state ~= 21 and player.oshCurrentState == 21 then
  321. player.oshCurrentState = 13
  322. end
  323. player.mo.state = player.oshCurrentState
  324. end
  325. --END OF THE WALL CRAWL--
  326. end
  327. end)
  328.  
  329. addHook("PostThinkFrame", function()
  330. for player in players.iterate
  331. if player.jointime < 1 then
  332.  
  333. else
  334. --IGNORE GROUND UPHILL SLOPES PART 2--
  335. if P_MobjFlip(player.mo)==1 then --If Gravity is normal--
  336. if player.mo.momz<=0 and player.oshSlopeThing == 1 then
  337. P_TeleportMove(player.mo,player.oshStoreX+FixedMul((player.mo.x-player.oshStoreX),cos(player.oshSlopeX)),player.oshStoreY+FixedMul((player.mo.y-player.oshStoreY),cos(player.oshSlopeY)),P_FloorzAtPos(player.oshStoreX+FixedMul((player.mo.x-player.oshStoreX),cos(player.oshSlopeX)),player.oshStoreY+FixedMul((player.mo.y-player.oshStoreY),cos(player.oshSlopeY)),player.mo.z+player.mo.height,player.mo.height))
  338. end
  339. else --If Gravity is flipped--
  340. if player.mo.momz>=0 and player.oshSlopeThing == 1 then
  341. P_TeleportMove(player.mo,player.oshStoreX+FixedMul((player.mo.x-player.oshStoreX),cos(player.oshSlopeX)),player.oshStoreY+FixedMul((player.mo.y-player.oshStoreY),cos(player.oshSlopeY)),P_CeilingzAtPos(player.oshStoreX+FixedMul((player.mo.x-player.oshStoreX),cos(player.oshSlopeX)),player.oshStoreY+FixedMul((player.mo.y-player.oshStoreY),cos(player.oshSlopeY)),player.mo.z,player.mo.height))
  342. end
  343. end
  344. --END OF IGNORE GROUND UPHILL SLOPES PART 2--
  345. if player.oshRunState == 2 then
  346. player.mo.state = player.oshCurrentState
  347. end
  348. --PRINTER SECTION--
  349. print ("Total Speed: "..FixedInt(player.oshTotMom))
  350. print ("On Ground: "..player.oshOnGround)
  351. -- print ("Run State: "..player.oshRunState)
  352. print ("Player Z: "..FixedInt(player.mo.z))
  353. print ("Ceiling Z: "..FixedInt(player.mo.ceilingz))
  354. print ("ToWallSlope: "..FixedInt(AngleFixed(player.oshCeilWallSlope)))
  355. --END OF PRINTER SECTION--
  356. end
  357. end
  358. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement