Add events for when forces set friends/cease-fires

Post Reply
ceresward
Inserter
Inserter
Posts: 21
Joined: Mon Dec 18, 2017 8:45 pm
Contact:

Add events for when forces set friends/cease-fires

Post by ceresward »

Hi, I'm just getting into modding, and the API seems to be lacking events for when a force sets a new friend/cease-fire. Something like on_force_cease_fire_changed, on_force_friend_changed, maybe?

In my mod, I am trying to create and manage 'sub-forces' that have mutual friend and cease-fire with the player force (I create them just as regular forces but with a name like 'player.subforce'). I'd like to be able to keep the friend/cease-fire lists of the sub-forces 'in sync' with the main force lists. For example, if a different mod creates a new force 'foobar' and configures it to have a cease-fire with 'player', I'd like to be able to listen for the cease-fire event so I can set up a cease-fire between 'foobar' and my sub-forces as well. Otherwise, entities in the 'foobar' force might attack entities in my sub-forces, which is not the desired behavior

ceresward
Inserter
Inserter
Posts: 21
Joined: Mon Dec 18, 2017 8:45 pm
Contact:

Re: Add events for when forces set friends/cease-fires

Post by ceresward »

Related - 'on_entity_force_changed' would also be handy, if it's possible...

slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: Add events for when forces set friends/cease-fires

Post by slippycheeze »

edit: I wrote this before I noticed this was "implemented mod requests", but figured I'd leave it for the future.

IDK if your mod is "diplomacy" or not, but if not, you might want to check out what they do to handle this.

Also, I'm not sure if this is one of the many attributes a mod can change without raising an event, since Factorio seems to trigger events in the "action that changes the state" rather than the "value of this valiable" part of the LuaEntity object in C++, but you might need to consider what happens if you come across an entity that was changed without notice in your code regardless. Like you might hit with, eg, entity creation in a script without event generation.

ceresward
Inserter
Inserter
Posts: 21
Joined: Mon Dec 18, 2017 8:45 pm
Contact:

Re: Add events for when forces set friends/cease-fires

Post by ceresward »

Thanks for the advice, diplomacy is not my mod but I took a look at its mod page. Seems like it is making diplomacy changes in response to player actions. My use case is a little different in that I want to make diplomacy changes in response to other diplomacy changes. And AFAIK there are currently no events in the API for listening for diplomacy changes (i.e. changes to the "friends" and "cease-fire" force relationships).

It's a limitation I can work with for now, though I'm hoping the move to this subforum means a fix is incoming :fingers-crossed:

Post Reply

Return to “Implemented mod requests”