Page 1 of 1

Specifying the biter's attack target

Posted: Wed Mar 19, 2025 2:39 am
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.

Re: Specifying the biter's attack target

Posted: Thu Mar 20, 2025 4:06 pm
by DaveMcW

Code: Select all

/c entity = game.player.selected
entity.is_military_target = true
https://lua-api.factorio.com/latest/cla ... ary_target

Re: Specifying the biter's attack target

Posted: Fri Mar 21, 2025 7:16 pm
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.

Re: Specifying the biter's attack target

Posted: Sat Mar 22, 2025 1:41 pm
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

Re: Specifying the biter's attack target

Posted: Sun Mar 23, 2025 8:57 am
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.