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    : ONATION.H
22 //Description : Header of class Nation
23 //Owner		  : Alex
24 
25 #ifndef __ONATION_H
26 #define __ONATION_H
27 
28 #ifndef __ONATIONB_H
29 #include <ONATIONB.h>
30 #endif
31 
32 #ifndef __OUNIT_H
33 #include <OUNIT.h>
34 #endif
35 
36 #ifndef __OTOWN_H
37 #include <OTOWN.h>
38 #endif
39 
40 //--------- define parameters ----------//
41 
42 #define  MAX_AI_REGION				20
43 
44 #define	AI_TOWN_INIT_SIZE    	60
45 #define	AI_BASE_TOWN_INIT_SIZE  60
46 #define	AI_BASE_INIT_SIZE			20
47 #define  AI_MINE_INIT_SIZE			10
48 #define	AI_FACTORY_INIT_SIZE	 	50
49 #define	AI_MARKET_INIT_SIZE		50
50 #define	AI_INN_INIT_SIZE			10
51 #define	AI_CAMP_INIT_SIZE			60
52 #define  AI_RESEARCH_INIT_SIZE	30
53 #define  AI_WAR_INIT_SIZE			30
54 #define  AI_HARBOR_INIT_SIZE		10
55 #define  AI_GENERAL_INIT_SIZE	 	50
56 #define  AI_CARAVAN_INIT_SIZE		100
57 #define  AI_SHIP_INIT_SIZE			50
58 
59 #define	AI_TOWN_INC_SIZE    		30
60 #define	AI_BASE_TOWN_INC_SIZE   30
61 #define	AI_BASE_INC_SIZE			10
62 #define  AI_MINE_INC_SIZE			10
63 #define	AI_FACTORY_INC_SIZE	 	10
64 #define	AI_MARKET_INC_SIZE		10
65 #define	AI_INN_INC_SIZE			10
66 #define	AI_CAMP_INC_SIZE			10
67 #define  AI_RESEARCH_INC_SIZE		10
68 #define  AI_WAR_INC_SIZE			10
69 #define  AI_HARBOR_INC_SIZE		10
70 #define  AI_GENERAL_INC_SIZE	 	20
71 #define  AI_CARAVAN_INC_SIZE		30
72 #define  AI_SHIP_INC_SIZE			20
73 
74 //--------------------------------------//
75 
76 enum	{	STD_ACTION_RETRY_COUNT = 4,		// retry this number of times before giving up
77 			MAX_SCORE = 600,
78 
79 			MIGRATE_DEMAND_SUPPLY_DIFF=25, // suppy > demand + MIGRATE_DEMAND_SUPPLY_DIFF
80 			MIGRATE_STOCK_QTY=150,
81 
82 			TRADE_STOCK_QTY=125,
83 			MAX_TRADE_MARKET = 4
84 
85 			//MAX_BASE_TOWN = 10 // Unused.
86 		};
87 
88 enum  {  ACTION_DYNAMIC,     		// for ActionNode::action_type
89 			ACTION_FIXED		};
90 
91 enum	{	ACTION_AI_BUILD_FIRM=1,		// define ActionNode::action_mode
92 			ACTION_AI_ASSIGN_OVERSEER,
93 			ACTION_AI_ASSIGN_CONSTRUCTION_WORKER,
94 			ACTION_AI_ASSIGN_WORKER,
95 			ACTION_AI_ASSIGN_SPY,
96          ACTION_AI_SCOUT,
97 			ACTION_AI_SETTLE_TO_OTHER_TOWN,
98 			ACTION_AI_PROCESS_TALK_MSG,
99 			ACTION_AI_SEA_TRAVEL,
100 			ACTION_AI_SEA_TRAVEL2,
101 			ACTION_AI_SEA_TRAVEL3,
102 		};
103 
104 enum  {  SEA_ACTION_SETTLE=1, 			// for AI marine actions
105 			SEA_ACTION_BUILD_CAMP,
106 			SEA_ACTION_ASSIGN_TO_FIRM,
107 			SEA_ACTION_MOVE,
108          SEA_ACTION_NONE,			// just transport them to the specific region and disembark and wait for their own actions
109 		};
110 
111 //--------- define AIRegion ---------//
112 
113 #pragma pack(1)
114 struct AIRegion
115 {
116 	uint8_t	region_id;
117 	char  town_count;
118 	char  base_town_count;
119 };
120 #pragma pack()
121 
122 //-------- define ActionNode structure -------//
123 
124 #pragma pack(1)
125 struct ActionNode
126 {
127 	enum { MAX_ACTION_GROUP_UNIT = 9 };
128 
129 	char 	action_mode;		// eg build firm, attack, etc
130 	char	action_type;		// action type. For 7kaa, this is always ACTION_FIXED.
131 	short action_para;		// parameter for the action. e.g. firmId for AI_BUILD_FIRM
132 	short action_para2;		// parameter for the action. e.g. firm race id. for building FirmBase
133 	uint16_t	action_id;			// an unique id. for identifying this node
134 
135 	int32_t add_date;			// when this action is added
136 	short	unit_recno;			// unit associated with this action.
137 
138 	short	action_x_loc;		// can be firm loc, or target loc, etc
139 	short	action_y_loc;
140 	short	ref_x_loc;			// reference x loc, eg the raw material location
141 	short	ref_y_loc;
142 
143 	char	retry_count;	 				// number of term to wait before this action is removed from the array if it cannot be processed
144 	char	instance_count; 				// no. of times this action needs to be carried out
145 
146 	short group_unit_array[MAX_ACTION_GROUP_UNIT]; 		// for group unit actions, the no. of units in the array is stored in instance_count
147 
148 	char  processing_instance_count;
149 	char  processed_instance_count;
150 
151 	int32_t next_retry_date; 				// continue processing this action after this date, this is used when training a unit for construction
152 };
153 #pragma pack()
154 
155 //------- Define struct AttackCamp --------//
156 
157 #define MAX_SUITABLE_ATTACK_CAMP    30    // total no. of useful camps
158 
159 #pragma pack(1)
160 struct AttackCamp
161 {
162 	short firm_recno;
163 	short combat_level;
164 	short distance;
165 	int   patrol_date;
166 };
167 #pragma pack()
168 
169 //--------- Define class Nation ---------//
170 
171 class  Firm;
172 class  Town;
173 class  Spy;
174 struct TalkMsg;
175 
176 #pragma pack(1)
177 class Nation : public NationBase
178 {
179 public:
180 	DynArray		action_array;
181 	uint16_t			last_action_id; 	// a 16-bit id. for identifying ActionNode
182 
183 public:
184 	Nation();
185 	~Nation();
186 
187 	//------------------------------------------------------//
188 	// array used to store the the waiting and procesing actions
189 	//------------------------------------------------------//
190 
action_count()191 	int			action_count() 			{ return action_array.size(); }
get_action(int recNo)192 	ActionNode* get_action(int recNo)   { return (ActionNode*) action_array.get(recNo); }
193 	ActionNode* get_action_based_on_id(int actionId);
194 
195 	//------------------------------------------------------//
196 	// array used to store the info. of the firms
197 	//------------------------------------------------------//
198 	short*		ai_town_array;
199 	short* 		ai_base_array;
200 	short* 		ai_mine_array;
201 	short*		ai_factory_array;
202 	short* 		ai_camp_array;
203 	short*		ai_research_array;
204 	short*		ai_war_array;
205 	short*		ai_harbor_array;
206 	short*      ai_market_array;
207 	short*		ai_inn_array;
208 	short*    	ai_general_array;
209 	short*		ai_caravan_array;
210 	short*		ai_ship_array;
211 
212 	//--------------------------------------------------------//
213 	// parameters used to make decisions
214 	//--------------------------------------------------------//
215 	short			ai_town_size;
216 	short			ai_base_size;
217 	short			ai_mine_size;
218 	short			ai_factory_size;
219 	short			ai_camp_size;
220 	short			ai_research_size;
221 	short			ai_war_size;
222 	short			ai_harbor_size;
223 	short			ai_market_size;
224 	short			ai_inn_size;
225 	short			ai_general_size;
226 	short			ai_caravan_size;
227 	short			ai_ship_size;
228 
229 	short			ai_town_count;
230 	short			ai_base_count;
231 	short			ai_mine_count;
232 	short			ai_factory_count;
233 	short			ai_camp_count;
234 	short			ai_research_count;
235 	short			ai_war_count;
236 	short			ai_harbor_count;
237 	short			ai_market_count;
238 	short			ai_inn_count;
239 	short			ai_general_count;
240 	short			ai_caravan_count;
241 	short			ai_ship_count;
242 
243 	short			ai_base_town_count;
244 
245 	short			firm_should_close_array[MAX_FIRM_TYPE];
246 
247 	//------------------------------------------------------//
248 	// parameters about the nation itself
249 	//------------------------------------------------------//
250 
251 	AIRegion		ai_region_array[MAX_AI_REGION];
252 	char			ai_region_count;
253 
254 	//------------------------------------------------------//
255 	// AI personalties
256 	//------------------------------------------------------//
257 
258 	char 			pref_force_projection;
259 	char			pref_military_development;		// pref_military_development + pref_economic_development = 100
260 	char			pref_economic_development;
261 	char			pref_inc_pop_by_capture;		// pref_inc_pop_by_capture + pref_inc_pop_by_growth = 100
262 	char			pref_inc_pop_by_growth;
263 	char			pref_peacefulness;
264 	char			pref_military_courage;
265 	char			pref_territorial_cohesiveness;
266 	char			pref_trading_tendency;
267 	char			pref_allying_tendency;
268 	char			pref_honesty;
269 	char			pref_town_harmony;
270 	char			pref_loyalty_concern;
271 	char			pref_forgiveness;
272 	char			pref_collect_tax;
273 	char			pref_hire_unit;
274 	char			pref_use_weapon;
275 	char			pref_keep_general;          	// whether to keep currently non-useful the general, or demote them.
276 	char			pref_keep_skilled_unit; 		// whether to keep currently non-useful skilled units, or assign them to towns.
277 	char			pref_diplomacy_retry;			// tedency to retry diplomatic actions after previous ones have been rejected.
278 	char			pref_attack_monster;
279 	char			pref_spy;
280 	char			pref_counter_spy;
281 	char			pref_food_reserve;
282 	char			pref_cash_reserve;
283 	char			pref_use_marine;
284 	char			pref_unit_chase_distance;
285 	char			pref_repair_concern;
286 	char			pref_scout;
287 
288 	//------- AI action vars --------//
289 
290 	short			ai_capture_enemy_town_recno;
291 	int  			ai_capture_enemy_town_plan_date;
292 	int  			ai_capture_enemy_town_start_attack_date;
293 	char			ai_capture_enemy_town_use_all_camp;
294 
295 	int			ai_last_defend_action_date;
296 
297 	short			ai_attack_target_x_loc;
298 	short			ai_attack_target_y_loc;
299 	short			ai_attack_target_nation_recno;		//	nation recno of the target
300 
301 	AttackCamp  attack_camp_array[MAX_SUITABLE_ATTACK_CAMP];
302 	short			attack_camp_count;
303 	short			lead_attack_camp_recno;		// the firm recno of the lead attacking firm
304 
305 public:
306 	//--------------------------------------------------------------//
307 	// functions to init. parameters and process ai actions
308 	//--------------------------------------------------------------//
309 	void			init(int nationType, int raceId, int colorSchemeId, uint32_t playerId); // init local parameters
310 	void			deinit();
311 
312 	void 			init_all_ai_info();
313 	void 			init_ai_info(short** aiInfoArray, short& aiInfoCount, short& aiInfoSize, int arrayInitSize );
314 
315 	void 			deinit_all_ai_info();
316 
317 	void			init_personalty();
318 
319 	void			process_ai();							// entry point to start ai
320 	void			process_ai_main();
321 	void 			process_on_going_action();
322 
323 	//---------------------------------------------------------------//
324 	// main AI thinking functions
325 	//---------------------------------------------------------------//
326 	void			think_trading();
327 	void			think_explore();
328 	int 			think_capture();
329 
330 	void			ai_improve_relation();
331 
332 	//---------------------------------------------------------------//
333 	// functions for processing waiting actions
334 	//---------------------------------------------------------------//
335 	int			ai_build_firm(ActionNode*);
336 	int			ai_assign_overseer(ActionNode*);
337 	int 			ai_assign_construction_worker(ActionNode*);
338 	int			ai_assign_worker(ActionNode*);
339 	int			ai_scout(ActionNode*);
340 	int			ai_settle_to_other_town(ActionNode*);
341 	int			ai_assign_spy(ActionNode*);
342 
343 	//-----------------------------------------------------------//
344 	// functions used to update internal parameters
345 	//-----------------------------------------------------------//
346 	short*		update_ai_firm_array(int firmId, int actionType, int actionRecno, int& arrayCount);
347 
348 	short*		update_ai_array(short& aiInfoCount, short& aiInfoSize,
349 						short** aiInfoArray, int arrayIncSize, int actionType, int actionRecno);
350 
351 	void			add_town_info(short townRecno);	// add town information
352 	void			del_town_info(short townRecno);	// remove town information
353 	void			add_firm_info(char firmId, short firmRecno);// add firm information
354 	void			del_firm_info(char firmId, short firmRecno);// remove useless information as firm is removed
355 	void 			add_general_info(short unitRecno);
356 	void 			del_general_info(short unitRecno);
357 	void 			add_caravan_info(short unitRecno);
358 	void 			del_caravan_info(short unitRecno);
359 	void 			add_ship_info(short unitRecno);
360 	void 			del_ship_info(short unitRecno);
361 	void			assign_firm_overseer(char firm_id, short firm_recno, short overseerUnitRecno);	// add overseer information
362 	void			remove_firm_overseer(char firm_id, short firm_recno);	// remove overseer information
363 	int 			is_caravan_exist(int firstMarket, int secondMarket, int setStopInternal=0);
364 	void 			update_ai_region();
365 
366 	AIRegion* 	get_ai_region(int regionId);
367 	int 			has_base_town_in_region(int regionId);
368 
369 	//-----------------------------------------------------------//
370 	// functions for building firms
371 	//-----------------------------------------------------------//
372 	void			think_build_firm();
373 	int 			think_build_mine();
374 
375 	int  			think_destroy_raw_site_guard();
376 	int 			ai_supported_inn_count();
377 	int 			ai_has_should_close_camp(int regionId);
378 	int			ai_should_build_mine();
379 
380 	//-----------------------------------------------------------//
381 	// functions used to locate position to build firms
382 	//-----------------------------------------------------------//
383 	int			seek_mine(short& xLoc, short& yLoc, short& refXLoc, short& refYLoc);
384 	void			seek_best_build_mine_location(short& xLoc, short& yLoc, short mapXLoc, short mapYLoc);
385 	void			cal_location_score(short x1, short y1, short width, short height, int& weight);
386 	int 			find_best_firm_loc(short firmId, short refXLoc, short refYLoc, short& resultXLoc, short& resultYLoc);
387 
388 	//------------------------------------------------------------//
389 	// functions for dealing with the AI action array
390 	//------------------------------------------------------------//
391 	int 			add_action(short xLoc, short yLoc, short refXLoc, short refYLoc, int actionType, int actionPara, int instanceCount=1, int unitRecno=0, int actionPara2=0, short* groupUnitArray=NULL);
392 	int 			add_action(ActionNode* actionNode, int immediateProcess=0);
393 	void			del_action(int actionRecno);
394 	int			is_action_exist(short actionXLoc, short actionYLoc, short refXLoc, short refYLoc, int actionType, int actionPara, int unitRecno=0, int checkMode=0);
395 	int			is_action_exist(int actionType, int actionPara, int regionId=0);
396 	int			is_build_action_exist(int firmId, int xLoc, int yLoc);
397 
398 	int 			process_action(int priorityActionRecno=0, int processActionMode=0);	// waiting --> processing
399 	int 			process_action_id(int actionId);
400 
401 	void			action_finished(uint16_t aiActionId, short unitRecno=0, int actionFailure=0);
402 	void			action_failure(uint16_t aiActionId, short unitRecno=0);
403 	void 			auto_next_action(ActionNode* actionNode);
404 
405 	void 			stop_unit_action(short unitRecno);
406 	int			check_firm_ready(short xLoc, short yLoc, int firmId=0); // check whether firm exists and belongs to our nation
407 	int			check_town_ready(short xLoc, short yLoc); // check whether town exists and belongs to our nation
408 
409 	//------------------------------------------------------------//
410 	// functions used to find skilled units
411 	//------------------------------------------------------------//
412 	Unit*			get_skilled_unit(int skillId, int raceId, ActionNode* actionNode);
413 	Unit*			find_skilled_unit(int skillId, int raceId, short destX, short destY, char& resultFlag, int actionId=0);
414 	int   		hire_unit(int skillId, int raceId, short destX, short destY);
415 	int			train_unit(int skillId, int raceId, short destX, short destY, int& trainTownRecno, int actionId=0);
416 	int   		recruit_jobless_worker(Firm* firmPtr, int preferedRaceId=0);
417 	int   		recruit_on_job_worker(Firm* firmPtr, int preferedRaceId=0);
418 	int 			ai_should_hire_unit(int considerProfit);
419 
420 	//------------------------------------------------------------//
421 	// other functions
422 	//------------------------------------------------------------//
423 
424 	void			settle_to_other_town();
425 	int 			can_ai_build(int firmId);
426 	int 			think_succeed_king();
427 	int 			closest_enemy_firm_distance(int firmId, int xLoc, int yLoc);
428 
429 	//------------------------------------------------------------//
430 	// military related functions
431 	//------------------------------------------------------------//
432 
433 	void			think_military();
434 
435 	int			think_secret_attack();
436 	int 			think_attack_town();
437 	int			think_close_camp();
438 
439 	int 			ai_attack_target(int targetXLoc, int targetYLoc, int targetCombatLevel, int defenseMode=0, int justMoveToFlag=0, int attackerMinCombatLevel=0, int attackerCampRecno=0, int useAllCamp=0);
440 	void 			ai_attack_target_sync();
441 	void 			ai_attack_target_execute(int directAttack);
442 	int 			ai_attack_order_nearby_mobile(int targetXLoc, int targetYLoc, int targetCombatLevel);
443 
444 	int 			ai_sea_attack_target(int targetXLoc, int targetYLoc);
445 
446 	void 			ai_attack_unit_in_area(int xLoc1, int yLoc1, int xLoc2, int yLoc2);
447 	int 			ai_defend(int attackerUnitRecno);
448 	int 			ai_request_military_aid();
449 
450 	void			reset_ai_attack_target();
451 
452 	int 			think_attack_monster();
453 	int 			think_monster_target(int& targetCombatLevel);
454 
455 	int			ai_should_expand_military();
456 	int 			ai_is_troop_need_new_camp();
457 	int 			ai_has_too_many_camp();
458 
459 	int 			ai_should_attack_friendly(int friendlyNationRecno, int attackTemptation);
460 
461 	void			enable_should_attack_on_target(int targetXLoc, int targetYLoc);
462 
463 	//------------------------------------------------------------//
464 	// economic related functions
465 	//------------------------------------------------------------//
466 
467 	void			think_reduce_expense();
468 	int 			surplus_supply_rating();
469 	int 			ai_trade_with_rating(int withNationRecno);
470 	int 			ai_should_spend(int importanceRating, float spendAmt=0);
471 	int 			ai_should_spend_war(int enemyMilitaryRating, int considerCeaseFire=0);
472 	int 			ai_has_enough_food();
473 
474 	//------------------------------------------------------------//
475 	// town related functions
476 	//------------------------------------------------------------//
477 
478 	void			think_town();
479 	void			optimize_town_race();
480 	void 			optimize_town_race_region(int regionId);
481 
482 	//--------------------------------------------------------------//
483 	// functions for capturing independent and enemy towns
484 	//--------------------------------------------------------------//
485 
486 	int 			think_capture_independent();
487 	int 			capture_expected_resistance(int townRecno, int *captureUnitRecno);
488 	int 			start_capture(int townRecno, int captureUnitRecno);
489 	int 			capture_build_camp(int townRecno, int raceId, int captureUnitRecno);
490 	int 			find_best_capturer(int townRecno, int raceId, int& bestResistanceReduce);
491 	int 			hire_best_capturer(int townRecno, int raceId);
492 	int			mobilize_capturer(int unitRecno);
493 
494 	int 			think_capture_new_enemy_town(Town* capturerTown, int useAllCamp=0);
495 	void 			think_capturing_enemy_town();
496 
497 	int 			attack_enemy_town_defense(Town* targetTown, int useAllCamp=0);
498 	Town* 		think_capture_enemy_town_target(Town* capturerTown);
499 	int 			enemy_town_combat_level(Town* targetTown, int returnIfWar, int& hasWar);
500 	int 			enemy_firm_combat_level(Firm* targetFirm, int returnIfWar, int& hasWar);
501 	int 			mobile_defense_combat_level(int targetXLoc, int targetYLoc, int targetNationRecno, int returnIfWar, int& hasWar);
502 
503 	int 			should_use_cash_to_capture();
504 
505 	//--------------------------------------------------------------//
506 	// marine functions
507 	//--------------------------------------------------------------//
508 
509 	void 			think_marine();
510 
511 	int			think_build_harbor_network();
512 
513 	int 			think_move_between_region();
514 	int 			think_move_troop_between_region();
515 	int 			think_move_people_between_region();
516 	int 			think_sea_attack_enemy();
517 
518 	int 			think_move_to_region_with_mine();
519 	int 			ai_build_camp_town_next_to(int xLoc1, int yLoc1, int xLoc2, int yLoc2);
520 	int 			ai_settle_to_region(int destXLoc, int destYLoc, int seaActionId);
521 	int 			ai_patrol_to_region(int destXLoc, int destYLoc, int seaActionId);
522 
523 	int 			ai_should_sail_to_rating(int regionStatId);
524 	int 			ai_build_harbor(int landRegionId, int seaRegionId);
525 
526 	int 			ai_sea_travel(ActionNode* actionNode);
527 	int 			ai_sea_travel2(ActionNode* actionNode);
528 	int 			ai_sea_travel3(ActionNode* actionNode);
529 
530 	int 			ai_find_transport_ship(int seaRegionId, int unitXLoc, int unitYLoc, int findBest=1);
531 	int 			ai_build_ship(int seaRegionId, int preferXLoc, int preferYLoc, int needTransportUnit);
532 
533 	int 			has_trade_ship(int firmRecno1, int firmRecno2);
534 
535 	int 			ai_is_sea_travel_safe();
536 	int 			max_human_battle_ship_count();
537 
538 	//--------------------------------------------------------------//
539 	// spy functions
540 	//--------------------------------------------------------------//
541 
542 	void 			think_spy();
543 
544 	int 			ai_assign_spy(int targetXLoc, int targetYLoc, int spyRaceId, int mobileOnly);
545 	int 			ai_assign_spy_to_town(int townRecno, int raceId=0);
546 	int 			ai_assign_spy_to_firm(int firmRecno);
547 
548 	Spy* 			ai_find_spy(int targetXLoc, int targetYLoc, int targetRaceId, int mobileOnly);
549 
550 	int 			think_assign_spy_target_camp(int raceId, int regionId);
551 	int 			think_assign_spy_target_town(int raceId, int regionId);
552 	int 			think_assign_spy_own_town(int raceId, int regionId);
553 
554 	//--------------------------------------------------------------//
555 	// strategic grand planning functions
556 	//--------------------------------------------------------------//
557 
558 	void 			think_grand_plan();
559 	int 			total_alliance_military();
560 	int 			total_enemy_military();
561 	int 			total_enemy_count();
562 
563 	int 	 		think_against_mine_monopoly();
564 	int 	 		think_ally_against_big_enemy();
565 	int 	 		think_unite_against_big_enemy();
566 
567 	void 			think_deal_with_all_enemy();
568 	void 			think_deal_with_one_enemy(int enemyNationRecno);
569 
570 	int 			think_eliminate_enemy_town(int enemyNationRecno);
571 	int 			think_eliminate_enemy_firm(int enemyNationRecno);
572 	int 			think_eliminate_enemy_unit(int enemyNationRecno);
573 
574 	int 			think_attack_enemy_firm(int enemyNationRecno, int firmId);
575 	int 			think_surrender();
576 
577 	int 			ai_surrender_to_rating(int nationRecno);
578 
579 	//--------------------------------------------------------------//
580 	// functions for responsing to diplomatic messages
581 	//--------------------------------------------------------------//
582 
583 	void			think_diplomacy();
584 	int 			think_trade_treaty();
585 	int			think_propose_friendly_treaty();
586 	int			think_propose_alliance_treaty();
587 	int 			think_end_treaty();
588 	int 			think_request_cease_war();
589 	int 			think_request_buy_food();
590 	int			think_declare_war();
591 	int			think_give_tech();
592 	int			think_demand_tech();
593 	int			think_demand_tribute_aid();
594 	int 			think_give_tribute_aid(TalkMsg* rejectedMsg);
595 	int			think_request_surrender();
596 
597 	int			ai_process_talk_msg(ActionNode* actionNode);
598 	void 			ai_notify_reply(int talkMsgRecno);
599 	int 			should_diplomacy_retry(int talkId, int nationRecno);
600 	void			ai_end_treaty(int nationRecno);
601 
602 	int			consider_talk_msg(TalkMsg* talkMsg);
603 	void			notify_talk_msg(TalkMsg* talkMsg);
604 
605 	int 			consider_trade_treaty(int withNationRecno);
606 	int 			consider_friendly_treaty(int withNationRecno);
607 	int 			consider_alliance_treaty(int withNationRecno);
608 	int 			consider_military_aid(TalkMsg* talkMsg);
609 	int 			consider_trade_embargo(TalkMsg* talkMsg);
610 	int 			consider_cease_war(int withNationRecno);
611 	int 			consider_declare_war(TalkMsg* talkMsg);
612 	int 			consider_sell_food(TalkMsg* talkMsg);
613 	int 			consider_take_tribute(TalkMsg* talkMsg);
614 	int 			consider_give_tribute(TalkMsg* talkMsg);
615 	int 			consider_take_aid(TalkMsg* talkMsg);
616 	int 			consider_give_aid(TalkMsg* talkMsg);
617 	int 			consider_take_tech(TalkMsg* talkMsg);
618 	int 			consider_give_tech(TalkMsg* talkMsg);
619 	int			consider_accept_surrender_request(TalkMsg* talkMsg);
620 
621 	int			consider_alliance_rating(int nationRecno);
622 	int 			should_consider_friendly(int withNationRecno);
623 	int 			ai_overall_relation_rating(int withNationRecno);
624 
625 	//--------- file functions -----------//
626 
627 	int 			write_file(File* filePtr);
628 	int			read_file(File* filePtr);
629 };
630 #pragma pack()
631 
632 #ifndef __ONATIONA_H
633 #include <ONATIONA.h>
634 #endif
635 
636 //-------------------------------------//
637 
638 #endif
639