Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //civdos diplomacy version 1.2
- FUN_big_diplomacy_func(int par_civ, int par_x, int par_y, int par_human_called_ai)
- //last param is 0 if AI called the talks and 1 if your diplomat did that
- {
- //mz6:050400
- int loc_player_dominance;
- FUN_reveal_map_in_xy(par_x, par_y);
- FUN_drawMapTerrainSquare_B(par_x, par_y);
- int loc_next_turn_to_talk = next_turn_for_talk_with_player[par_civ];
- //mz_6::050430
- if (civ_number_and_pair[par_civ] == 0xE) //0x6(pink)+0x8 (2nd civ from pair): english
- {
- FUN_strcpy(civ_leader_title[6][1],"empress");
- FUN_strcpy(civ_leader_title[6][2],"queen");
- }
- //mz_6::050457
- if (par_human_called_ai == 0)
- {
- next_turn_for_talk_with_player[par_civ] = game_turn; //next talks: 16 turns later...
- }
- gl_diplomacy_started_flag = 0;
- int loc_AI_wants_to_attack = 0;
- menu_selection_result = par_human_called_ai;
- int loc_fear_give_you_something = 0;
- int loc_money_demand = 0;
- int loc_ai_wants_some_tribute = 1;
- end_of_main_talk_flag_mb = 0;
- for (int cont = 1; cont < 15; cont++) //loop: continents
- {
- int cities_AX = 0; //AX
- if (civ_cities[par_civ] > 1)
- {
- cities_AX = 1;
- }
- //mz_6::050491
- if (cities_per_continent[cont][par_civ] > cities_AX)
- {
- if (FUN_get_civ_attack_power_on_cont(player_civ,cont) > FUN_get_civ_defence_power_on_cont(par_civ,cont)) //AX > SI
- //FUN_get_civ_attack_power_on_cont uses 3rd PUSH here: par_civ, but this func does not have 3rd parameter...
- {
- int diff_mult_AX = 2; //AX
- if (difficulty == 0)
- {
- diff_mult_AX = 4;
- }
- loc_fear_give_you_something += (diff_mult_AX*FUN_get_civ_attack_power_on_cont(player_civ,cont))/(FUN_get_civ_defence_power_on_cont(par_civ,cont)+1); //(AX*DI)/SI, DI == CX
- //again, FUN_get_civ_attack_power_on_cont uses 3rd PUSH here: par_civ, but this func doesn't have 3rd parameter...
- }
- }
- else //mz_6::05050c
- {
- if (defence_per_cont[cont][player_civ] != 0)
- {
- if (defence_per_cont[cont][par_civ] != 0)
- loc_AI_wants_to_attack = 1;
- }
- //mz_6::050531
- if (cities_per_continent[cont][player_civ] != 0)
- {
- if (cities_per_continent[cont][par_civ] > 1)
- {
- loc_money_demand += attack_per_cont[cont][par_civ]-FUN_get_civ_attack_power_on_cont(player_civ,cont); //+= CX end: jump -> mz_6::0505d7
- //again, FUN_get_civ_attack_power_on_cont uses 3rd PUSH here: par_civ, but this func doesn't have 3rd parameter...
- }
- else
- {
- loc_money_demand += attack_per_cont[cont][par_civ];
- }
- }
- else //mz_6::050582
- {
- int temp_power_AX = 0; //AX
- if (cities_per_continent[cont][par_civ] != 0)
- {
- temp_power_AX = ((defence_per_cont[cont][par_civ]-attack_per_cont[cont][player_civ]) >> 1);
- }
- else
- {
- temp_power_AX = ((attack_per_cont[cont][par_civ]-attack_per_cont[cont][player_civ])>>2);
- }
- //mz_6::0505d4
- loc_money_demand += temp_power_AX;
- }
- }
- } //loop: 15 continents
- //mz_6::0505f5 (LAB_mz6_check_player_dominance)
- if (civilization_powgraph_place[player_civ] == 7 //human player is numbah one.
- && civ_cities[player_civ] > 4
- && civ_cities[par_civ] > 1
- && unit_counter[player_civ][U_NUCLEAR] == 0
- && game_turn > 200)
- {
- loc_player_dominance = 1;
- }
- else
- {
- loc_player_dominance = 0;
- }
- //mz_6::05063a
- if (loc_player_dominance != 0 //(OR AX,AX) else (flow) -> mz_6::050641 dominance of the player - always set money demand...
- //mz_6::050641
- || ((diplomacy_status[par_civ][player_civ]&0x8) != 0 //else -> mz_6::0506a0. vendetta or... par_civ: 16, player_civ: 2
- //mz_6::050655
- && 3*civ_military_power[par_civ] > civ_military_power[player_civ])) //else -> mz_6::0506a0 AI civ is not too weak (AI > player/3)
- {
- //mz_6::050667
- if (FUN_return_numb_of_nukes(player_civ) == 0)) //and player doesn't have any nukes...
- {
- loc_AI_wants_to_attack = 1; //AI want to declare war...
- loc_money_demand = FUN_minmax(loc_money_demand,10*civilization_powgraph_place[par_civ],9999); //basic value of money demand is defined by AI powergraph place...
- loc_fear_give_you_something = 0;
- }
- }
- //mz_6::0506a0
- if (unit_counter[par_civ][U_NUCLEAR] != 0)
- {
- diplomacy[par_civ][player_civ] |= 0x80; //nuclear stance par_civ: 16, player_civ: 2
- }
- //mz_6::0506c1
- if (unit_counter[par_civ][U_NUCLEAR] != 0) //else -> mz_6::0506fb
- {
- if (FUN_return_numb_of_nukes(player_civ) == 0) //(OR AX,AX)
- {
- loc_AI_wants_to_attack = 1;
- loc_money_demand = FUN_minmax(loc_money_demand,100,9999); //if AI has nukes and you don't, then min basic value of demanded money is set to 100$...
- }
- }
- //mz_6::0506fb
- if (unit_counter[player_civ][U_NUCLEAR] != 0)
- {
- if (FUN_return_numb_of_nukes(par_civ) == 0)
- {
- loc_fear_give_you_something = 4;
- }
- else
- {
- loc_money_demand = (unit_counter[par_civ][U_NUCLEAR]*(loc_money_demand/2))/unit_counter[player_civ][U_NUCLEAR];
- //if both you and AI has some nukes, basic value of money demand is divided by 2,
- //and then if AI has more nukes than you, it will increase, and if you have more nukes - then it will decrease...
- }
- }
- //mz_6::05074c
- if (loc_fear_give_you_something != 0)
- {
- loc_AI_wants_to_attack = 0;
- loc_ai_wants_some_tribute = 0;
- }
- //mz_6::05075c
- if (FUN_check_wonder_eff(player_civ,7) != 0 //great wall
- || FUN_check_wonder_eff(player_civ,0x12) != 0) //United Nations
- {
- loc_player_dominance = 0;
- loc_AI_wants_to_attack = 0;
- if (loc_next_turn_to_talk == -2)
- {
- loc_next_turn_to_talk = -1;
- }
- }
- //mz_6::050797
- if ((diplomacy[par_civ][player_civ]&8) != 0) //vendetta. par_civ: 16 player_civ: 2
- {
- loc_money_demand = loc_money_demand<<1; //if vendetta, double money demand...
- }
- else
- {
- //mz_6::0507b0
- if (loc_next_turn_to_talk == -2) //after you captured AI city or after AI nuked you...
- {
- loc_money_demand = loc_money_demand/4;
- }
- }
- //mz_6::0507c2
- loc_money_demand = FUN_minmax((loc_money_demand*(difficulty+1))>>5,0,20)*50; //modify money demand by game difficulty...
- //mz_6::0507fc
- if (loc_money_demand > civ_treasury[player_civ]) // CMP AX,SI //if player doesn't have enough money to pay...
- {
- if (loc_money_demand <= (civ_treasury[player_civ]<<1)) //but demanded money is less than player_treasury*2...
- {
- if (civ_treasury[player_civ] >= 50)
- {
- //then demand as much as possible...
- loc_money_demand = (civ_treasury[player_civ]/50)*50;
- }
- }
- }
- //mz_6::050817
- if (unit_counter[par_civ][U_NUCLEAR] != 0)
- {
- //mz_6::050833
- //NEVER happens: see 0506c1. Nuclear stance flag is already set!..
- if ((diplomacy[par_civ][player_civ]&0x80) == 0) //there was no nucl. stance before. else -> mz_6::050852 par_civ: 16 player_civ: 2
- {
- //mz_6::05083d
- if (civ_treasury[player_civ] < loc_money_demand)
- {
- loc_money_demand = (civ_treasury[player_civ]/50)*50; //if demand was too much, set it to the possible max (nuclear blackmail?)
- }
- }
- //mz_6::050852
- diplomacy[par_civ][player_civ] |= 0x80; //set "nuclear stance" diplomacy bit... actually, it's always already set at the time...
- }
- //mz_6::050864
- if (loc_money_demand == 0 //AI don't want to demand any money...
- || 3*civ_military_power[par_civ] < civ_military_power[player_civ]) //or AI is too weak...
- {
- loc_AI_wants_to_attack = 0;
- }
- //mz_6::050887
- if (loc_AI_wants_to_attack != 0)
- {
- loc_ai_wants_some_tribute = 2;
- }
- //mz_6::050892
- if (loc_AI_wants_to_attack == 0)
- {
- if (diplomacy[par_civ][player_civ]&4) != 0) //ALLY. It actually kinda works! par_civ: 16 player_civ: 2
- {
- loc_ai_wants_some_tribute = 0; //when ALLY doesn't want to attack you, it will never demand anything from you...
- }
- }
- //mz_6::0508b1
- loc_AI_wants_to_att_old = loc_AI_wants_to_attack;
- int loc_fear_of_others = 0;
- //mz_6::0508c9
- if ((diplomacy[par_civ][player_civ]&8) != 0) //vendetta.
- {
- loc_fear_of_others = -2; //if vendetta, AI want to attack the player even if AI already at war with some other civs...
- }
- //mz_6::0508d5
- int loc_demand_break_peace_civ = -1;
- for (int civ = 1; civ < MAX_CIVS; civ++)
- {
- if (civ != player_civ
- && (diplomacy[par_civ][civ]&3) == 1) //contact+war else -> mz_6::050944
- {
- if (civ_military_power[par_civ] < (civ_military_power[civ]<<2)) //if (other_ai_civ_pow*4 > our_ai_civ_pow)
- {
- loc_fear_of_others++; //add point, if 3rd civ's power is 1/4 of "our" AI civ power or more...
- }
- //mz_6::050913
- if (civ_military_power[civ] > civ_military_power[par_civ])
- {
- loc_fear_of_others++; //add another point, if 3rd civ is stronger than our AI civ...
- }
- //mz_6::05092a
- if ((diplomacy[player_civ][civ]&2) != 0) //human is in peace with this 3rd civ. else -> mz_6::050944
- {
- loc_demand_break_peace_civ = civ; //demand break peace with which civ?
- }
- }
- //mz_6::050944
- } //loop: civs
- //mz_6::05094d
- loc_fear_of_others -= leader_aggress[civ_number_and_pair[par_civ]]; //aggressive leader tends to not make peace with the player even if this leader wages many wars already
- if (civ_military_power[player_civ] < civ_military_power[par_civ])
- {
- loc_fear_of_others--; //AI civ can smash us pretty easily, so they don't care about other wars this much...
- }
- //mz_6::050975
- war = (diplomacy[par_civ][player_civ]&2); //AL. not used?..
- //3c 01 CMP AL ,0x1 <- not used! AL at the moment can be 0 or 2
- //1b c9 SBB CX ,CX <- why? -CFlag now in CX?..
- //f7 d9 NEG CX <- why? CFlag now in CX?..
- //maybe some info here: https://reverseengineering.stackexchange.com/questions/14128/x86-sbb-with-same-register-as-first-and-second-operand/14133
- //also compare with the code for "exchange ambassadors" (in this case, ghidra doesn't decompile it as it presumes flow does not goes here)
- //according to ghidra decompilation, here should be (but why?):
- //if (((diplomacy[par_civ][player_civ]&2) == 0) < loc_fear_of_others)
- //mz_6::05098e 3b 4e d6 CMP CX ,word ptr [BP + loc_fear_of_others ]
- //mz_6::05098e my version:
- if (loc_fear_of_others > 0) //because CX should be 0, I think...
- //Ghidra version:
- if (loc_fear_of_others > ((diplomacy[par_civ][player_civ]&2) == 0)) //i.e. > 0 if peace and > 1 if war
- {
- if (loc_player_dominance == 0) //With dominant position of player, AI will be aggressive anyway...
- {
- loc_AI_wants_to_attack = 0;
- if (FUN_random(2) != 0) //(OR AX,AX) else -> mz_6::0509b3
- {
- loc_money_demand = 0; //in this case, 1/2 chance for AI to cancel any of its money demands from you...
- }
- }
- }
- //mz_6::0509b3
- if (civ_govt[par_civ] >= 4) //AI Republic (or Democracy - never happens)
- {
- //mz_6::0509bf
- if (loc_AI_wants_to_attack != 0) //AI want to attack you...
- {
- if ((diplomacy[par_civ][player_civ]&8) == 0) //but not in vendetta with you... else -> mz_6::050a06
- {
- if (3*civ_military_power[player_civ] <= civ_military_power[par_civ]<<1 //AI*2 >= player*3 AI is very strong...
- || loc_player_dominance != 0) //or player dominance...
- {
- FUN_civ_changes_govt(par_civ,2); //change govt to monarchy (even if we don't know the tech...)
- }
- else
- loc_AI_wants_to_attack = 0; //possible meaning: so Republican AI will not declare the war (except if vendetta)...
- }
- }
- }
- //mz_6::050a06
- int loc_ready_to_cancel_peace = 0;
- int loc_dip_status = (diplomacy[par_civ][player_civ]&2); //2: peace 0: war
- //mz_6::050a23
- if ((loc_dip_status&2) != 0) //(i.e. peace)
- {
- //mz_6::050a25
- if (loc_AI_wants_to_attack != 0)
- {
- //mz_6::050a34
- if (civ_military_power[par_civ] < civ_military_power[player_civ]
- || (loc_dip_status&8) != 0) //vendetta
- {
- loc_AI_wants_to_attack = 0;
- loc_ready_to_cancel_peace = 1;
- loc_ai_wants_some_tribute = 0;
- }
- }
- }
- int loc_best_tech;
- int loc_tech_for_you; //what tech AI can give to you as tribute
- int loc_best_tech_desire; //So AI not always demands tech, if you have some, but only if its desire is high enough...
- int loc_tot_ai_tech;
- int loc_tot_player_tech;
- int loc_tech_civ_count;
- while (1) //endless loop: tech exchange...
- {
- //mz_6::050a4f
- //what tech to demand? (with max AI desire, without any randomization)
- //also counters for player's and AI civ advances
- loc_best_tech = -1;
- loc_tech_for_you = -1;
- loc_best_tech_desire = 0; //So AI not always demands tech, if you have some, but only if its desire is high enough...
- loc_tot_ai_tech = 0;
- loc_tot_player_tech = 0;
- loc_tech_civ_count = 0;
- do
- {
- //mz_6::050a66
- if (civ_has_tech_check(player_civ,loc_tech_civ_count) != 0)
- {
- loc_tot_player_tech++;
- }
- //mz_6::050a7c
- if (civ_has_tech_check(par_civ,loc_tech_civ_count) != 0)
- {
- loc_tot_ai_tech++;
- }
- //mz_6::050a91
- if (civ_has_tech_check(player_civ,loc_tech_civ_count) == 0)
- {
- if (civ_has_tech_check(par_civ,loc_tech_civ_count) != 0)
- {
- loc_tech_for_you = loc_tech_civ_count; //what tech AI can give to you
- }
- }
- //mz_6::050abc
- if (civ_has_tech_check(player_civ,loc_tech_civ_count) != 0)
- {
- if (civ_has_tech_check(par_civ,loc_tech_civ_count) == 0)
- {
- if (FUN_ai_tech_desire(par_civ,loc_tech_civ_count) >= loc_best_tech_desire)
- {
- //mz_6::050af7
- loc_best_tech = loc_tech_civ_count; //what tech AI will demand from you
- loc_best_tech_desire = FUN_ai_tech_desire(par_civ,loc_best_tech);
- }
- }
- }
- //mz_6::050b09
- loc_tech_civ_count++;
- }
- //mz_6::050b0c
- while (loc_tech_civ_count < 72);
- //mz_6::050b15
- //0x20: you attacked AI before or AI attacked you before...
- if ((((diplomacy[par_civ][player_civ]&0x20) != 0 || loc_AI_wants_to_attack != 0) //AI not gonna trade techs with you: some mil. actions happened before OR AI wants war
- && loc_tot_ai_tech > 6) //but if AI has less than 7 tech, then it wants to exchange anyway...
- ||
- (loc_tot_player_tech < loc_tot_ai_tech || loc_tech_for_you == -1)) //or: if player has less techs than AI OR AI doesn't have any tech to give to player
- {
- break;
- }
- //mz_6::050b4c
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) == -1)
- break;
- //mz_6::050b62
- science_or_diplomacy_special_screen = 1;
- main_string[0] = 0;
- FUN_strcpy(str_insert_b,tech_names[local_tech2]);
- FUN_read_from_king_txt_and_some_string_stuff("*EXCHANGE"); //We note that your primitive civilization...
- sci_or_dip_flag_b = 0xc;
- //mz_6::050ba8
- if (FUN_message_on_dip_screen(main_string,20,139) != 1) //*str, x, y answer: NO!
- break;
- FUN_common_func_mb_black_screen_A();
- FUN_clear_screen_mb_B();
- FUN_update_screen_mb();
- science_or_diplomacy_special_screen = -1;
- cpedia_from_city_screen_flag = 1;
- FUN_get_tech_from_city_capture(par_civ,player_civ);
- //SKIPPED! something-something...
- FUN_get_tech_from_city_capture(player_civ,par_civ);
- FUN_triple_little_black_magic_A();
- //SKIPPED! something-something...
- loc_AI_wants_to_attack = 0;
- science_or_diplomacy_special_screen = 1;
- FUN_common_func_mb_black_screen_A();
- FUN_clear_all_screen_mb();
- FUN_update_screen_mb();
- } //endless loop: tech exchange...
- //mz_6::050c22
- if (loc_AI_wants_to_attack == 0)
- {
- if (par_human_called_ai == 0)
- {
- if ((diplomacy[par_civ][player_civ]&2) == 2) //(peace)
- {
- if (loc_fear_give_you_something > 2)
- {
- //goto: mz_6::051a5d !!
- goto: LAB_end_of_diplomacy;
- }
- }
- }
- }
- //mz_6::050c4e
- if ((global_debug_flags&1)==0)
- {
- loc_AI_wants_to_attack = 0;
- loc_ai_wants_some_tribute = 0;
- loc_fear_give_you_something = 0;
- loc_ready_to_cancel_peace = 0;
- }
- //mz_6::050c69
- //request or demand break peace with some civ...
- if (loc_demand_break_peace_civ != -1)
- {
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- //mz_6::050c88
- if (loc_ai_wants_some_tribute != 0)
- {
- main_string[0] = '\0';
- FUN_strcpy(str_insert_c_mb,civ_name_plural[loc_demand_break_peace_civ]);
- if (loc_AI_wants_to_attack == 0)
- FUN_strcpy(str_insert_b,'request');
- else
- FUN_strcpy(str_insert_b,'demand');
- FUN_read_from_king_txt_and_some_string_stuff("*CANCEL"); //"You have made peace with our evil neighbors..."
- //mz_6::050cd2
- if (loc_AI_wants_to_attack == 0)
- science_or_diplomacy_special_screen = 1;
- else
- science_or_diplomacy_special_screen = 2;
- SCI_OR_DIP_FLAG_B = 0xc;
- if (loc_AI_wants_to_attack != 0)
- {
- FUN_play_sound(0x21); //threat sound
- }
- //mz_6::050cfb
- if (FUN_message_on_dip_screen(main_string,20,139) == 1) //show "You have made peace..." message and dialog (yes/no)
- {
- //your answer is "yes"
- loc_AI_wants_to_attack = 0;
- if (FUN_random(2) != 0) //50% chance
- {
- loc_money_demand = 0;
- }
- FUN_cancel_diplomacy_status(player_civ,loc_demand_break_peace_civ,2); //cancel "peace" bit...
- diplomacy[loc_demand_break_peace_civ][player_civ] |= 8; //vendetta with this 3rd civ!
- }
- } //AI want to demand something from you...
- }
- } //AI want you to cancel peace with some civ...
- //mz_6::050d52
- if (loc_money_demand != 0 && loc_ai_wants_some_tribute == 2)
- {
- //mz_6::050d64
- if (civ_treasury[player_civ] > loc_money_demand)
- {
- //mz_6::050d76
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- main_string[0] = '\0';
- char* str = FUN_number_to_string(loc_money_demand,inserted_string_1,10); //10 - decimal notation
- FUN_strcat(main_string,str);
- FUN_strcpy(str_insert_d_mb,main_string);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*TRIBUTE");
- end_of_main_talk_flag_mb = 0;
- science_or_diplomacy_special_screen = 2;
- sci_or_dip_flag_b = 0xc;
- FUN_play_sound(0x21); //threating
- if (FUN_message_on_dip_screen(main_string,20,139) == 1)
- {
- //mz_6::050e08
- //you agreed to give them some money...
- civ_treasury[player_civ] -= loc_money_demand;
- civ_treasury[par_civ] += loc_money_demand;
- loc_AI_wants_to_attack = 0;
- }
- loc_money_demand = 999; //flag: AI demanded something from you...
- } //we continue talks OR this is beginning of talks and we agree to speak...
- } //we have enough money to pay...
- }
- //mz_6::050e28
- if (loc_ai_wants_some_tribute != 0
- && loc_best_tech != -1
- && loc_money_demand != 999)
- {
- //mz_6::050e44
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- //mz_6::050e57
- main_string[0] = '\0';
- FUN_strcpy(str_insert_b,tech_names[loc_best_tech]);
- FUN_read_from_king_txt_and_some_string_stuff("*TAKECIV");
- end_of_main_talk_flag_mb = 0;
- science_or_diplomacy_special_screen = 2;
- sci_or_dip_flag_b = 0xc;
- FUN_play_sound(0x21); //threat: tech demand
- if (FUN_message_on_dip_screen(main_string,20,139) == 1) //draw "Your civilization makes us laugh..." dialog
- {
- FUN_civ_advance_discovery(par_civ,loc_best_tech,player_civ); //source: player_civ
- loc_AI_wants_to_attack = 0;
- }
- loc_money_demand = 999; //flag: AI demanded something from you
- }
- }
- //mz_6::050ed0
- if (loc_AI_wants_to_attack == 0
- || ((diplomacy[par_civ][player_civ]) & 2) == 0 //at war
- || loc_money_demand <= 50)
- {
- //mz_6::050f5f
- if (loc_AI_wants_to_attack == 0
- || loc_money_demand != 999)
- {
- //mz_6::050f98
- if (loc_AI_wants_to_attack != 0
- && ((diplomacy[par_civ][player_civ] & 1) == 0 || par_human_called_ai != 0) //no contact or you called AI with your diplomat
- {
- //mz_6::050fbb
- s16 res = FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y);
- if (res == -1) //you don't want to even talk with them...
- {
- main_string[0] = '\0';
- AX = "*RID"; //We have decided to rid the world of your worthless civilization.
- goto LAB_goto_A;
- }
- FUN_play_sound(0x21);
- main_string[0] = '\0';
- AX = "*RID";
- //mz_6::050fe2
- goto LAB_goto_B; //same message, but on the diplomacy screen after greetings...
- }
- }
- else
- {
- //mz_6::050f6c
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- //mz_6::050f82
- FUN_play_sound(0x21);
- main_string[0] = '\0';
- AX = "*REJECT"; //You reject our generous offer? Your insolence must be punished. Prepare for WAR!
- //mz_6::050f1a
- LAB_goto_B:
- FUN_read_from_king_txt_and_some_string_stuff(AX);
- FUN_string_func_unknown(0x28);
- end_of_main_talk_flag_mb = 1;
- science_or_diplomacy_special_screen = 2;
- sci_or_dip_flag_b = 0xc;
- FUN_message_on_dip_screen(main_string,20,139);
- goto LAB_goto_cancel_peace;
- }
- }
- }
- else
- {
- //mz_6::050ef3
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- FUN_play_sound(0x21);
- main_string[0] = '\0';
- AX = "*PROVOKE";
- goto LAB_goto_B;
- }
- main_string[0] = '\0';
- AX = "*PROVOKE";
- //mz_6::050fed
- LAB_goto_A:
- FUN_read_from_king_txt_and_some_string_stuff(AX);
- FUN_string_func_unknown(0x28);
- FUN_draw_some_message_A(main_string,40,100); //message "We have decide to rid the world of your worthless civ..." on the normal, map screen
- //mz_6::051013
- LAB_goto_cancel_peace:
- FUN_cancel_diplomacy_status(player_civ,par_civ,2); //cancel peace status
- }
- //mz_6::051029
- if (loc_AI_wants_to_attack == 0
- && ((diplomacy[par_civ][player_civ]&2) == 0 || par_human_called_ai != 0))
- {
- //mz_6::05104f
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- //mz_6::051065
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*PEACE");
- end_of_main_talk_flag_mb = 0;
- science_or_diplomacy_special_screen = 0;
- sci_or_dip_flag_b = 0xc;
- s16 res = FUN_message_on_dip_screen(main_string,20,139);
- if (res == 1) //yes
- {
- FUN_show_treaty_message(par_civ);
- FUN_set_peace_and_disband_units_on_chieftain(par_civ);
- next_turn_for_talk_with_player[par_civ] = game_turn+16;
- }
- else //no, reject peace
- {
- //mz_6::0510c6
- if (civ_govt[player_civ] < 4) //not Republic or Democracy
- {
- //mz_6::051103
- if ((diplomacy[par_civ][player_civ]&2)!=0) //we were at peace before...
- {
- FUN_cancel_diplomacy_status(player_civ,par_civ,2); //cancel peace
- }
- //mz_6::05112a
- if (loc_fear_give_you_something > 3
- && local_tech2 != -1
- && (diplomacy[par_civ][player_civ]&0xa) == 0) //0x10+0x2: we never meet before + still not peace
- {
- //mz_6::051153
- FUN_strcpy(str_insert_b,tech_names[local_tech2]);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*GIVECIV"); //In exchange for peace we will share with you the secret of $RPLC1.
- science_or_diplomacy_special_screen = 0;
- sci_or_dip_flag_b = 0xc;
- if (FUN_message_on_dip_screen(main_string,20,139) == 1) //1: yes, give me your tech for peace...
- {
- //mz_6::05119e
- FUN_common_func_mb_black_screen_A();
- FUN_clear_screen_mb_B();
- FUN_update_screen_mb();
- FUN_triple_little_black_magic_A();
- science_or_diplomacy_special_screen = -1;
- cpedia_from_city_screen_flag = 1;
- FUN_civ_advance_discovery(player_civ,local_tech2,par_civ);
- //skipped: something-something...
- FUN_triple_little_black_magic_A();
- science_or_diplomacy_special_screen = 0;
- FUN_common_func_mb_black_screen_A();
- FUN_clear_all_screen_mb();
- FUN_update_screen_mb();
- FUN_show_treaty_message(par_civ);
- FUN_set_peace_and_disband_units_on_chieftain(par_civ);
- loc_next_turn_to_talk = game_turn;
- } //yes, give me your tech for peace...
- } //conditions for: 1 tech tribute from AI to you (for peace)
- //mz_6::05120e
- if ((diplomacy[par_civ][player_civ]&0xa)==0) //0x10+0x2: we never meet before + still not peace
- {
- //mz_6::051225
- loc_merc_cost = FUN_minmax((loc_fear_give_you_something<<1)-4,0,civ_treasury[par_civ]/50);
- loc_merc_cost *= 50;
- if (loc_merc_cost != 0) //here: how much AI is ready to pay for peace...
- {
- //mz_6::05125a
- char* str = FUN_number_to_string(loc_merc_cost,inserted_string_1,10);
- FUN_strcat(main_string,str);
- FUN_strcpy(str_insert_d_mb,main_string);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*GIVECASH"); //In exchange for peace we offer you $BUCKS$
- science_or_diplomacy_special_screen = 0;
- sci_or_dip_flag_b = 0xc;
- if (FUN_message_on_dip_screen(main_string,20,139) == 1) //yes, give me your money for peace...
- {
- //mz_6::0512c4
- FUN_show_treaty_message(par_civ);
- FUN_set_peace_and_disband_units_on_chieftain(par_civ);
- civ_treasury[player_civ] += loc_merc_cost;
- civ_treasury[par_civ] -= loc_merc_cost;
- loc_next_turn_to_talk = game_turn;
- } //yes, give me your money for peace...
- }
- } //conditions for: AI gives you money for peace
- //mz_6::0512ed
- if (loc_fear_give_you_something != 0 && civ_cities[par_civ] < 2
- && (diplomacy[par_civ][player_civ]&0xa) == 0) //0x10+0x2: we never meet before + still not peace
- {
- main_string[0] = '\0';
- char* str = FUN_number_to_string(civ_money[par_civ],inserted_string_1,10);
- FUN_strcat(main_string,str);
- FUN_strcpy(str_insert_d_mb,main_string);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*GROVEL");
- science_or_diplomacy_special_screen = 0;
- sci_or_dip_flag_b = 0xc;
- if (FUN_message_on_dip_screen(main_string,20,139) == 1)
- {
- //mz_6::05138a
- FUN_show_treaty_message(par_civ);
- FUN_set_peace_and_disband_units_on_chieftain(par_civ);
- civ_treasury[player_civ] += civ_treasury[par_civ];
- civ_treasury[par_civ] = 0;
- FUN_common_func_mb_black_screen_A();
- FUN_clear_screen_mb_B();
- FUN_update_screen_mb();
- FUN_triple_little_black_magic_A();
- science_or_diplomacy_special_screen = -1;
- loc_tech_civ_count = 0;
- do
- {
- //mz_6::0513d1
- if (civ_has_tech_check(player_civ,loc_tech_civ_count) == 0)
- {
- if (civ_has_tech_check(par_civ,loc_tech_civ_count) == 1)
- {
- cpedia_from_city_screen_flag = 1;
- FUN_civ_advance_discovery(player_civ,loc_tech_civ_count,par_civ);
- }
- }
- loc_tech_civ_count++;
- }
- while (loc_tech_civ_count < 72);
- //mz_6::051417
- //something-something...
- FUN_triple_little_black_magic_A();
- science_or_diplomacy_special_screen = 0;
- FUN_common_func_mb_black_screen_A();
- FUN_clear_all_screen_mb();
- FUN_update_screen_mb();
- loc_next_turn_to_talk = game_turn;
- }
- } //conditions for *GROVEL response
- //mz_6::051453
- if ((diplomacy[par_civ][player_civ]&2) == 0) //peace had not been reached...
- {
- //mz_6::051455
- FUN_play_sound(0x21); //very well! prepare for war!
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*MOBILIZE");
- end_of_main_talk_flag_mb = 1;
- science_or_diplomacy_special_screen = 2;
- sci_or_dip_flag_b = 4;
- FUN_message_on_dip_screen(main_string,20,139);
- }
- }
- else //republic or democracy
- {
- FUN_strcpy(main_string,"You are overruled bla-bla-bla"); //senate
- FUN_message_on_dip_screen(main_string,20,139);
- FUN_set_peace_and_disband_units_on_chieftain(par_civ);
- }
- } //reject peace offer
- } //you continue talks or you agreed to start talks...
- }
- //mz_6::051497
- //actually, not used here?..
- if (civ_number_and_pair[par_civ] == 0xe) //English
- {
- FUN_strcpy(civ_leader_title[6][1],"empress");
- FUN_strcpy(civ_leader_title[6][2],"queen");
- }
- main_string[0] = '\0';
- //mz_6::0514c9
- if (loc_AI_wants_to_attack == 0
- && (diplomacy[par_civ][player_civ] & 2) == 2) //already peace..
- {
- //mz_6::0514ec
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- if (loc_ai_wants_some_tribute == 0 || loc_money_demand == 999)
- {
- //mz_6::05152f
- FUN_strcpy(main_string, "We welcome friendship...");
- FUN_strcat(main_string, civ_name_adjective[player_civ]);
- FUN_strcat(main_string, "people and their most...");
- FUN_strcat(main_string, civ_leader_title[player_civ][civ_govt[player_civ]]);
- FUN_strcat(main_string, str_welcome_end);
- FUN_strcat(main_string, leader_name[player_civ]);
- FUN_strcat(main_string, str_welcome_end_period);
- }
- else
- {
- //mz_6::05150f
- science_or_diplomacy_special_screen = 1;
- sci_or_dip_flag_b = 4;
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*ATTITUDE");
- }
- FUN_message_on_dip_screen(main_string,20,139);
- }
- }
- //mz_6::0515d6
- if ((diplomacy[par_civ][player_civ] & 2) != 0) //peace
- {
- if (FUN_dipl_create_diplomacy_dialog_mb(par_civ,par_x,par_y) != -1)
- {
- while (1)
- {
- //mz_6::051609
- FUN_strcpy(str_insert_b, civ_name_plural[par_civ]);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*THREAT");
- if (game_turn - loc_next_turn_to_talk < 16
- || civ_govt[player_civ] >= 4)
- gl_blocked_menu_items_bits = 4; //block 3rd menu item of responce (1st: 1, 2nd: 2, 3rd: 4)
- //mz_6::05164d
- if ((1<<par_civ) | (1<<player_civ) == civ_activity_flags) //only you and AI civ are active...
- {
- gl_blocked_menu_items_bits = 2; //block 2nd menu item of responce
- }
- int res = FUN_message_on_dip_screen(main_string,20,139);
- if (res == 2) //we demand money...
- {
- //mz_6::051689
- loc_merc_cost = FUN_minmax(loc_fear_give_you_something,0,civ_treasury[par_civ]/50);
- loc_merc_cost *= 50;
- if (loc_merc_cost == 0)
- {
- if (loc_AI_wants_to_att_old == 0)
- {
- FUN_strcpy(main_string, "We ignore your threats bla-bla");
- science_or_diplomacy_special_screen = 1;
- sci_or_dip_flag_b = 4;
- }
- else
- {
- //mz_6::051738
- FUN_play_sound(0x21);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*PROVOKE");
- FUN_cancel_diplomacy_status(player_civ,par_civ,2); //cancel peace
- science_or_diplomacy_special_screen = 2;
- sci_or_dip_flag_b = 0xc;
- }
- FUN_message_on_dip_screen(main_string,20,139);
- }
- else
- {
- //mz_6::0516b3
- main_string[0] = '\0';
- char* str = FUN_number_to_string(loc_merc_cost,inserted_string_1,10);
- FUN_strcat(main_string,str);
- FUN_strcpy(str_insert_d_mb,main_string);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*GIVEMOVE");
- science_or_diplomacy_special_screen = 0;
- sci_or_dip_flag_b = 0xc;
- FUN_message_on_dip_screen(main_string,20,139);
- civ_treasury[player_civ] += loc_merc_cost;
- civ_treasury[par_civ] -= loc_merc_cost;
- next_turn_for_talk_with_player[par_civ] = game_turn;
- }
- } //we demand money from AI...
- if (res != 1) //not mercenary routine...
- goto LAB_goto_D; //goto -> mz_6::0519e2
- FUN_strcpy(main_string, "You must attack evil:");
- //mz_6::0517be
- int loc_list_counter = 0;
- for (int i = 1; i < MAX_CIVS; i++)
- {
- if (i != player_civ && i != par_civ && civ_activity_flags&(1<<i) != 0)
- {
- loc_civs_array[loc_list_counter] = i; //position in list -> civ
- loc_list_counter++; //position in list
- FUN_strcat(main_string,civ_name_plural[i]);
- FUN_strcat(main_string,str_mz6_ret_merc_att_list);
- }
- }
- //mz_6::051826
- loc_merc_cost = FUN_message_on_dip_screen(main_string,20,139);
- science_or_diplomacy_special_screen = 1;
- //mz_6::051842
- if (loc_merc_cost == -1)
- {
- goto LAB_goto_D;
- }
- att_civ = loc_civs_array[loc_merc_cost]; //position->civ
- FUN_strcpy(str_insert_b,civ_name_plural[att_civ]);
- sci_or_dip_flag_b = 4;
- if ((diplomacy[att_civ][par_civ]&1) == 0) //no contact
- {
- main_string[0] = '\0';
- AX = "*NOCONTACT";
- goto LAB_show_nocontact_or_unfortunate_mess;
- }
- //mz_6::051887
- if ((diplomacy[par_civ][[att_civ]&2) != 0) //they are at peace with this 3rd civ...
- break;
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*ATWAR");
- FUN_message_on_dip_screen(main_string,20,139);
- } //endless loop
- //mz_6::0518c1
- loc_merc_cost = (((civ_military_power[att_civ])>>1)*(civ_treasury[par_civ]/100))/50;
- loc_merc_cost = FUN_minmax(loc_merc_cost, 2, 9999);
- loc_merc_cost *= 50;
- main_string[0] = '\0';
- char* str = FUN_number_to_string(loc_merc_cost,inserted_string_1,10);
- FUN_strcat(main_string,str);
- FUN_strcpy(str_insert_d_mb,main_string);
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*MERCENARY");
- if (FUN_message_on_dip_screen(main_string,20,139) == 1)
- {
- //loc_dip_status_and_money = civ_treasury[player_civ]; //BX
- if (civ_treasury[player_civ] < loc_merc_cost)
- {
- //mz_6::0519be
- main_string[0] = '\0';
- AX = "*UNFORTUNATE";
- LAB_show_nocontact_or_unfortunate_mess:
- FUN_read_from_king_txt_and_some_string_stuff(AX);
- }
- else
- {
- //mz_6::051976
- civ_treasury[par_civ] += loc_merc_cost;
- civ_treasury[par_civ] -= loc_merc_cost;
- FUN_strcpy(main_string,civ_name_plural[par_civ]);
- FUN_strcat(main_string, "declare war at the");
- FUN_strcat(main_string,civ_name_plural[att_civ]);
- FUN_strcat(main_string,str_declare_war_at_end);
- //actually doesn't declare war!! cunning AI.
- }
- FUN_message_on_dip_screen(main_string,20,139);
- } //"yes" to mercenary proposal
- } //we continue talks or we started talks...
- } //if peace: We respond... dialog etc.
- //mz_6::0519e2
- LAB_goto_D:
- if (loc_ready_to_cancel_peace != 0)
- {
- diplomacy_flags_next_byte[par_civ][player_civ] |= 0x1; //i.e. 0x100 for normal diplomacy byte, 0xe498 instead of 0xe499
- //25% chance at the beginning of turn to cancel peace one-way... when it happens, 0x200 flag is set...
- }
- //mz_6::0519fa
- diplomacy[par_civ][player_civ] &= 0xdf; //1101 1111, cancel 6th bit (5th from 0) - 0x20
- //cancel "previous attacks" flag...
- loc_dip_status_and_money = diplomacy[par_civ][player_civ];
- diplomacy[par_civ][player_civ] &= 0xdf; //cancel 0x20 bit also "in other direction"
- if (menu_selection_result != -1
- && civ_cities[par_civ] > 4 //DI: par_civ, SI: player_civ
- && civ_place[player_civ]+1 < civ_place[par_civ]
- && (loc_dip_status_and_money)&2 == 0) //at war
- {
- FUN_strcpy(str_insert_c_mb, civ_name_plural[par_civ]);
- INT_04(0x02d3, "*SCHISM"); //show help message from HELP.TXT, if before A.D. and if instance advice is set to "ON"
- }
- //mz_6::051a5d
- LAB_end_of_diplomacy:
- if (menu_selection_result != -1)
- {
- FUN_mz6_maybe_end_of_diplomacy_talks();
- }
- //mz_6::051a68
- if (civ_number_and_pair[par_civ] == 0xe) //English
- //set it back to normal...
- {
- FUN_strcpy(civ_leader_title[6][1],civ_leader_global_title[1]); //0x19b4, 0x33aa -> Emperor
- FUN_strcpy(civ_leader_title[6][2],civ_leader_global_title[2]); // ->King
- }
- gl_diplomacy_started_flag = 0;
- menu_selection_result = -1;
- science_or_diplomacy_special_screen = -1;
- return;
- }
- void FUN_cancel_diplomacy_status(int par_civ1, int par_civ2, int par_status)
- {
- if (par_status == 2 //peace
- && (diplomacy[par_civ1][par_civ2]&2) != 0)
- {
- FUN_write_replay_entry(2,1,par_civ1*16+par_civ2);
- }
- diplomacy[par_civ1][par_civ2] &= ~par_status;
- diplomacy[par_civ2][par_civ1] &= ~par_status;
- if ((par_status&2) != 0) //we canceled peace...
- {
- diplomacy[par_civ1][par_civ2] &= 0xfb; //cancel 0x04 (ALLY) status
- diplomacy[par_civ2][par_civ1] &= 0xfb; //cancel 0x04 (ALLY) status
- }
- }
- void FUN_set_diplomacy_status(int par_civ1, int par_civ2, int par_status)
- {
- if (par_status == 2 //peace
- && (diplomacy[par_civ1][par_civ2]&2) == 0) //were at war...
- {
- FUN_write_replay_entry(3,1,par_civ1*16+par_civ2);
- }
- diplomacy[par_civ1][par_civ2] |= par_status;
- diplomacy[par_civ2][par_civ1] |= par_status;
- if (par_status == 2) //peace
- {
- diplomacy[par_civ1][par_civ2] &= 0xdf; //cancel 0x20 (some actual military actions before) status
- diplomacy[par_civ2][par_civ1] &= 0xdf; //cancel 0x20 (some actual military actions before) status
- }
- }
- FUN_dipl_create_diplomacy_dialog_mb(int civ, int x, int y)
- {
- if (gl_diplomacy_started_flag == 0) //diplomacy dialog "will you talk with him?.." was not called yet...
- {
- gl_diplomacy_started_flag = 1;
- if (menu_selection_result == 0) //not not from diplomat menu
- {
- if (x != -1)
- {
- FUN_mb_change_map_view_position(player_civ,x,y):
- }
- while (1)
- {
- //create string: an emissary from... bla-bla-bla
- if (diplomacy[player_civ][civ] & 0x40) != 0) //embassy //player_civ: 16 civ: 2
- {
- //add "Check embassy" string
- }
- FUN_play_sound(leader_jingle[civ]);
- FUN_update_screen_in_some_cases();
- menu_selection_result = FUN_draw_some_message_A(main_string,100,80);
- thunk_FUN_11a8_029a(); //??
- if (menu_selection_result == -2)
- {
- INT_0E_1164(civ); //call intelligence report screen...
- }
- else
- break;
- }
- if (menu_selection_result != -1) //yes, let's talk...
- {
- FUN_common_func_mb_black_screen_A();
- FUN_prepare_dip_scr_king_and_advisors(civ,5,1); //actually func uses only 1 param...
- FUN_play_sound(leader_melody[civ]);
- FUN_update_screen_mb();
- gl_some_dip_scr_anim_graphics = civ_1_or_2_same_color[civ]+8;
- if (gl_some_dip_scr_anim_graphics == 10) // 1 0000 barbarians (???)
- {
- gl_some_dip_scr_anim_graphics = 3; //???
- }
- //something-something...
- (*0xd2dc) = 1; //??
- science_or_diplomacy_special_screen = 1;
- draw_advisor_faces_a = -1;
- advisor_face_mb = 0;
- sci_or_dip_flag_b = 0xc;
- FUN_dipl_greetings_message(civ); //create greatings message (check vendetta ("O untruthworthy...", 4 random greatings, check if at least 1 nuke -> BACKED BY)
- FUN_message_on_dip_screen(main_string,20,139); //show this message
- }
- } //menu_selection_result == 0, i.e. not from diplomat menu
- } //diplomacy is not started yet
- return menu_selection_result;
- }
- FUN_show_treaty_message(int par_civ)
- {
- FUN_strcpy(str_insert_b,civ_name_adjective[par_civ]);
- FUN_strcpy(str_insert_a,civ_name_adjective[player_civ]);
- sci_or_dip_flag_b = 0xc;
- main_string[0] = '\0';
- FUN_read_from_king_txt_and_some_string_stuff("*TREATY");
- FUN_message_on_dip_screen(main_string,20,139);
- }
- FUN_set_peace_and_disband_units_on_chieftain(int par_civ)
- {
- FUN_set_diplomacy_status(player_civ,par_civ,2); //set "peace" bit
- next_turn_for_talk_with_player[par_civ] = game_turn + 16; //next talks: 32 turns later...
- if (difficulty == 0)
- {
- (for int i = 0; i < 128; i++)
- {
- if (unit_list[par_civ][i] != -1)
- {
- int cit = FUN_find_closest_city(unit_list[par_civ][i].x,unit_list[par_civ][i].y); //this function also change gl_distance (i.e. distance from founded city)
- if (citie[cit].civ == player_civ
- && gl_distance <= 2)
- {
- disband_unit(par_civ,i);
- }
- }
- }
- }
- }
- FUN_mz6_maybe_end_of_diplomacy_talks()
- {
- FUN_dipl_mb_memory_error_and_sound();
- //something-something...
- FUN_screen_fadeout_work();
- science_or_diplomacy_special_screen = -1;
- menu_selection_result = 0;
- gl_diplomacy_started_flag = 0;
- }
- //END OF OVERLAY MZ 6----------------------------------------------------------------
- FUN_main_diplomacy(int par_civ1, int par_civ2, int par_x, int par_y)
- //when 2 units meet...
- {
- if (par_civ1 != 0 && par_civ2 != 0)
- {
- if (par_civ1 == player_civ)
- {
- if ((diplomacy_status[par_civ1][par_civ2]&1) == 0
- || game_turn-diplomacy_timer[par_civ2] >= 16)
- {
- FUN_big_diplomacy_func(par_civ2,par_x,par_y);
- }
- }
- if (par_civ2 == player_civ)
- {
- if (diplomacy_status[par_civ1][par_civ2]&1) == 0
- || game_turn-diplomacy_timer[] >= 16)
- {
- FUN_big_diplomacy_func(par_civ1,par_x,par_y);
- }
- }
- int loc_dip_status = diplomacy_status[par_civ1][par_civ2];
- diplomacy_status[par_civ1][par_civ2] |= 0x11; //contact + first contact
- diplomacy_status[par_civ2][par_civ1] |= 0x11; //contact + first contact
- if (par_civ1 != player_civ && par_civ2 != player_civ)
- {
- if ((((par_civ1 + par_civ2 + game_turn)&3) == 0) //"magic year"
- || loc_dip_status&1 == 0) //no contact
- &&
- (
- ((diplomacy_status[par_civ1][par_civ2])&8) == 0
- && ((diplomacy_status[par_civ2][par_civ1])&8) == 0 //no vendetta between AIs...
- )
- {
- int res1 = FUN_some_comparison_ai_civs_milit_power(par_civ1,par_civ2);
- int res2 = FUN_some_comparison_ai_civs_milit_power(par_civ2,par_civ1);
- if ((res1 == 0 || FUN_check_wonder_eff(par_civ2,7) != 0 || civ_govt[par_civ1] >= G_REPUBLIC) //7 - great wall
- &&
- (res2 == 0 || FUN_check_wonder_eff(par_civ1,7) != 0 || civ_govt[par_civ2] >= G_REPUBLIC)) //7 - great wall
- {
- FUN_2_ai_civs_exchange_tech(par_civ1,par_civ2);
- if ((diplomacy_status[par_civ1][par_civ2]&2)==0) //war
- {
- if ((diplomacy_status[player_civ][par_civ1]&0x40)!=0
- || diplomacy_status[player_civ][par_civ2]&0x40)!=0) //embassy
- {
- FUN_strcpy(main_string,civ_name_plural[par_civ1]);
- FUN_strcat(main_string,0x2a13); //" and "
- FUN_strcat(main_string,civ_name_plural[par_civ2]);
- FUN_strcat(main_string,0x2a19); //" sign a peace treaty."
- message_type = 1; //diplomats report...
- FUN_draw_some_message_A(main_string,100,80);
- }
- FUN_set_diplomacy_status(par_civ1,par_civ2,2); //set peace status
- }
- }
- else //time for war!
- {
- if (((diplomacy_status[par_civ1][par_civ2])&2)!=0 //peace
- || (loc_dip_status&1) == 0) //no contact
- {
- if ((diplomacy_status[player_civ][par_civ1]&0x40) != 0
- || (diplomacy_status[player_civ][par_civ2]&0x40) != 0)
- {
- FUN_strcpy(main_string,civ_name_plural[par_civ1]);
- FUN_strcat(main_string,0x2a30);
- FUN_strcat(main_string,civ_name_plural[par_civ2]);
- if ((diplomacy_status[par_civ1][par_civ2]&2) == 0)
- AX = 0x2a4d; //" declared war on each other."
- else
- AX = 0x2a36; //" cancel peace treaty."
- FUN_strcat(main_string,AX);
- message_type = 1; //diplomats report...
- FUN_draw_some_message_A(main_string,100,80);
- }
- FUN_cancel_diplomacy_status(par_civ1,par_civ2,2);//cancel peace status
- }
- }
- }
- }
- } //not barbarians
- }
- int FUN_some_comparison_ai_civs_milit_power(par_civ1, par_civ2)
- {
- if ((global_debug_flags&1) == 0)
- {
- return 1; //wants war
- }
- if ((((diplomacy_status[par_civ1][player_civ]&3) != 1 //no "contact+no peace" (no war) //peace with player -> time to war with other AI...
- || civ_military_power[player_civ] <= civ_military_power[par_civ2]
- || (diplomacy_status[par_civ2][player_civ]&4) != 0) //ALLY
- &&
- ((diplomacy_status[par_civ2][player_civ]&3) != 1
- || civ_military_power[player_civ] <= civ_military_power[par_civ1]
- || (diplomacy_status[par_civ1][player_civ]&4) != 0))
- &&
- FUN_return_numb_of_nukes(par_civ2) <= unit_counter[par_civ1][U_NUCLEAR])
- {
- int loc_tot_civs = 0;
- for (int civ = 1; civ < 8; civ++)
- {
- if (civ != par_civ1 && civ != par_civ2
- && (diplomacy_status[par_civ1][civ]&3) == 1) //contact+no peace = war
- {
- loc_tot_civs++;
- }
- }
- if (diplomacy_status[par_civ1][par_civ2]&2) != 0) //if peace, we want to start war less...
- {
- loc_tot_civs++;
- }
- int aggr_AX = leader_aggress[civ_number_and_pair[par_civ1]];
- int loc_tot_cities = 0;
- int loc_tot_attack = 0;
- int loc_tot_def_and_half_att = 0;
- for (int cont = 1; cont < 15; cont++)
- {
- if (cities_per_continent[par_civ1][cont] != 0
- && attack_per_cont[par_civ1][cont]/2 + defence_per_cont[par_civ1][cont] < FUN_get_civ_attack_power_on_cont(par_civ2,cont,par_civ1))
- //3rd param actually is not used
- return 0; //wants peace
- if (attack_per_cont[par_civ1][cont] != 0)
- {
- int loc_def_per_cont = defence_per_cont[par_civ2][cont];
- if (loc_def_per_cont != 0)
- {
- loc_tot_attack += attack_per_cont[par_civ1][cont];
- loc_tot_def_and_half_att += FUN_get_civ_attack_power_on_cont(par_civ2,cont,par_civ1)/2 + loc_def_per_cont;
- //3rd param in get_civ_attack_power is not used
- loc_tot_cities += cities_per_continent[par_civ1][cont];
- }
- }
- }
- if ((loc_tot_civs-aggr_AX+4 <= (loc_tot_attack << 2) / loc_tot_def_and_half_att)
- || loc_tot_cities == 0)
- {
- return 1; //wants war
- }
- }
- return 0; //wants peace
- }
- FUN_2_ai_civs_exchange_tech(par_civ1, par_civ2)
- {
- u16 loc_exchange_tech_flags = 0x0000;
- int loc_selected_tech12;
- int loc_selected_tech21;
- for (int tech = 0; tech < 72; tech++)
- {
- if (civ_has_tech_check(par_civ1,tech) == 0
- && civ_has_tech_check(par_civ2,tech) != 0)
- {
- loc_exchange_tech_flags |= 1;
- loc_selected_tech12 = tech;
- }
- if (civ_has_tech_check(par_civ2,tech) == 0
- && civ_has_tech_check(par_civ1,tech) != 0)
- {
- loc_exchange_tech_flags |= 2;
- loc_selected_tech21 = tech;
- }
- }
- if (loc_exchange_tech_flags == 3)
- {
- FUN_civ_advance_discovery(par_civ1,loc_selected_tech12,par_civ2);
- FUN_civ_advance_discovery(par_civ2,loc_selected_tech21,par_civ1);
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment