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 : OF_MONS.H 22 //Description : Header of Firm Monster 23 24 #ifndef __OF_MONS_H 25 #define __OF_MONS_H 26 27 #ifndef __OFIRM_H 28 #include <OFIRM.h> 29 #endif 30 31 //---------- Define constant ---------// 32 33 #define MAX_MONSTER_GENERAL_IN_FIRM 8 // maximum no. of monster generals in a firm 34 #define MAX_SOLDIER_PER_GENERAL 8 // maximum soldier can be led by a general 35 #define MAX_MONSTER_IN_FIRM ( 1 + MAX_MONSTER_GENERAL_IN_FIRM * (1+MAX_SOLDIER_PER_GENERAL) ) 36 37 #define MONSTER_ATTACK_NEIGHBOR_RANGE 6 // it will attack any firms/towns within 3 location away from it 38 #define MONSTER_EXPAND_RANGE 8 // the new firm built should be within this distance with the current firm 39 40 41 //------ Define struct MonsterGeneral -------// 42 // 43 // Monster generals who live in monster firms. 44 // 45 #pragma pack(1) 46 struct MonsterInFirm 47 { 48 public: 49 char monster_id; 50 char _unused; 51 short mobile_unit_recno; // unit recno of this monster when it is a mobile unit 52 // this is only used as a reference for soldiers to find their leaders 53 char combat_level; 54 short hit_points; 55 short max_hit_points; 56 57 char soldier_monster_id; // monster id. of the soldiers led by this monster general 58 char soldier_count; // no. of soldiers commaned by this monster general/king 59 60 public: 61 void set_combat_level(int combatLevel); 62 }; 63 #pragma pack() 64 65 struct FirmMonsterCrc; 66 67 //------- Define class FirmMonster --------// 68 69 #pragma pack(1) 70 class FirmMonster : public Firm 71 { 72 public: 73 enum { MAX_WAITING_SOLDIER = 30 }; // maximum no. of soldiers queued in the monster firm waiting for their generals 74 75 short monster_id; // the monster type id. of the firm. 76 short monster_general_count; 77 78 char monster_aggressiveness; // 0-100 79 80 char defending_king_count; 81 char defending_general_count; 82 char defending_soldier_count; 83 total_defender()84 int total_defender() { return defending_king_count + defending_general_count + defending_soldier_count; } 85 86 MonsterInFirm monster_king; 87 MonsterInFirm monster_general_array[MAX_MONSTER_GENERAL_IN_FIRM]; 88 89 char waiting_soldier_count; 90 short waiting_soldier_array[MAX_WAITING_SOLDIER]; // the unit recno of their generals are kept here 91 92 char monster_nation_relation; // each bit n is high representing this independent town will attack nation n. 93 short defend_target_recno; // used in defend mode, store recno of the latest unit attacking this firm 94 95 char patrol_unit_count; // for AI to get the recno of the patrol units 96 short patrol_unit_array[MAX_SOLDIER_PER_GENERAL+1]; 97 98 public: 99 void init_derived(); 100 void deinit_derived(); 101 102 ~FirmMonster(); 103 104 char* firm_name(); 105 106 void put_info(int refreshFlag); 107 int detect_info(); 108 109 void next_day(); 110 111 void assign_unit(int unitRecno); 112 int can_assign_monster(int unitRecno); 113 114 void set_king(int monsterId, int combatLevel); 115 void add_general(int generalUnitRecno); 116 void add_soldier(int generalUnitRecno); 117 118 int recruit_general(int soldierCount= -1); 119 void recruit_soldier(); 120 121 int mobilize_king(); 122 int mobilize_general(int generalId, int mobilizeSoldier=1); 123 124 int total_combat_level(); 125 126 void being_attacked(int attackerUnitRecno); 127 void clear_defense_mode(); 128 void reduce_defender_count(int rankId); 129 130 void set_hostile_nation(int nationRecno); 131 void reset_hostile_nation(int nationRecno); 132 int is_hostile_nation(int nationRecno); 133 134 //-------------- multiplayer checking codes ---------------// 135 virtual uint8_t crc8(); 136 virtual void clear_ptr(); 137 virtual void init_crc(FirmMonsterCrc *c); 138 139 private: 140 void disp_monster_info(int dispY1, int refreshFlag); 141 142 void validate_patrol_unit(); 143 void recover_hit_points(); 144 145 int mobilize_monster(int monsterId, int rankId, int combatLevel, int hitPoints=0); 146 147 int think_attack_neighbor(); 148 int think_attack_human(); 149 int think_expansion(); 150 }; 151 #pragma pack() 152 153 //--------------------------------------// 154 155 #endif 156