fakerz

assbutt2

Jun 3rd, 2013
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if SERVER then
  2. AddCSLuaFile("shared.lua")
  3. end
  4.  
  5.  
  6. ENT.Type = "anim"
  7. ENT.Model = Model("models/Items/combine_rifle_ammo01.mdl")
  8.  
  9. ENT.Stuck = false
  10. ENT.Weaponised = false
  11.  
  12. ENT.PunchMax = 6
  13. ENT.PunchRemaining = 6
  14.  
  15.  
  16. function ENT:Initialize()
  17.  
  18. self.Entity:SetHealth(50)
  19. self.Entity:SetModel("models/Items/combine_rifle_ammo01.mdl")
  20. self.Entity:PhysicsInit(SOLID_VPHYSICS)
  21. self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
  22. self.Entity:SetSolid(SOLID_VPHYSICS)
  23. self.Entity:DrawShadow(false)
  24. self.Entity:SetCollisionGroup(COLLISION_GROUP_WORLD)
  25.  
  26. local phys = self.Entity:GetPhysicsObject():EnableMotion(false)
  27. self:SetColor(Color(25, 122, 21, 255))
  28.  
  29. --self:StartEffects()
  30. --self:Explosive()
  31. self.Entity:EmitSound("C4.Plant")
  32.  
  33.  
  34. end
  35.  
  36. local matTripmineLaser = Material( "sprites/bluelaser1" )
  37. local matLight = Material( "models/roller/rollermine_glow" )
  38. local colBeam = Color( 100, 100, 210, 30 )
  39. local colLaser = Color( 100, 100, 240, 30 )
  40.  
  41. function ENT:Think()
  42.  
  43.  
  44.  
  45.  
  46. local t = {}
  47. t.start = self:GetPos()
  48. t.endpos = t.start + self:GetUp() * 4096
  49. t.filter = self
  50. local tr = util.TraceLine(t)
  51. self.endpos = tr.HitPos
  52. --[[if tr.HitNonWorld then
  53.  
  54. if SERVER then
  55. local ply = self.Owner
  56. local ignore = {ply, self}
  57. if not IsValid(ply) then return end
  58. for k, v in pairs(player.GetAll()) do
  59. if v:GetRole() == ROLE_TRAITOR then
  60. table.insert(ignore, v)
  61. end
  62. if (not table.HasValue(ignore,tr.Entity)) and tr.Entity:IsPlayer() then
  63. self:Explosive()
  64. self:Remove()
  65. end
  66.  
  67.  
  68. end
  69. end
  70. end --]]
  71. end
  72.  
  73. ENT.OurHealth = 50
  74.  
  75. function ENT:OnTakeDamage(dmg)
  76. self:TakePhysicsDamage(dmg)
  77.  
  78. if(self.OurHealth <= 0) then return; end
  79.  
  80. self.OurHealth = self.OurHealth - dmg:GetDamage()
  81.  
  82. if(self.OurHealth <= 0) then
  83. self:Explosive()
  84. self:Remove()
  85. end
  86. end
  87.  
  88. function ENT:Draw()
  89.  
  90.  
  91.  
  92. if not self.endpos then
  93. return
  94. end
  95.  
  96. render.SetMaterial( matTripmineLaser )
  97. local TexOffset = 6
  98. local Distance = self.endpos:Distance( self:GetPos() )
  99. render.DrawBeam( self.endpos, self.Entity:GetPos(), 6, TexOffset, TexOffset+Distance, colBeam )
  100. render.DrawBeam( self.endpos, self.Entity:GetPos(), 3, TexOffset, TexOffset+Distance, colBeam )
  101. render.SetMaterial( matLight )
  102. local Size = math.Rand( 3, 5 )
  103. local Normal = (self.Entity:GetPos()-self.endpos):GetNormal() * 0.1
  104. render.DrawQuadEasy( self.endpos + Normal, Normal, Size, Size, colLaser, 0 )
  105. self.Entity:DrawModel()
  106.  
  107. end
  108. function ENT:StartTouch( ent )
  109. if (ent:IsPlayer()) then
  110. if (ent:GetRole() != ROLE_TRAITOR) then
  111. self:Explosive()
  112. self:Remove()
  113. end
  114. end
  115. end
  116.  
  117.  
  118. function ENT:Explosive()
  119. local phexp = ents.Create("env_explosion")
  120. if IsValid(phexp) then
  121. phexp:SetPos(self:GetPos())
  122. phexp:SetKeyValue("magnitude", 100)
  123. phexp:SetKeyValue("radius", 128)
  124. phexp:SetKeyValue("spawnflags", 1 + 2)
  125. phexp:Spawn()
  126. phexp:Fire("Explode", "", 0)
  127. end
  128. local phyexp = ents.Create("env_physexplosion")
  129.  
  130. phyexp:SetPos(self:GetPos())
  131. phyexp:SetKeyValue("magnitude", 100)
  132. phyexp:SetKeyValue("radius", 128)
  133. phyexp:SetKeyValue("spawnflags", 1 + 2)
  134. phyexp:Spawn()
  135. phyexp:Fire("Explode", "", 0)
  136.  
  137. local norm = self:GetAngles():Up() * -1
  138.  
  139. util.BlastDamage(self, self:GetOwner(), self:GetPos(), 200, 50)
  140. local effect = EffectData()
  141. effect:SetStart(self:GetPos())
  142. effect:SetOrigin(self:GetPos())
  143. effect:SetNormal(norm * -1)
  144. effect:SetRadius(16)
  145. effect:SetScale(1)
  146. util.Effect("ManhackSparks", effect, true, true)
  147. end
RAW Paste Data