Files
wnsrc/lua/entities/arccw_gl_ammodet.lua
lifestorm 6a58f406b1 Upload
2024-08-04 23:54:45 +03:00

126 lines
3.3 KiB
Lua

--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "HE Round"
ENT.Author = ""
ENT.Information = ""
ENT.Spawnable = false
AddCSLuaFile()
ENT.Model = "models/items/ar2_grenade.mdl"
ENT.Ticks = 0
ENT.FuseTime = 10
function ENT:Draw()
self:DrawModel()
end
ENT.Ticks = 0
function ENT:Detonate()
if !self:IsValid() then return end
local effectdata = EffectData()
effectdata:SetOrigin( self:GetPos() )
if self:WaterLevel() >= 1 then
util.Effect( "WaterSurfaceExplosion", effectdata )
self:EmitSound("weapons/underwater_explode3.wav", 125, 100, 1, CHAN_AUTO)
else
util.Effect( "Explosion", effectdata)
self:EmitSound("phx/kaboom.wav", 125, 100, 1, CHAN_AUTO)
end
local attacker = self
if self:GetOwner():IsValid() then
attacker = self:GetOwner()
end
util.BlastDamage(self, attacker, self:GetPos(), 300, 50)
self:FireBullets({
Attacker = attacker,
Damage = 0,
Tracer = 0,
Distance = 20000,
Dir = self:GetVelocity(),
Src = self:GetPos(),
Callback = function(att, tr, dmg)
util.Decal("Scorch", tr.StartPos, tr.HitPos - (tr.HitNormal * 16), self)
end
})
self:Remove()
end
if CLIENT then
function ENT:Think()
if self.Ticks % 2 == 0 then
local emitter = ParticleEmitter(self:GetPos())
if !self:IsValid() or self:WaterLevel() > 2 then return end
if !IsValid(emitter) then return end
local smoke = emitter:Add("particle/particle_smokegrenade", self:GetPos())
smoke:SetVelocity( VectorRand() * 25 )
smoke:SetGravity( Vector(math.Rand(-5, 5), math.Rand(-5, 5), math.Rand(-20, -25)) )
smoke:SetDieTime( math.Rand(1.5, 2.0) )
smoke:SetStartAlpha( 255 )
smoke:SetEndAlpha( 0 )
smoke:SetStartSize( 0 )
smoke:SetEndSize( 100 )
smoke:SetRoll( math.Rand(-180, 180) )
smoke:SetRollDelta( math.Rand(-0.2,0.2) )
smoke:SetColor( 20, 20, 20 )
smoke:SetAirResistance( 5 )
smoke:SetPos( self:GetPos() )
smoke:SetLighting( false )
emitter:Finish()
end
self.Ticks = self.Ticks + 1
end
else
function ENT:Initialize()
local pb_vert = 1
local pb_hor = 1
self:SetModel(self.Model)
self:PhysicsInitBox( Vector(-pb_vert,-pb_hor,-pb_hor), Vector(pb_vert,pb_hor,pb_hor) )
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
self.SpawnTime = CurTime()
timer.Simple(0.1, function()
if !IsValid(self) then return end
self:SetCollisionGroup(COLLISION_GROUP_PROJECTILE)
end)
end
function ENT:Think()
if SERVER and CurTime() - self.SpawnTime >= self.FuseTime then
self:Detonate()
end
end
function ENT:PhysicsCollide(colData, collider)
self:Detonate()
end
end