Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile("shared.lua")
- end
- if CLIENT then
- SWEP.PrintName = "Fists"
- SWEP.Slot = 2
- SWEP.SlotPos = 1
- SWEP.DrawAmmo = false
- SWEP.DrawCrosshair = true
- function SWEP:DrawHUD()
- surface.DrawCircle( ScrW() / 2, ScrH() / 2, 2, Color(200,200,200,255))
- end
- end
- SWEP.Author = "NMRIH, Fredy, StephenPuffs"
- SWEP.Instructions = "Left Click: Punch, Right Click: Shove/Drag, Reload to search suspects as police"
- SWEP.Contact = ""
- SWEP.Purpose = ""
- SWEP.ViewModelFOV = 62
- SWEP.ViewModelFlip = false
- SWEP.AnimPrefix = "rpg"
- SWEP.LockSound = "doors/door_latch1.wav"
- SWEP.UnlockSound = "doors/door_latch3.wav"
- SWEP.Spawnable = false
- SWEP.AdminSpawnable = true
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = 0
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = ""
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = 0
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = ""
- SWEP.ViewPunch = Angle( 0, 0, 0 )
- SWEP.Enabled = true
- SWEP.AnimDeploy = nil
- --[[function SWEP:Initialize()
- self:SetHoldType("normal")
- self.LastPunch = 0
- end
- SWEP.ViewModel = "models/weapons/me_fists/v_me_fists.mdl";
- SWEP.WorldModel = "models/perp2/w_fists.mdl";
- function SWEP:Holster()
- if(SERVER) then
- if(self.Owner.grabbeditem != nil && IsValid(self.Owner.grabbeditem)) then
- if(self.Owner.grabbeditem.playerholding == self.Owner) then
- self.Owner.grabbeditem:GetPhysicsObject():ClearGameFlag(FVPHYSICS_PLAYER_HELD)
- self.Owner.grabbeditem.playerholding = nil
- self.Owner.grabbeditem:SetOwner(nil)
- self.Owner.grabbeditem.grabbeditem = nil;
- self.Owner.grabbeditem:SetNWEntity("grabbeditem", nil)
- end
- if(IsValid(self.Owner.CarryHack)) then
- self.Owner.CarryHack:Remove();
- self.Owner.CarryHack = nil;
- end
- return true;
- end
- end
- return true;
- end
- function SWEP:CanPrimaryAttack ( ) return true; end
- function SWEP:PrimaryAttack()
- if(CLIENT && !IsFirstTimePredicted()) then return end
- self.LastPunch = CurTime()
- self.Owner:StopAnimation()
- self.Weapon:SetNextPrimaryFire(CurTime() + .6)
- if(self:GetHoldType() != "fist") then self:SetHoldType("fist") end
- local EyeTrace = self.Owner:GetEyeTrace()
- if(hook.Call("PlayerFistsAttack", nil, self.Owner, self, EyeTrace)) then
- return
- end
- self.Owner.Stamina = math.Clamp((self.Owner.Stamina or 100) - 1, 0, 100)
- //Default primary attack action = punching
- self:SendWeaponAnim(ACT_VM_IDLE)
- local Animation = self.Owner:GetViewModel()
- Animation:SetSequence(Animation:LookupSequence("Attack_Quick_" .. math.random(1,2)))
- self.Owner:SetAnimation(PLAYER_ATTACK1)
- timer.Simple(0.06, function()
- if(!IsValid(self) || !IsValid(self.Owner)) then return end
- local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
- if Distance > 45 then return false; end
- if EyeTrace.MatType == MAT_GLASS then
- self.Weapon:EmitSound("physics/glass/glass_cup_break" .. math.random(1, 2) .. ".wav");
- local ran = math.random(1, 3)
- if ran == 3 then
- self.Weapon:EmitSound("physics/flesh/flesh_bloody_break.wav");
- end
- return false
- end
- if EyeTrace.HitWorld then
- self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav");
- return false;
- end
- if !IsValid(EyeTrace.Entity) or !EyeTrace.HitNonWorld or EyeTrace.Entity:IsNPC() then return false; end
- if EyeTrace.MatType == MAT_FLESH then
- // probably another person
- self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
- if EyeTrace.Entity:IsPlayer() then
- local gender = GetGenderOfModel(EyeTrace.Entity:GetModel())
- if math.random(1, 30) == 30 then
- if(!(EyeTrace.Entity:Team() != TEAM_CITIZEN && self.Owner:Team() != TEAM_CITIZEN)) then
- EyeTrace.Entity:SetNWFloat("bleeding", EyeTrace.Entity:GetNWFloat("bleeding", 0)+1)
- EyeTrace.Entity:SetNWEntity("bleedingcause", self.Owner)
- end
- EyeTrace.Entity:EmitSound("physics/body/body_medium_break3.wav")
- if gender == SEX_FEMALE then
- EyeTrace.Entity:EmitSound("Jarheads/Bodysounds/Coughing/Female_Cough" .. math.random(1, 4) .. ".wav")
- else
- EyeTrace.Entity:EmitSound("Jarheads/Bodysounds/Coughing/Male_Cough" .. math.random(1, 4) .. ".wav")
- end
- else
- if math.random(1, 5) == 5 then
- if gender == SEX_FEMALE then
- local tbl = {"gasp02", "gasp03", "hurt04", "hurt05", "hurt06", "hurt08", "uggh01", "uggh02"}
- local ran = math.random(1, 8)
- local sound = tbl[math.random(1,8)];
- EyeTrace.Entity:EmitSound("vo/npc/Alyx/" .. sound .. ".wav")
- else
- EyeTrace.Entity:EmitSound("ambient/voices/citizen_beaten" .. math.random(1, 5) .. ".wav")
- end
- end
- end
- --local OurEffect = EffectData();
- --OurEffect:SetOrigin(EyeTrace.HitPos);
- --util.Effect("BloodImpact", OurEffect, true);
- end
- if SERVER then
- local dmgInfo = DamageInfo()
- dmgInfo:SetDamage(math.ceil(math.Rand(1,4)*math.max(self.Owner:GetPERPLevel(SKILL_UNARMED_COMBAT), 1)/(math.max(GAMEMODE.MaxGeneLevel-self.Owner:GetPERPLevel(GENE_STRENGTH), 1))))
- dmgInfo:SetDamageType(DMG_RADIATION) //Stupid source engine, so now armor damage is done
- dmgInfo:SetAttacker(self.Owner)
- dmgInfo:SetInflictor(self)
- EyeTrace.Entity:TakeDamageInfo(dmgInfo);
- self.Owner:GiveExperience(SKILL_UNARMED_COMBAT, math.random(1, 2), true);
- if(EyeTrace.Entity:IsPlayer()) then hook.Call("OnPlayerPunchedPlayer", nil, EyeTrace.Entity, self.Owner) end
- end
- return false;
- elseif(EyeTrace.Entity:IsDoor() && self.Owner:GetNWBool("IsZombie")) then
- EyeTrace.Entity:EmitSound("physics/wood/wood_box_impact_hard" .. math.random(1, 3) .. ".wav",65)
- if(SERVER) then
- if(math.random(1,50) == 1) then
- EyeTrace.Entity:Fire("unlock","",0)
- EyeTrace.Entity:Fire("open","",0.1)
- end
- end
- else
- // something else?
- self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
- end
- end)
- end
- function SWEP:Think()
- hook.Call("PlayerFistThink", nil, self, self.Owner)
- if(SERVER) then
- if(self.Owner:KeyPressed(IN_RELOAD) && (!self.Owner.lastflippeddrug || CurTime() - self.Owner.lastflippeddrug > 0.5)) then
- self.Owner.lastflippeddrug = CurTime()
- hook.Call("PlayerFistReload", nil, self, self.Owner)
- GAMEMODE.FlipDrug(self.Owner)
- end
- end
- if((self.LastPunch or 0) + 5 < CurTime() && self:GetHoldType() != "normal") then self:SetHoldType("normal") end
- end
- function SWEP:SecondaryAttack()
- self.Weapon:SetNextSecondaryFire(CurTime() + .5)
- if(self.Owner:KeyDown(IN_SPEED)) then return false end
- local EyeTrace = self.Owner:GetEyeTrace()
- hook.Call("PlayerFistsUse", nil, self.Owner, self, EyeTrace)
- local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
- if(IsValid(EyeTrace.Entity:GetPhysicsObject()) && (self.Owner.grabbeditem != EyeTrace.Entity)) then if(!EyeTrace.Entity:GetPhysicsObject():IsMoveable()) then return; end end
- if !EyeTrace.Entity:IsValid() then return false end
- --SHOVE
- if(EyeTrace.Entity:IsPlayer() && Distance <= 60) then
- if(EyeTrace.Entity:IsPolice(true)) then return false end
- local aimvector = self.Owner:GetAimVector()
- local superpush = self.Owner:EV_IsOwner() && self.Owner:KeyDown(IN_RELOAD)
- if(!superpush) then aimvector.z = 0 end
- EyeTrace.Entity:SetVelocity(aimvector*200*Either(superpush,5,1))
- self:SendWeaponAnim(ACT_VM_IDLE)
- self.Owner:Animate("ph_push")
- local Animation = self.Owner:GetViewModel()
- Animation:SetSequence(Animation:LookupSequence("shove"))
- return
- end
- --KNOCK
- if(EyeTrace.Entity:IsDoor()) then
- if Distance > 75 then return false; end
- self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
- self.Weapon:EmitSound("physics/plastic/plastic_box_impact_hard" .. tostring(math.random(1, 4)) .. ".wav", 82, 80)
- self.Owner:RestartGesture(ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST)
- self.Weapon:SetNextSecondaryFire(CurTime() + .25)
- end
- end]]
- function SWEP:Initialize()
- self:SetHoldType("normal")
- self:SetWeaponHoldType( self.HoldType )
- end
- SWEP.ViewModel = "models/weapons/me_fists/v_me_fists.mdl";
- SWEP.WorldModel = "models/perp2/w_fists.mdl";
- function SWEP:CanPrimaryAttack ( ) return true; end
- function SWEP:PrimaryAttack()
- self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
- self.Weapon:EmitSound("npc/vort/claw_swing" .. math.random(1, 2) .. ".wav");
- self:SetHoldType("fist")
- timer.Simple(5, function() self.SetHoldType ("normal") end )
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- self.Owner:ViewPunch( self.ViewPunch )
- self.Weapon:SetNextPrimaryFire(CurTime() + .5)
- local EyeTrace = self.Owner:GetEyeTrace();
- local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
- if Distance > 75 then return false; end
- if EyeTrace.MatType == MAT_GLASS then
- self.Weapon:EmitSound("physics/glass/glass_cup_break" .. math.random(1, 2) .. ".wav");
- return false
- end
- if EyeTrace.HitWorld then
- self.Weapon:EmitSound("physics/flesh/flesh_impact_hard" .. math.random(1, 5) .. ".wav");
- return false;
- end
- if !EyeTrace.Entity or !EyeTrace.Entity:IsValid() or !EyeTrace.HitNonWorld then return false; end
- if EyeTrace.MatType == MAT_FLESH then
- // probably another person or NPC
- self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
- local OurEffect = EffectData();
- OurEffect:SetOrigin(EyeTrace.HitPos);
- util.Effect("BloodImpact", OurEffect);
- if SERVER and !EyeTrace.Entity:IsNPC() then
- EyeTrace.Entity:TakeDamage(GAMEMODE.FistDamage, self.Owner, self.Weapon);
- self.Owner:GiveExperience(SKILL_UNARMED_COMBAT, 2, true);
- end
- return false;
- else
- // something else?
- self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
- end
- end
- function SWEP:SecondaryAttack()
- local EyeTrace = self.Owner:GetEyeTrace()
- if !EyeTrace.Entity:IsValid() or !EyeTrace.Entity:IsDoor() then return false; end
- local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
- if Distance > 75 then return false; end
- self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
- self.Weapon:EmitSound("physics/plastic/plastic_box_impact_hard" .. tostring(math.random(1, 4)) .. ".wav", 100, 100)
- self.Owner:RestartGesture(ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST)
- self.Weapon:SetNextSecondaryFire(CurTime() + .25)
- end
- /*
- function SWEP:SetWeaponHoldType( )
- self.ActivityTranslate = {}
- self.ActivityTranslate[ACT_HL2MP_IDLE] = ACT_HL2MP_IDLE_FIST;
- self.ActivityTranslate[ACT_HL2MP_WALK] = ACT_HL2MP_IDLE_FIST + 1;
- self.ActivityTranslate[ACT_HL2MP_RUN] = ACT_HL2MP_IDLE_FIST + 2;
- self.ActivityTranslate[ACT_HL2MP_IDLE_CROUCH] = ACT_HL2MP_IDLE_FIST + 3;
- self.ActivityTranslate[ACT_HL2MP_WALK_CROUCH] = ACT_HL2MP_IDLE_FIST + 4;
- self.ActivityTranslate[ACT_HL2MP_GESTURE_RANGE_ATTACK] = ACT_HL2MP_IDLE_FIST + 5;
- self.ActivityTranslate[ACT_HL2MP_GESTURE_RELOAD] = ACT_HL2MP_IDLE_FIST + 6;
- self.ActivityTranslate[ACT_HL2MP_JUMP] = ACT_HL2MP_IDLE_FIST + 7;
- self.ActivityTranslate[ACT_RANGE_ATTACK1] = ACT_HL2MP_IDLE_FIST + 8;
- end
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement