I have a weapon script that has 5 different spell abilities.
[url]http://deception.esy.es/Media/Video/leetaddo.mp4[/url]
I have made an entity fireball that has fire particles and everything and when it touches a player/npc/entity it blows up and deals damage however I cannot get it to
blow up on conflict with the world which is the main objective of the fireball as it deals area damage, I know ent:touch doesn't work with the world so
I tried using ENT:PhysicsCollide() however it warned me about crashes in console and that got annoying. Does anyone know of any alternatives to my problem?
- Entity Code -
[CODE]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/hunter/blocks/cube025x025x025.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetTrigger(true)
local phys = self:GetPhysicsObject()
phys:SetMass(1)
if phys:IsValid() then
phys:Wake()
end
self:SetMaterial("Models/effects/vol_light001")
end
function ENT:Think()
local part = EffectData()
part:SetStart(self:GetPos() + Vector(0,0,7) )
part:SetOrigin(self:GetPos() + Vector(0,0,7) )
part:SetEntity(self)
part:SetScale(20)
util.Effect( "fireball", part)
if !self:IsInWorld() then
self:Remove()
end
end
function ENT:Touch(ent)
if ent == self:GetOwner() then
elseif ent:IsWorld() or ent:IsPlayer() or ent:IsNPC() then
self:EmitSound( "ambient/explosions/explode_" .. math.random( 1, 3 ) .. ".wav" )
for k,v in pairs(ents.FindInSphere(self:GetPos(), 400)) do
if v:IsPlayer() or v:IsNPC() then
if v != self:GetOwner() then
v:TakeDamage(100)
v:SetVelocity((v:GetPos() *15 - self:GetPos() *15) + Vector(0,0,240))
end
end
self:Remove()
end
end
print(ent)
end
[/CODE]
Thanks in advance.
[editline]23rd January 2017[/editline]
Anyone? I'm guessing my question is stupid.
PhysicsCollide shouldn't give you warnings unless you're doing something wrong in it.
[editline]23rd January 2017[/editline]
Replace 'self:Remove()' with 'self.doremove = true', and replace 'if !self:IsInWorld() then' with 'if !self:IsInWorld() or self.doremove then' and you shouldn't get warnings with PhysicsCollide (maybe)
Already fixed it. Thanks anyway though.
Sorry, you need to Log In to post a reply to this thread.