From a70f3d12aa3aea59497202aa728533b0c716d30e Mon Sep 17 00:00:00 2001 From: Apickx Date: Wed, 12 Feb 2025 16:38:39 -0600 Subject: Inital commit --- data/artery/global/sh_player_dodge.txt | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 data/artery/global/sh_player_dodge.txt 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) -- cgit v1.2.3-70-g09d2