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

Function Script_General_GetDistanceToTile

src/script/general.c:71–82  ·  view source on GitHub ↗

* Get the distance from the current unit/structure to the tile. * * Stack: 1 - An encoded tile index. * * @param script The script engine to operate on. * @return Distance to it, where distance is (longest(x,y) + shortest(x,y) / 2). */

Source from the content-addressed store, hash-verified

69 * @return Distance to it, where distance is (longest(x,y) + shortest(x,y) / 2).
70 */
71uint16 Script_General_GetDistanceToTile(ScriptEngine *script)
72{
73 Object *o;
74 uint16 encoded;
75
76 encoded = STACK_PEEK(1);
77 o = g_scriptCurrentObject;
78
79 if (!Tools_Index_IsValid(encoded)) return 0xFFFF;
80
81 return Tile_GetDistance(o->position, Tools_Index_GetTile(encoded));
82}
83
84/**
85 * Do nothing. This function has absolutely no functionality other than

Callers

nothing calls this directly

Calls 3

Tools_Index_IsValidFunction · 0.85
Tile_GetDistanceFunction · 0.85
Tools_Index_GetTileFunction · 0.85

Tested by

no test coverage detected