When combat robots spawn they slowly drift towards their Entity.orientation until they hit their leash radius. Normally, this means they slowly drift towards the right until the player moves around. The player's random motion + leash behavior causes them to orbit chaotically. But combat robots created for static entities like turrets will always drift and never act alive like they do for players. You can change the drift direction using Entity.orientation but there's no way to give them a nudge to start orbiting around. Trying to set the speed with LuaEntity.speed causes an error.
Minimum example to reproduce
data.lua
Code: Select all
local turret = data.raw['ammo-turret']['gun-turret']
turret.created_effect = {
type = 'direct',
action_delivery = {
type = "instant",
target_effects = { {
type = "create-entity",
entity_name = 'defender',
show_in_tooltip = true,
offset_deviation = { { -4, -4 }, { 4, 4 } },
trigger_created_entity = true,
offsets = {{0,0}}
} },
}
};
Code: Select all
script.on_event(defines.events.on_script_trigger_effect,
function(event)
if event.entity.name == 'defender' then
event.entity.orientation = math.random()
--event.entity.speed = 1 -- causes an error
end
end)