2014-10-02 08:49:54 +08:00
|
|
|
AddCSLuaFile()
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.PrintName = "Knife"
|
|
|
|
SWEP.Description = "A small bladed weapon that deals double damage to the back."
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
if CLIENT then
|
2014-10-02 08:49:54 +08:00
|
|
|
SWEP.ViewModelFlip = false
|
|
|
|
SWEP.ViewModelFOV = 55
|
|
|
|
end
|
|
|
|
|
|
|
|
SWEP.Base = "weapon_zs_basemelee"
|
|
|
|
|
|
|
|
SWEP.HoldType = "knife"
|
|
|
|
|
|
|
|
SWEP.ViewModel = "models/weapons/cstrike/c_knife_t.mdl"
|
|
|
|
SWEP.WorldModel = "models/weapons/w_knife_t.mdl"
|
|
|
|
SWEP.UseHands = true
|
|
|
|
|
|
|
|
SWEP.MeleeDamage = 19
|
2014-11-10 11:51:43 +08:00
|
|
|
SWEP.MeleeRange = 52
|
2014-10-02 08:49:54 +08:00
|
|
|
SWEP.MeleeSize = 0.875
|
|
|
|
|
|
|
|
SWEP.WalkSpeed = SPEED_FASTEST
|
|
|
|
|
|
|
|
SWEP.Primary.Delay = 0.85
|
|
|
|
|
|
|
|
SWEP.HitDecal = "Manhackcut"
|
|
|
|
|
|
|
|
SWEP.HitGesture = ACT_HL2MP_GESTURE_RANGE_ATTACK_KNIFE
|
|
|
|
SWEP.MissGesture = SWEP.HitGesture
|
|
|
|
|
|
|
|
SWEP.HitAnim = ACT_VM_MISSCENTER
|
|
|
|
SWEP.MissAnim = ACT_VM_PRIMARYATTACK
|
|
|
|
|
|
|
|
SWEP.NoHitSoundFlesh = true
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.AllowQualityWeapons = true
|
|
|
|
|
|
|
|
GAMEMODE:AttachWeaponModifier(SWEP, WEAPON_MODIFIER_FIRE_DELAY, -0.085)
|
|
|
|
|
2014-10-02 08:49:54 +08:00
|
|
|
function SWEP:PlaySwingSound()
|
|
|
|
self:EmitSound("weapons/knife/knife_slash"..math.random(2)..".wav")
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PlayHitSound()
|
|
|
|
self:EmitSound("weapons/knife/knife_hitwall1.wav")
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PlayHitFleshSound()
|
|
|
|
self:EmitSound("weapons/knife/knife_hit"..math.random(4)..".wav")
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:OnMeleeHit(hitent, hitflesh, tr)
|
2018-05-02 06:32:59 +08:00
|
|
|
if hitent:IsValid() and hitent:IsPlayer() and not self.m_BackStabbing and math.abs(hitent:GetForward():Angle().yaw - self:GetOwner():GetForward():Angle().yaw) <= 90 then
|
2014-10-02 08:49:54 +08:00
|
|
|
self.m_BackStabbing = true
|
|
|
|
self.MeleeDamage = self.MeleeDamage * 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PostOnMeleeHit(hitent, hitflesh, tr)
|
|
|
|
if self.m_BackStabbing then
|
|
|
|
self.m_BackStabbing = false
|
|
|
|
|
|
|
|
self.MeleeDamage = self.MeleeDamage / 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if SERVER then
|
|
|
|
function SWEP:InitializeHoldType()
|
|
|
|
self.ActivityTranslate = {}
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_IDLE] = ACT_HL2MP_IDLE_KNIFE
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_WALK] = ACT_HL2MP_WALK_KNIFE
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_RUN] = ACT_HL2MP_RUN_KNIFE
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_IDLE_CROUCH] = ACT_HL2MP_IDLE_CROUCH_PHYSGUN
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_WALK_CROUCH] = ACT_HL2MP_WALK_CROUCH_KNIFE
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_GESTURE_RANGE_ATTACK] = ACT_HL2MP_GESTURE_RANGE_ATTACK_KNIFE
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_GESTURE_RELOAD] = ACT_HL2MP_GESTURE_RELOAD_KNIFE
|
|
|
|
self.ActivityTranslate[ACT_HL2MP_JUMP] = ACT_HL2MP_JUMP_KNIFE
|
|
|
|
self.ActivityTranslate[ACT_RANGE_ATTACK1] = ACT_RANGE_ATTACK_KNIFE
|
|
|
|
end
|
|
|
|
end
|