[new feature] Turn order for units (implemented)

I’ve made some improvements to game_cobbutton gadget. It now can pass directions or map point coordinates to COB function called when the button is pressed. As a demonstration, ISU-152 now has a Turn order that forces it to turn to face the specified map point. If that feels right, it can easily be added to other units as well.

To add Turn to other units: edit LuaRules/Configs/cob_buttons.lua to include the unit, then add RotateHere(newDirection) function to its script (look for function in ISU-152 script).

Possible improvements:

  • read turn speed from unitdef? Currently it’s hardcoded in script;
  • special ‘turn there’ cirsor? Currently uses patrol cursor;
  • a way to abort turning by pressing Stop?

maybe just press the move button then it should stop turing and move?

awesome anyway! thats what we need…

Excellent yuri! This is something a lot of people have been asking about for quite some time.

yeess i asked yuri before xD he told me that he asked tenthousend of times for a tool like this. xD all tanks need that!

By the way: the Tracks dont move while turning !!!

I changed the way Turn button is defined. Now all that’s needed is to add hasturnbutton=1; to unit’s customParams, include TurnButton.h in script and recompile script. No need to list each and every unit in cob_buttons.lua.

Should probably do the same to mine clear and smoke code, so they could as well be defined in customParams.

Looks awesome, except that it turns sooooooooooooooooooooooooooo oooooooooooooo ooooooooooooo fucking slowly. Maybe it should; it is an ISU-152 afterall. But it almost seems as if using the Turn function takes longer than doing it manually.

It seems that the turn is not overridden by move orders, so you can get some quite strange behaviour.

Well, it uses <5> as turn speed. I just don’t see how to get the ‘real’ turn speed from COB side. And doing it with actual move orders has recently become quite hard, with reverse movement and such.

As for move orders overriding turn, that’s easy to fix. But it will require modifications to all affected unit scripts (StartMoving should produce a signal).

Fixed move orders messing up turns by using SIG_MOVE. Units that do not currently have SIG_MOVE need it defined and the following added at the start of StartMoving() (optionally to StopMoving() as well) for those units to use Turn function:

signal SIG_MOVE;

Examples are in ISU-152 and T-34-76 scripts.

Edit: made Turn command use the turnRate from unitdef if any (it uses some default value if turnRate is not given to avoid div0)