Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --designed to run at gamespeed 1
- --recommend running at uncapped framerate to speedup death animation
- --automatically makes the checkpoint the script will revert to so dw about that
- --hold H in game to run the script after executing this code
- --turn on your flashlight to end the script
- incrementer = 0.001 -- adjust this for how far to turn between checks
- -- set to a negative number if you want to check left to right
- -- for reference, moving your mouse 1 pixel to the side turns you about 0.001 in these units
- -- doing a 90 degree turn is half pi (~1.571) in these units
- -- a single subpixel (smallest possible turn) is about 0.0000005 of these units
- -- don't adjust these unless you're having issues
- anglewaitsetting = 10 -- adjust for angle wait
- walkwaitsetting = 120 -- how long in centiseconds you expect the teleport to happen after the start of movement inputs
- --variable initialization/reset
- jumpflag = false
- waitingtostart = true
- startcheck = false
- walkingflag = false
- waitforangle = false
- readytowalk = false
- waitingtorevert = false
- jumpingdone = false
- walkingdone = false
- print("hold H to start")
- local timer = createTimer(getMainForm())
- timer.Interval = 10
- timer.OnTimer = function(timer)
- currentflashlight = readFloat("[_player]+344")
- if currentflashlight < 1 then
- DoneState = true
- else
- DoneState = false
- end
- if DoneState == true then
- currentvertangle = readFloat (0x402AD4B8)
- print ("vertangle up to: ", currentvertangle)
- writeBytes (0x006B1640, 0)
- timer.destroy()
- end
- --main logic goes here
- if waitingtostart then
- currentH = readBytes(0x006B1652, 1)
- if currentH > 100 then
- waitingtostart = false
- end
- end
- if not startcheck and not waitingtostart then
- playerstartx = readFloat ("[_player]+5C")
- playerstarty = readFloat ("[_player]+60")
- playerstartvertangle = readFloat (0x402AD4B8)
- startcheck = true
- iterationindex = 0
- print ("startchecking")
- readytowalk = true
- starttick = readInteger(0x006F1D8C)
- writeBytes(0x0071973F, 1) -- makes checkpoint
- end
- if readytowalk then
- iterationindex = iterationindex + incrementer
- --print ("setting angle")
- writeFloat (0x402AD4B8, (playerstartvertangle + iterationindex))
- waitforangle = true
- waitforanglecount = 0
- readytowalk = false
- jumpflag = false
- end
- if waitforangle and (waitforanglecount == anglewaitsetting or waitforanglecount > anglewaitsetting) then
- currenttick = readInteger(0x006F1D8C)
- if currenttick > (starttick + 21) and not walkingdone then -- adjust the "21" here to change which tick this input happens
- writeBytes (0x006B1640, 255) -- walk forward
- -- print ("walktick", currenttick)
- walkingflag = true
- walkingdone = true
- walkflag = 0
- end
- 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
- -- print ("jumptick", currenttick)
- writeBytes (0x006B1668, 255) --jump
- jumpflag = true
- jumpingdone = true
- end
- if walkingdone and jumpingdone then
- waitforangle = false
- end
- end
- if waitforangle and waitforanglecount < anglewaitsetting then
- waitforanglecount = waitforanglecount + 1
- end
- if walkingflag and walkflag == walkwaitsetting then
- playerx = readFloat ("[_player]+5C")
- playery = readFloat ("[_player]+60")
- currentvertangle = readFloat (0x402AD4B8)
- xsquared = (math.abs(playerx - playerstartx)) * (math.abs(playerx - playerstartx))
- ysquared = (math.abs(playery - playerstarty)) * (math.abs(playery - playerstarty))
- sumsq = xsquared + ysquared
- totaldist = math.sqrt(sumsq)
- if totaldist > 5 then -- how long should a tele be to bother printing it to console
- print ("tele dist is ", totaldist)
- print ("x dist is ", (playerx - playerstartx))
- print ("y dist is ", (playery - playerstarty))
- print ("vertangle: ", currentvertangle)
- print ("in a row: ", sequence)
- sequence = sequence + 1
- else
- sequence = 0
- end
- writeFloat ("[_player]+70", -1)
- writeBytes (0x006B1640, 0) -- reset walk forward
- writeBytes (0x006B1668, 0) -- reset jump
- walkingflag = false
- readytowalk = false
- jumpflag = false
- jumpingdone = false
- walkingdone = false
- waitingtorevert = true
- revertwait = 0
- --print("killing")
- end
- if walkingflag and walkflag < walkwaitsetting then
- walkflag = walkflag + 1
- end
- if waitingtorevert then
- playervelocity = readFloat ("[_player]+70")
- playerhealth = readFloat ("[_player]+E0")
- if playerhealth > 0 and playervelocity > -0.5 then
- waitingtorevert = false
- readytowalk = true
- end
- end
- --main logic ends here
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement