Zero-K icon indicating copy to clipboard operation
Zero-K copied to clipboard

Retreat is broken when spam clicking commands in multiplayer games

Open Godde opened this issue 1 year ago • 4 comments

Steps to reproduce:

Host multiplayer lobby so that you have a latency to the server. Start game. Setup retreat zone. Set unit to retreat at 99%. Continually spam click orders for the unit as you enter the enemy range and takes damage. The unit becomes deselected but continues to the target destination, probably because the command reaches the server after it was deselected and ordered to retreat.

Godde avatar Jan 01 '25 16:01 Godde

The simple solution is for the unit to become immune to player commands for 500ms or so after being told to retreat. There might be edge cases though.

GoogleFrog avatar Jan 01 '25 23:01 GoogleFrog

Yeah, that could work decently. In 500ms seems low enough that you wont be able to react to the deselection of the unit and give it a new order before the time has passed. I guess there would be a few rare occasions where you are about to select the unit being damaged and selects it right after it getting below the threshold and the command won't get registered because it is still within that 500ms window.

Godde avatar Jan 03 '25 21:01 Godde

Two extra solutions that could be more correct but sound annoying/dangerous to implement:

  • IIRC ping is readable from synced, so the 500ms could instead be ping.
  • orders given to retreating units could be poisoned with extra metadata (cmd options bit flag) and the unit would be immune to anything without it (in particular, orders given before the unit started retreating).

sprunk avatar Jan 04 '25 00:01 sprunk

orders given to retreating units could be poisoned with extra metadata (cmd options bit flag) and the unit would be immune to anything without it (in particular, orders given before the unit started retreating).

How about this for an engine feature: All commands include the frame they were issued on, where the frame is whatever was local to the issuer. So if a player issues a command on frame 100 and it hits synced on frame 110, the command has an issue time of 100. Commands issued by luarules can set issue frame, in case luarules merely transforms a command from unsynced, and wants to retain the data for other purposes. But most of the time it would default to the current frame.

GoogleFrog avatar Jan 04 '25 04:01 GoogleFrog