Skip to content

Commit

Permalink
Implemented first hit damage
Browse files Browse the repository at this point in the history
  • Loading branch information
xDShot committed Sep 3, 2016
1 parent e68e40e commit 5269273
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Type these in console or in server config:
| csgo_knives_secondary | 1 | Allow secondary attacks |
| **Numerical variables** |||
| csgo_knives_dmg_prim_back | 90 | How much damage deal when hit with primary attack from behind |
| csgo_knives_dmg_prim_front1 | 40 | How much damage deal when hit with primary attack in front or from side (value randomly being picked between *\_front1* and *\_front2*) |
| csgo_knives_dmg_prim_front2 | 25 | How much damage deal when hit with primary attack in front or from side (value randomly being picked between *\_front1* and *\_front2*) |
| csgo_knives_dmg_prim_front1 | 40 | How much damage deal when firstly hit with primary attack in front or from side |
| csgo_knives_dmg_prim_front2 | 25 | How much damage deal when subsequently hit with primary attack in front or from side |
| csgo_knives_dmg_sec_back | 180 | How much damage deal when hit with secondary attack from behind |
| csgo_knives_dmg_sec_front | 65 | How much damage deal when hit with secondary attack in front or from side |

Expand Down
11 changes: 6 additions & 5 deletions lua/weapons/csgo_baseknife.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ if ( SERVER ) then
CreateConVar("csgo_knives_dmg_sec_back", 180, FCVAR_ARCHIVE, "How much damage deal when hit with secondary attack from behind")
CreateConVar("csgo_knives_dmg_sec_front", 65, FCVAR_ARCHIVE, "How much damage deal when hit with secondary attack in front or from side")
CreateConVar("csgo_knives_dmg_prim_back", 90, FCVAR_ARCHIVE, "How much damage deal when hit with primary attack from behind")
CreateConVar("csgo_knives_dmg_prim_front1", 40, FCVAR_ARCHIVE, "How much damage deal when hit with primary attack in front or from side (value randomly being picked between *_front1 and *_front2)")
CreateConVar("csgo_knives_dmg_prim_front2", 25, FCVAR_ARCHIVE, "How much damage deal when hit with primary attack in front or from side (value randomly being picked between *_front1 and *_front2)")
CreateConVar("csgo_knives_dmg_prim_front1", 40, FCVAR_ARCHIVE, "How much damage deal when firstly hit with primary attack in front or from side")
CreateConVar("csgo_knives_dmg_prim_front2", 25, FCVAR_ARCHIVE, "How much damage deal when subsequently hit with primary attack in front or from side")
end


Expand Down Expand Up @@ -249,7 +249,7 @@ function SWEP:DoAttack( Altfire )
local HitEntity = IsValid(tr.Entity) and tr.Entity or Entity(0) -- Ugly hack to destroy glass surf. 0 is worldspawn.
local DidHitPlrOrNPC = HitEntity and ( HitEntity:IsPlayer() or HitEntity:IsNPC() ) and IsValid( HitEntity )

Attacker:LagCompensation(false) -- Don't forget to disable it!
local FirstHit = not Altfire and ( ( self.Weapon:GetNextPrimaryFire() + 0.4 ) < CurTime() ) -- First swing does full damage, subsequent swings do less

tr.HitGroup = HITGROUP_GENERIC -- Hack to disable damage scaling. No matter where we hit it, the damage should be as is.

Expand All @@ -261,7 +261,7 @@ function SWEP:DoAttack( Altfire )
local LMB_FRONT1 = cvars.Number("csgo_knives_dmg_prim_front1", 40)
local LMB_FRONT2 = cvars.Number("csgo_knives_dmg_prim_front2", 25)

local Damage = ( Altfire and ( Backstab and RMB_BACK or RMB_FRONT ) ) or ( Backstab and LMB_BACK ) or ( ( math.random(0,5) == 3 ) and LMB_FRONT1 ) or LMB_FRONT2 -- This is random it chooses between LMB_FRONT1 AND LMB_FRONT2
local Damage = ( Altfire and ( Backstab and RMB_BACK or RMB_FRONT ) ) or ( Backstab and LMB_BACK ) or ( FirstHit and LMB_FRONT1 ) or LMB_FRONT2

local damageinfo = DamageInfo()
damageinfo:SetAttacker( Attacker )
Expand Down Expand Up @@ -299,7 +299,8 @@ function SWEP:DoAttack( Altfire )

local Snd = DidHitPlrOrNPC and ( Altfire and StabSnd or HitSnd ) or DidHit and HitwallSnd or SlashSnd
Weapon:EmitSound( Snd )


Attacker:LagCompensation(false) -- Don't forget to disable it!
end


Expand Down

0 comments on commit 5269273

Please sign in to comment.