Hi all,
I would like to create a new enemy force from scratch and haven't found any examples of this yet.
1.) I'm trying to see how they do it in base and a couple mods (BigEnemies for example) but it seems like mods copy existing biters and in base I can't see how they actually implement the force.
2.) In base, biters are of type unit, and the only reference I see to enemies is the subgroup (subgroup="enemies").
3.) I'm also looking through the LuaForce class but I'm not sure how to actually create the new force.
Do I extend data like we do with entities? I don't see a 'Type' field in the LuaForce class, so wasn't sure what to put in the Type if I did it that way.
The overall objective is to create a simple enemy force, add in a couple units, and see if I can make them attack me. Then add in CAPITAL SHIPS WOOT.
[Solved] Create New Enemy Force
[Solved] Create New Enemy Force
Last edited by rookhaven on Sat Sep 26, 2020 5:16 pm, edited 1 time in total.
Re: Create New Enemy Force
Code: Select all
/c
local force_name = 'enemy-2'
if not game.forces[force_name] then game.create_force(force_name) end
local surface = game.player.surface
local entities = surface.find_entities_filtered {force='enemy', type = 'unit'}
for i, ent in pairs (entities) do
ent.force = force_name
rendering.draw_sprite {sprite = "utility/custom_tag_in_map_view", surface = surface, target = ent}
end
Re: Create New Enemy Force
Sweet, thanks!