• SWEP:laser gun only kills on headshot, and cant change recoil
    1 replies, posted
okay so im making a laser gun thingy, and i found a piece of script that fires the toolgun laser and when it hits somebodys head kills them however, i want it so nomatter where it hits them it will kill them this is the script for that part [CODE]local ShootSound = "fire.wav" end function SWEP:Distance_Point_Line( Line1, Line2, Point ) local v = Line2 - Line1 local w = Point - Line1 local c1 = w:DotProduct(v) local c2 = v:DotProduct(v) local b = c1 / c2 local a = Line1 + b * v return (Point - a):Length() end function SWEP:PrimaryAttack() local ply = self.Weapon:GetOwner() local vStart = ply:GetShootPos() local vForward = ply:GetAimVector() self.Weapon:SetNextPrimaryFire( CurTime() + 3 ) self.Weapon:EmitSound(ShootSound) local effect = EffectData() effect:SetStart(self.Owner:GetShootPos()+self.Owner:EyeAngles():Forward()*20+self.Owner:EyeAngles():Up()*-6+self.Owner:EyeAngles():Right()*5) effect:SetOrigin(vStart + (vForward * self.Range)) effect:SetAngle(self.Owner:EyeAngles()) effect:SetAttachment( 1 ) effect:SetEntity( self.Weapon ) util.Effect("ToolTracer", effect) if CLIENT then return end local dist for k,v in pairs( ents.FindInSphere( vStart, self.Range ) ) do if v:IsValid() and v != self.Owner and (v:IsPlayer() or v:IsNPC()) then local vPos = v:GetBonePosition(v:LookupBone("ValveBiped.Bip01_Head1")) dist = self:Distance_Point_Line( vStart, vStart + (vForward * self.Range) , vPos ) if dist < self.Fuzziness then local extra = self.MaxDamage - (self.MaxDamage / self.Range) * vStart:Distance(vPos) local damage = self.MinDamage + extra damage = damage - (damage / self.Fuzziness) * dist v:TakeDamage(damage, self.Owner, self.Weapon) end end end end [/CODE] and the part which determines which part of the body kills them [CODE]function SWEP:Distance_Point_Line( Line1, Line2, Point ) local v = Line2 - Line1 local w = Point - Line1 local c1 = w:DotProduct(v) local c2 = v:DotProduct(v) local b = c1 / c2 local a = Line1 + b * v return (Point - a):Length() end[/CODE] --------------------------------------------- Also the recoil on a v_model i have downloaded doesnt seem to work its reload animation works fine and stuff but even after changing [CODE]SWEP.Primary.Recoil = 1.2[/CODE] the gun remains completely still so any ideas?
im not sure im trying to figure out how to rig a gun properly but you may need recoil animations
Sorry, you need to Log In to post a reply to this thread.