**This is an old revision of the document!**
Placing Units
Reviewed For: SDK 2.1
The Unit class represents all buildings and vehicles in Outpost 2. All scenarios will require some initial units.
Building position is determined by the point where the vertical and horizontal tube of a building would intercept if they continued through.
LOCATION offset
Unit positions are represented in game by either the structure LOCATION or by passing 2 integers into a function, representing the x and y position. LOCATION represents the tile currently being occupied by the unit. The Outpost 2 game engine requires units to be placed +31 X tiles and -1 Y tiles from their actual position. For example: LOCATION(21 + 31, 15 - 1) would be the position (21,15) on the map.
Building Origin
When attempting to place units on the map, you can reference the map coordinates by using the mapper and looking in the lower right corner. See the image below for an example.
For a building without tube connections like a Tokamak, the LOCATION of the building cooresponds with the lower right tile of the structure.
Vehicle Lights
When any vehicle is created, it defaults to lights off. The function void DoSetLights(int boolOn)
from Unit.h can be used to turn the lights on.
Using the CreateUnit Function
Some variables used in CreateUnit
are not required depending on what unit is being created. For example, a command center cannot have cargo or if you want to create a truck that does not contain any cargo. In these situations use the enum map_id::mapNone to indicate no cargo is required.
When placing buildings, the variable rotation does not have any meaning and can be set to any value.
Related Source Code
From TethysGame
static int __fastcall CreateUnit( Unit& returnedUnit, map_id unitType, LOCATION location, int playerNum, map_id weaponCargoType, int rotation);
Unit.h
void DoSetLights(int boolOn);
NonExportedEnums.h
enum UnitDirection { East = 0, SouthEast = 1, South = 2, SouthWest = 3, West = 4, NorthWest = 5, North = 6, NorthEast = 7, };
MapIdEnum.h
enum map_id { mapAny = -1, // FF Use to specify 'all' or 'any' mapNone = 0, // 00 mapCargoTruck, // 01 mapConVec, // 02 mapSpider, // 03 mapScorpion, // 04 mapLynx, // 05 mapPanther, // 06 mapTiger, // 07 mapRoboSurveyor, // 08 mapRoboMiner, // 09 mapGeoCon, // 0A mapScout, // 0B mapRoboDozer, // 0C mapEvacuationTransport, // 0D mapRepairVehicle, // 0E mapEarthworker, // 0F mapSmallCapacityAirTransport, // 10 Crashes game when it moves (looks like a scout) mapTube, // 11 mapWall, // 12 mapLavaWall, // 13 mapMicrobeWall, // 14 mapCommonOreMine, // 15 mapRareOreMine, // 16 mapGuardPost, // 17 mapLightTower, // 18 mapCommonStorage, // 19 mapRareStorage, // 1A mapForum, // 1B mapCommandCenter, // 1C mapMHDGenerator, // 1D mapResidence, // 1E mapRobotCommand, // 1F mapTradeCenter, // 20 mapBasicLab, // 21 mapMedicalCenter, // 22 mapNursery, // 23 mapSolarPowerArray, // 24 mapRecreationFacility, // 25 mapUniversity, // 26 mapAgridome, // 27 mapDIRT, // 28 mapGarage, // 29 mapMagmaWell, // 2A mapMeteorDefense, // 2B mapGeothermalPlant, // 2C mapArachnidFactory, // 2D mapConsumerFactory, // 2E mapStructureFactory, // 2F mapVehicleFactory, // 30 mapStandardLab, // 31 mapAdvancedLab, // 32 mapObservatory, // 33 mapReinforcedResidence, // 34 mapAdvancedResidence, // 35 mapCommonOreSmelter, // 36 mapSpaceport, // 37 mapRareOreSmelter, // 38 mapGORF, // 39 mapTokamak, // 3A mapAcidCloud, // 3B mapEMP, // 3C mapLaser, // 3D mapMicrowave, // 3E mapRailGun, // 3F mapRPG, // 40 mapStarflare, // 41 Vehicle Starflare mapSupernova, // 42 Vehicle Supernova mapStarflare2, // 43 GuardPost Starflare mapSupernova2, // 44 GuardPost Supernova mapNormalUnitExplosion, // 45 mapESG, // 46 mapStickyfoam, // 47 mapThorsHammer, // 48 mapEnergyCannon, // 49 mapBlast, // 4A EMP/Sticky foam blast //mapUnknown4B, // 4B Unknown what this is "BFG" mapLightning = 0x4C, // 4C mapVortex, // 4D mapEarthquake, // 4E mapEruption, // 4F mapMeteor, // 50 mapMiningBeacon, // 51 mapMagmaVent, // 52 mapFumarole, // 53 mapWreckage, // 54 mapDisasterousBuildingExplosion, // 55 mapCatastrophicBuildingExplosion, // 56 mapAtheistBuildingExplosion, // 57 mapEDWARDSatellite, // 58 Lynx (in Cargo Truck) mapSolarSatellite, // 59 Wreckage (in Cargo Truck) mapIonDriveModule, // 5A Gene Bank 5 (in Cargo Truck) mapFusionDriveModule, // 5B mapCommandModule, // 5C mapFuelingSystems, // 5D mapHabitatRing, // 5E mapSensorPackage, // 5F mapSkydock, // 60 mapStasisSystems, // 61 mapOrbitalPackage, // 62 mapPhoenixModule, // 63 mapRareMetalsCargo, // 64 mapCommonMetalsCargo, // 65 mapFoodCargo, // 66 mapEvacuationModule, // 67 mapChildrenModule, // 68 mapSULV, // 69 mapRLV, // 6A mapEMPMissile, // 6B mapImpulseItems, // 6C mapWares, // 6D mapLuxuryWares, // 6E mapInterColonyShuttle, // 6F mapSpider3Pack, // 70 mapScorpion3Pack, // 71 mapPrettyArt, // 72 (Used for explosions) mapGeneralUnit, // 73 Don't try to create this unless you're implementing a new unit class };
Sample Code
int InitProc() { // Create a Command Center for player 1. Unit commandCenter; TethysGame::CreateUnit( commandCenter, map_id::mapCommandCenter, LOCATION(30 + 31, 208 - 1), 0, map_id::mapNone, UnitDirection::East); // Create an Acid Cloud guard post for player 2. Unit guardPost; TethysGame::CreateUnit( guardPost, map_id::mapGuardPost, LOCATION(3 + 31, 2 - 1), 1, map_id::mapAcidCloud, UnitDirection::East) // Create a ConVec with a Tokamak Kit for player 2 and turn it's lights on. Unit conVec; TethysGame::CreateUnit( conVec, map_id::mapConVec, LOCATION(50 + 31, 10 - 1), 1, map_id::mapTokamak, UnitDirection::North); conVec.DoSetLights(true); }
- Go Back to Programming a Scenario
- Go Back to Outpost 2 Mapmaking
- Go Back to Outpost 2 Main page
- Go Back to Wiki Home Page