1 #ifndef __CAMPAIGN_TYPES_H
2 #define __CAMPAIGN_TYPES_H
3
4 #include "Debug.h"
5 #include "Types.h"
6
IS_VALID_SECTOR(UINT8 const x,UINT8 const y)7 static inline bool IS_VALID_SECTOR(UINT8 const x, UINT8 const y)
8 {
9 return 1 <= x && x <= 16 && 1 <= y && y <= 16;
10 }
11
12 //Macro to convert sector coordinates (1-16,1-16) to 0-255
SECTOR(UINT8 const x,UINT8 const y)13 static inline UINT8 SECTOR(UINT8 const x, UINT8 const y)
14 {
15 Assert(IS_VALID_SECTOR(x, y));
16 return (y - 1) * 16 + x - 1;
17 }
18
IS_VALID_SECTOR_SHORT_STRING(ST::string shortString)19 static inline bool IS_VALID_SECTOR_SHORT_STRING(ST::string shortString)
20 {
21 size_t len = shortString.size();
22 if (len < 2 || len > 3) return false;
23
24 char y = shortString[0], x = shortString[1];
25 if (y < 'A' || y > 'P' || x < '1' || x > '9') return false;
26
27 if (len == 3)
28 {
29 char x2 = shortString[2];
30 if (x != '1' || x2 < '0' || x2 > '6') return false;
31 }
32
33 return true;
34 }
35
36 //Macro to convert sector short strings such as A1 and P16, to the 0-255 SectorInfo[] index
SECTOR_FROM_SECTOR_SHORT_STRING(const char * coordinates)37 static inline UINT8 SECTOR_FROM_SECTOR_SHORT_STRING(const char* coordinates)
38 {
39 Assert(strlen(coordinates) > 1);
40 UINT8 y = coordinates[0] - 'A' + 1;
41 UINT8 x = atoi(coordinates + 1);
42 return SECTOR(x, y);
43 }
44
45 #define SECTORX(SectorID) ((SectorID % 16) + 1)
46 #define SECTORY(SectorID) ((SectorID / 16) + 1)
47
48 // short string representation of the sector, e.g. A1, P16
SECTOR_SHORT_STRING(UINT8 sector)49 static inline ST::string SECTOR_SHORT_STRING(UINT8 sector)
50 {
51 return ST::format("{c}{}", SECTORY(sector) + 'A' - 1, SECTORX(sector));
52 }
53
54 //Sector enumerations
55 //
56 //NOTE: These use the 0-255 SectorInfo[] numbering system, and CAN'T be used as indexes into the StrategicMap[] array
57 //Use SECTOR_INFO_TO_STRATEGIC_INDEX() macro to convert...
58 enum
59 {
60 SEC_A1, SEC_A2, SEC_A3, SEC_A4, SEC_A5, SEC_A6, SEC_A7, SEC_A8, SEC_A9, SEC_A10, SEC_A11, SEC_A12, SEC_A13, SEC_A14, SEC_A15, SEC_A16,
61 SEC_B1, SEC_B2, SEC_B3, SEC_B4, SEC_B5, SEC_B6, SEC_B7, SEC_B8, SEC_B9, SEC_B10, SEC_B11, SEC_B12, SEC_B13, SEC_B14, SEC_B15, SEC_B16,
62 SEC_C1, SEC_C2, SEC_C3, SEC_C4, SEC_C5, SEC_C6, SEC_C7, SEC_C8, SEC_C9, SEC_C10, SEC_C11, SEC_C12, SEC_C13, SEC_C14, SEC_C15, SEC_C16,
63 SEC_D1, SEC_D2, SEC_D3, SEC_D4, SEC_D5, SEC_D6, SEC_D7, SEC_D8, SEC_D9, SEC_D10, SEC_D11, SEC_D12, SEC_D13, SEC_D14, SEC_D15, SEC_D16,
64 SEC_E1, SEC_E2, SEC_E3, SEC_E4, SEC_E5, SEC_E6, SEC_E7, SEC_E8, SEC_E9, SEC_E10, SEC_E11, SEC_E12, SEC_E13, SEC_E14, SEC_E15, SEC_E16,
65 SEC_F1, SEC_F2, SEC_F3, SEC_F4, SEC_F5, SEC_F6, SEC_F7, SEC_F8, SEC_F9, SEC_F10, SEC_F11, SEC_F12, SEC_F13, SEC_F14, SEC_F15, SEC_F16,
66 SEC_G1, SEC_G2, SEC_G3, SEC_G4, SEC_G5, SEC_G6, SEC_G7, SEC_G8, SEC_G9, SEC_G10, SEC_G11, SEC_G12, SEC_G13, SEC_G14, SEC_G15, SEC_G16,
67 SEC_H1, SEC_H2, SEC_H3, SEC_H4, SEC_H5, SEC_H6, SEC_H7, SEC_H8, SEC_H9, SEC_H10, SEC_H11, SEC_H12, SEC_H13, SEC_H14, SEC_H15, SEC_H16,
68 SEC_I1, SEC_I2, SEC_I3, SEC_I4, SEC_I5, SEC_I6, SEC_I7, SEC_I8, SEC_I9, SEC_I10, SEC_I11, SEC_I12, SEC_I13, SEC_I14, SEC_I15, SEC_I16,
69 SEC_J1, SEC_J2, SEC_J3, SEC_J4, SEC_J5, SEC_J6, SEC_J7, SEC_J8, SEC_J9, SEC_J10, SEC_J11, SEC_J12, SEC_J13, SEC_J14, SEC_J15, SEC_J16,
70 SEC_K1, SEC_K2, SEC_K3, SEC_K4, SEC_K5, SEC_K6, SEC_K7, SEC_K8, SEC_K9, SEC_K10, SEC_K11, SEC_K12, SEC_K13, SEC_K14, SEC_K15, SEC_K16,
71 SEC_L1, SEC_L2, SEC_L3, SEC_L4, SEC_L5, SEC_L6, SEC_L7, SEC_L8, SEC_L9, SEC_L10, SEC_L11, SEC_L12, SEC_L13, SEC_L14, SEC_L15, SEC_L16,
72 SEC_M1, SEC_M2, SEC_M3, SEC_M4, SEC_M5, SEC_M6, SEC_M7, SEC_M8, SEC_M9, SEC_M10, SEC_M11, SEC_M12, SEC_M13, SEC_M14, SEC_M15, SEC_M16,
73 SEC_N1, SEC_N2, SEC_N3, SEC_N4, SEC_N5, SEC_N6, SEC_N7, SEC_N8, SEC_N9, SEC_N10, SEC_N11, SEC_N12, SEC_N13, SEC_N14, SEC_N15, SEC_N16,
74 SEC_O1, SEC_O2, SEC_O3, SEC_O4, SEC_O5, SEC_O6, SEC_O7, SEC_O8, SEC_O9, SEC_O10, SEC_O11, SEC_O12, SEC_O13, SEC_O14, SEC_O15, SEC_O16,
75 SEC_P1, SEC_P2, SEC_P3, SEC_P4, SEC_P5, SEC_P6, SEC_P7, SEC_P8, SEC_P9, SEC_P10, SEC_P11, SEC_P12, SEC_P13, SEC_P14, SEC_P15, SEC_P16
76 };
77
78
79 //Various flag definitions
80 enum SectorFlags
81 {
82 SF_USE_MAP_SETTINGS = 0x00000001,
83 SF_ENEMY_AMBUSH_LOCATION = 0x00000002,
84
85 /* Special case flag used when players encounter enemies in a sector, then
86 * retreat. The number of enemies will display on mapscreen until time is
87 * compressed. When time is compressed, the flag is cleared, and a question
88 * mark is displayed to reflect that the player no longer knows. */
89 SF_PLAYER_KNOWS_ENEMIES_ARE_HERE = 0x00000004,
90
91 SF_ALREADY_VISITED = 0x00000020,
92 SF_USE_ALTERNATE_MAP = 0x00000040,
93 SF_PENDING_ALTERNATE_MAP = 0x00000080,
94 SF_ALREADY_LOADED = 0x00000100,
95 SF_HAS_ENTERED_TACTICAL = 0x00000200,
96 SF_SKYRIDER_NOTICED_ENEMIES_HERE = 0x00000400,
97 SF_HAVE_USED_GUIDE_QUOTE = 0x00000800,
98
99
100 SF_SMOKE_EFFECTS_TEMP_FILE_EXISTS = 0x00100000, // Temp File starts with sm_
101 SF_LIGHTING_EFFECTS_TEMP_FILE_EXISTS = 0x00200000, // Temp File starts with l_
102
103 SF_REVEALED_STATUS_TEMP_FILE_EXISTS = 0x01000000, // Temp File starts with v_
104 SF_DOOR_STATUS_TEMP_FILE_EXISTS = 0x02000000, // Temp File starts with ds_
105 SF_ENEMY_PRESERVED_TEMP_FILE_EXISTS = 0x04000000, // Temp File starts with e_
106 SF_CIV_PRESERVED_TEMP_FILE_EXISTS = 0x08000000, // Temp File starts with c_
107 SF_ITEM_TEMP_FILE_EXISTS = 0x10000000, // Temp File starts with i_
108 SF_ROTTING_CORPSE_TEMP_FILE_EXISTS = 0x20000000, // Temp File starts with r_
109 SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS = 0x40000000, // Temp File starts with m_
110 SF_DOOR_TABLE_TEMP_FILES_EXISTS = 0x80000000 // Temp File starts with d_
111 };
112
113
114 // town militia experience categories
115 enum
116 {
117 GREEN_MILITIA = 0,
118 REGULAR_MILITIA,
119 ELITE_MILITIA,
120 MAX_MILITIA_LEVELS
121 };
122
123 // facilities flags
124 #define SFCF_HOSPITAL 0x00000001
125 #define SFCF_INDUSTRY 0x00000002
126 #define SFCF_PRISON 0x00000004
127 #define SFCF_MILITARY 0x00000008
128 #define SFCF_AIRPORT 0x00000010
129 #define SFCF_GUN_RANGE 0x00000020
130
131 // coordinates of shooting range sector
132 #define GUN_RANGE_X 13
133 #define GUN_RANGE_Y MAP_ROW_H
134 #define GUN_RANGE_Z 0
135
136
137 //Vehicle types
138 #define FOOT 0x01 //anywhere
139 #define CAR 0x02 //roads
140 #define TRUCK 0x04 //roads, plains, sparse
141 #define TRACKED 0x08 //roads, plains, sand, sparse
142 #define AIR 0x10 //can traverse all terrains at 100%
143
144 //Traversability ratings
145 enum
146 {
147 TOWN, //instant
148 ROAD, //everything travels at 100%
149 PLAINS, //foot 90%, truck 75%, tracked 100%
150 SAND, //foot 70%, tracked 60%
151 SPARSE, //foot 70%, truck 50%, tracked 60%
152 DENSE, //foot 50%
153 SWAMP, //foot 20%
154 WATER, //foot 15%
155 HILLS, //foot 50%, truck 50%, tracked 50%
156 GROUNDBARRIER,//only air (super dense forest, ocean, etc.)
157 NS_RIVER, //river from north to south
158 EW_RIVER, //river from east to west
159 EDGEOFWORLD, //nobody can traverse.
160 //NEW (not used for border values -- traversal calculations)
161 TROPICS,
162 FARMLAND,
163 PLAINS_ROAD,
164 SPARSE_ROAD,
165 FARMLAND_ROAD,
166 TROPICS_ROAD,
167 DENSE_ROAD,
168 COASTAL,
169 HILLS_ROAD,
170 COASTAL_ROAD,
171 SAND_ROAD,
172 SWAMP_ROAD,
173 //only used for text purposes and not assigned to areas (SAM sites are hard coded throughout the code)
174 SPARSE_SAM_SITE, //D15 near Drassen
175 SAND_SAM_SITE, //I8 near Tixa
176 TROPICS_SAM_SITE, //D2 near Chitzena
177 MEDUNA_SAM_SITE, //N4 in Meduna
178 CAMBRIA_HOSPITAL_SITE,
179 DRASSEN_AIRPORT_SITE,
180 MEDUNA_AIRPORT_SITE,
181 SAM_SITE,
182
183 REBEL_HIDEOUT,
184 TIXA_DUNGEON,
185 CREATURE_LAIR,
186 ORTA_BASEMENT,
187 TUNNEL,
188 SHELTER,
189 ABANDONED_MINE,
190
191 NUM_TRAVTERRAIN_TYPES
192 };
193
194 //Used by ubGarrisonID when a sector doesn't point to a garrison. Used by strategic AI only.
195 #define NO_GARRISON 255
196
197 struct SECTORINFO
198 {
199 //information pertaining to this sector
200 UINT32 uiFlags; //various special conditions
201 UINT8 ubGarrisonID; //IF the sector has an ID for this (non 255), then the queen values this sector and it
202 //indexes the garrison group.
203 INT8 ubPendingReinforcements; //when the enemy owns this sector, this value will keep track of HIGH priority reinforcements -- not regular.
204 BOOLEAN fMilitiaTrainingPaid;
205 UINT8 ubMilitiaTrainingPercentDone;
206 UINT8 ubMilitiaTrainingHundredths;
207 //enemy only info
208 UINT8 ubNumTroops; //the actual number of troops here.
209 UINT8 ubNumElites; //the actual number of elites here.
210 UINT8 ubNumAdmins; //the actual number of admins here.
211 UINT8 ubNumCreatures; //only set when immediately before ground attack made!
212 UINT8 ubTroopsInBattle, ubElitesInBattle, ubAdminsInBattle, ubCreaturesInBattle;
213
214 UINT32 ubDayOfLastCreatureAttack;
215 UINT32 uiFacilitiesFlags; // the flags for various facilities
216
217 UINT8 ubTraversability[5];//determines the traversability ratings to adjacent sectors.
218 //The last index represents the traversability if travelling
219 //throught the sector without entering it.
220 INT8 bBloodCats;
221 INT8 bBloodCatPlacements;
222
223 UINT8 ubTravelRating; //Represents how travelled a sector is. Typically, the higher the travel rating,
224 //the more people go near it. A travel rating of 0 means there are never people
225 //around. This value is used for determining how often items would "vanish" from
226 //a sector (nice theory, except it isn't being used that way. Stealing is only in towns. ARM)
227 UINT8 ubNumberOfCivsAtLevel[ MAX_MILITIA_LEVELS ]; // town militia per experience class, 0/1/2 is GREEN/REGULAR/ELITE
228 UINT32 uiTimeCurrentSectorWasLastLoaded; //Specifies the last time the player was in the sector
229 UINT32 uiTimeLastPlayerLiberated; //in game seconds (used to prevent the queen from attacking for awhile)
230
231 BOOLEAN fSurfaceWasEverPlayerControlled;
232
233 UINT32 uiNumberOfWorldItemsInTempFileThatCanBeSeenByPlayer;
234 };
235
236 #define NO_ADJACENT_SECTOR 0x00
237 #define NORTH_ADJACENT_SECTOR 0x01
238 #define EAST_ADJACENT_SECTOR 0x02
239 #define SOUTH_ADJACENT_SECTOR 0x04
240 #define WEST_ADJACENT_SECTOR 0x08
241
242
243 struct UNDERGROUND_SECTORINFO
244 {
245 UINT32 uiFlags;
246 UINT8 ubSectorX, ubSectorY, ubSectorZ;
247 UINT8 ubNumElites, ubNumTroops, ubNumAdmins, ubNumCreatures;
248 UINT32 uiTimeCurrentSectorWasLastLoaded; //Specifies the last time the player was in the sector
249 UNDERGROUND_SECTORINFO* next;
250 UINT8 ubAdjacentSectors; //mask containing which sectors are adjacent
251 UINT8 ubCreatureHabitat; //determines how creatures live in this sector (see creature spreading.c)
252 UINT8 ubElitesInBattle, ubTroopsInBattle, ubAdminsInBattle, ubCreaturesInBattle;
253
254 UINT32 uiNumberOfWorldItemsInTempFileThatCanBeSeenByPlayer;
255 };
256
257
258 //The sector information required for the strategic AI. Contains the number of enemy troops,
259 //as well as intentions, etc.
260 extern SECTORINFO SectorInfo[256];
261 extern UNDERGROUND_SECTORINFO *gpUndergroundSectorInfoHead;
262
263 #endif
264