Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
op2_sdk:placing_units [2016/01/31 14:38] – created vagabond | op2_sdk:placing_units [2016/03/27 20:56] – [Level 2 Headline] vagabond | ||
---|---|---|---|
Line 3: | Line 3: | ||
'' | '' | ||
- | The Unit class represents all buildings and vehicles in Outpost 2. All scenarios will require some initial | + | The Unit class represents all buildings and vehicles in Outpost 2. New units should be created using the function '' |
===== LOCATION offset ===== | ===== LOCATION offset ===== | ||
- | Unit positions | + | Positions in game are represented by either the structure |
+ | |||
+ | ===== Building Origin ===== | ||
+ | |||
+ | For buildings in Outpost 2 that span more than one tile, the position is determined by the point where the vertical and horizontal tube of a building would intercept if they were continuous. See the graphic below for a visual representation. For a building without tube connections, | ||
+ | |||
+ | {{ op2_sdk: | ||
+ | < | ||
+ | |||
+ | When attempting to place units on the map, map coordinates can be referenced by using the mapper and looking in the lower right corner to see which coordinate is highlighted. | ||
+ | |||
+ | {{ op2_sdk: | ||
+ | < | ||
+ | |||
+ | If you can load the map in Outpost 2, map coordinates can also be referenced in the lower left side of the in game screen. The current highlighted coordinate still updates as you move your mouse after pausing a game. See the image below for an example. | ||
+ | |||
+ | {{ op2_sdk: | ||
+ | < | ||
+ | |||
+ | ===== Vehicle Lights ===== | ||
+ | |||
+ | When any vehicle is created, the Outpost 2 SDK defaults to turning its lights off. The function '' | ||
+ | |||
+ | ===== Placing Units In a Garage ===== | ||
+ | |||
+ | During level initialization, | ||
+ | |||
+ | Call PutInGarage on the vehicle that you plan to place in a garage. The arguments tileX and tileY are the position of the garage you want the vehicle placed inside. | ||
+ | |||
+ | You CAN add vehicles to a garage that are not owned by the same player as the garage owner. | ||
+ | ===== Using the CreateUnit Function ===== | ||
+ | |||
+ | <code cpp> | ||
+ | static int __fastcall CreateUnit( | ||
+ | Unit& returnedUnit, | ||
+ | map_id unitType, | ||
+ | LOCATION location, | ||
+ | int playerNum, | ||
+ | map_id weaponCargoType, | ||
+ | int rotation); | ||
+ | |||
+ | Unit& returnedUnit //Passes the address of a unit. Where you can access the newly created unit later. | ||
+ | map_id unitType //The type of unit to create. Check the map_id enum set in MapIdEnum.h. | ||
+ | LOCATION location //Where the unit will be created. | ||
+ | int playerNum //The player who will own the structure, with player 1 being represented as 0. | ||
+ | map_id weaponCargoType //For a guardpost or tank, the turret type. | ||
+ | //Use map_id:: | ||
+ | //For a ConVec or Cargo Truck, this represents the vehicle' | ||
+ | // | ||
+ | //For a building, use the function SetFactoryCargo. | ||
+ | int rotation //Sets the initial rotation of a unit. 0 is east and continues in clockwise direction. | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | Some variables used in '' | ||
+ | |||
+ | The variable rotation is meaningless to the creation of a structure. Any value can be used. | ||
- | 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. | ||
===== Related Source Code ===== | ===== Related Source Code ===== | ||
- | Stub | + | //From TethysGame// |
+ | <code cpp> | ||
+ | static int __fastcall CreateUnit( | ||
+ | Unit& returnedUnit, | ||
+ | </ | ||
+ | |||
+ | // | ||
+ | <code cpp> | ||
+ | void DoSetLights(int boolOn); | ||
+ | </ | ||
+ | |||
+ | // | ||
+ | <code cpp> | ||
+ | enum UnitDirection | ||
+ | { | ||
+ | East = 0, | ||
+ | SouthEast = 1, | ||
+ | South = 2, | ||
+ | SouthWest = 3, | ||
+ | West = 4, | ||
+ | NorthWest = 5, | ||
+ | North = 6, | ||
+ | NorthEast = 7, | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | // | ||
+ | <code cpp> | ||
+ | enum map_id { | ||
+ | mapAny = -1, // FF Use to specify ' | ||
+ | |||
+ | mapNone = 0, // 00 | ||
+ | mapCargoTruck, | ||
+ | mapConVec, | ||
+ | mapSpider, | ||
+ | mapScorpion, | ||
+ | mapLynx, | ||
+ | mapPanther, | ||
+ | mapTiger, | ||
+ | mapRoboSurveyor, | ||
+ | mapRoboMiner, | ||
+ | mapGeoCon, | ||
+ | mapScout, | ||
+ | mapRoboDozer, | ||
+ | mapEvacuationTransport, | ||
+ | mapRepairVehicle, | ||
+ | mapEarthworker, | ||
+ | mapSmallCapacityAirTransport, | ||
+ | |||
+ | mapTube, | ||
+ | mapWall, | ||
+ | mapLavaWall, | ||
+ | mapMicrobeWall, | ||
+ | |||
+ | mapCommonOreMine, | ||
+ | mapRareOreMine, | ||
+ | mapGuardPost, | ||
+ | mapLightTower, | ||
+ | mapCommonStorage, | ||
+ | mapRareStorage, | ||
+ | mapForum, | ||
+ | mapCommandCenter, | ||
+ | mapMHDGenerator, | ||
+ | mapResidence, | ||
+ | mapRobotCommand, | ||
+ | mapTradeCenter, | ||
+ | mapBasicLab, | ||
+ | mapMedicalCenter, | ||
+ | mapNursery, | ||
+ | mapSolarPowerArray, | ||
+ | mapRecreationFacility, | ||
+ | mapUniversity, | ||
+ | mapAgridome, | ||
+ | mapDIRT, | ||
+ | mapGarage, | ||
+ | mapMagmaWell, | ||
+ | mapMeteorDefense, | ||
+ | mapGeothermalPlant, | ||
+ | mapArachnidFactory, | ||
+ | mapConsumerFactory, | ||
+ | mapStructureFactory, | ||
+ | mapVehicleFactory, | ||
+ | mapStandardLab, | ||
+ | mapAdvancedLab, | ||
+ | mapObservatory, | ||
+ | mapReinforcedResidence, | ||
+ | mapAdvancedResidence, | ||
+ | mapCommonOreSmelter, | ||
+ | mapSpaceport, | ||
+ | mapRareOreSmelter, | ||
+ | mapGORF, | ||
+ | mapTokamak, | ||
+ | |||
+ | mapAcidCloud, | ||
+ | mapEMP, | ||
+ | mapLaser, | ||
+ | mapMicrowave, | ||
+ | mapRailGun, | ||
+ | mapRPG, | ||
+ | mapStarflare, | ||
+ | mapSupernova, | ||
+ | mapStarflare2, | ||
+ | mapSupernova2, | ||
+ | mapNormalUnitExplosion, | ||
+ | mapESG, | ||
+ | mapStickyfoam, | ||
+ | mapThorsHammer, | ||
+ | mapEnergyCannon, | ||
+ | |||
+ | mapBlast, | ||
+ | // | ||
+ | |||
+ | mapLightning = 0x4C, // 4C | ||
+ | mapVortex, | ||
+ | mapEarthquake, | ||
+ | mapEruption, | ||
+ | mapMeteor, | ||
+ | |||
+ | mapMiningBeacon, | ||
+ | mapMagmaVent, | ||
+ | mapFumarole, | ||
+ | |||
+ | mapWreckage, | ||
+ | |||
+ | mapDisasterousBuildingExplosion, | ||
+ | mapCatastrophicBuildingExplosion, | ||
+ | mapAtheistBuildingExplosion, | ||
+ | |||
+ | mapEDWARDSatellite, | ||
+ | mapSolarSatellite, | ||
+ | mapIonDriveModule, | ||
+ | mapFusionDriveModule, | ||
+ | mapCommandModule, | ||
+ | mapFuelingSystems, | ||
+ | mapHabitatRing, | ||
+ | mapSensorPackage, | ||
+ | mapSkydock, | ||
+ | mapStasisSystems, | ||
+ | mapOrbitalPackage, | ||
+ | mapPhoenixModule, | ||
+ | |||
+ | mapRareMetalsCargo, | ||
+ | mapCommonMetalsCargo, | ||
+ | mapFoodCargo, | ||
+ | mapEvacuationModule, | ||
+ | mapChildrenModule, | ||
+ | |||
+ | mapSULV, | ||
+ | mapRLV, | ||
+ | mapEMPMissile, | ||
+ | |||
+ | mapImpulseItems, | ||
+ | mapWares, | ||
+ | mapLuxuryWares, | ||
+ | |||
+ | mapInterColonyShuttle, | ||
+ | mapSpider3Pack, | ||
+ | mapScorpion3Pack, | ||
+ | |||
+ | mapPrettyArt, | ||
+ | |||
+ | mapGeneralUnit, | ||
+ | }; | ||
+ | </ | ||
===== Sample Code ===== | ===== Sample Code ===== | ||
<code cpp> | <code cpp> | ||
+ | |||
+ | int InitProc() | ||
+ | { | ||
+ | // Create a Command Center for player 1. | ||
+ | Unit commandCenter; | ||
+ | | ||
+ | TethysGame:: | ||
+ | commandCenter, | ||
+ | map_id:: | ||
+ | LOCATION(30 + 31, 208 - 1), | ||
+ | 0, | ||
+ | map_id:: | ||
+ | UnitDirection:: | ||
+ | | ||
+ | | ||
+ | // Create an Acid Cloud guard post for player 2. | ||
+ | Unit guardPost; | ||
+ | | ||
+ | TethysGame:: | ||
+ | guardPost, | ||
+ | map_id:: | ||
+ | LOCATION(3 + 31, 2 - 1), | ||
+ | 1, | ||
+ | map_id:: | ||
+ | UnitDirection:: | ||
+ | | ||
+ | // Create a ConVec with a Tokamak Kit for player 2 and turn it's lights on. | ||
+ | Unit conVec; | ||
+ | | ||
+ | TethysGame:: | ||
+ | conVec, | ||
+ | map_id:: | ||
+ | LOCATION(50 + 31, 10 - 1), | ||
+ | 1, | ||
+ | map_id:: | ||
+ | UnitDirection:: | ||
+ | | ||
+ | conVec.DoSetLights(true); | ||
+ | } | ||
</ | </ |