diff --git a/gamemodes/zombiesurvival/entities/entities/projectile_stone/init.lua b/gamemodes/zombiesurvival/entities/entities/projectile_stone/init.lua index 6d644f9..bd1736b 100644 --- a/gamemodes/zombiesurvival/entities/entities/projectile_stone/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/projectile_stone/init.lua @@ -44,7 +44,7 @@ function ENT:StartTouch(ent) if ent ~= owner and ent:Team() ~= self.Team then ent:EmitSound("weapons/crossbow/hitbod"..math.random(2)..".wav") - ent:TakeDamage(self.Damage, owner, self) + ent:TakeSpecialDamage(self.Damage, DMG_CLUB, owner, self, nil, Vector(0, 0, 60000)) self:Explode() end end diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_axe.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_axe.lua index 16bd1ee..70b26ea 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_axe.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_axe.lua @@ -27,7 +27,7 @@ SWEP.HoldType = "melee2" SWEP.MeleeDamage = 45 SWEP.MeleeRange = 55 SWEP.MeleeSize = 1.5 -SWEP.MeleeKnockBack = SWEP.MeleeDamage * 1.5 +SWEP.MeleeKnockBack = 32 SWEP.WalkSpeed = SPEED_FAST diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_basemelee/shared.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_basemelee/shared.lua index 8708230..6a60a50 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_basemelee/shared.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_basemelee/shared.lua @@ -195,7 +195,6 @@ function SWEP:MeleeSwing() dmginfo:SetAttacker(owner) dmginfo:SetInflictor(self) dmginfo:SetDamageType(self.DamageType) - dmginfo:SetDamageForce(self.MeleeDamage * 20 * owner:GetAimVector()) if hitent:IsPlayer() then hitent:MeleeViewPunch(damage) if hitent:IsHeadcrab() then @@ -207,6 +206,9 @@ function SWEP:MeleeSwing() if self.MeleeKnockBack > 0 then hitent:ThrowFromPositionSetZ(tr.HitPos, self.MeleeKnockBack, nil, true) end + if hitent:IsPlayer() and hitent:WouldDieFrom(damage, dmginfo:GetDamagePosition()) then + dmginfo:SetDamageForce(math.min(self.MeleeDamage, 50) * 400 * owner:GetAimVector()) + end end if hitent:IsPlayer() then diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_crowbar.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_crowbar.lua index 8e0e2ce..21f064e 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_crowbar.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_crowbar.lua @@ -18,7 +18,7 @@ SWEP.HoldType = "melee" SWEP.MeleeDamage = 35 SWEP.MeleeRange = 55 SWEP.MeleeSize = 1.5 -SWEP.MeleeKnockBack = SWEP.MeleeDamage * 1.5 +SWEP.MeleeKnockBack = 10 SWEP.Primary.Delay = 0.7 diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_fists.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_fists.lua new file mode 100644 index 0000000..9535407 --- /dev/null +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_fists.lua @@ -0,0 +1,231 @@ +AddCSLuaFile() + +SWEP.PrintName = "Fists" + +SWEP.WalkSpeed = SPEED_NORMAL +SWEP.IsMelee = true + +SWEP.UseHands = true + +SWEP.ViewModel = "models/weapons/c_arms_citizen.mdl" +SWEP.WorldModel = "" + +SWEP.Damage = 5 +SWEP.UppercutDamageMultiplier = 3 +SWEP.HitDistance = 40 + +SWEP.ViewModelFOV = 52 + +SWEP.AutoSwitchFrom = true + +SWEP.NoMagazine = true +SWEP.Undroppable = true +SWEP.NoPickupNotification = true + +local SwingSound = Sound( "weapons/slam/throw.wav" ) +local HitSound = Sound( "Flesh.ImpactHard" ) + +function SWEP:Initialize() + --self:SetHoldType("normal") + self:SetHoldType("fist") +end + +function SWEP:PreDrawViewModel(vm, wep, pl) + vm:SetMaterial("engine/occlusionproxy") +end + +function SWEP:SetupDataTables() + self:NetworkVar("Float", 0, "NextMeleeAttack") + self:NetworkVar("Float", 1, "NextIdle") + self:NetworkVar("Float", 2, "NextIdleHoldType") + self:NetworkVar("Int", 2, "Combo") +end + +function SWEP:UpdateNextIdle() + local vm = self.Owner:GetViewModel() + self:SetNextIdle( CurTime() + vm:SequenceDuration() ) +end + +function SWEP:PrimaryAttack(right) + --self:SetHoldType("fist") + self:SetNextIdleHoldType(CurTime() + 2) + self.Owner:SetAnimation(PLAYER_ATTACK1) + self.WalkSpeed = 165 + self.Owner:ResetSpeed() + + local anim = "fists_left" + if ( right ) then anim = "fists_right" end + if ( self:GetCombo() >= 2 ) then + anim = "fists_uppercut" + end + + local vm = self.Owner:GetViewModel() + vm:SendViewModelMatchingSequence( vm:LookupSequence( anim ) ) + + self:EmitSound( SwingSound ) + + self:UpdateNextIdle() + self:SetNextMeleeAttack( CurTime() + 0.2 ) + + self:SetNextPrimaryFire( CurTime() + 0.9 ) + self:SetNextSecondaryFire( CurTime() + 0.9 ) +end + +function SWEP:SecondaryAttack() + self:PrimaryAttack( true ) +end + +function SWEP:DealDamage() + local owner = self.Owner + local shootpos = owner:GetShootPos() + local aimvector = owner:GetAimVector() + local anim = self:GetSequenceName(owner:GetViewModel():GetSequence()) + local filter = owner:GetMeleeFilter() + + owner:LagCompensation( true ) + + local tr = util.TraceLine( { + start = shootpos, + endpos = shootpos + aimvector * self.HitDistance, + filter = filter + } ) + + if not IsValid( tr.Entity ) then + tr = util.TraceHull( { + start = shootpos, + endpos = shootpos + aimvector * self.HitDistance, + filter = filter, + mins = Vector( -3, -3, -3 ), + maxs = Vector( 3, 3, 3 ) + } ) + end + + local hitent = tr.Entity + + -- We need the second part for single player because SWEP:Think is ran shared in SP. + if tr.Hit and not ( game.SinglePlayer() and CLIENT ) then + self:EmitSound( HitSound ) + end + + local hit = false + local hitplayer = false + + if SERVER and IsValid( hitent ) then + hitplayer = hitent:IsNPC() or hitent:IsPlayer() + + local dmginfo = DamageInfo() + dmginfo:SetAttacker(IsValid(owner) and owner or self) + dmginfo:SetInflictor(self) + dmginfo:SetDamageType(DMG_CLUB) + dmginfo:SetDamagePosition(tr.HitPos) + if anim == "fists_uppercut" then + dmginfo:SetDamage(self.Damage * self.UppercutDamageMultiplier) + else + dmginfo:SetDamage(self.Damage) + end + + if hitent:IsPlayer() and hitent:WouldDieFrom(dmginfo:GetDamage(), dmginfo:GetDamagePosition()) then + if anim == "fists_left" then + dmginfo:SetDamageForce(owner:GetRight() * 4912 + owner:GetForward() * 9998) + elseif anim == "fists_right" then + dmginfo:SetDamageForce(owner:GetRight() * -4912 + owner:GetForward() * 9989) + elseif anim == "fists_uppercut" then + dmginfo:SetDamageForce(owner:GetUp() * 5158 + owner:GetForward() * 10012) + end + end + + hitent:TakeDamageInfo( dmginfo ) + hit = true + end + + if SERVER and IsValid( hitent ) and hitent:GetMoveType() == MOVETYPE_VPHYSICS then + local phys = hitent:GetPhysicsObject() + if IsValid( phys ) then + phys:ApplyForceOffset( aimvector * 2000, tr.HitPos ) + hitent:SetPhysicsAttacker(owner) + end + end + + if SERVER then + if hitplayer and anim ~= "fists_uppercut" then + self:SetCombo( self:GetCombo() + 1 ) + else + self:SetCombo( 0 ) + end + end + + owner:LagCompensation(false) +end + +function SWEP:OnRemove() + if CLIENT and self.Owner:IsValid() and self.Owner:IsPlayer() then + local vm = self.Owner:GetViewModel() + if IsValid(vm) then vm:SetMaterial("") end + end +end + +function SWEP:Holster(wep) + if CurTime() >= self:GetNextPrimaryFire() then + self:OnRemove() + + return true + end + + return false +end + +function SWEP:Deploy() + local vm = self.Owner:GetViewModel() + vm:SendViewModelMatchingSequence(vm:LookupSequence("fists_draw")) + + self:UpdateNextIdle() + + if SERVER then + self:SetCombo(0) + end + + return true +end + +function SWEP:Think() + local vm = self.Owner:GetViewModel() + local curtime = CurTime() + local idletime = self:GetNextIdle() + local idle_holdtype_time = self:GetNextIdleHoldType() + + if idle_holdtype_time > 0 and curtime >= idle_holdtype_time then + --self:SetHoldType("normal") + self:SetNextIdleHoldType(0) + self.WalkSpeed = SPEED_NORMAL + self.Owner:ResetSpeed() + end + + if idletime > 0 and curtime >= idletime then + vm:SendViewModelMatchingSequence( vm:LookupSequence("fists_idle_0"..math.random(2))) + + self:UpdateNextIdle() + end + + local meleetime = self:GetNextMeleeAttack() + + if meleetime > 0 and curtime >= meleetime then + self:DealDamage() + self:SetNextMeleeAttack( 0 ) + end + + if SERVER and curtime >= self:GetNextPrimaryFire() + 0.1 then + self:SetCombo( 0 ) + end +end + +if not CLIENT then return end + +function SWEP:DrawWeaponSelection(...) + return self:BaseDrawWeaponSelection(...) +end + +function SWEP:GetViewModelPosition(pos, ang) + pos = pos - ang:Up() * 3 + + return pos, ang +end diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_megamasher.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_megamasher.lua index 432f7cd..58c7375 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_megamasher.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_megamasher.lua @@ -29,7 +29,7 @@ SWEP.WorldModel = "models/weapons/w_sledgehammer.mdl" SWEP.MeleeDamage = 190 SWEP.MeleeRange = 75 SWEP.MeleeSize = 4 -SWEP.MeleeKnockBack = SWEP.MeleeDamage * 2 +SWEP.MeleeKnockBack = 150 SWEP.Primary.Delay = 2.25 diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sawhack.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sawhack.lua index 8200702..9c8fe94 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sawhack.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sawhack.lua @@ -31,7 +31,7 @@ SWEP.Primary.Delay = 0.45 SWEP.MeleeDamage = 32 SWEP.MeleeRange = 55 SWEP.MeleeSize = 1.9 -SWEP.MeleeKnockBack = SWEP.MeleeDamage * 0.5 +SWEP.MeleeKnockBack = 10 SWEP.WalkSpeed = SPEED_FAST diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_shovel.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_shovel.lua index 76828aa..7572f9d 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_shovel.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_shovel.lua @@ -30,7 +30,7 @@ SWEP.UseHands = true SWEP.MeleeDamage = 50 SWEP.MeleeRange = 68 SWEP.MeleeSize = 1.5 -SWEP.MeleeKnockBack = SWEP.MeleeDamage * 2 +SWEP.MeleeKnockBack = 40 SWEP.Primary.Delay = 1.2 diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sledgehammer.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sledgehammer.lua index da468c3..6365d6e 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sledgehammer.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_sledgehammer.lua @@ -17,7 +17,7 @@ SWEP.WorldModel = "models/weapons/w_sledgehammer.mdl" SWEP.MeleeDamage = 75 SWEP.MeleeRange = 64 SWEP.MeleeSize = 1.75 -SWEP.MeleeKnockBack = SWEP.MeleeDamage * 1.75 +SWEP.MeleeKnockBack = 70 SWEP.Primary.Delay = 1.3 diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_swissarmyknife.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_swissarmyknife.lua index 2941d19..7cf6c16 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_swissarmyknife.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_swissarmyknife.lua @@ -17,7 +17,7 @@ SWEP.WorldModel = "models/weapons/w_knife_t.mdl" SWEP.UseHands = true SWEP.MeleeDamage = 19 -SWEP.MeleeRange = 62 +SWEP.MeleeRange = 52 SWEP.MeleeSize = 0.875 SWEP.WalkSpeed = SPEED_FASTEST diff --git a/gamemodes/zombiesurvival/gamemode/init.lua b/gamemodes/zombiesurvival/gamemode/init.lua index feda187..5270d80 100644 --- a/gamemodes/zombiesurvival/gamemode/init.lua +++ b/gamemodes/zombiesurvival/gamemode/init.lua @@ -3514,6 +3514,8 @@ function GM:PlayerSpawn(pl) pl:SetNoTarget(false) pl:SetMaxHealth(100) + pl:Give("weapon_zs_fists") + if self.ZombieEscape then pl:Give("weapon_zs_zeknife") pl:Give("weapon_zs_zegrenade") diff --git a/gamemodes/zombiesurvival/gamemode/obj_entity_extend.lua b/gamemodes/zombiesurvival/gamemode/obj_entity_extend.lua index 6404e58..479cc94 100644 --- a/gamemodes/zombiesurvival/gamemode/obj_entity_extend.lua +++ b/gamemodes/zombiesurvival/gamemode/obj_entity_extend.lua @@ -13,18 +13,23 @@ function meta:GetVolume() return (maxs.x - mins.x) + (maxs.y - mins.y) + (maxs.z - mins.z) end -function meta:TakeSpecialDamage(damage, damagetype, attacker, inflictor, hitpos) +function meta:TakeSpecialDamage(damage, damagetype, attacker, inflictor, hitpos, damageforce) attacker = attacker or self if not attacker:IsValid() then attacker = self end inflictor = inflictor or attacker if not inflictor:IsValid() then inflictor = attacker end + local nearest = self:NearestPoint(inflictor:NearestPoint(self:LocalToWorld(self:OBBCenter()))) + local dmginfo = DamageInfo() dmginfo:SetDamage(damage) dmginfo:SetAttacker(attacker) dmginfo:SetInflictor(inflictor) - dmginfo:SetDamagePosition(hitpos or self:NearestPoint(inflictor:NearestPoint(self:LocalToWorld(self:OBBCenter())))) + dmginfo:SetDamagePosition(hitpos or nearest) dmginfo:SetDamageType(damagetype) + if damageforce then + dmginfo:SetDamageForce(damageforce) + end self:TakeDamageInfo(dmginfo) return dmginfo diff --git a/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua b/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua index c7ffeb9..b06c0c1 100644 --- a/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua +++ b/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua @@ -208,6 +208,10 @@ function meta:GetLegDamage() return math.max(0, base - CurTime()) end +function meta:WouldDieFrom(damage, hitpos) + return self:Health() <= damage * GAMEMODE:GetZombieDamageScale(hitpos, self) +end + function meta:ProcessDamage(dmginfo) local attacker, inflictor = dmginfo:GetAttacker(), dmginfo:GetInflictor() diff --git a/gamemodes/zombiesurvival/gamemode/obj_player_extend_sv.lua b/gamemodes/zombiesurvival/gamemode/obj_player_extend_sv.lua index af4fdc7..2b6a48a 100644 --- a/gamemodes/zombiesurvival/gamemode/obj_player_extend_sv.lua +++ b/gamemodes/zombiesurvival/gamemode/obj_player_extend_sv.lua @@ -248,6 +248,20 @@ function meta:GiveEmptyWeapon(weptype) end end +meta.OldGive = meta.Give +function meta:Give(weptype) + if self:Team() ~= TEAM_HUMAN then return end + + local weps = self:GetWeapons() + local autoswitch = #weps == 1 and weps[1]:IsValid() and weps[1].AutoSwitchFrom + + self:OldGive(weptype) + + if autoswitch then + self:SelectWeapon(weptype) + end +end + -- Here for when garry makes weapons use 357 ammo like he does every other update. --[[local oldgive = meta.Give function meta:Give(...)