Unit groups cancel current action

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
kyranzor
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Oct 31, 2014 4:52 pm
Contact:

Unit groups cancel current action

Post by kyranzor »

Hey,

In my Robot Army mod, i'm having a tough time making the units do things when requested.

Example: Squad of units is moving north, but a new command is given to them to move-to a position ~100 tiles south of their current location - 2 things I notice go wrong - the calcuation of the unitgroup position is wrong (the unit group circle moves south instead of staying with/near the units) and the units keep going north instead of stopping and turning back and moving to the new location.

I've tried this with the start_moving() command after setting the new position, and also without this.

I think in general it would be nice if the API for unit groups caused units to stop and re-evaluate their orders when they get a new command, or let modders request this with some kind of "cancel current action" command.

The calculation of the unit's position seems bugged because the API says "When the group is moving, the position is the expected position of its members along the path" the units can be WAY off and in my example the unit circle actually does what I want, going south to the new position, while the units continue north ignoring the orders. Their VIRTUAL unit group position/indicator DOES follow orders and ends up completing the order and thus my custom AI scripting thinks that the job is done despite the units being 100's of tiles away.

I suggest that the API is fixed so that the unit_group.position is calculated while moving to be the average position just like in attack mode, and that the units correctly stop what they are doing and act appropriately to their newly received command. This will make the unit commanding behaviour much more responsive and make things a lot easier for us modders to manipulate units (be they biters for AI mods like Misanthrope or Rampant AI, or in my case, friendly robotic soldiers)
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Unit groups cancel current action

Post by aubergine18 »

Rather than a 'cancel current action' command (which doesn't clarify what happens next) it might be more descriptive to have a `hold_position` command (with optional distraction field).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: Unit groups cancel current action

Post by Oxyd »

kyranzor wrote:Example: Squad of units is moving north, but a new command is given to them to move-to a position ~100 tiles south of their current location - 2 things I notice go wrong - the calcuation of the unitgroup position is wrong (the unit group circle moves south instead of staying with/near the units)
The unit group executes the command you gave it – it's moving south. That is as expected.
kyranzor wrote:and the units keep going north instead of stopping and turning back and moving to the new location.
That is a bug – the group's members don't update their command. I've fixed that in 0.14.4.
kyranzor
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Oct 31, 2014 4:52 pm
Contact:

Re: Unit groups cancel current action

Post by kyranzor »

Oh awesome thanks Oxyd.

Well I think with the bug fix I am happy. Don't worry about this request then.
Post Reply

Return to “Modding interface requests”