summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorU-DESKTOP-FOJ6TK1\Alex <alex@cogarr.net>2025-02-12 16:29:47 -0600
committerU-DESKTOP-FOJ6TK1\Alex <alex@cogarr.net>2025-02-12 16:29:47 -0600
commit3e099306ba0c30dae89a1ad6e4bfbebe3c8ad4ec (patch)
tree1b885e3c09ed2be26a22c4b7e73bd27af3ed79b6 /data
downloadartery_dodge-3e099306ba0c30dae89a1ad6e4bfbebe3c8ad4ec.tar.gz
artery_dodge-3e099306ba0c30dae89a1ad6e4bfbebe3c8ad4ec.tar.bz2
artery_dodge-3e099306ba0c30dae89a1ad6e4bfbebe3c8ad4ec.zip
Inital commitHEADmaster
Diffstat (limited to 'data')
-rw-r--r--data/artery/global/sh_player_dodge.txt51
1 files changed, 51 insertions, 0 deletions
diff --git a/data/artery/global/sh_player_dodge.txt b/data/artery/global/sh_player_dodge.txt
new file mode 100644
index 0000000..2ee6841
--- /dev/null
+++ b/data/artery/global/sh_player_dodge.txt
@@ -0,0 +1,51 @@
+local stam = nil
+if SERVER then
+ stam = nrequire("sv_stamina.lua") -- Depends on artery_stamina
+else
+ stam = nrequire("cl_stamina.lua")
+end
+local dodgeing = {}
+local last_dodge = {}
+local tostop = {}
+
+hook.Add( "KeyPress", "keypress_dodge_toggle", function( ply, key )
+ if ( key == IN_WALK ) then
+ dodgeing[ply] = true
+ end
+end )
+
+hook.Add( "KeyRelease", "keypress_dodge_toggle", function( ply, key )
+ if ( key == IN_WALK ) then
+ dodgeing[ply] = false
+ end
+end )
+
+hook.Add( "PlayerInitialSpawn", "dodge_cooldown_init",function(ply)
+ last_dodge[ply] = CurTime()
+end )
+hook.Add( "PlayerDisconnected", "dodge_cooldown_desc",function(ply)
+ last_dodge[ply] = nil
+end )
+
+
+
+hook.Add( "Move", "move_dodge_dodge", function(ply,cmv)
+ --print("Player's stamina was",stam.getStamina(ply))
+ if dodgeing[ply] and CurTime() > ((last_dodge[ply] or 0) + 1) and stam.getStamina(ply) >= 10 then
+ if SERVER then
+ stam.takeStamina(ply,10)
+ end
+ local vel = cmv:GetVelocity()
+ vel.z = 0
+ vel = (vel * 20) + Vector(0,0,-64)
+ for k,v in pairs({"x","y","z"}) do
+ vel[v] = math.Clamp(vel[v],-1000,1000)
+ end
+ cmv:SetVelocity(vel)
+ last_dodge[ply] = CurTime()
+ tostop[ply] = CurTime() + 0.1
+ elseif tostop[ply] and CurTime() > tostop[ply] then
+ cmv:SetVelocity(Vector(0,0,0))
+ tostop[ply] = nil
+ end
+end)