Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
op2_sdk:placing_units [2016/01/31 21:04] – 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 '' |
- | + | ||
- | Building position is determined by the point where the vertical and horizontal tube of a building would intercept if they continued through. | + | |
===== LOCATION offset ===== | ===== LOCATION offset ===== | ||
- | Unit positions | + | Positions in game are represented by either the structure |
===== Building Origin ===== | ===== Building Origin ===== | ||
- | When attempting to place units on the map, you can reference | + | For buildings in Outpost 2 that span more than one tile, the position is determined |
- | For a building without tube connections like a Tokamak, the LOCATION of the building cooresponds with the lower right tile of the structure. | + | {{ op2_sdk: |
+ | < | ||
- | {{op2_sdk:buildingoriginexample.png.png?450}}\\ | + | 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. |
- | <fs small>//Image Credits: Sir Bomber//</fs> | + | |
+ | {{ op2_sdk:mappercoordinatesexample.png }} | ||
+ | < | ||
+ | |||
+ | 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: | ||
+ | <html>< | ||
===== Vehicle Lights ===== | ===== Vehicle Lights ===== | ||
- | When any vehicle is created, | + | When any vehicle is created, |
+ | |||
+ | ===== 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. | ||
===== Related Source Code ===== | ===== Related Source Code ===== | ||
Line 30: | Line 71: | ||
<code cpp> | <code cpp> | ||
static int __fastcall CreateUnit( | static int __fastcall CreateUnit( | ||
- | Unit& returnedUnit, | + | Unit& returnedUnit, |
- | | + | |
- | | + | |
</ | </ | ||
Line 44: | Line 83: | ||
enum UnitDirection | enum UnitDirection | ||
{ | { | ||
- | East = 0, | + | |
- | SouthEast = 1, | + | SouthEast = 1, |
- | South = 2, | + | South = 2, |
- | SouthWest = 3, | + | SouthWest = 3, |
- | West = 4, | + | West = 4, |
- | NorthWest = 5, | + | NorthWest = 5, |
- | North = 6, | + | North = 6, |
- | NorthEast = 7, | + | NorthEast = 7, |
}; | }; | ||
</ | </ |