So the simplest way of doing this would be to use one of the functions from utillib:
local U = require "scriptbank\\utillib"
function ai_hurtzone_init( e )
Include( "utillib.lua" )
end
local timer = 0
local hurtValue = 1
local hurtDist = 2000
function ai_hurtzone_main( e )
if g_Time > timer then
timer = g_Time + 1000
local Ent = g_Entity[ e ]
for _, v in pairs( U.ClosestEntities( hurtDist, math.huge, Ent.x, Ent.z ) ) do
if ai_bot_state[ v ] ~= nil then
if g_Entity[ v ].health > 0 then
SetEntityHealth( v, g_Entity[ v ].health - hurtValue )
end
end
end
end
end
This will remove 1 health every second from any AI with 2000 unit radius of the attached entity (or centre of zone).
Unfortunately there is no function to tell when an AI enters a zone though.
Been there, done that, got all the T-Shirts!