Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. --player : CPlayerPuppetEntity
  2. local worldInfo = worldGlobals.worldInfo
  3.  
  4. local NotVersus = {
  5.   ["SinglePlayer"] = true,
  6.   ["Cooperative"] = true,
  7.   ["Survival"] = true,
  8.   ["TeamSurvival"] = true,
  9.   ["BeastHunt"] = true,
  10.   ["BeastSurvival"] = true,
  11.   ["CooperativeStandard"] = true,
  12.   ["CooperativeCoinOp"] = true,
  13.   ["TeamBeastHunt"] = true,
  14.   ["OneShotSurvival"] = true,
  15. }
  16.  
  17. local DJEnabled = false
  18.  
  19. if NotVersus[worldInfo:GetGameMode()] or worldInfo:IsSinglePlayer() then DJEnabled = true end
  20. Wait(Times(2,CustomEvent("OnStep")))
  21. if not (worldGlobals.DoubleJumpEnabled == nil) then
  22.   DJEnabled = worldGlobals.DoubleJumpEnabled
  23. end
  24.  
  25. if not DJEnabled then return end
  26.  
  27. local player
  28. local Pi = 3.14159265359
  29. local dashDelay = 5
  30.  
  31. local findPlayer = function()
  32.   while (player == nil) do
  33.     local Players = worldInfo:GetAllPlayersInRange(worldInfo,10000)
  34.     for i=1,#Players,1 do
  35.       if Players[i]:IsLocalOperator() then
  36.         player = Players[i]
  37.         break
  38.       end
  39.     end
  40.   end
  41. end
  42. findPlayer()
  43.  
  44. local prevVel = player:GetLinearVelocity()
  45. local searching = false
  46. local k = 0
  47. local deltaDash = dashDelay
  48.  
  49. RunHandled(WaitForever,
  50.  
  51. OnEvery(CustomEvent("OnStep")),
  52. function(step)
  53.   if not IsDeleted(player) then
  54.     local tempo = player:GetDesiredTempoAbs()
  55.     local vel = player:GetLinearVelocity()
  56.     local speed = player:GetSpeedMultiplier()
  57.     if player:IsCommandPressed("plcmdShield") and deltaDash >= dashDelay then
  58.       print("cur=" + deltaDash)
  59.       deltaDash = 0
  60.       if (tempo.y <= 0) then
  61.         if ((vel.y - prevVel.y) < 0) then      
  62.           tempo.x = tempo.x * 40 * speed.x
  63.           tempo.y = tempo.y * 1 * speed.y
  64.           tempo.z = tempo.z * 40 * speed.z
  65.           player:SetLinearVelocity(tempo)
  66.           player:PlaySchemeSound("Dash")
  67.         end
  68.       end
  69.     else
  70.       deltaDash = deltaDash + worldInfo:SimGetStep()
  71.       print("btw=" + deltaDash)
  72.     end
  73.     prevVel = vel
  74.   elseif not searching then
  75.     searching = true
  76.     player = nil
  77.     findPlayer()
  78.     searching = false
  79.   end
  80. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement