AddCSLuaFile('cl_init.lua')
AddCSLuaFile('shared.lua')
include('shared.lua')
local Model = "models/NightReaper/Ordinance/gbu-28_bunker_buster.mdl"
function ENT:SpawnFunction(ply, tr)
if (!tr.Hit) then
return
end
local SpawnPos = tr.HitPos+tr.HitNormal*30
local ent = ents.Create("sent_gbu_28")
ent:SetPos(SpawnPos)
ent:SetVar("Owner",ply)
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Initialize()
self.Entity:SetModel(Model)
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Position = Vector()
local phys = self.Entity:GetPhysicsObject()
if phys:IsValid() then
if (WireAddon != nil) then
self.Inputs = Wire_CreateInputs(self.Entity,{"Detonate!"})
end
phys:Wake()
end
end
function ENT:TriggerInput(iname,value)
if (iname == "Detonate!") then
if (value == 1) then
self.Position=self.Entity:GetPos()
self:Detonate()
end
end
end
function ENT:OnTakeDamage(dmginfo)
if (dmginfo:GetDamage() >= 25) then
self:Detonate()
end
end
function ENT:Detonate()
self:EmitSound("ambient/explosions/explode_4.wav", 500, 500)
local position = self.Position
local damage = 250
local radius = 500
local attacker = self.Owner
local inflictor = self.Entity
util.BlastDamage(inflictor, attacker, position, radius, damage)
for key,found in pairs(ents.FindInSphere(self.Entity:GetPos(),500)) do
found:Fire("enablemotion","",0)
constraint.RemoveAll(found)
if (found:GetMoveType() == 6 and found:GetPhysicsObject():IsValid()) then
found:GetPhysicsObject():ApplyForceCenter(Vector(math.random(-1,1),math.random(-1,1),1):GetNormalized()*500)
end
end
self.Entity:Remove()
end
function ENT:Think()
end
function ENT:OnRemove()
end