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).
read turn speed from unitdef? Currently it’s hardcoded in script;
special ‘turn there’ cirsor? Currently uses patrol cursor;
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.
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:
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)