* Transform an MCV into Construction Yard. * * Stack: *none*. * * @param script The script engine to operate on. * @return 1 if and only if the transformation succeeded. */
| 1832 | * @return 1 if and only if the transformation succeeded. |
| 1833 | */ |
| 1834 | uint16 Script_Unit_MCVDeploy(ScriptEngine *script) |
| 1835 | { |
| 1836 | Unit *u; |
| 1837 | Structure *s = NULL; |
| 1838 | uint16 i; |
| 1839 | |
| 1840 | VARIABLE_NOT_USED(script); |
| 1841 | |
| 1842 | u = g_scriptCurrentUnit; |
| 1843 | |
| 1844 | Unit_UpdateMap(0, u); |
| 1845 | |
| 1846 | for (i = 0; i < 4; i++) { |
| 1847 | static const int8 offsets[4] = { 0, -1, -64, -65 }; |
| 1848 | |
| 1849 | s = Structure_Create(STRUCTURE_INDEX_INVALID, STRUCTURE_CONSTRUCTION_YARD, Unit_GetHouseID(u), Tile_PackTile(u->o.position) + offsets[i]); |
| 1850 | |
| 1851 | if (s != NULL) { |
| 1852 | Unit_Remove(u); |
| 1853 | return 1; |
| 1854 | } |
| 1855 | } |
| 1856 | |
| 1857 | if (Unit_GetHouseID(u) == g_playerHouseID) { |
| 1858 | GUI_DisplayText(String_Get_ByIndex(STR_UNIT_IS_UNABLE_TO_DEPLOY_HERE), 0); |
| 1859 | } |
| 1860 | |
| 1861 | Unit_UpdateMap(1, u); |
| 1862 | |
| 1863 | return 0; |
| 1864 | } |
| 1865 | |
| 1866 | /** |
| 1867 | * Get the best target around you. Only considers units on sand. |
nothing calls this directly
no test coverage detected