Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.79 KB | None | 0 0
  1. --designed to run at gamespeed 1
  2. --recommend running at uncapped framerate to speedup death animation
  3. --automatically makes the checkpoint the script will revert to so dw about that
  4. --hold H in game to run the script after executing this code
  5. --turn on your flashlight to end the script
  6.  
  7.  
  8. incrementer = 0.001 -- adjust this for how far to turn between checks
  9.                      -- set to a negative number if you want to check left to right
  10.                      -- for reference, moving your mouse 1 pixel to the side turns you about 0.001 in these units
  11.                      -- doing a 90 degree turn is half pi (~1.571) in these units
  12.                      -- a single subpixel (smallest possible turn) is about 0.0000005 of these units
  13.  
  14.  
  15.                      -- don't adjust these unless you're having issues
  16. anglewaitsetting = 10 -- adjust for angle wait
  17. walkwaitsetting = 120 -- how long in centiseconds you expect the teleport to happen after the start of movement inputs
  18.  
  19. --variable initialization/reset
  20. jumpflag = false
  21. waitingtostart = true
  22. startcheck = false
  23. walkingflag = false
  24. waitforangle = false
  25. readytowalk = false
  26. waitingtorevert = false
  27. jumpingdone = false
  28. walkingdone = false
  29. print("hold H to start")
  30.  
  31. local timer = createTimer(getMainForm())
  32. timer.Interval = 10
  33. timer.OnTimer = function(timer)
  34.  
  35.  
  36. currentflashlight = readFloat("[_player]+344")
  37. if currentflashlight < 1 then
  38. DoneState = true
  39. else
  40. DoneState = false
  41. end
  42.  
  43. if DoneState == true then
  44.     currentvertangle = readFloat (0x402AD4B8)
  45.     print ("vertangle up to: ", currentvertangle)
  46.     writeBytes (0x006B1640, 0)
  47.     timer.destroy()
  48. end
  49.  
  50. --main logic goes here
  51.  
  52.  
  53.  
  54.  
  55. if waitingtostart then
  56.  
  57. currentH = readBytes(0x006B1652, 1)
  58. if currentH > 100 then
  59. waitingtostart = false
  60. end
  61. end
  62.  
  63.  
  64. if not startcheck and not waitingtostart then
  65.     playerstartx = readFloat ("[_player]+5C")
  66.     playerstarty = readFloat ("[_player]+60")
  67.     playerstartvertangle = readFloat (0x402AD4B8)
  68.     startcheck = true
  69.     iterationindex = 0
  70.     print ("startchecking")
  71.     readytowalk = true
  72.     starttick = readInteger(0x006F1D8C)
  73.     writeBytes(0x0071973F, 1) -- makes checkpoint
  74. end
  75.  
  76.  
  77. if readytowalk then
  78.     iterationindex = iterationindex + incrementer
  79.     --print ("setting angle")
  80.     writeFloat (0x402AD4B8, (playerstartvertangle + iterationindex))
  81.     waitforangle = true
  82.     waitforanglecount = 0
  83.     readytowalk = false
  84.     jumpflag = false
  85. end
  86.  
  87.  
  88.     if waitforangle and (waitforanglecount == anglewaitsetting or waitforanglecount > anglewaitsetting) then
  89.     currenttick = readInteger(0x006F1D8C)
  90.  
  91.  
  92.     if currenttick > (starttick + 21) and not walkingdone then -- adjust the "21" here to change which tick this input happens
  93.     writeBytes (0x006B1640, 255) -- walk forward
  94. --    print ("walktick", currenttick)
  95.     walkingflag = true
  96.     walkingdone = true
  97.     walkflag = 0
  98.     end
  99.  
  100.     if currenttick > (starttick + 20) and not jumpflag then -- adjust the "20" here to change which tick this input happens. in this example jump happens the tick before walking
  101. --    print ("jumptick", currenttick)
  102.     writeBytes (0x006B1668, 255) --jump
  103.     jumpflag = true
  104.     jumpingdone = true
  105.     end
  106.  
  107.     if walkingdone and jumpingdone then
  108.     waitforangle = false
  109.     end
  110.  end
  111.  
  112.   if waitforangle and waitforanglecount < anglewaitsetting then
  113.     waitforanglecount = waitforanglecount + 1
  114.  end
  115.  
  116.  
  117. if walkingflag and walkflag == walkwaitsetting then
  118.     playerx = readFloat ("[_player]+5C")
  119.     playery = readFloat ("[_player]+60")
  120.     currentvertangle = readFloat (0x402AD4B8)
  121.      xsquared = (math.abs(playerx - playerstartx)) * (math.abs(playerx - playerstartx))
  122.      ysquared = (math.abs(playery - playerstarty)) * (math.abs(playery - playerstarty))
  123.      sumsq = xsquared + ysquared
  124.      totaldist = math.sqrt(sumsq)
  125.    if totaldist > 5 then -- how long should a tele be to bother printing it to console
  126.    print ("tele dist is ", totaldist)
  127.    print ("x dist is ", (playerx - playerstartx))
  128.    print ("y dist is ", (playery - playerstarty))
  129.    print ("vertangle: ", currentvertangle)
  130.    print ("in a row: ", sequence)
  131.    sequence = sequence + 1
  132.    else
  133.    sequence = 0
  134.    end
  135. writeFloat ("[_player]+70", -1)
  136. writeBytes (0x006B1640, 0) -- reset walk forward
  137. writeBytes (0x006B1668, 0) -- reset jump
  138. walkingflag = false
  139. readytowalk = false
  140. jumpflag = false
  141. jumpingdone = false
  142. walkingdone = false
  143. waitingtorevert = true
  144. revertwait = 0
  145. --print("killing")
  146. end
  147.  
  148. if walkingflag and walkflag < walkwaitsetting then
  149. walkflag = walkflag + 1
  150. end
  151.  
  152.  
  153. if waitingtorevert then
  154. playervelocity = readFloat ("[_player]+70")
  155. playerhealth = readFloat ("[_player]+E0")
  156. if playerhealth > 0 and playervelocity > -0.5 then
  157. waitingtorevert = false
  158. readytowalk = true
  159. end
  160. end
  161.  
  162.  
  163.  
  164. --main logic ends here
  165.  
  166. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement