OUNITRES.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. //Filename : OUNITRES.H
  21. //Description : Header file of Object Unit resource
  22. #ifndef __OUNITRES_H
  23. #define __OUNITRES_H
  24. #ifndef __ALL_H
  25. #include <ALL.h>
  26. #endif
  27. #ifndef __ORESDB_H
  28. #include <ORESDB.h>
  29. #endif
  30. #ifdef NO_DEBUG_UNIT
  31. #undef DEBUG
  32. #endif
  33. //---------- Define constant ------------//
  34. enum { UNIT_NORMAN=1,
  35. UNIT_MAYA,
  36. UNIT_GREEK,
  37. UNIT_VIKING,
  38. UNIT_PERSIAN,
  39. UNIT_CHINESE,
  40. UNIT_JAPANESE,
  41. UNIT_CARAVAN,
  42. UNIT_CATAPULT,
  43. UNIT_BALLISTA,
  44. UNIT_FLAMETHROWER,
  45. UNIT_CANNON,
  46. UNIT_EXPLOSIVE_CART,
  47. UNIT_VESSEL,
  48. UNIT_TRANSPORT,
  49. UNIT_CARAVEL,
  50. UNIT_GALLEON,
  51. UNIT_DRAGON,
  52. UNIT_CHINESE_DRAGON,
  53. UNIT_PERSIAN_HEALER,
  54. UNIT_VIKING_GOD,
  55. UNIT_PHOENIX,
  56. UNIT_KUKULCAN,
  57. UNIT_JAPANESE_GOD,
  58. UNIT_SKELETON,
  59. UNIT_LYW,
  60. UNIT_HOBGLOBLIN,
  61. UNIT_GIANT_ETTIN,
  62. UNIT_GITH,
  63. UNIT_ROCKMAN,
  64. UNIT_GREMJERM,
  65. UNIT_FIREKIN,
  66. UNIT_GNOLL,
  67. UNIT_GOBLIN,
  68. UNIT_LIZARDMAN,
  69. UNIT_MAN,
  70. UNIT_HEADLESS,
  71. #ifdef AMPLUS
  72. UNIT_EGYPTIAN,
  73. UNIT_INDIAN,
  74. UNIT_ZULU,
  75. UNIT_EGYPTIAN_GOD,
  76. UNIT_INDIAN_GOD,
  77. UNIT_ZULU_GOD,
  78. UNIT_F_BALLISTA,
  79. #endif
  80. UNIT_LAST // keep this line after the last unit
  81. };
  82. enum { MAX_UNIT_TYPE = UNIT_LAST-1,
  83. #ifdef AMPLUS
  84. MAX_WEAPON_TYPE = 6, // no. of types of weapons
  85. #else
  86. MAX_WEAPON_TYPE = 5, // no. of types of weapons
  87. #endif
  88. MAX_SHIP_TYPE = 4, // no. of types of ships
  89. };
  90. //--------- Define Unit Classes --------//
  91. enum { UNIT_CLASS_HUMAN = 'H',
  92. UNIT_CLASS_CARAVAN = 'C',
  93. UNIT_CLASS_WEAPON = 'W',
  94. UNIT_CLASS_SHIP = 'S',
  95. UNIT_CLASS_MONSTER = 'M',
  96. UNIT_CLASS_GOD = 'G',
  97. };
  98. //------------ Mobile Types -------------//
  99. enum { UNIT_AIR ='A',
  100. UNIT_LAND='L',
  101. UNIT_SEA ='S',
  102. };
  103. //--------- Define constant ------------//
  104. #define STD_UNIT_HIT_POINTS 200 // the hit points for all standard units
  105. //--------- Define constant -----------//
  106. enum { UNIT_SMALL_ICON_WIDTH=24,
  107. UNIT_SMALL_ICON_HEIGHT=20,
  108. UNIT_LARGE_ICON_WIDTH=46,
  109. UNIT_LARGE_ICON_HEIGHT=38
  110. };
  111. //-------- Define struct UnitRec ----------//
  112. struct UnitRec
  113. {
  114. enum { NAME_LEN=15, SPRITE_CODE_LEN=8, RACE_CODE_LEN=8, UNIT_CLASS_LEN=8, UNIT_PARA_LEN=3,
  115. BUILD_DAYS_LEN=3, YEAR_COST_LEN=3, CARRY_CAPACITY_LEN=3, FREE_WEAPON_COUNT_LEN=1,
  116. FILE_NAME_LEN=8, BITMAP_PTR_LEN=4, SPRITE_ID_LEN=3, RACE_ID_LEN=3 };
  117. char name[NAME_LEN];
  118. char sprite_code[SPRITE_CODE_LEN];
  119. char race_code[RACE_CODE_LEN];
  120. char unit_class[UNIT_CLASS_LEN];
  121. char mobile_type;
  122. char all_know;
  123. char visual_range[UNIT_PARA_LEN];
  124. char visual_extend[UNIT_PARA_LEN];
  125. char shealth[UNIT_PARA_LEN];
  126. char hit_points[UNIT_PARA_LEN];
  127. char armor[UNIT_PARA_LEN];
  128. char build_days[BUILD_DAYS_LEN];
  129. char year_cost[YEAR_COST_LEN];
  130. char weapon_power; // an index from 1 to 9 indicating the powerfulness of the weapon
  131. char carry_unit_capacity[CARRY_CAPACITY_LEN];
  132. char carry_goods_capacity[CARRY_CAPACITY_LEN];
  133. char free_weapon_count[FREE_WEAPON_COUNT_LEN];
  134. char vehicle_code[SPRITE_CODE_LEN];
  135. char vehicle_unit_code[SPRITE_CODE_LEN];
  136. char transform_unit[SPRITE_CODE_LEN];
  137. char transform_combat_level[UNIT_PARA_LEN];
  138. char guard_combat_level[UNIT_PARA_LEN];
  139. char large_icon_file_name[FILE_NAME_LEN];
  140. char large_icon_ptr[BITMAP_PTR_LEN];
  141. char general_icon_file_name[FILE_NAME_LEN];
  142. char general_icon_ptr[BITMAP_PTR_LEN];
  143. char king_icon_file_name[FILE_NAME_LEN];
  144. char king_icon_ptr[BITMAP_PTR_LEN];
  145. char small_icon_file_name[FILE_NAME_LEN];
  146. char small_icon_ptr[BITMAP_PTR_LEN];
  147. // ###### begin Gilbert 17/10 #######//
  148. char general_small_icon_file_name[FILE_NAME_LEN];
  149. char general_small_icon_ptr[BITMAP_PTR_LEN];
  150. char king_small_icon_file_name[FILE_NAME_LEN];
  151. char king_small_icon_ptr[BITMAP_PTR_LEN];
  152. // ###### end Gilbert 17/10 #######//
  153. char die_effect_sprite[SPRITE_CODE_LEN];
  154. char sprite_id[SPRITE_ID_LEN];
  155. char dll_sprite_id[SPRITE_ID_LEN];
  156. char race_id[RACE_ID_LEN];
  157. char vehicle_id[SPRITE_ID_LEN];
  158. char vehicle_unit_id[SPRITE_ID_LEN];
  159. char transform_unit_id[SPRITE_ID_LEN];
  160. char die_effect_id[UNIT_PARA_LEN];
  161. char first_attack[UNIT_PARA_LEN];
  162. char attack_count[UNIT_PARA_LEN];
  163. };
  164. //-------- Define struct UnitAttackRec ----------//
  165. struct UnitAttackRec
  166. {
  167. enum { SPRITE_CODE_LEN=8, UNIT_PARA_LEN=3, COMBAT_LEVEL_LEN=3 };
  168. char sprite_code[SPRITE_CODE_LEN];
  169. char attack_id[UNIT_PARA_LEN];
  170. char combat_level[COMBAT_LEVEL_LEN];
  171. char attack_delay[UNIT_PARA_LEN];
  172. char attack_range[UNIT_PARA_LEN];
  173. char attack_damage[UNIT_PARA_LEN];
  174. char pierce_damage[UNIT_PARA_LEN];
  175. char bullet_out_frame[UNIT_PARA_LEN];
  176. char bullet_speed[UNIT_PARA_LEN];
  177. char bullet_radius[UNIT_PARA_LEN];
  178. char bullet_sprite_code[SPRITE_CODE_LEN];
  179. char bullet_sprite_id[UNIT_PARA_LEN];
  180. char dll_bullet_sprite_id[UNIT_PARA_LEN];
  181. char eqv_attack_next[UNIT_PARA_LEN];
  182. char min_power[UNIT_PARA_LEN];
  183. char consume_power[UNIT_PARA_LEN];
  184. char fire_radius[UNIT_PARA_LEN];
  185. char effect_code[SPRITE_CODE_LEN];
  186. char effect_id[UNIT_PARA_LEN];
  187. };
  188. //-------- Define struct UnitInfo ----------//
  189. struct UnitInfo
  190. {
  191. //-------- define constant ---------//
  192. enum { NAME_LEN=15 };
  193. char name[NAME_LEN+1];
  194. short unit_id;
  195. short sprite_id;
  196. short dll_sprite_id;
  197. char race_id;
  198. char unit_class;
  199. char is_monster;
  200. char mobile_type;
  201. BYTE visual_range;
  202. BYTE visual_extend;
  203. BYTE shealth;
  204. BYTE armor;
  205. short hit_points;
  206. char build_days;
  207. short build_cost;
  208. short year_cost;
  209. char weapon_power; // an index from 1 to 9 indicating the powerfulness of the weapon
  210. char carry_unit_capacity;
  211. short carry_goods_capacity;
  212. char free_weapon_count; // only for ships. It's the no. of free weapons can be loaded onto the ship
  213. char vehicle_id;
  214. char vehicle_unit_id;
  215. char solider_id;
  216. char transform_unit_id;
  217. char transform_combat_level;
  218. char guard_combat_level;
  219. short first_attack;
  220. char attack_count;
  221. short die_effect_id;
  222. // char* large_icon_ptr;
  223. char* soldier_icon_ptr;
  224. char* general_icon_ptr;
  225. char* king_icon_ptr;
  226. // ######### begin Gilbert 17/10 #######//
  227. // char* small_icon_ptr;
  228. char* soldier_small_icon_ptr;
  229. char* general_small_icon_ptr;
  230. char* king_small_icon_ptr;
  231. // ######### end Gilbert 17/10 #######//
  232. //------- game vars -----------//
  233. char nation_tech_level_array[MAX_NATION]; // each nation's tech level on this unit
  234. int get_nation_tech_level(int nationRecno) { return nation_tech_level_array[nationRecno-1]; }
  235. void set_nation_tech_level(int nationRecno, char techLevel) { nation_tech_level_array[nationRecno-1] = techLevel; }
  236. short nation_unit_count_array[MAX_NATION]; // mobile units + soldiers in camps, not including workers and prayers in bases
  237. short nation_general_count_array[MAX_NATION];
  238. public:
  239. int is_loaded(); // whether the sprite data of this unit is in the memory or not
  240. char* get_large_icon_ptr(char rankId);
  241. // ###### begin Gilbert 17/10 ######//
  242. char* get_small_icon_ptr(char rankId);
  243. // ###### end Gilbert 17/10 ######//
  244. void inc_nation_unit_count(int nationRecno);
  245. void dec_nation_unit_count(int nationRecno);
  246. void inc_nation_general_count(int nationRecno);
  247. void dec_nation_general_count(int nationRecno);
  248. void unit_change_nation(int newNationRecno, int oldNationRecno, int rankId);
  249. };
  250. //--------- Define struct AttackInfo ----------//
  251. #pragma pack(1)
  252. struct AttackInfo
  253. {
  254. BYTE combat_level;
  255. BYTE attack_delay;
  256. BYTE attack_range;
  257. BYTE attack_damage;
  258. BYTE pierce_damage;
  259. short bullet_out_frame; // on which attacking frames the bullet should be out
  260. char bullet_speed;
  261. char bullet_radius;
  262. char bullet_sprite_id;
  263. char dll_bullet_sprite_id;
  264. char eqv_attack_next;
  265. // cur_attack of the next equivalent attack
  266. // so as to cycle through several similar attacks
  267. short min_power;
  268. short consume_power;
  269. char fire_radius;
  270. short effect_id;
  271. };
  272. #pragma pack()
  273. //---------- Define class UnitRes ------------//
  274. class UnitRes
  275. {
  276. public:
  277. char init_flag;
  278. int unit_info_count;
  279. int attack_info_count;
  280. UnitInfo* unit_info_array;
  281. AttackInfo* attack_info_array;
  282. ResourceDb res_large_icon;
  283. ResourceDb res_general_icon;
  284. ResourceDb res_king_icon;
  285. ResourceDb res_small_icon;
  286. // ###### begin Gilbert 17/10 #######//
  287. ResourceDb res_general_small_icon;
  288. ResourceDb res_king_small_icon;
  289. // ###### end Gilbert 17/10 #######//
  290. short mobile_monster_count;
  291. public:
  292. UnitRes() { init_flag=0; }
  293. void init();
  294. void deinit();
  295. int write_file(File* filePtr);
  296. int read_file(File* filePtr);
  297. #ifdef DEBUG
  298. UnitInfo* operator[](int unitId);
  299. AttackInfo* get_attack_info(int attackId);
  300. #else
  301. UnitInfo* operator[](int unitId) { return unit_info_array+unitId-1; }
  302. AttackInfo* get_attack_info(int attackId) { return attack_info_array+attackId-1; }
  303. #endif
  304. static char mobile_type_to_mask(int mobileType);
  305. private:
  306. void load_info();
  307. void load_attack_info();
  308. };
  309. extern UnitRes unit_res;
  310. //----------------------------------------------//
  311. #endif