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

Function Script_Unit_GetRandomTile

src/script/unit.c:1726–1738  ·  view source on GitHub ↗

* Get a random tile around the Unit. * * Stack: 1 - An encoded index of a tile, completely ignored, as long as it is a tile. * * @param script The script engine to operate on. * @return An encoded tile, or 0. */

Source from the content-addressed store, hash-verified

1724 * @return An encoded tile, or 0.
1725 */
1726uint16 Script_Unit_GetRandomTile(ScriptEngine *script)
1727{
1728 Unit *u;
1729 tile32 tile;
1730
1731 u = g_scriptCurrentUnit;
1732
1733 if (Tools_Index_GetType(STACK_PEEK(1)) != IT_TILE) return 0;
1734
1735 tile = Tile_MoveByRandom(u->o.position, 80, true);
1736
1737 return Tools_Index_Encode(Tile_PackTile(tile), IT_TILE);
1738}
1739
1740/**
1741 * Perform a random action when we are sitting idle, like rotating around.

Callers

nothing calls this directly

Calls 3

Tools_Index_GetTypeFunction · 0.85
Tile_MoveByRandomFunction · 0.85
Tools_Index_EncodeFunction · 0.85

Tested by

no test coverage detected