mirror of
https://github.com/lifestorm/wnsrc.git
synced 2026-02-04 20:23:47 +03:00
54 lines
1.3 KiB
Lua
54 lines
1.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 = "brush"
|
|
ENT.Base = "base_brush"
|
|
|
|
function ENT:KeyValue(key, value)
|
|
if key == "TraitorsFound" then
|
|
-- this is our output, so handle it as such
|
|
self:StoreOutput(key, value)
|
|
end
|
|
end
|
|
|
|
local function VectorInside(vec, mins, maxs)
|
|
return (vec.x > mins.x and vec.x < maxs.x
|
|
and vec.y > mins.y and vec.y < maxs.y
|
|
and vec.z > mins.z and vec.z < maxs.z)
|
|
end
|
|
|
|
function ENT:CountTraitors()
|
|
local mins = self:LocalToWorld(self:OBBMins())
|
|
local maxs = self:LocalToWorld(self:OBBMaxs())
|
|
|
|
local trs = 0
|
|
for _,ply in player.Iterator() do
|
|
if IsValid(ply) and ply:IsActiveTraitor() and ply:Alive() then
|
|
local pos = ply:GetPos()
|
|
if VectorInside(pos, mins, maxs) then
|
|
trs = trs + 1
|
|
end
|
|
end
|
|
end
|
|
|
|
return trs
|
|
end
|
|
|
|
function ENT:AcceptInput(name, activator, caller)
|
|
if name == "CheckForTraitor" then
|
|
local traitors = self:CountTraitors()
|
|
|
|
self:TriggerOutput("TraitorsFound", activator, traitors)
|
|
|
|
return true
|
|
end
|
|
end
|