Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.05 KB | None | 0 0
  1.  
  2. if SERVER then
  3. AddCSLuaFile("shared.lua")
  4. end
  5.  
  6. if CLIENT then
  7. SWEP.PrintName = "Fists"
  8. SWEP.Slot = 2
  9. SWEP.SlotPos = 1
  10. SWEP.DrawAmmo = false
  11. SWEP.DrawCrosshair = true
  12.  
  13.  
  14. function SWEP:DrawHUD()
  15. surface.DrawCircle( ScrW() / 2, ScrH() / 2, 2, Color(200,200,200,255))
  16. end
  17.  
  18. end
  19.  
  20. SWEP.Author = "NMRIH, Fredy, StephenPuffs"
  21. SWEP.Instructions = "Left Click: Punch, Right Click: Shove/Drag, Reload to search suspects as police"
  22. SWEP.Contact = ""
  23. SWEP.Purpose = ""
  24.  
  25. SWEP.ViewModelFOV = 62
  26. SWEP.ViewModelFlip = false
  27. SWEP.AnimPrefix = "rpg"
  28.  
  29. SWEP.LockSound = "doors/door_latch1.wav"
  30. SWEP.UnlockSound = "doors/door_latch3.wav"
  31.  
  32. SWEP.Spawnable = false
  33. SWEP.AdminSpawnable = true
  34.  
  35. SWEP.Primary.ClipSize = -1
  36. SWEP.Primary.DefaultClip = 0
  37. SWEP.Primary.Automatic = true
  38. SWEP.Primary.Ammo = ""
  39.  
  40. SWEP.Secondary.ClipSize = -1
  41. SWEP.Secondary.DefaultClip = 0
  42. SWEP.Secondary.Automatic = false
  43. SWEP.Secondary.Ammo = ""
  44.  
  45. SWEP.ViewPunch = Angle( 0, 0, 0 )
  46. SWEP.Enabled = true
  47.  
  48. SWEP.AnimDeploy = nil
  49.  
  50. --[[function SWEP:Initialize()
  51. self:SetHoldType("normal")
  52. self.LastPunch = 0
  53. end
  54. SWEP.ViewModel = "models/weapons/me_fists/v_me_fists.mdl";
  55. SWEP.WorldModel = "models/perp2/w_fists.mdl";
  56.  
  57. function SWEP:Holster()
  58. if(SERVER) then
  59. if(self.Owner.grabbeditem != nil && IsValid(self.Owner.grabbeditem)) then
  60. if(self.Owner.grabbeditem.playerholding == self.Owner) then
  61. self.Owner.grabbeditem:GetPhysicsObject():ClearGameFlag(FVPHYSICS_PLAYER_HELD)
  62. self.Owner.grabbeditem.playerholding = nil
  63. self.Owner.grabbeditem:SetOwner(nil)
  64. self.Owner.grabbeditem.grabbeditem = nil;
  65. self.Owner.grabbeditem:SetNWEntity("grabbeditem", nil)
  66. end
  67. if(IsValid(self.Owner.CarryHack)) then
  68. self.Owner.CarryHack:Remove();
  69. self.Owner.CarryHack = nil;
  70. end
  71. return true;
  72. end
  73. end
  74. return true;
  75. end
  76. function SWEP:CanPrimaryAttack ( ) return true; end
  77.  
  78. function SWEP:PrimaryAttack()
  79. if(CLIENT && !IsFirstTimePredicted()) then return end
  80. self.LastPunch = CurTime()
  81. self.Owner:StopAnimation()
  82. self.Weapon:SetNextPrimaryFire(CurTime() + .6)
  83. if(self:GetHoldType() != "fist") then self:SetHoldType("fist") end
  84. local EyeTrace = self.Owner:GetEyeTrace()
  85. if(hook.Call("PlayerFistsAttack", nil, self.Owner, self, EyeTrace)) then
  86. return
  87. end
  88. self.Owner.Stamina = math.Clamp((self.Owner.Stamina or 100) - 1, 0, 100)
  89. //Default primary attack action = punching
  90. self:SendWeaponAnim(ACT_VM_IDLE)
  91.  
  92. local Animation = self.Owner:GetViewModel()
  93. Animation:SetSequence(Animation:LookupSequence("Attack_Quick_" .. math.random(1,2)))
  94. self.Owner:SetAnimation(PLAYER_ATTACK1)
  95.  
  96. timer.Simple(0.06, function()
  97. if(!IsValid(self) || !IsValid(self.Owner)) then return end
  98.  
  99. local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
  100. if Distance > 45 then return false; end
  101.  
  102. if EyeTrace.MatType == MAT_GLASS then
  103. self.Weapon:EmitSound("physics/glass/glass_cup_break" .. math.random(1, 2) .. ".wav");
  104. local ran = math.random(1, 3)
  105. if ran == 3 then
  106. self.Weapon:EmitSound("physics/flesh/flesh_bloody_break.wav");
  107. end
  108. return false
  109. end
  110.  
  111. if EyeTrace.HitWorld then
  112. self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav");
  113.  
  114. return false;
  115. end
  116.  
  117. if !IsValid(EyeTrace.Entity) or !EyeTrace.HitNonWorld or EyeTrace.Entity:IsNPC() then return false; end
  118.  
  119. if EyeTrace.MatType == MAT_FLESH then
  120. // probably another person
  121. self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
  122.  
  123. if EyeTrace.Entity:IsPlayer() then
  124. local gender = GetGenderOfModel(EyeTrace.Entity:GetModel())
  125. if math.random(1, 30) == 30 then
  126. if(!(EyeTrace.Entity:Team() != TEAM_CITIZEN && self.Owner:Team() != TEAM_CITIZEN)) then
  127. EyeTrace.Entity:SetNWFloat("bleeding", EyeTrace.Entity:GetNWFloat("bleeding", 0)+1)
  128. EyeTrace.Entity:SetNWEntity("bleedingcause", self.Owner)
  129. end
  130. EyeTrace.Entity:EmitSound("physics/body/body_medium_break3.wav")
  131. if gender == SEX_FEMALE then
  132. EyeTrace.Entity:EmitSound("Jarheads/Bodysounds/Coughing/Female_Cough" .. math.random(1, 4) .. ".wav")
  133. else
  134. EyeTrace.Entity:EmitSound("Jarheads/Bodysounds/Coughing/Male_Cough" .. math.random(1, 4) .. ".wav")
  135. end
  136. else
  137. if math.random(1, 5) == 5 then
  138. if gender == SEX_FEMALE then
  139. local tbl = {"gasp02", "gasp03", "hurt04", "hurt05", "hurt06", "hurt08", "uggh01", "uggh02"}
  140. local ran = math.random(1, 8)
  141. local sound = tbl[math.random(1,8)];
  142. EyeTrace.Entity:EmitSound("vo/npc/Alyx/" .. sound .. ".wav")
  143. else
  144. EyeTrace.Entity:EmitSound("ambient/voices/citizen_beaten" .. math.random(1, 5) .. ".wav")
  145. end
  146. end
  147. end
  148. --local OurEffect = EffectData();
  149. --OurEffect:SetOrigin(EyeTrace.HitPos);
  150. --util.Effect("BloodImpact", OurEffect, true);
  151. end
  152.  
  153. if SERVER then
  154. local dmgInfo = DamageInfo()
  155. 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))))
  156. dmgInfo:SetDamageType(DMG_RADIATION) //Stupid source engine, so now armor damage is done
  157. dmgInfo:SetAttacker(self.Owner)
  158. dmgInfo:SetInflictor(self)
  159. EyeTrace.Entity:TakeDamageInfo(dmgInfo);
  160. self.Owner:GiveExperience(SKILL_UNARMED_COMBAT, math.random(1, 2), true);
  161. if(EyeTrace.Entity:IsPlayer()) then hook.Call("OnPlayerPunchedPlayer", nil, EyeTrace.Entity, self.Owner) end
  162. end
  163.  
  164. return false;
  165. elseif(EyeTrace.Entity:IsDoor() && self.Owner:GetNWBool("IsZombie")) then
  166. EyeTrace.Entity:EmitSound("physics/wood/wood_box_impact_hard" .. math.random(1, 3) .. ".wav",65)
  167. if(SERVER) then
  168. if(math.random(1,50) == 1) then
  169. EyeTrace.Entity:Fire("unlock","",0)
  170. EyeTrace.Entity:Fire("open","",0.1)
  171. end
  172. end
  173. else
  174. // something else?
  175.  
  176. self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
  177. end
  178. end)
  179.  
  180. end
  181.  
  182. function SWEP:Think()
  183. hook.Call("PlayerFistThink", nil, self, self.Owner)
  184. if(SERVER) then
  185. if(self.Owner:KeyPressed(IN_RELOAD) && (!self.Owner.lastflippeddrug || CurTime() - self.Owner.lastflippeddrug > 0.5)) then
  186. self.Owner.lastflippeddrug = CurTime()
  187. hook.Call("PlayerFistReload", nil, self, self.Owner)
  188. GAMEMODE.FlipDrug(self.Owner)
  189. end
  190. end
  191. if((self.LastPunch or 0) + 5 < CurTime() && self:GetHoldType() != "normal") then self:SetHoldType("normal") end
  192. end
  193.  
  194. function SWEP:SecondaryAttack()
  195. self.Weapon:SetNextSecondaryFire(CurTime() + .5)
  196. if(self.Owner:KeyDown(IN_SPEED)) then return false end
  197. local EyeTrace = self.Owner:GetEyeTrace()
  198. hook.Call("PlayerFistsUse", nil, self.Owner, self, EyeTrace)
  199. local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
  200. if(IsValid(EyeTrace.Entity:GetPhysicsObject()) && (self.Owner.grabbeditem != EyeTrace.Entity)) then if(!EyeTrace.Entity:GetPhysicsObject():IsMoveable()) then return; end end
  201. if !EyeTrace.Entity:IsValid() then return false end
  202. --SHOVE
  203. if(EyeTrace.Entity:IsPlayer() && Distance <= 60) then
  204. if(EyeTrace.Entity:IsPolice(true)) then return false end
  205. local aimvector = self.Owner:GetAimVector()
  206. local superpush = self.Owner:EV_IsOwner() && self.Owner:KeyDown(IN_RELOAD)
  207. if(!superpush) then aimvector.z = 0 end
  208. EyeTrace.Entity:SetVelocity(aimvector*200*Either(superpush,5,1))
  209. self:SendWeaponAnim(ACT_VM_IDLE)
  210. self.Owner:Animate("ph_push")
  211. local Animation = self.Owner:GetViewModel()
  212. Animation:SetSequence(Animation:LookupSequence("shove"))
  213. return
  214. end
  215. --KNOCK
  216. if(EyeTrace.Entity:IsDoor()) then
  217. if Distance > 75 then return false; end
  218. self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
  219. self.Weapon:EmitSound("physics/plastic/plastic_box_impact_hard" .. tostring(math.random(1, 4)) .. ".wav", 82, 80)
  220. self.Owner:RestartGesture(ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST)
  221. self.Weapon:SetNextSecondaryFire(CurTime() + .25)
  222. end
  223. end]]
  224. function SWEP:Initialize()
  225. self:SetHoldType("normal")
  226. self:SetWeaponHoldType( self.HoldType )
  227.  
  228. end
  229.  
  230. SWEP.ViewModel = "models/weapons/me_fists/v_me_fists.mdl";
  231. SWEP.WorldModel = "models/perp2/w_fists.mdl";
  232.  
  233. function SWEP:CanPrimaryAttack ( ) return true; end
  234.  
  235. function SWEP:PrimaryAttack()
  236. self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
  237. self.Weapon:EmitSound("npc/vort/claw_swing" .. math.random(1, 2) .. ".wav");
  238. self:SetHoldType("fist")
  239. timer.Simple(5, function() self.SetHoldType ("normal") end )
  240. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  241. self.Owner:ViewPunch( self.ViewPunch )
  242.  
  243. self.Weapon:SetNextPrimaryFire(CurTime() + .5)
  244.  
  245. local EyeTrace = self.Owner:GetEyeTrace();
  246.  
  247. local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
  248. if Distance > 75 then return false; end
  249.  
  250. if EyeTrace.MatType == MAT_GLASS then
  251. self.Weapon:EmitSound("physics/glass/glass_cup_break" .. math.random(1, 2) .. ".wav");
  252. return false
  253. end
  254.  
  255. if EyeTrace.HitWorld then
  256. self.Weapon:EmitSound("physics/flesh/flesh_impact_hard" .. math.random(1, 5) .. ".wav");
  257.  
  258. return false;
  259. end
  260.  
  261. if !EyeTrace.Entity or !EyeTrace.Entity:IsValid() or !EyeTrace.HitNonWorld then return false; end
  262.  
  263. if EyeTrace.MatType == MAT_FLESH then
  264. // probably another person or NPC
  265. self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
  266.  
  267. local OurEffect = EffectData();
  268. OurEffect:SetOrigin(EyeTrace.HitPos);
  269. util.Effect("BloodImpact", OurEffect);
  270.  
  271. if SERVER and !EyeTrace.Entity:IsNPC() then
  272. EyeTrace.Entity:TakeDamage(GAMEMODE.FistDamage, self.Owner, self.Weapon);
  273. self.Owner:GiveExperience(SKILL_UNARMED_COMBAT, 2, true);
  274. end
  275.  
  276. return false;
  277. else
  278. // something else?
  279.  
  280. self.Weapon:EmitSound("physics/flesh/flesh_impact_bullet" .. math.random(1, 5) .. ".wav")
  281. end
  282. end
  283.  
  284. function SWEP:SecondaryAttack()
  285. local EyeTrace = self.Owner:GetEyeTrace()
  286.  
  287. if !EyeTrace.Entity:IsValid() or !EyeTrace.Entity:IsDoor() then return false; end
  288.  
  289. local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
  290.  
  291. if Distance > 75 then return false; end
  292.  
  293. self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
  294. self.Weapon:EmitSound("physics/plastic/plastic_box_impact_hard" .. tostring(math.random(1, 4)) .. ".wav", 100, 100)
  295. self.Owner:RestartGesture(ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST)
  296.  
  297. self.Weapon:SetNextSecondaryFire(CurTime() + .25)
  298. end
  299.  
  300. /*
  301. function SWEP:SetWeaponHoldType( )
  302. self.ActivityTranslate = {}
  303.  
  304. self.ActivityTranslate[ACT_HL2MP_IDLE] = ACT_HL2MP_IDLE_FIST;
  305. self.ActivityTranslate[ACT_HL2MP_WALK] = ACT_HL2MP_IDLE_FIST + 1;
  306. self.ActivityTranslate[ACT_HL2MP_RUN] = ACT_HL2MP_IDLE_FIST + 2;
  307. self.ActivityTranslate[ACT_HL2MP_IDLE_CROUCH] = ACT_HL2MP_IDLE_FIST + 3;
  308. self.ActivityTranslate[ACT_HL2MP_WALK_CROUCH] = ACT_HL2MP_IDLE_FIST + 4;
  309. self.ActivityTranslate[ACT_HL2MP_GESTURE_RANGE_ATTACK] = ACT_HL2MP_IDLE_FIST + 5;
  310. self.ActivityTranslate[ACT_HL2MP_GESTURE_RELOAD] = ACT_HL2MP_IDLE_FIST + 6;
  311. self.ActivityTranslate[ACT_HL2MP_JUMP] = ACT_HL2MP_IDLE_FIST + 7;
  312. self.ActivityTranslate[ACT_RANGE_ATTACK1] = ACT_HL2MP_IDLE_FIST + 8;
  313. end
  314. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement