beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
210 stars 99 forks source link

Add goal reached event #1497

Closed marcushutchings closed 4 months ago

marcushutchings commented 5 months ago

Fixes https://github.com/beyond-all-reason/spring/issues/1459

This fixes the issue where Zero-K rand the engine may not agree on exactly when a unit has reached its goal. The engine will send an UnitArrivedAtGoal event so that the game can tell that the engine believes the move is complete and so the game can take the necessary actions to ensure any further orders are carried out.

Zero-K can use the following diff file to add support for this new event. Use_UnitArrivedAtGoal_InRawMove.diff.zip Though I didn't run into any issues with these Zero-K changes, there may be the need to add some protections around some of it. Think of it as starting point.

Builds on the work undertaken in https://github.com/beyond-all-reason/spring/pull/1493

sprunk commented 4 months ago

Why can't the units just path to their requested destination properly like they used to? If somebody else bumps a unit off course then the unit could adjust the angle. Apparently units used to arrive at the destination properly despite bumping before, what changed?

marcushutchings commented 4 months ago

There's two things to discuss here:

1) Are you suggesting that there is no value in the engine providing a 'goal reached' event?

2) What we're seeing here, isn't due to unit's be pushed around after reaching their goal. No. If a unit touches a unit that is standing on its goal, the engine will decide that the unit has got as far they are need to go - rather than insisting that it must push that other unit out of the way.

This helps mitigiate units stringing out into a single line as they follow complex paths and it also reduces tight battlelines from being pushed further forward than the player had intended (which is what happens when every unit insists that it has to touch it's destination, but there isn't space for them stand in a line.) I'd hope that you can see the benefit of reducing groups of units stringing out into a single column, and tight battle front lines that more closely match the player's request.

As for unit's forcibly pushing through units reaching the single designated spot at every expense, even Zero-K has code in their raw move to reduce that.

sprunk commented 4 months ago

1) The new event is valuable. 2) Alright, so "consider the goal reached when touching another unit standing on the goal" is an undocumented (?) but intended behaviour change for raw move and not a bug. This sounds good for existing games. Just to check though, can I make an important unit still push out whatever chaff is standing on its goal?

marcushutchings commented 4 months ago

At the moment, no, but I can certainly add that. Is that something you would want on a per-unit basis? or is it more a per-unitType basis? (or perhaps even by moveDef?)

marcushutchings commented 4 months ago

Or possibily would push-resist units be the ones that would do that?

sprunk commented 4 months ago

I'm not necessarily asking to add it right now, just knowing that it sounds easy to bring back is reassuring.

But if you do then the more granularity the better (perhaps even per move request, i.e. another bool param to Spring.SetMoveGoal).

marcushutchings commented 4 months ago

I like that idea on a per-move-request basis.

sprunk commented 4 months ago

Thanks for the zip with the fix, applied https://github.com/ZeroK-RTS/Zero-K/commit/1a663a9a925b09867f1ec2c996e891a08357d502