zombiesurvival-evolved/gamemodes/zombiesurvival/entities/entities/projectile_poisonspit/init.lua
2014-10-01 20:49:54 -04:00

74 lines
1.7 KiB
Lua

AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self.DeathTime = CurTime() + 30
self:SetModel("models/props/cs_italy/orange.mdl")
self:PhysicsInitSphere(1)
self:SetSolid(SOLID_VPHYSICS)
self:SetCollisionGroup(COLLISION_GROUP_PROJECTILE)
self:SetColor(Color(0, 255, 0, 255))
self:SetCustomCollisionCheck(true)
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:SetMass(4)
phys:SetBuoyancyRatio(0.002)
phys:EnableMotion(true)
phys:Wake()
end
end
function ENT:Think()
if self.PhysicsData then
self:Explode(self.PhysicsData.HitPos, self.PhysicsData.HitNormal, self.PhysicsData.HitEntity)
end
if self.DeathTime <= CurTime() then
self:Remove()
end
end
function ENT:Explode(vHitPos, vHitNormal, eHitEntity)
if self.Exploded then return end
self.Exploded = true
self.DeathTime = 0
local owner = self:GetOwner()
if not owner:IsValid() then owner = self end
vHitPos = vHitPos or self:GetPos()
vHitNormal = vHitNormal or Vector(0, 0, 1)
if eHitEntity:IsValid() then
eHitEntity:PoisonDamage(15, owner, self)
if eHitEntity:IsPlayer() and eHitEntity:Team() ~= TEAM_UNDEAD then
local attach = eHitEntity:GetAttachment(1)
if attach then
if vHitPos:Distance(attach.Pos) <= 18 then
eHitEntity:PlayEyePoisonedSound()
local status = eHitEntity:GiveStatus("confusion")
if status then
status.EyeEffect = true
end
end
end
end
end
local effectdata = EffectData()
effectdata:SetOrigin(vHitPos)
effectdata:SetNormal(vHitNormal)
util.Effect("spithit", effectdata)
end
function ENT:PhysicsCollide(data, phys)
if not self:HitFence(data, phys) then
self.PhysicsData = data
end
self:NextThink(CurTime())
end