gravwell_proto = {
attribs = {
effect_range = 3000,
stun_duration = 1, -- ideally the same as the tick rate,
stun_effect = "PowerOff"
}
};
-- customcommand update is called 'go' instead of 'do' (since do is a lua keyword)
function gravwell_proto:go()
local ships_to_stun = modkit.table.filter(
GLOBAL_REGISTRY.all(),
function (ship)
local in_range = %self:distanceTo(ship) < %self.effect_range;
local is_stunnable_type = ship:isFighter() == 0 or ship:isCorvette();
local not_salvette = ship:isSalvager();
return in_range and is_stunnable_type and not_salvette;
end
);
for _, ship in ships_to_stun do
ship:stunned(1, self.stun_duration);
ship:playFx(self.stun_effect);
end
end