/** * Start the animation on the current tile. * * Stack: *none*. * * @param script The script engine to operate on. * @return The value 1. Always. */ uint16 Script_Unit_StartAnimation(ScriptEngine *script) { Unit *u; uint16 animationUnitID; uint16 position; VARIABLE_NOT_USED(script); u = g_scriptCurrentUnit; position = Tile_PackTile(Tile_Center(u->o.position)); Animation_Stop_ByTile(position); animationUnitID = g_table_landscapeInfo[Map_GetLandscapeType(Tile_PackTile(u->o.position))].isSand ? 0 : 1; if (u->o.script.variables[1] == 1) animationUnitID += 2; g_map[position].houseID = Unit_GetHouseID(u); assert(animationUnitID < 4); if (g_table_unitInfo[u->o.type].displayMode == 3) { Animation_Start(g_table_animation_unitScript1[animationUnitID], u->o.position, 0, Unit_GetHouseID(u), 4); } else { Animation_Start(g_table_animation_unitScript2[animationUnitID], u->o.position, 0, Unit_GetHouseID(u), 4); } return 1; }
/** * Start an Animation. * @param commands List of commands for the Animation. * @param tile The tile to do the Animation on. * @param layout The layout of tiles for the Animation. * @param houseID The house of the item being Animation. * @param iconGroup In which IconGroup the sprites of the Animation belongs. */ void Animation_Start(void *commands, tile32 tile, uint16 tileLayout, uint8 houseID, uint8 iconGroup) { Animation *animation = g_animations; uint16 packed = Tile_PackTile(tile); Tile *t; int i; t = &g_map[packed]; Animation_Stop_ByTile(packed); for (i = 0; i < ANIMATION_MAX; i++, animation++) { if (animation->commands != NULL) continue; animation->tickNext = g_timerGUI; animation->tileLayout = tileLayout; animation->houseID = houseID; animation->current = 0; animation->iconGroup = iconGroup; animation->commands = commands; animation->tile = tile; s_animationTimer = 0; t->houseID = houseID; t->hasAnimation = true; return; } }