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

Function Script_Unit_StartAnimation

src/script/unit.c:1463–1489  ·  view source on GitHub ↗

* Start the animation on the current tile. * * Stack: *none*. * * @param script The script engine to operate on. * @return The value 1. Always. */

Source from the content-addressed store, hash-verified

1461 * @return The value 1. Always.
1462 */
1463uint16 Script_Unit_StartAnimation(ScriptEngine *script)
1464{
1465 Unit *u;
1466 uint16 animationUnitID;
1467 uint16 position;
1468
1469 VARIABLE_NOT_USED(script);
1470
1471 u = g_scriptCurrentUnit;
1472
1473 position = Tile_PackTile(Tile_Center(u->o.position));
1474 Animation_Stop_ByTile(position);
1475
1476 animationUnitID = g_table_landscapeInfo[Map_GetLandscapeType(Tile_PackTile(u->o.position))].isSand ? 0 : 1;
1477 if (u->o.script.variables[1] == 1) animationUnitID += 2;
1478
1479 g_map[position].houseID = Unit_GetHouseID(u);
1480
1481 assert(animationUnitID < 4);
1482 if (g_table_unitInfo[u->o.type].displayMode == DISPLAYMODE_INFANTRY_3_FRAMES) {
1483 Animation_Start(g_table_animation_unitScript1[animationUnitID], u->o.position, 0, Unit_GetHouseID(u), 4);
1484 } else {
1485 Animation_Start(g_table_animation_unitScript2[animationUnitID], u->o.position, 0, Unit_GetHouseID(u), 4);
1486 }
1487
1488 return 1;
1489}
1490
1491/**
1492 * Call a UnitType and make it go to the current unit. In general, type should

Callers

nothing calls this directly

Calls 5

Tile_CenterFunction · 0.85
Animation_Stop_ByTileFunction · 0.85
Map_GetLandscapeTypeFunction · 0.85
Unit_GetHouseIDFunction · 0.85
Animation_StartFunction · 0.85

Tested by

no test coverage detected