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)
Unit groups cancel current action
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Unit groups cancel current action
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.
Re: Unit groups cancel current action
The unit group executes the command you gave it – it's moving south. That is as expected.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)
That is a bug – the group's members don't update their command. I've fixed that in 0.14.4.kyranzor wrote:and the units keep going north instead of stopping and turning back and moving to the new location.
Re: Unit groups cancel current action
Oh awesome thanks Oxyd.
Well I think with the bug fix I am happy. Don't worry about this request then.
Well I think with the bug fix I am happy. Don't worry about this request then.