Hello,
I am new to modding for Factorio and I have a problem with a mod I want to create.
My goal is to make placable biter spawns for multiplayer so that the spawned biters do attack (actually I dont care if they attack the placer of the spawner but maybe in the future I would like that they only attack the enemy teams).
So far I made a mod where the player can build biter spawns and place them. The spawns automatically produce biters like the normal spawns (I just copied the biter-spawn entity from the data.raw). But they are totally passive. They walk a bit around their base but dont attack. And me as aplayer am not able to attack them neither. It seems that they belong to the same team as the player who hast placed them even when it says
subgroup = "enemies".
Can someone help me fix this problem?
I want that the biters attack like normal when they spwned from the spawner the player places.
Thank you very much!
edit: even when I switched my force by cheat they did not attack me
Please help me. My biter spawner does not attack
-
- Inserter
- Posts: 30
- Joined: Tue Nov 13, 2018 4:50 pm
- Contact:
Re: Please help me. My biter spawner does not attack
MrFactorio wrote: ↑Tue Nov 13, 2018 4:57 pmeven when I switched my force by cheat they did not attack me
Works for me, they instantly attack when I change forces.
Code: Select all
/c game.create_force("player2")
/c game.player.force = "player2"
-
- Inserter
- Posts: 30
- Joined: Tue Nov 13, 2018 4:50 pm
- Contact:
Re: Please help me. My biter spawner does not attack
Thats good. But how can I set the building to be in a specific force when I place the building?
edit: I see.. i just created the force but did not placed me (the player) in that force. Thats why the cheat did not work. But the main problem stays. I think I need to react after the "on_built_entity" event and force the building to be force enemy.
edit: I see.. i just created the force but did not placed me (the player) in that force. Thats why the cheat did not work. But the main problem stays. I think I need to react after the "on_built_entity" event and force the building to be force enemy.
-
- Inserter
- Posts: 30
- Joined: Tue Nov 13, 2018 4:50 pm
- Contact:
Re: Please help me. My biter spawner does not attack
it works
Solution:
function on_build(e)
if e.created_entity.type == 'unit-spawner' then
e.created_entity.force ="enemy"
end
end
script.on_event(defines.events.on_built_entity,on_build)
Solution:
function on_build(e)
if e.created_entity.type == 'unit-spawner' then
e.created_entity.force ="enemy"
end
end
script.on_event(defines.events.on_built_entity,on_build)