eqmac-quests/lua_modules/mob_ext.lua

25 lines
616 B
Lua
Raw Normal View History

2023-07-24 13:24:37 -07:00
function Mob:ForeachHateList(func, cond)
cond = cond or function(ent, hate, damage, frenzy) return true end;
local lst = self:GetHateList();
for ent in lst.entries do
local cv = cond(ent.ent, ent.hate, ent.damage, ent.frenzy);
if(cv) then
func(ent.ent, ent.hate, ent.damage, ent.frenzy);
end
end
end
function Mob:CountHateList(cond)
cond = cond or function(ent, hate, damage, frenzy) return true end;
local lst = self:GetHateList();
local ret = 0;
for ent in lst.entries do
local cv = cond(ent.ent, ent.hate, ent.damage, ent.frenzy);
if(cv) then
ret = ret + 1;
end
end
return ret;
end