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_CAMP.H 22 //Description : Header of FirmCamp 23 24 #ifndef __OF_CAMP_H 25 #define __OF_CAMP_H 26 27 #ifndef __OFIRM_H 28 #include <OFIRM.h> 29 #endif 30 31 //------------ define constant -----------// 32 33 enum { INSIDE_CAMP=0, 34 OUTSIDE_CAMP, 35 }; 36 37 //-------- Define struct DefenseUnit ----------// 38 39 #pragma pack(1) 40 struct DefenseUnit 41 { 42 short unit_recno; 43 char status; // inside / outside the camp 44 }; 45 #pragma pack() 46 47 //------- Define class FirmCamp --------// 48 49 struct FirmCampCrc; 50 class Town; 51 class Unit; 52 53 #pragma pack(1) 54 class FirmCamp : public Firm 55 { 56 public: 57 //-------------------------------------// 58 59 DefenseUnit defense_array[MAX_WORKER+1]; // plus 1 with the overseer 60 char employ_new_worker; 61 short defend_target_recno; // used in defend mode, store recno of the latest target attacking this firm 62 char defense_flag; 63 64 int is_worker_full(); 65 66 //---------- AI related vars ----------// 67 68 char patrol_unit_count; // for AI to get the recno of the patrol units 69 short patrol_unit_array[MAX_WORKER+1]; 70 71 char coming_unit_count; // for AI to get the recno of the coming units 72 short coming_unit_array[MAX_WORKER+1]; 73 74 short ai_capture_town_recno; // >0 if the troop is in the process of attacking the independent village for capturing it. 75 char ai_recruiting_soldier; 76 77 char is_attack_camp; 78 79 int total_combat_level(); 80 int average_combat_level(); 81 int ai_combat_level_needed(); 82 83 int ai_has_excess_worker(); 84 85 public: 86 FirmCamp(); 87 88 void init_derived(); 89 void deinit(); 90 91 void put_info(int refreshFlag); 92 int detect_info(); 93 94 void next_day(); 95 void patrol(); 96 int patrol_all_soldier(); 97 98 void assign_unit(int unitRecno); 99 void assign_overseer(int overseerRecno); 100 void assign_worker(int unitRecno); 101 102 void defense(short targetRecno, int useRangeAttack=0); 103 void defense_inside_camp(short unitRecno, short targetRecno); 104 void defense_outside_camp(short unitRecno, short targetRecno); 105 void clear_defense_mode(); 106 107 int mobilize_worker(int workerId, char remoteAction); 108 int mobilize_overseer(); 109 110 void change_nation(int newNationRecno); 111 112 void update_defense_unit(short unitRecno); 113 void set_employ_worker(char flag); 114 cast_to_FirmCamp()115 virtual FirmCamp *cast_to_FirmCamp() { return this; }; 116 117 //----------- AI functions ----------// 118 119 void process_ai(); 120 int ai_should_close(); // overloaded function 121 void ai_update_link_status(); 122 123 int cur_commander_leadership(int bestRaceId=0); 124 int new_commander_leadership(int newRaceId, int newSkillLevel); 125 126 //-------------- multiplayer checking codes ---------------// 127 virtual uint8_t crc8(); 128 virtual void clear_ptr(); 129 virtual void init_crc(FirmCampCrc *c); 130 131 private: 132 void reset_unit_home_camp(int firmRecno); 133 void reset_attack_camp(int firmRecno); 134 135 void disp_camp_info(int dispY1, int refreshFlag); 136 137 void train_unit(); 138 void recover_hit_point(); 139 void pay_weapon_expense(); 140 141 void update_influence(); 142 void validate_patrol_unit(); 143 144 //-------------- AI functions --------------// 145 146 void ai_reset_defense_mode(); 147 void think_recruit(); 148 int think_attack(); 149 int ai_recruit(int combatLevelNeeded); 150 void ai_attack_town_defender(Unit*); 151 int think_attack_nearby_enemy(); 152 void think_change_town_link(); 153 154 void think_capture(); 155 int think_capture_return(); 156 int think_capture_use_spy(Town* targetTown); 157 int think_capture_use_spy2(Town* targetTown, int raceId, int curSpyLevel); 158 int think_assign_better_overseer(Town* targetTown); 159 int think_assign_better_overseer2(int targetTownRecno, int raceId); 160 void process_ai_capturing(); 161 162 int think_capture_target_town(); 163 int ai_capture_independent_town(Town* targetTown, int defenseCombatLevel); 164 int ai_capture_enemy_town(Town* targetTown, int defenseCombatLevel); 165 166 int think_use_cash_to_capture(); 167 void think_linked_town_change_nation(int linkedTownRecno, int oldNationRecno, int newNationRecno); 168 169 int think_assign_better_commander(); 170 int best_commander_race(); 171 }; 172 #pragma pack() 173 174 //--------------------------------------// 175 176 #endif 177