All pastes #516886 Raw Edit

Untitled

public text v1 · immutable
#516886 ·published 2007-05-28 21:48 UTC
rendered paste body
function dive(pl, command, args)
   if pl.Diving then return end
   if pl:GetVelocity() == Vector(0,0,0) then return end
   
   local momentumScale = 300.0
   local zScale = 200
   pl:SetVelocity(pl:GetVelocity():Normalize() * momentumScale + Vector(0, 0, zScale))
     
   pl.Diving = true
   timer.Simple(2, completeDive, pl)
end

function completeDive(pl) 
   pl.DiveCompleted = true 
   print "dive completed"
end

function onThink(pl)
   if (pl.Diving && pl.DiveCompleted) then
      print("think detected that diving is completed")
   end
   
   if (pl.Diving && pl.DiveCompleted && pl:IsOnGround()) then
      print("initiating roll")
      pl:SetVelocity(pl:GetVelocity():Normalize() * 300.0)
      pl.Diving = false
   end
end

concommand.Add("dive", dive) 
hook.Add("Think", "ahl_think_dive", onThink)