diff options
| author | Apickx <apickx@cogarr.com> | 2025-02-12 16:38:39 -0600 |
|---|---|---|
| committer | Apickx <apickx@cogarr.com> | 2025-02-12 16:38:39 -0600 |
| commit | a70f3d12aa3aea59497202aa728533b0c716d30e (patch) | |
| tree | 914d94f97fb303939baf63a05915b19b8af5f382 /data | |
| parent | 2568d8b47bfb77ba3a748e189901846b4ae7860c (diff) | |
| download | artery_stamina-a70f3d12aa3aea59497202aa728533b0c716d30e.tar.gz artery_stamina-a70f3d12aa3aea59497202aa728533b0c716d30e.tar.bz2 artery_stamina-a70f3d12aa3aea59497202aa728533b0c716d30e.zip | |
Diffstat (limited to 'data')
| -rw-r--r-- | data/artery/global/sh_player_dodge.txt | 51 |
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) |
