MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Script_Unit_SetDestinationDirect

Function Script_Unit_SetDestinationDirect

src/script/unit.c:918–936  ·  view source on GitHub ↗

* Set the current destination of a Unit, bypassing any pathfinding. * It is wise to only use this function on Carry-Alls. * * Stack: 1 - An encoded tile, the destination. * * @param script The script engine to operate on. * @return The value 0. Always. */

Source from the content-addressed store, hash-verified

916 * @return The value 0. Always.
917 */
918uint16 Script_Unit_SetDestinationDirect(ScriptEngine *script)
919{
920 Unit *u;
921 uint16 encoded;
922
923 encoded = STACK_PEEK(1);
924
925 if (!Tools_Index_IsValid(encoded)) return 0;
926
927 u = g_scriptCurrentUnit;
928
929 if ((u->currentDestination.x == 0 && u->currentDestination.y == 0) || g_table_unitInfo[u->o.type].flags.isNormalUnit) {
930 u->currentDestination = Tools_Index_GetTile(encoded);
931 }
932
933 Unit_SetOrientation(u, Tile_GetDirection(u->o.position, u->currentDestination), false, 0);
934
935 return 0;
936}
937
938/**
939 * Get information about the unit, like hitpoints, current target, etc.

Callers

nothing calls this directly

Calls 4

Tools_Index_IsValidFunction · 0.85
Tools_Index_GetTileFunction · 0.85
Unit_SetOrientationFunction · 0.85
Tile_GetDirectionFunction · 0.85

Tested by

no test coverage detected