Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.25 KB | None | 0 0
  1.  
  2. AddCSLuaFile( "cl_init.lua" )
  3. AddCSLuaFile( "shared.lua" )
  4. include( 'shared.lua' )
  5.  
  6. resource.AddFile( "materials/VGUI/entities/sent_gasbomb.vmt" );
  7. resource.AddFile( "materials/VGUI/entities/sent_gasbomb.vtf" );
  8.  
  9. local isarmed = 0
  10. local caninuke = 1
  11. local canbeeb = 1
  12. util.PrecacheSound( "ambient/explosions/explode_3.wav" )
  13. util.PrecacheSound( "ambient/explosions/explode_5.wav" )
  14.  
  15. function ENT:Initialize()
  16. self.Entity:SetModel( "models/weapons/w_eq_smokegrenade.mdl" )  
  17. self.Entity:PhysicsInit( SOLID_VPHYSICS )    
  18. self.Entity:SetMoveType( MOVETYPE_VPHYSICS )  
  19. self.Entity:SetSolid( SOLID_VPHYSICS )              
  20. local phys = self.Entity:GetPhysicsObject()  
  21. if not (WireAddon == nil) then self.Inputs = Wire_CreateInputs(self.Entity, { "Detonate!", "Arm"}) end 
  22. if not (WireAddon == nil) then self.Outputs = Wire_CreateOutputs(self.Entity, { "Armed"}) end
  23. if (phys:IsValid()) then       
  24. phys:Wake()    
  25. end
  26.  
  27. end  
  28.  
  29. function ENT:TriggerInput(iname, value) --wire inputs
  30.     if (iname == "Detonate!") then
  31.         if value == 1 then
  32.             if self.isarmed == 1 then
  33.                 self:MakeGas()
  34.             end
  35.         end
  36.     end
  37.     if (iname == "Arm") then
  38.         if value == 1 then
  39.             self.isarmed = 1
  40.         end
  41.         if value == 0 then
  42.             self.isarmed = 0
  43.         end
  44.     end
  45. end
  46.  
  47. function ENT:SpawnFunction( ply, tr)
  48.  
  49.     if ( !tr.Hit ) then return end
  50.    
  51.     local SpawnPos = tr.HitPos + tr.HitNormal * 16
  52.    
  53.     local ent = ents.Create( "sent_sarin" )
  54.         ent:SetPos( SpawnPos )
  55.     ent:Spawn()
  56.     ent:Activate()
  57.    
  58.     return ent
  59.  
  60. end
  61.  
  62. function ENT:PhysicsCollide( data, physobj )
  63.     if ( self.isarmed == 1 ) then
  64.         if data.Speed > 600 and data.DeltaTime > 0.15 then -- if it hits an object at over 600 speed
  65.             self:MakeGas()
  66.         end
  67.     end
  68. end
  69.  
  70. function ENT:OnTakeDamage(dmginfo)
  71. self.Entity:TakePhysicsDamage( dmginfo )
  72. end
  73.  
  74. function ENT:Think()
  75.     if ( self.isarmed == 1 ) then
  76.         self:SetOverlayText( " ARMED " )
  77.     else
  78.         self:SetOverlayText( " Unarmed " )
  79.     end
  80.     if not (WireAddon == nil) then Wire_TriggerOutput(self.Entity, "Armed", self.isarmed) end
  81. end
  82.  
  83. --function ENT:Kaboom()
  84. --    if self.isarmed == 1 then
  85. --      if self.caninuke == 1 then
  86. --          self:MakeGas()
  87. --          self.Entity:Remove()
  88. --      end
  89. --  end
  90. --end  
  91.  
  92. function ENT:OnRemove()
  93. self.caninuke = 0
  94. end
  95.  
  96. function ENT:MakeGas()
  97. if caninuke == 1 then
  98.     self.Entity:EmitSound(Sound("BaseSmokeEffect.Sound"))
  99.     local CL = ents.Create("env_steam")  
  100.         CL:SetKeyValue("spreadspeed","350")
  101.         CL:SetKeyValue("speed","20")
  102.         CL:SetKeyValue("startsize","125")
  103.         CL:SetKeyValue("endsize","200")
  104.         CL:SetKeyValue("rate","250")
  105.         CL:SetKeyValue("Jetlength","50")
  106.         CL:SetKeyValue("angles","90")
  107.         CL:SetKeyValue("rendercolor","255 255 255")
  108.             CL:SetPos( self.Entity:GetPos() )
  109.         CL:Fire("turnon","",0)
  110.         CL:Fire("kill","",15)
  111.         CL:Spawn()
  112.             CL:Activate()
  113.  
  114.     local b = ents.Create( "point_hurt" )
  115.     b:SetKeyValue("targetname", "fier" )
  116.     b:SetKeyValue("DamageRadius", "800" )
  117.     b:SetKeyValue("Damage", "3.5" )
  118.     b:SetKeyValue("DamageDelay", "0.1" )
  119.     b:SetKeyValue("DamageType", "262144" )
  120.     b:SetPos( self.Entity:GetPos() )
  121.     b:Spawn()
  122.     b:Fire("turnon", "", 0)
  123.     b:Fire("turnoff", "", 15)
  124. self.Entity:Remove()
  125. end
  126. end
  127. function ENT:Use()
  128.     self.isarmed = 1
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement