Specifying the biter's attack target

Place to get help with not working mods / modding interface.
mugi
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Mar 19, 2025 2:23 am
Contact:

Specifying the biter's attack target

Post by mugi »

Hallo, this is my first post. I'm a beginner who just started making modding recently.

Is it possible to specify which target a biter should prioritize attacking?

For example, I would like to prioritize attacking nuclear power plants, or attacking players who have specific items.

Thank you very much.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Specifying the biter's attack target

Post by DaveMcW »

Code: Select all

/c entity = game.player.selected
entity.is_military_target = true
https://lua-api.factorio.com/latest/cla ... ary_target
mugi
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Mar 19, 2025 2:23 am
Contact:

Re: Specifying the biter's attack target

Post by mugi »

Thanks for answering. I tried but it didn't work.
I get the following exception: "entity nuclear-reactor (reactor) does not allow to change is_military_target run-time"

I guess "entity.prototype.allow_run_time_change_of_is_military_target" needs to be true, but the value is false and cannot be changed.
Is there a way to change that value?

And is there a way to specify something like is_military_target for a player?

Thank you very much.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Specifying the biter's attack target

Post by DaveMcW »

You need to set that in data.lua.

Code: Select all

data.raw['entity']['nuclear-reactor'].allow_run_time_change_of_is_military_target = true
mugi
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Mar 19, 2025 2:23 am
Contact:

Re: Specifying the biter's attack target

Post by mugi »

Thank you for your answer.
I was able to change is_military_target by setting the following in data.lua.

Code: Select all

data.raw['reactor']['nuclear-reactor'].allow_run_time_change_of_is_military_target = true
Thank you very match.
Post Reply

Return to “Modding help”