Advertisement
Guest User

Untitled

a guest
Jan 29th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1.  
  2. AddCSLuaFile( "cl_init.lua" )
  3. AddCSLuaFile( "shared.lua" )
  4. include( 'shared.lua' )
  5.  
  6. function ENT:SpawnFunction( ply, tr )
  7.  
  8. if ( !tr.Hit ) then return end
  9.  
  10. local SpawnPos = tr.HitPos + tr.HitNormal * 16
  11.  
  12. local ent = ents.Create( "ent_plasma" )
  13. ent:SetPos( SpawnPos )
  14. ent:Spawn()
  15. ent:Activate()
  16.  
  17. return ent
  18.  
  19. end
  20.  
  21. /*---------------------------------------------------------
  22. Name: Initialize
  23. ---------------------------------------------------------*/
  24. function ENT:Initialize()
  25. self.Entity:SetModel( "models/Items/AR2_Grenade.mdl" )
  26. self.Entity:SetSolid(SOLID_VPHYSICS)
  27. self.Entity:PhysicsInit(SOLID_VPHYSICS)
  28. self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
  29. local phys = self.Entity:GetPhysicsObject()
  30. self.Angles = self.Entity:GetAngles()
  31.  
  32. if phys:IsValid( ) then
  33. phys:EnableGravity( false )
  34. phys:Wake( )
  35. end
  36.  
  37. self.Start = CurTime()
  38.  
  39. end
  40.  
  41. /*---------------------------------------------------------
  42. Name: PhysicsCollide
  43. ---------------------------------------------------------*/
  44. function ENT:PhysicsCollide( data, physobj )
  45. local target = data.HitEntity
  46. local BadNpc = 0
  47. if target:IsPlayer()then
  48. target.PlyHp = target:Health()
  49. self:Remove()
  50. else
  51. self.Entity:GetPhysicsObject():EnableMotion( false )
  52. self.Entity:SetAngles(self.Angles)
  53. inactive = true
  54. end
  55. end
  56.  
  57. /*---------------------------------------------------------
  58. Name: OnTakeDamage
  59. ---------------------------------------------------------*/
  60. function ENT:OnTakeDamage( dmginfo )
  61. end
  62.  
  63. /*---------------------------------------------------------
  64. Name: Use
  65. ---------------------------------------------------------*/
  66. function ENT:Use( activator, caller )
  67. end
  68.  
  69. function ENT:PhysicsUpdate( PhysObj )
  70.  
  71. if self.Start < CurTime( ) - ( 10 / GetConVarNumber( "phys_timescale" ) ) then
  72. self.Entity:Remove( )
  73. return
  74. end
  75.  
  76. local Trace = {
  77. start = self.Entity:GetPos( ),
  78. endpos = self.Entity:GetPos( ) + ( self.Entity:GetForward( ) * 20 ),
  79. filter = self.Entity
  80. }
  81.  
  82. local TraceRes = util.TraceLine( Trace )
  83.  
  84. if TraceRes.Hit or TraceRes.HitWorld then
  85.  
  86. if TraceRes.Entity:GetClass( ) ~= "ent_plasma" then
  87.  
  88. local Bullet = {
  89. Src = self.Entity:GetPos( ),
  90. Dir = self.Entity:GetForward( ),
  91. Spread = 0,
  92. Num = 1,
  93. Damage = self.Damage,
  94. Force = self.Force,
  95. Tracer = 0,
  96. TracerName = "Pistol"
  97. }
  98.  
  99. self.Owner:FireBulletsOld( Bullet )
  100.  
  101. self.Entity:Remove( )
  102.  
  103. return false
  104.  
  105. end
  106.  
  107. end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement