1 /* 2 * Seven Kingdoms: Ancient Adversaries 3 * 4 * Copyright 1997,1998 Enlight Software Ltd. 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 //Filename : OUNITRES.H 22 //Description : Header file of Object Unit resource 23 24 #ifndef __OUNITRES_H 25 #define __OUNITRES_H 26 27 #ifndef __ALL_H 28 #include <ALL.h> 29 #endif 30 31 #ifndef __ORESDB_H 32 #include <ORESDB.h> 33 #endif 34 35 #ifdef NO_DEBUG_UNIT 36 #undef DEBUG 37 #endif 38 39 //---------- Define constant ------------// 40 41 enum { UNIT_NORMAN=1, 42 UNIT_MAYA, 43 UNIT_GREEK, 44 UNIT_VIKING, 45 UNIT_PERSIAN, 46 UNIT_CHINESE, 47 UNIT_JAPANESE, 48 UNIT_CARAVAN, 49 UNIT_CATAPULT, 50 UNIT_BALLISTA, 51 UNIT_FLAMETHROWER, 52 UNIT_CANNON, 53 UNIT_EXPLOSIVE_CART, 54 UNIT_VESSEL, 55 UNIT_TRANSPORT, 56 UNIT_CARAVEL, 57 UNIT_GALLEON, 58 UNIT_DRAGON, 59 UNIT_CHINESE_DRAGON, 60 UNIT_PERSIAN_HEALER, 61 UNIT_VIKING_GOD, 62 UNIT_PHOENIX, 63 UNIT_KUKULCAN, 64 UNIT_JAPANESE_GOD, 65 UNIT_SKELETON, 66 UNIT_LYW, 67 UNIT_HOBGLOBLIN, 68 UNIT_GIANT_ETTIN, 69 UNIT_GITH, 70 UNIT_ROCKMAN, 71 UNIT_GREMJERM, 72 UNIT_FIREKIN, 73 UNIT_GNOLL, 74 UNIT_GOBLIN, 75 UNIT_LIZARDMAN, 76 UNIT_MAN, 77 UNIT_HEADLESS, 78 UNIT_EGYPTIAN, 79 UNIT_INDIAN, 80 UNIT_ZULU, 81 UNIT_EGYPTIAN_GOD, 82 UNIT_INDIAN_GOD, 83 UNIT_ZULU_GOD, 84 UNIT_F_BALLISTA, 85 UNIT_LAST // keep this line after the last unit 86 }; 87 88 enum { MAX_UNIT_TYPE = UNIT_LAST-1, 89 MAX_WEAPON_TYPE = 6, // no. of types of weapons 90 MAX_SHIP_TYPE = 4, // no. of types of ships 91 }; 92 93 //--------- Define Unit Classes --------// 94 95 enum { UNIT_CLASS_HUMAN = 'H', 96 UNIT_CLASS_CARAVAN = 'C', 97 UNIT_CLASS_WEAPON = 'W', 98 UNIT_CLASS_SHIP = 'S', 99 UNIT_CLASS_MONSTER = 'M', 100 UNIT_CLASS_GOD = 'G', 101 }; 102 103 //------------ Mobile Types -------------// 104 105 enum { UNIT_AIR ='A', 106 UNIT_LAND='L', 107 UNIT_SEA ='S', 108 }; 109 110 //--------- Define constant ------------// 111 112 #define STD_UNIT_HIT_POINTS 200 // the hit points for all standard units 113 114 //--------- Define constant -----------// 115 116 enum { UNIT_SMALL_ICON_WIDTH=24, 117 UNIT_SMALL_ICON_HEIGHT=20, 118 UNIT_LARGE_ICON_WIDTH=46, 119 UNIT_LARGE_ICON_HEIGHT=38 120 }; 121 122 //-------- Define struct UnitRec ----------// 123 124 struct UnitRec 125 { 126 enum { NAME_LEN=15, SPRITE_CODE_LEN=8, RACE_CODE_LEN=8, UNIT_CLASS_LEN=8, UNIT_PARA_LEN=3, 127 BUILD_DAYS_LEN=3, YEAR_COST_LEN=3, CARRY_CAPACITY_LEN=3, FREE_WEAPON_COUNT_LEN=1, 128 FILE_NAME_LEN=8, BITMAP_PTR_LEN=4, SPRITE_ID_LEN=3, RACE_ID_LEN=3 }; 129 130 char name[NAME_LEN]; 131 char sprite_code[SPRITE_CODE_LEN]; 132 char race_code[RACE_CODE_LEN]; 133 char unit_class[UNIT_CLASS_LEN]; 134 135 char mobile_type; 136 char all_know; 137 138 char visual_range[UNIT_PARA_LEN]; 139 char visual_extend[UNIT_PARA_LEN]; 140 char shealth[UNIT_PARA_LEN]; 141 char hit_points[UNIT_PARA_LEN]; 142 char armor[UNIT_PARA_LEN]; 143 144 char build_days[BUILD_DAYS_LEN]; 145 char year_cost[YEAR_COST_LEN]; 146 147 char weapon_power; // an index from 1 to 9 indicating the powerfulness of the weapon 148 149 char carry_unit_capacity[CARRY_CAPACITY_LEN]; 150 char carry_goods_capacity[CARRY_CAPACITY_LEN]; 151 char free_weapon_count[FREE_WEAPON_COUNT_LEN]; 152 153 char vehicle_code[SPRITE_CODE_LEN]; 154 char vehicle_unit_code[SPRITE_CODE_LEN]; 155 156 char transform_unit[SPRITE_CODE_LEN]; 157 char transform_combat_level[UNIT_PARA_LEN]; 158 char guard_combat_level[UNIT_PARA_LEN]; 159 160 char large_icon_file_name[FILE_NAME_LEN]; 161 char large_icon_ptr[BITMAP_PTR_LEN]; 162 char general_icon_file_name[FILE_NAME_LEN]; 163 char general_icon_ptr[BITMAP_PTR_LEN]; 164 char king_icon_file_name[FILE_NAME_LEN]; 165 char king_icon_ptr[BITMAP_PTR_LEN]; 166 167 char small_icon_file_name[FILE_NAME_LEN]; 168 char small_icon_ptr[BITMAP_PTR_LEN]; 169 // ###### begin Gilbert 17/10 #######// 170 char general_small_icon_file_name[FILE_NAME_LEN]; 171 char general_small_icon_ptr[BITMAP_PTR_LEN]; 172 char king_small_icon_file_name[FILE_NAME_LEN]; 173 char king_small_icon_ptr[BITMAP_PTR_LEN]; 174 // ###### end Gilbert 17/10 #######// 175 176 char die_effect_sprite[SPRITE_CODE_LEN]; 177 178 char sprite_id[SPRITE_ID_LEN]; 179 char dll_sprite_id[SPRITE_ID_LEN]; 180 char race_id[RACE_ID_LEN]; 181 182 char vehicle_id[SPRITE_ID_LEN]; 183 char vehicle_unit_id[SPRITE_ID_LEN]; 184 185 char transform_unit_id[SPRITE_ID_LEN]; 186 char die_effect_id[UNIT_PARA_LEN]; 187 188 char first_attack[UNIT_PARA_LEN]; 189 char attack_count[UNIT_PARA_LEN]; 190 }; 191 192 //-------- Define struct UnitAttackRec ----------// 193 194 struct UnitAttackRec 195 { 196 enum { SPRITE_CODE_LEN=8, UNIT_PARA_LEN=3, COMBAT_LEVEL_LEN=3 }; 197 198 char sprite_code[SPRITE_CODE_LEN]; 199 200 char attack_id[UNIT_PARA_LEN]; 201 char combat_level[COMBAT_LEVEL_LEN]; 202 203 char attack_delay[UNIT_PARA_LEN]; 204 char attack_range[UNIT_PARA_LEN]; 205 206 char attack_damage[UNIT_PARA_LEN]; 207 char pierce_damage[UNIT_PARA_LEN]; 208 209 char bullet_out_frame[UNIT_PARA_LEN]; 210 char bullet_speed[UNIT_PARA_LEN]; 211 char bullet_radius[UNIT_PARA_LEN]; 212 char bullet_sprite_code[SPRITE_CODE_LEN]; 213 char bullet_sprite_id[UNIT_PARA_LEN]; 214 char dll_bullet_sprite_id[UNIT_PARA_LEN]; 215 char eqv_attack_next[UNIT_PARA_LEN]; 216 char min_power[UNIT_PARA_LEN]; 217 char consume_power[UNIT_PARA_LEN]; 218 char fire_radius[UNIT_PARA_LEN]; 219 char effect_code[SPRITE_CODE_LEN]; 220 char effect_id[UNIT_PARA_LEN]; 221 }; 222 223 //-------- Define struct UnitInfo ----------// 224 225 struct UnitInfo 226 { 227 //-------- define constant ---------// 228 229 enum { NAME_LEN=15 }; 230 231 char name[NAME_LEN+1]; 232 233 short unit_id; 234 short sprite_id; 235 short dll_sprite_id; 236 char race_id; 237 char unit_class; 238 char is_monster; 239 240 char mobile_type; 241 242 int visual_range; 243 int visual_extend; 244 int shealth; 245 int armor; 246 247 short hit_points; 248 249 char build_days; 250 short build_cost; 251 short year_cost; 252 253 char weapon_power; // an index from 1 to 9 indicating the powerfulness of the weapon 254 255 char carry_unit_capacity; 256 short carry_goods_capacity; 257 char free_weapon_count; // only for ships. It's the no. of free weapons can be loaded onto the ship 258 259 char vehicle_id; 260 char vehicle_unit_id; 261 char solider_id; 262 263 char transform_unit_id; 264 char transform_combat_level; 265 char guard_combat_level; 266 267 short first_attack; 268 char attack_count; 269 short die_effect_id; 270 271 // char* large_icon_ptr; 272 char* soldier_icon_ptr; 273 char* general_icon_ptr; 274 char* king_icon_ptr; 275 // ######### begin Gilbert 17/10 #######// 276 // char* small_icon_ptr; 277 char* soldier_small_icon_ptr; 278 char* general_small_icon_ptr; 279 char* king_small_icon_ptr; 280 // ######### end Gilbert 17/10 #######// 281 282 //------- game vars -----------// 283 284 char nation_tech_level_array[MAX_NATION]; // each nation's tech level on this unit get_nation_tech_levelUnitInfo285 int get_nation_tech_level(int nationRecno) { return nation_tech_level_array[nationRecno-1]; } set_nation_tech_levelUnitInfo286 void set_nation_tech_level(int nationRecno, char techLevel) { nation_tech_level_array[nationRecno-1] = techLevel; } 287 288 short nation_unit_count_array[MAX_NATION]; // mobile units + soldiers in camps, not including workers and prayers in bases 289 short nation_general_count_array[MAX_NATION]; 290 291 public: 292 int is_loaded(); // whether the sprite data of this unit is in the memory or not 293 char* get_large_icon_ptr(char rankId); 294 // ###### begin Gilbert 17/10 ######// 295 char* get_small_icon_ptr(char rankId); 296 // ###### end Gilbert 17/10 ######// 297 298 void inc_nation_unit_count(int nationRecno); 299 void dec_nation_unit_count(int nationRecno); 300 301 void inc_nation_general_count(int nationRecno); 302 void dec_nation_general_count(int nationRecno); 303 304 void unit_change_nation(int newNationRecno, int oldNationRecno, int rankId); 305 }; 306 307 //--------- Define struct AttackInfo ----------// 308 309 #pragma pack(1) 310 struct AttackInfo 311 { 312 uint8_t combat_level; 313 314 uint8_t attack_delay; 315 uint8_t attack_range; 316 317 uint8_t attack_damage; 318 uint8_t pierce_damage; 319 320 short bullet_out_frame; // on which attacking frames the bullet should be out 321 char bullet_speed; 322 char bullet_radius; 323 char bullet_sprite_id; 324 char dll_bullet_sprite_id; 325 char eqv_attack_next; 326 // cur_attack of the next equivalent attack 327 // so as to cycle through several similar attacks 328 short min_power; 329 short consume_power; 330 char fire_radius; 331 short effect_id; 332 }; 333 #pragma pack() 334 335 //---------- Define class UnitRes ------------// 336 337 class UnitRes 338 { 339 public: 340 char init_flag; 341 int unit_info_count; 342 int attack_info_count; 343 344 UnitInfo* unit_info_array; 345 AttackInfo* attack_info_array; 346 347 ResourceDb res_large_icon; 348 ResourceDb res_general_icon; 349 ResourceDb res_king_icon; 350 ResourceDb res_small_icon; 351 // ###### begin Gilbert 17/10 #######// 352 ResourceDb res_general_small_icon; 353 ResourceDb res_king_small_icon; 354 // ###### end Gilbert 17/10 #######// 355 356 short mobile_monster_count; 357 358 public: UnitRes()359 UnitRes() { init_flag=0; } 360 361 void init(); 362 void deinit(); 363 364 int write_file(File* filePtr); 365 int read_file(File* filePtr); 366 367 #ifdef DYNARRAY_DEBUG_ELEMENT_ACCESS 368 UnitInfo* operator[](int unitId); 369 AttackInfo* get_attack_info(int attackId); 370 #else 371 UnitInfo* operator[](int unitId) { return unit_info_array+unitId-1; } get_attack_info(int attackId)372 AttackInfo* get_attack_info(int attackId) { return attack_info_array+attackId-1; } 373 #endif 374 375 static char mobile_type_to_mask(int mobileType); 376 377 private: 378 void load_info(); 379 void load_attack_info(); 380 }; 381 382 extern UnitRes unit_res; 383 384 //----------------------------------------------// 385 386 #endif 387 388