Advertisement
Guest User

Untitled

a guest
Jul 14th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. AddCSLuaFile()
  2.  
  3. ENT.Type = "anim"
  4. ENT.Base = "base_gmodentity"
  5.  
  6. ENT.Armed = false
  7. ENT.Spawnable = false
  8. ENT.exploded = false
  9.  
  10. if SERVER then
  11.     function ENT:Initialize()
  12.         self:SetModel("models/props_junk/PopCan01a.mdl")
  13.         self:SetMoveType(MOVETYPE_VPHYSICS)
  14.         self:SetSolid(SOLID_VPHYSICS)
  15.         self:PhysicsInit(SOLID_VPHYSICS)
  16.  
  17.         local phys = self:GetPhysicsObject()
  18.  
  19.         if IsValid(phys) then
  20.             phys:SetMaterial("popcan")
  21.             phys:SetMass(1)
  22.             phys:Wake()
  23.         end
  24.  
  25.         util.SpriteTrail(self.Entity, 0, Color(255,255,255,120), true, 3, 3, 0.5, 1 / (3-3) * 0.5, "trails/smoke" )
  26.     end
  27.  
  28.     function ENT:PhysicsCollide(data,phys)
  29.         if !self.Armed then
  30.             if data.HitEntity == self:GetOwner() then return end
  31.  
  32.             if SERVER then
  33.                 self:EmitSound(Sound("physics/metal/soda_can_impact_hard"..math.random(1,3)..".wav"))
  34.             end
  35.  
  36.             if IsValid(data.HitEntity) then
  37.                 self.Entity:SetParent(data.HitEntity)
  38.             else
  39.                 phys:EnableMotion(false)
  40.             end
  41.         else
  42.             self:Explode()
  43.  
  44.         end
  45.        
  46.     end
  47.  
  48.     function ENT:Explode()
  49.  
  50.         local ply = self:GetOwner()
  51.  
  52.         if !self.exploded then
  53.  
  54.  
  55.             if !IsValid(ply) then ply = self end
  56.  
  57.             local effdata = EffectData()
  58.                 effdata:SetOrigin(self:GetPos())
  59.                 effdata:SetEntity(self)
  60.             util.Effect("WaterSurfaceExplosion", effdata)
  61.             util.Effect("azbr_grenade_exp", effdata)
  62.  
  63.             util.ScreenShake(self:GetPos(), 5, 5, 1, 1000)
  64.  
  65.             local dmg = DamageInfo()
  66.  
  67.  
  68.             self:EmitSound("azbr/Nade_Explode"..math.random(1,3)..".wav")
  69.  
  70.             self:Remove()
  71.  
  72.             self.exploded = true
  73.         end
  74.  
  75.     end
  76.  
  77.     function ENT:Think()
  78.         for k,v in pairs(ents.FindInSphere(self:GetPos(), 150)) do
  79.             if v:GetClass() == "player" then
  80.                 self:Explode()
  81.             end
  82.         end
  83.  
  84.     end
  85.  
  86.  
  87. end
  88.  
  89. function ENT:OnTakeDamage(dmg)
  90.     print("test")
  91. end
  92.  
  93. function ENT:Draw()
  94.     self:DrawModel()
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement