Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.13 KB | None | 0 0
  1. function SWEP:PrimaryAttack()
  2. if self.Weapon:Clip1() <= 0 then self:EmitSound("common/wpn_denyselect.wav") return end
  3. local tr = self.Owner:GetEyeTrace()
  4. local target = tr.Entity
  5. if (tr.HitPos - self.Owner:GetShootPos()):Length() < 100 then
  6. local chancestun = math.random(1,20)
  7. if (string.find(tr.Entity:GetClass(), "npc_strider")
  8. -- There are all classes,who cant stun.
  9. or string.find(tr.Entity:GetClass(), "npc_helicopter")
  10. or string.find(tr.Entity:GetClass(), "npc_combinegunship")
  11. or string.find(tr.Entity:GetClass(), "npc_combinedropship")
  12. or string.find(tr.Entity:GetClass(), "npc_turret_floor")
  13. or string.find(tr.Entity:GetClass(), "npc_turret_ceiling")
  14. or string.find(tr.Entity:GetClass(), "npc_turret_ground")
  15. or string.find(tr.Entity:GetClass(), "npc_clawscanner")
  16. or string.find(tr.Entity:GetClass(), "npc_cscanner")
  17. or string.find(tr.Entity:GetClass(), "npc_manhack")
  18. or string.find(tr.Entity:GetClass(), "npc_barnacle")) then
  19. self:EmitSound(Sound(self.Primary.Sound))
  20. else
  21. if SERVER and tr.Entity:IsNPC() and IsValid(tr.Entity) and
  22. MyChanceStun(chancestun) then
  23. self:EmitSound("weapons/stunstick/stunstick_fleshhit" .. math.random(1,2) .. ".wav")
  24. -- This is all vars,what we need.
  25. if target:GetActiveWeapon():IsValid() and IsValid(target:GetActiveWeapon()) then
  26. weaponnpc = target:GetActiveWeapon():GetClass()
  27. weaponmodel = target:GetActiveWeapon():GetModel()
  28. else
  29. weaponnpc = nil
  30. weaponmodel = nil
  31. end
  32. npcskin = target:GetSkin()
  33. npcclass = target:GetClass()
  34. npchealth = target:Health()
  35. npcangle = target:GetAngles()
  36. npcmodel = target:GetModel()
  37. npcmaterial = target:GetMaterial()
  38. npcname = target:GetName()
  39. npccolor = target:GetColor()
  40. -- Spawning stunning ragdoll.Lol :D
  41. local rag = ents.Create("prop_ragdoll")
  42. rag:SetModel(npcmodel)
  43. rag:SetSkin(npcskin)
  44. rag:SetMaterial(npcmaterial)
  45. rag:SetPos(target:GetPos())
  46. rag:Spawn()
  47. rag:GetTable().ang = npcangle
  48. rag:SetNWString("NpcClass",npcclass)
  49. rag:SetColor(Color(npccolor.r,npccolor.g,npccolor.b,npccolor.a))
  50. rag:SetNWString("NpcName",npcname)
  51. rag:SetName(rag:GetNWString("NpcName"))
  52. rag:SetNWInt("Health",npchealth)
  53. rag:SetNWInt("Takedamages",0)
  54. rag:SetNWBool("IsStunedNPC",true)
  55. if !(weaponnpc == nil) then
  56. rag:SetNWString("WeaponNpc",weaponnpc)
  57. end
  58. for i = 0,32 do
  59. rag:SetBodygroup(i,target:GetBodygroup(i))
  60. end
  61. for i = 0, rag:GetPhysicsObjectCount( ) do
  62. local physobj = rag:GetPhysicsObjectNum( i )
  63. if (physobj) and IsValid(physobj)then
  64. local pos, ang = target:GetBonePosition( target:TranslatePhysBoneToBone( i ) )
  65. physobj:SetPos(pos)
  66. physobj:SetAngles(ang)
  67. physobj:EnableMotion(false)
  68. end
  69. end
  70. if weaponmodel != nil then
  71. local wep = ents.Create("cycler")
  72. wep:SetModel( weaponmodel )
  73. wep:SetParent(rag)
  74. wep:AddEffects( EF_BONEMERGE )
  75. wep:Spawn()
  76. end
  77. target:Remove()
  78. timer.Simple(ststuntimecvar:GetFloat(),function() if IsValid(rag) then
  79. -- Spawning our npc.
  80. local npc = ents.Create(rag:GetNWString("NpcClass"))
  81. if !(rag:GetTable().ang == nil) then
  82. npc:SetAngles(rag:GetTable().ang)
  83. else
  84. npc:SetAngles(Angle(0,0,0))
  85. end
  86. npc:SetPos(rag:GetPos())
  87. -- So,npc cant use player weapons.
  88. if !(rag:GetNWString("WeaponNpc") == nil) then
  89. if rag:GetNWString("WeaponNpc") == "weapon_smg1" then
  90. npc:SetKeyValue("additionalequipment","ai_weapon_smg1")
  91. elseif rag:GetNWString("WeaponNpc") == "weapon_357" then
  92. npc:SetKeyValue("additionalequipment","ai_weapon_357")
  93. elseif rag:GetNWString("WeaponNpc") == "weapon_crossbow" then
  94. npc:SetKeyValue("additionalequipment","ai_weapon_crossbow")
  95. elseif rag:GetNWString("WeaponNpc") == "weapon_crowbar" then
  96. npc:SetKeyValue("additionalequipment","ai_weapon_crowbar")
  97. elseif rag:GetNWString("WeaponNpc") == "weapon_rpg" then
  98. npc:SetKeyValue("additionalequipment","ai_weapon_rpg")
  99. elseif rag:GetNWString("WeaponNpc") == "weapon_stunstick" then
  100. npc:SetKeyValue("additionalequipment","ai_weapon_stunstick")
  101. elseif rag:GetNWString("WeaponNpc") == "weapon_pistol" then
  102. npc:SetKeyValue("additionalequipment","ai_weapon_pistol")
  103. elseif rag:GetNWString("WeaponNpc") == "ai_weapon_shotgun" then
  104. npc:SetKeyValue("additionalequipment","ai_weapon_shotgun")
  105. elseif rag:GetNWString("WeaponNpc") == "weapon_ar2" then
  106. npc:SetKeyValue("additionalequipment","ai_weapon_ar2")
  107. else
  108. npc:SetKeyValue("additionalequipment",rag:GetNWString("WeaponNpc"))
  109. end
  110. end
  111. npc:SetSkin(rag:GetSkin())
  112. npc:Activate()
  113. npc:Spawn()
  114. npc:SetModel(rag:GetModel())
  115. npc:SetMaterial(rag:GetMaterial())
  116. npc:SetColor(Color(rag:GetColor().r,rag:GetColor().g,rag:GetColor().b,rag:GetColor().a))
  117. npc:SetName(rag:GetNWString("NpcName"))
  118. npc:SetHealth(rag:GetNWInt("Health"))
  119. for i = 0,32 do
  120. npc:SetBodygroup(i,rag:GetBodygroup(i))
  121. end
  122. rag:Remove()
  123. end
  124. end)
  125. elseif SERVER and tr.Entity:IsNPC() and IsValid(tr.Entity) and
  126. MyChanceShock(chancestun) then
  127. self:EmitSound("weapons/stunstick/stunstick_fleshhit" .. math.random(1,2) .. ".wav")
  128. -- This is all vars,what we need.
  129. if target:GetActiveWeapon():IsValid() and IsValid(target:GetActiveWeapon()) then
  130. weaponnpc2 = target:GetActiveWeapon():GetClass()
  131. weaponmodel2 = target:GetActiveWeapon():GetModel()
  132. else
  133. weaponnpc2 = nil
  134. weaponmodel2 = nil
  135. end
  136. npcskin2 = target:GetSkin()
  137. npcclass2 = target:GetClass()
  138. npchealth2 = target:Health()
  139. npcangle2 = target:GetAngles()
  140. npcmodel2 = target:GetModel()
  141. npcmaterial2 = target:GetMaterial()
  142. npcname2 = target:GetName()
  143. npccolor2 = target:GetColor()
  144. local rag2 = ents.Create("prop_ragdoll")
  145. rag2:SetModel(npcmodel2)
  146. rag2:SetSkin(npcskin2)
  147. rag2:SetMaterial(npcmaterial2)
  148. rag2:SetPos(target:GetPos())
  149. rag2:SetColor(Color(npccolor2.r,npccolor2.g,npccolor2.b,npccolor2.a))
  150. rag2:Spawn()
  151. rag2:SetNWString("NpcClass2",npcclass2)
  152. rag2:SetNWString("NpcName2",npcname2)
  153. rag2:SetName(rag2:GetNWString("NpcName2"))
  154. rag2:GetTable().ang2 = npcangle
  155. rag2:SetNWBool("IsStunedNPC2",true)
  156. rag2:SetNWBool("NotAlivenpc",false)
  157. rag2:SetNWInt("Takedamages2",0)
  158. rag2:SetNWInt("Health2",npchealth2)
  159. if !(weaponnpc2 == nil) then
  160. rag2:SetNWString("WeaponNpc2",weaponnpc2)
  161. end
  162. for i = 0,32 do
  163. rag2:SetBodygroup(i,target:GetBodygroup(i))
  164. end
  165. for i = 0, rag2:GetPhysicsObjectCount( ) do
  166. local physobj = rag2:GetPhysicsObjectNum( i )
  167. if (physobj) and IsValid(physobj)then
  168. local pos, ang = target:GetBonePosition( target:TranslatePhysBoneToBone( i ) )
  169. physobj:SetPos(pos)
  170. physobj:SetAngles(ang)
  171. physobj:EnableMotion(true)
  172. physobj:ApplyForceCenter((target:GetPos() - self.Owner:GetPos())*20)
  173. end
  174. end
  175. if weaponmodel2 != nil then
  176. local wep2 = ents.Create("cycler")
  177. wep2:SetModel( weaponmodel2 )
  178. wep2:SetParent(rag2)
  179. wep2:AddEffects( EF_BONEMERGE )
  180. wep2:Spawn()
  181. end
  182. target:Remove()
  183. timer.Create( "shockstunrag" .. rag2:EntIndex(),0.2,(stshocktimecvar:GetFloat()*10)/2,function()
  184. if IsValid(rag2) then
  185. local PhysObj = rag2:GetPhysicsObject()
  186. local mass = PhysObj:GetMass()
  187. PhysObj:ApplyForceOffset((mass * 4 * Vector(math.Rand(-13.5, 15.2), math.Rand(-13.5, 15.2), math.Rand(13.5, 20.2))), (PhysObj:GetPos() + Vector(math.Rand(-82, 82), math.Rand(-82, 82), math.Rand(-82, 82))))
  188. if stshockeffectencvar:GetBool() then
  189. local effectdata = EffectData()
  190. effectdata:SetOrigin( rag2:GetPos() )
  191. effectdata:SetStart( rag2:GetPos() )
  192. effectdata:SetMagnitude(15)
  193. effectdata:SetEntity( rag2 )
  194. util.Effect( "TeslaHitBoxes", effectdata)
  195. local light = ents.Create("light_dynamic")
  196. light:SetPos( rag2:GetPos() )
  197. light:Spawn()
  198. light:SetKeyValue("_light","235 235 255")
  199. light:SetKeyValue("distance",120)
  200. light:SetParent( rag2 )
  201. light:Fire("kill","",0.1)
  202. end
  203. rag2:EmitSound("Town.d1_town_01_LoudSpark")
  204. end
  205. end)
  206. timer.Simple(stshocktimecvar:GetFloat() + stragdolltimecvar:GetFloat(),function()
  207. if SERVER and IsValid(rag2) and rag2:GetNWBool("NotAlivenpc") == true then
  208. rag2:Fire( "FadeAndRemove", "", 0.4)
  209. end
  210. end)
  211. timer.Simple(stshocktimecvar:GetFloat(),function() if IsValid(rag2) and !(rag2:GetNWBool("NotAlivenpc") == true) then
  212. -- Spawning our npc.
  213. local npc = ents.Create(rag2:GetNWString("NpcClass2"))
  214. if !(rag2:GetTable().ang2 == nil) then
  215. npc:SetAngles(rag2:GetTable().ang2)
  216. else
  217. npc:SetAngles(Angle(0,0,0))
  218. end
  219. npc:SetPos(rag2:GetPos())
  220. -- So,npc cant use player weapons.
  221. if !(rag2:GetNWString("WeaponNpc2") == nil) then
  222. if rag2:GetNWString("WeaponNpc2") == "weapon_smg1" then
  223. npc:SetKeyValue("additionalequipment","ai_weapon_smg1")
  224. elseif rag2:GetNWString("WeaponNpc2") == "weapon_357" then
  225. npc:SetKeyValue("additionalequipment","ai_weapon_357")
  226. elseif rag2:GetNWString("WeaponNpc2") == "weapon_crossbow" then
  227. npc:SetKeyValue("additionalequipment","ai_weapon_crossbow")
  228. elseif rag2:GetNWString("WeaponNpc2") == "weapon_crowbar" then
  229. npc:SetKeyValue("additionalequipment","ai_weapon_crowbar")
  230. elseif rag2:GetNWString("WeaponNpc2") == "weapon_rpg" then
  231. npc:SetKeyValue("additionalequipment","ai_weapon_rpg")
  232. elseif rag2:GetNWString("WeaponNpc2") == "weapon_stunstick" then
  233. npc:SetKeyValue("additionalequipment","ai_weapon_stunstick")
  234. elseif rag2:GetNWString("WeaponNpc2") == "weapon_pistol" then
  235. npc:SetKeyValue("additionalequipment","ai_weapon_pistol")
  236. elseif rag2:GetNWString("WeaponNpc2") == "ai_weapon_shotgun" then
  237. npc:SetKeyValue("additionalequipment","ai_weapon_shotgun")
  238. elseif rag2:GetNWString("WeaponNpc2") == "weapon_ar2" then
  239. npc:SetKeyValue("additionalequipment","ai_weapon_ar2")
  240. else
  241. npc:SetKeyValue("additionalequipment",rag2:GetNWString("WeaponNpc2"))
  242. end
  243. end
  244. npc:SetSkin(rag2:GetSkin())
  245. npc:Activate()
  246. npc:Spawn()
  247. npc:SetModel(rag2:GetModel())
  248. npc:SetMaterial(rag2:GetMaterial())
  249. npc:SetColor(Color(rag2:GetColor().r,rag2:GetColor().g,rag2:GetColor().b,rag2:GetColor().a))
  250. npc:SetName(rag2:GetNWString("NpcName2"))
  251. npc:SetHealth(rag2:GetNWInt("Health2"))
  252. for i = 0,32 do
  253. npc:SetBodygroup(i,rag2:GetBodygroup(i))
  254. end
  255. rag2:Remove()
  256. end
  257. end)
  258. elseif SERVER and tr.Entity:IsPlayer() and tr.Entity:Alive() and IsValid(tr.Entity) and target:GetNWBool("StunnedPlayer")==false and
  259. MyChanceStun(chancestun) then
  260. self:EmitSound("weapons/stunstick/stunstick_fleshhit" .. math.random(1,2) .. ".wav")
  261. target:Freeze(true)
  262. target:ViewPunch( Angle( -16,math.Rand(-48, -24),2 ) )
  263. target:ScreenFade(bit.bor(SCREENFADE.OUT,SCREENFADE.PURGE),color_white,0.3,0)
  264. target:SetNWBool("StunnedPlayer",true)
  265. timer.Simple(ststuntimecvar:GetFloat(),function() if IsValid(target) then
  266. target:Freeze(false)
  267. target:SetNWBool("StunnedPlayer",false)
  268. end
  269. end)
  270. elseif SERVER and tr.Entity:IsPlayer() and tr.Entity:Alive() and IsValid(tr.Entity) and
  271. MyChanceShock(chancestun) then
  272. -- This is all vars,what we need.
  273. local myweps={}
  274. for k, v in pairs(target:GetWeapons()) do
  275. table.insert(myweps,v:GetClass())
  276. end
  277. local myammo={}
  278. for k, v in pairs(target:GetWeapons()) do
  279. table.insert(myammo,v:Clip1())
  280. end
  281. local myammoin={}
  282. local myammointype={}
  283. for k, v in pairs(target:GetWeapons()) do
  284. table.insert(myammoin,target:GetAmmoCount(v:GetPrimaryAmmoType()))
  285. table.insert(myammointype,v:GetPrimaryAmmoType())
  286. end
  287. local myammoin2={}
  288. local myammointype2={}
  289. for k, v in pairs(target:GetWeapons()) do
  290. table.insert(myammoin2,target:GetAmmoCount(v:GetSecondaryAmmoType()))
  291. table.insert(myammointype2,v:GetSecondaryAmmoType())
  292. end
  293. if target:GetActiveWeapon():IsValid() and IsValid(target:GetActiveWeapon()) then
  294. weaponply = target:GetActiveWeapon():GetClass()
  295. weaponplymodel = target:GetActiveWeapon():GetModel()
  296. else
  297. weaponply = nil
  298. weaponplymodel = nil
  299. end
  300. plyskin = target:GetSkin()
  301. plyhealth = target:Health()
  302. plyangle = target:GetAngles()
  303. plymodel = target:GetModel()
  304. plycolor = target:GetColor()
  305. plyarmor = target:Armor()
  306. plymaterial = target:GetMaterial()
  307. local rag3 = ents.Create("prop_ragdoll")
  308. rag3:SetModel(plymodel)
  309. rag3:SetSkin(plyskin)
  310. rag3:SetPos(target:GetPos())
  311. rag3:SetColor(Color(plycolor.r,plycolor.g,plycolor.b,plycolor.a))
  312. rag3:SetMaterial(plymaterial)
  313. rag3:Spawn()
  314. rag3:GetTable().ang3 = plyangle
  315. rag3:SetNWBool("IsStunedNPC2",true)
  316. rag3:SetNWBool("IsStunedPlayer",true)
  317. rag3:SetNWBool("NotAlivenpc",false)
  318. rag3:SetNWInt("Takedamages2",0)
  319. rag3:SetNWInt("Health2",plyhealth)
  320. rag3:SetNWInt("Armor",plyarmor)
  321. rag3:SetNWEntity("Playerent",target)
  322. rag3.mywepsgive = myweps
  323. rag3.myammogive = myammo
  324. rag3.myammoingive = myammoin
  325. rag3.myammointypegive = myammointype
  326. rag3.myammoingive2 = myammoin2
  327. rag3.myammointypegive2 = myammointype2
  328. target:Spectate( OBS_MODE_CHASE )
  329. target:SpectateEntity( rag3 )
  330. target:StripWeapons()
  331. for i = 0,32 do
  332. rag3:SetBodygroup(i,target:GetBodygroup(i))
  333. end
  334. for i = 0, rag3:GetPhysicsObjectCount( ) do
  335. local physobj = rag3:GetPhysicsObjectNum( i )
  336. if (physobj) and IsValid(physobj)then
  337. local pos, ang = target:GetBonePosition( target:TranslatePhysBoneToBone( i ) )
  338. physobj:SetPos(pos)
  339. physobj:SetAngles(ang)
  340. physobj:EnableMotion(true)
  341. physobj:ApplyForceCenter((target:GetPos() - self.Owner:GetPos())*20)
  342. end
  343. end
  344. if weaponply!= nil then
  345. local wep2 = ents.Create("cycler")
  346. wep2:SetModel( weaponplymodel )
  347. wep2:SetParent(rag3)
  348. wep2:AddEffects( EF_BONEMERGE )
  349. wep2:Spawn()
  350. end
  351. target:Spectate( OBS_MODE_CHASE )
  352. target:SpectateEntity( rag3 )
  353. timer.Create( "shockstunragply" .. rag3:EntIndex(),0.2,(stshocktimecvar:GetFloat()*10)/2,function()
  354. if IsValid(rag3) then
  355. local PhysObj = rag3:GetPhysicsObject()
  356. local mass = PhysObj:GetMass()
  357. PhysObj:ApplyForceOffset((mass * 4 * Vector(math.Rand(-13.5, 15.2), math.Rand(-13.5, 15.2), math.Rand(13.5, 20.2))), (PhysObj:GetPos() + Vector(math.Rand(-82, 82), math.Rand(-82, 82), math.Rand(-82, 82))))
  358. if stshockeffectencvar:GetBool() then
  359. local effectdata = EffectData()
  360. effectdata:SetOrigin( rag3:GetPos() )
  361. effectdata:SetStart( rag3:GetPos() )
  362. effectdata:SetMagnitude(15)
  363. effectdata:SetEntity( rag3 )
  364. util.Effect( "TeslaHitBoxes", effectdata)
  365. local light = ents.Create("light_dynamic")
  366. light:SetPos( rag3:GetPos() )
  367. light:Spawn()
  368. light:SetKeyValue("_light","235 235 255")
  369. light:SetKeyValue("distance",120)
  370. light:SetParent( rag3 )
  371. light:Fire("kill","",0.1)
  372. end
  373. rag3:EmitSound("Town.d1_town_01_LoudSpark")
  374. end
  375. end)
  376. timer.Simple(stshocktimecvar:GetFloat() + stragdolltimecvar:GetFloat(),function()
  377. if SERVER and IsValid(rag3) and rag3:GetNWBool("NotAlivenpc") == true then
  378. rag3:Fire( "FadeAndRemove", "", 0.4)
  379. end
  380. end)
  381. timer.Simple(stshocktimecvar:GetFloat(),function() if IsValid(rag3) and !(rag3:GetNWBool("NotAlivenpc") == true) then
  382. -- Spawning our player.
  383. rag3:GetNWEntity("Playerent"):UnSpectate()
  384. local ply = rag3:GetNWEntity("Playerent")
  385. ply:Activate()
  386. ply:Spawn()
  387. ply:StripWeapons()
  388. local weps = rag3.mywepsgive
  389. local ammos = rag3.myammogive
  390. for i=1, #weps, 1 do
  391. ply:Give(weps[i])
  392. end
  393. local plywp = ply:GetWeapons()
  394. local plyams = ammos
  395. for i=1, #plywp, 1 do
  396. for k=1, #plyams, 1 do
  397. plywp[i]:SetClip1(plyams[i])
  398. end
  399. end
  400. local plammoin = rag3.myammoingive
  401. local plammointype = rag3.myammointypegive
  402. for i=1, #plammoin, 1 do
  403. for b=1, #plammointype, 1 do
  404. ply:SetAmmo(plammoin[i], plammointype[i])
  405. end
  406. end
  407. local plammoin2 = rag3.myammoingive2
  408. local plammointype2 = rag3.myammointypegive2
  409. for i=1, #plammoin2, 1 do
  410. for b=1, #plammointype2, 1 do
  411. ply:SetAmmo(plammoin2[i], plammointype2[i])
  412. end
  413. end
  414. ply:GetWeapon("weapon_stunner")
  415. ply:SetAngles(rag3:GetTable().ang3 )
  416. ply:SetPos(rag3:GetPos())
  417. ply:SetModel(rag3:GetModel())
  418. ply:SetMaterial(rag3:GetMaterial())
  419. ply:SetSkin(rag3:GetSkin())
  420. ply:SetHealth(rag3:GetNWInt("Health2"))
  421. ply:SetArmor(rag3:GetNWInt("Armor"))
  422. if ply:Armor() <= 0 then
  423. ply:SetArmor(0)
  424. end
  425. for i = 0,32 do
  426. ply:SetBodygroup(i,rag3:GetBodygroup(i))
  427. end
  428. rag3:SetNWBool("notrespawnneed",true)
  429. rag3:Remove()
  430. end
  431. end)
  432. elseif SERVER and tr.Entity:IsNPC() and IsValid(tr.Entity) and MyChanceNormal(chancestun) then
  433. self:EmitSound("weapons/stunstick/stunstick_fleshhit" .. math.random(1,2) .. ".wav")
  434. else
  435. self:EmitSound(Sound(self.Primary.Sound))
  436. end
  437. end
  438. local bullet = {}
  439. bullet.Num = 1
  440. bullet.Src = self.Owner:GetShootPos()
  441. bullet.Dir = self.Owner:GetAimVector()
  442. bullet.Spread = Vector( 0.1 * 0.1 , 0.1 * 0.1, 0)
  443. bullet.Tracer = 0
  444. bullet.Force = 20
  445. bullet.Damage = math.random(stdmgcvarmin:GetInt(),stdmgcvarmax:GetInt())
  446. bullet.Callback = function(attacker, trace, dmginfo)
  447. dmginfo:SetDamageType(DMG_GENERIC)
  448. end
  449. bullet.AmmoType = self.Primary.Ammo
  450. local rnda = 2 * -1
  451. local rndb = 2 * math.random(-1, 1)
  452. self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
  453. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  454. self.Owner:FireBullets( bullet )
  455. self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
  456. if !(stunlimitedpowercvar:GetBool()) then
  457. self:TakePrimaryAmmo(self.Primary.TakeAmmo)
  458. end
  459. self:SetNextPrimaryFire( CurTime() + stfireratecvar:GetFloat() )
  460. self:SetNextSecondaryFire( CurTime() + stfireratecvar:GetFloat() )
  461. timer.Create( "stunner_idle" .. self:EntIndex(), 0.6, 1, function() if IsValid(self.Weapon) and self.Weapon:GetOwner():GetActiveWeapon():GetClass() == "weapon_stunner" then self.Weapon:SendWeaponAnim(ACT_VM_IDLE) end end)
  462. else
  463. self:EmitSound("weapons/stunstick/stunstick_swing" .. math.random(1,2) .. ".wav" )
  464. self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
  465. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  466. self:SetNextPrimaryFire( CurTime() + stfireratecvar:GetFloat() )
  467. self:SetNextSecondaryFire( CurTime() + stfireratecvar:GetFloat() )
  468. timer.Create( "stunner_idle" .. self:EntIndex(), 0.6, 1, function() if IsValid(self.Weapon) and self.Weapon:GetOwner():GetActiveWeapon():GetClass() == "weapon_stunner" then self.Weapon:SendWeaponAnim(ACT_VM_IDLE) end end)
  469. end
  470. end
  471.  
  472. hook.Add( "EntityRemoved", "PlayerRemoved", function( ent )
  473. if SERVER and ent:GetClass()=="prop_ragdoll" and ent:GetNWBool("IsStunedNPC2") == true and !(ent:GetNWBool("NotAlivenpc") == true) and !(ent:GetNWBool("notrespawnneed")==true) and ent:GetNWInt("Health2")>0 and IsValid(ent:GetNWEntity("Playerent")) then
  474. local rply = ent:GetNWEntity("Playerent")
  475. timer.Simple(2,function() if IsValid(rply) then
  476. local ply = rply
  477. ply:Activate()
  478. ply:Spawn()
  479. end
  480. end)
  481. end
  482. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement