Please help me. My biter spawner does not attack

Place to get help with not working mods / modding interface.
Post Reply
MrFactorio
Inserter
Inserter
Posts: 30
Joined: Tue Nov 13, 2018 4:50 pm
Contact:

Please help me. My biter spawner does not attack

Post by MrFactorio »

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

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Please help me. My biter spawner does not attack

Post by DaveMcW »

MrFactorio wrote:
Tue Nov 13, 2018 4:57 pm
even 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"

MrFactorio
Inserter
Inserter
Posts: 30
Joined: Tue Nov 13, 2018 4:50 pm
Contact:

Re: Please help me. My biter spawner does not attack

Post by MrFactorio »

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.

MrFactorio
Inserter
Inserter
Posts: 30
Joined: Tue Nov 13, 2018 4:50 pm
Contact:

Re: Please help me. My biter spawner does not attack

Post by MrFactorio »

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)

Post Reply

Return to “Modding help”