//////////////////////////////////////////////////////////////////////////////////////////////////////// // 2) New Diplomod: Beta Version // by Peter Triggs and Player1 // // PEDRUNN: - AI responds to another AI proposal depending on the regard among them (Code line: 5261) // - The regard for Scientific, Military and Trade leader decay -10 towards all civs every turn (Code line: 5025) // - If human is a common enemy they continue making treats to each others but dont love each other (Code line: 5050) // //////////////////////////////////////////////////////////////////////////////////////////////////////// int_t NDM_MAX_PLAYERS; int_t NDM_NUM_PLAYERS; int_t NDM_PLAYER_COUNT; int_t NDM_DIFF_LEVEL; int_t NDM_TREATY_LENGTH; int_t NDM_TMP_PLAYER;//for Surrender handler messages int_t NDM_AMT_GOLD; int_t PIRACY_FLG_5_20;//for when we want the human to accept a no piracy agreement int_t PIRACY_FLG_34_5; int_t PIRACY_FLG_34_6; int_t NP_FIRST_TYPE; //New Proposal types (== DB index) int_t NP_SECOND_TYPE; int_t RES_first_type;// response type (1==reject, 2==accept, etc) int_t RES_second_type; int_t CR_first_type;// Counter response types (== DB index) int_t CR_second_type; int_t REJ_first_type; int_t REJ_second_type; int_t TH_first_type; // initial proposal int_t TH_second_type; // following proposal int_t TH_RES_first_type; int_t TH_RES_second_type; int_t NDM_ToneMod;//Tone modifier, varies AI's response according to the tone the Human used when sending the proposal int_t NDM_Tone; int_t NDM_sender_science_result; int_t NDM_receiver_science_result; int_t NDM_sender_gold_result; int_t NDM_receiver_gold_result; city_t NDM_TMP_CITY;//for surrender handler // temp int_t EFF_REG_01; int_t EFF_REG_10; int_t TEST_RESULT_1; int_t TEST_RESULT_2; int_t TEST_RESULT_3; int_t TEST_RESULT_4; //EMBASSY AND TREATY LOGS: int_t NDM_NUM_EMBASSY_TREATIES; int_t NDM_TEMP_EMBASSY0[]; //a player int_t NDM_TEMP_EMBASSY1[]; //another player int_t NDM_TEMP_EMBASSY_VALUE[]; //NTS: probably can't use, but as a reminder int_t NDM_NUM_TRESPASSING_TREATIES; int_t NDM_TEMP_TRESPASSING0[]; //a player int_t NDM_TEMP_TRESPASSING1[]; //another player int_t NDM_TEMP_TRESPASSING_VALUE[]; int_t NDM_NUM_CEASEFIRE_TREATIES; int_t NDM_TEMP_CEASEFIRE0[]; //a player int_t NDM_TEMP_CEASEFIRE1[]; //another player int_t NDM_TEMP_CEASEFIRE_VALUE[]; //NDM_TEMP_CEASEFIRE_VALUE[i] is the length of the ceasefire pact between NDM_TEMP_CEASEFIRE0[i] and NDM_TEMP_CEASEFIRE1[i] int_t NDM_NUM_PEACE_TREATIES; int_t NDM_TEMP_PEACE0[]; int_t NDM_TEMP_PEACE1[]; int_t NDM_TEMP_PEACE_VALUE[]; //NDM_TEMP_PEACE_VALUE[i] is the length of the peace treaty between NDM_TEMP_PEACE0[i] and NDM_TEMP_PEACE1[i] int_t NDM_NUM_TRADE_TREATIES; int_t NDM_TEMP_TRADE0[]; int_t NDM_TEMP_TRADE1[]; int_t NDM_TEMP_TRADE_VALUE[]; //NDM_TEMP_TRADE_VALUE[i] is the length of the trade pact between NDM_TEMP_TRADE0[i] and NDM_TEMP_TRADE1[i] int_t NDM_NUM_RESEARCH_TREATIES; int_t NDM_TEMP_RESEARCH0[]; int_t NDM_TEMP_RESEARCH1[]; int_t NDM_TEMP_RESEARCH_VALUE[]; //NDM_TEMP_RESEARCH_VALUE[i] is the length of the research pact between NDM_TEMP_RESEARCH0[i] and NDM_TEMP_RESEARCH1[i] int_t NDM_NUM_MILITARY_TREATIES; int_t NDM_TEMP_MILITARY0[]; int_t NDM_TEMP_MILITARY1[]; int_t NDM_TEMP_MILITARY_VALUE[]; //NDM_TEMP_MILITARY_VALUE[i] is the length of the military pact between NDM_TEMP_MILITARY0[i] and NDM_TEMP_MILITARY1[i] int_t NDM_NUM_ALLIANCE_TREATIES; int_t NDM_TEMP_ALLIANCE0[]; int_t NDM_TEMP_ALLIANCE1[]; int_t NDM_TEMP_ALLIANCE_VALUE[]; //NDM_TEMP_ALLIANCE_VALUE[i] is the length of the alliance between NDM_TEMP_ALLIANCE0[i] and NDM_TEMP_ALLIANCE1[i] // FUNCTIONS: // returns 5 if the Human proposal sender follows the advice in the manual when choosing his tone int_f NDM_SetToneModifier(int_t player0, int_t player1){ int_t ToneMod; int_t tone; tone=GetLastNewProposalTone(player0, player1); if (tone==0) { if (GetRelativeStrength(player0, player1)==1 ) { ToneMod=5; } } elseif (tone==1) { if (GetRelativeStrength(player0, player1)==2 || GetEffectiveRegard(player0, player1)>400) { ToneMod=5; } } elseif (tone==2) { if (GetRelativeStrength(player0, player1)>2 ) { ToneMod=5; } } elseif (tone==3) { if (GetRelativeStrength(player0, player1)<2 ) {//'suspect weaker'? ToneMod=5; } } elseif (tone==4) { if (GetRelativeStrength(player0, player1)==0 || GetEffectiveRegard(player0, player1)<300) { ToneMod=5; } } else{ ToneMod=0; } return ToneMod; } void_f NDM_WithdrawNow(int_t player0, int_t player1){ // player[1] accepted int_t j;//army index army_t tmpArmy; int_t k;//location index location_t tmpLoc; int_t c;//city index city_t tmpCity; int_t i;//unit index unit_t tmpUnit; unit_t tmpunit2; int_t numarmies; int_t veteran; player[4]=player1; numarmies=player[4].armies; if (numarmies) {//if he has any, for(j=0; j= 17 ){//and on land, we expell it for (i=0;i=17 )) { CreateUnit(player1, tmpunit.type, tmploc, 0, tmpunit2);//create a new unit there if(veteran == 1) {//that's maybe a veteran ToggleVeteran(tmpunit2, 1); } Event:DisbandUnit(tmpunit);//and vaporize the trespassor c=PlayerCityCount(player1);//success: break the cities loop } } } } } } //else it's a ship ...TBD } } } if (IsHumanPlayer(player0)) { message(player0,'WithdrawMessage'); } } //returns the city index value of thePlayer's nearest city to theLoc (not used now) int_f GetNearestCityIndex(location_t theLoc, int_t thePlayer) { location_t tmpLoc; city_t tmpCity; int_t cityIndex; int_t i; int_t min; int_t val; int_t tmpPlayer; tmpLoc = theLoc; min = 10000; for(i = 0; i < PlayerCityCount(thePlayer); i = i + 1) { GetCityByIndex(thePlayer, i, tmpCity); val = SquaredDistance(tmpCity.location, tmpLoc); if(val < min) { min = val; cityIndex = i; } } return cityIndex; } // returns 1 if some of player1's armies are in player0's territory (land or sea) int_f NDM_GetTrespassingBy(int_t player0, int_t player1){ int_t i; int_t tpchk; int_t numarmies; army_t tmpArmy; player[1]=player1; numarmies=player[1].armies; if (numarmies) { tpchk=0; for (i=0; i0) { for (i=0;iMilitaryRank(player[1])+20) {//Human much stronger NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept anything? } elseif(MilitaryRank(player[0])>MilitaryRank(player[1])- NDM_ToneMod ){ if (MilitaryRank(player[0])>MilitaryRank(player[1])+10- NDM_ToneMod) {//Human stronger and maybe asks properly term=60; baseGoldPC=0; SetString(0,ID_medium); } elseif (MilitaryRank(player[0])>MilitaryRank(player[1])- NDM_ToneMod) {//Human just stronger and maybe asks properly term=30; baseGoldPC=5; SetString(0,ID_short); } termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;//0-10% of his gold if (hisGold<100) { hisGold=100; } //can't counter, so if termPen we HAVE to reject, otherwise as when prop==second_type if (first_type==1 ) { if (termPen) { if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==2) { ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (first_type==19 ){ if (termPen) { if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ if (hisGoldPlayerGold(player[0])) {//if we've got more gold than him, we'll consider it ourGold=((30-(termPen+baseGoldPC))*100*PlayerGold(player[1]) )/10000;//20 to 30% of our gold if (ourGold<100) { ourGold=100; } if (NDM_sender_gold_result<=ourGold) {//and he wants less than we're prepared to pay ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'LeaningTowardsCeasefire');//asking too much } ConsiderResponse(player[0], player[1], 1500, 1);//reject } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'GreedyGreedy'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } } } elseif (first_type==23 ) { if(IsHumanPlayer(player[0])) { message(player[0],'LeaningTowardsCeasefire'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (first_type==24 ) { if(IsHumanPlayer(player[0])) { message(player[0],'LeaningTowardsCeasefire'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } } // if the AI is stronger it will only accept a short term ceasefire elseif (MilitaryRank(player[0])+30-1) { baseGoldPC=baseGoldPC+10;//if we've been at war before then up the price } SetString(0,ID_short); termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } if (first_type==1 ) { if (termPen) { if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==2) { ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (first_type==19 ){ if (termPen) { if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ if (hisGoldMilitaryRank(player[1])+30) {//Human much stronger NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept anything? //message hope that we can put our previous differences behind us ...blah blah blah } elseif(MilitaryRank(player[0])>MilitaryRank(player[1])- NDM_ToneMod ){ if (MilitaryRank(player[0])>MilitaryRank(player[1])+10- NDM_ToneMod) {//Human stronger and maybe asks properly term=60; baseGoldPC=0; SetString(0,ID_medium); } elseif (MilitaryRank(player[0])>MilitaryRank(player[1])- NDM_ToneMod) {//Human just stronger and maybe asks properly term=30; baseGoldPC=5; SetString(0,ID_short); } termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;//0-10% of his gold if (hisGold<100) { hisGold=100; } if (second_type==0) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } elseif (second_type==1) { NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } ConsiderResponse(player[0], player[1], 1500, 2); //accept with fixed term treaty } elseif (second_type==2) { ConsiderResponse(player[0], player[1], 1500, 1);//reject if (Random(4)<2) { if(IsHumanPlayer(player[0])) { message(player[0],'NeverPartWithHolyCity'); } } } elseif (second_type==19){ if (hisGoldPlayerGold(player[0])) {//if we've got more gold than him, we'll consider it ourGold=((30-(termPen+baseGoldPC))*100*PlayerGold(player[1]) )/10000;//20 to 30% of our gold if (ourGold<100) { ourGold=100; } if (NDM_sender_gold_result<=ourGold) {//and he wants less than we're prepared to pay ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement');//counter with smaller offer } ConsiderResponse(player[0], player[1], 1500, 3,20,ourGold); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'GreedyGreedy'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } } elseif (second_type==23) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } elseif (second_type==24) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } } // if the AI is winning it will only accept a short term ceasefire elseif (MilitaryRank(player[0])+30-1) { baseGoldPC=baseGoldPC+10;//if we've been at war before then up the price } SetString(0,ID_short); termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;// 20-35% of his gold if (hisGold<100) { hisGold=100; } if (second_type==0) { if (Random(4)<2) { GetMostAtRiskCity(player[0], player[1], theCity); ConsiderResponse(player[0], player[1], 1500, 3, 1, theCity, 4); } else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } } if (second_type==1) { ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } elseif (second_type==2) { ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (second_type==19){ if (hisGold should this depend on NDM_DIFF_LEVEL? term=60; baseGoldPC=0; SetString(0,ID_medium); } else{ term=30; baseGoldPC=5; SetString(0,ID_short); } termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;//0-10% of his gold if (hisGold<100) { hisGold=100; } if (second_type==0 ) {//unacompanied if (TradeRank(player[1])< ((80+PersBonus+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)//AI RECEIVER && TradeRank(player[0])< ((80+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)){ //30% at impossible to 70% at easy NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ // but we can sometimes be bribed if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } } elseif (second_type==1 ||second_type==17 ) {//offers city or advance NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } elseif (second_type==2 ) {//proposes trade pact and requests a city ConsiderResponse(player[0], player[1], 1500, 1); //just reject } elseif (second_type==3) { if (HasAgreement(player[1],player[0],3) ){ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } else{ if(NDM_GetTrespassingBy(player[1], player[0]) ){ setstring(2,ID_withdraw); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithShowGoodIntentions'); } ConsiderResponse(player[0], player[1],1500,1);//reject } else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } } } elseif (second_type==4) { if(HasAgreement(player[0],player[1],4) ){//if we have the agreement if(NDM_GetTrespassingBy(player[0], player[1]) ){ //and we've been breaking our word, we apologize and accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithApologeticTradeMessage'); } } else{//otherwise he's bluffing, and if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } } else{//if we don't have the agreement we just accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (second_type==5) {//offers to stop piracy amtGold=3*GetPiracyIncomeFrom(player[0],player[1]); if (amtGold<100) { amtGold=100; } if (amtGoldGetPiracyIncomeFrom(player[0],player[1])) {//we're better pirates than he is amtGold=3*GetPiracyIncomeFrom(player[1],player[0]); if (amtGold<100) { amtGold=100; } if (amtGoldPlayerGold(player[0])) {//if we've got more gold than him amtGold=(1500*PlayerGold(player[1]) )/10000;//15% of our gold if (amtGold<100) { amtGold=100; } if (NDM_sender_gold_result<=amtGold) { ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 20, amtGold);//counter with offer of 15% of our gold, } } else{//he's being greedy if (hisGold(90+PersBonus+ NDM_ToneMod)-10*NDM_DIFF_LEVEL) { if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'NothingtoOfferUsTrade'); } } } elseif (TradeRank(player[0])>(90+ NDM_ToneMod)-10*NDM_DIFF_LEVEL ) { if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'EconomicImperialism'); } } } } } void_f AI_Responses_to_Human_Proposals_trade_pact_second(int_t first_type, int_t second_type){ int_t PersBonus; //bonus given dependent on AI RECEIVER personality, increases chances of him accepting proposal int_t term; int_t termPen; int_t hisGold; int_t amtGold; int_t baseGoldPC; NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; if (GetPersonalityType(player[1])==5) {//Medici (economic) PersBonus=10; } else{ PersBonus=0; } if (!GetDesireWarWith(player[1],player[0]) //we don't want to be at war with him && TradeRank(player[1])< (90+PersBonus+ NDM_ToneMod)-10*NDM_DIFF_LEVEL//AI RECEIVER && TradeRank(player[0])< (90+ NDM_ToneMod)-10*NDM_DIFF_LEVEL ){ //40/55% at impossible to 80/85% at easy // these are the same conditions as when we offer him the deal // so, we're both behind the trade leader and we dont DesireWarWith the Human sender //response depends on 1) what he offers and 2) how long he wants the treaty to last SetString(1,ID_TradePact); if ( (TradeRank(player[1])+TradeRank(player[0]))/2 <50 ){//our average trade rank is <50% that of the trade leader's //=> this should depend on NDM_DIFF_LEVEL? term=60; baseGoldPC=0; SetString(0,ID_medium); } else{ term=30; baseGoldPC=5; SetString(0,ID_short); } termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;//0-10% of his gold if (hisGold<100) { hisGold=100; } if (first_type==0 //unacompanied || first_type==23 ||second_type==24) {//maps if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (TradeRank(player[1])< ((80+PersBonus+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)//AI RECEIVER && TradeRank(player[0])< ((80+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)){ //30% at impossible to 70% at easy NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'WantMoreGold'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (first_type==1 || first_type==17) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TREATY_LENGTH=0; } } elseif (first_type==2 ) {//proposes trade pact and requests a city ConsiderResponse(player[0], player[1], 1500, 1); //just reject } elseif (first_type==3) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } if (HasAgreement(player[1],player[0],3) ){ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } //maybe add flag elseif(NDM_GetTrespassingBy(player[1], player[0]) ){ setstring(2,ID_withdraw); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithShowGoodIntentions'); } ConsiderResponse(player[0], player[1],1500,1);//reject } } elseif (first_type==4) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } if (HasAgreement(player[0],player[1],4)) { if(NDM_GetTrespassingBy(player[0], player[1]) ){ //and we've been breaking our word, we apologize and accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithApologeticMessage'); } } else{//otherwise he's bluffing, and if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithNoTroopsThere'); } ConsiderResponse(player[0], player[1],1500,1);//reject } } else{//if we don't have the agreement we accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==5) { if(IsHumanPlayer(player[0])) { message(player[0],'CleanUpYourAct'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,0);//how did AI like the human's offering it (displeased) } elseif (first_type==6) {//wants us to stop piracy if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } if (GetPiracyIncomeFrom(player[1],player[0])>GetPiracyIncomeFrom(player[0],player[1])) {//we're better pirates than he is amtGold=3*GetPiracyIncomeFrom(player[1],player[0]); if (amtGold<100) { amtGold=100; } if (amtGoldPlayerGold(player[0])) {//if we've got more gold than him amtGold=(1500*PlayerGold(player[1]) )/10000;//15% of our gold if (amtGold<100) { amtGold=100; } if (NDM_sender_gold_result<=amtGold) { ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'AskingTooMuch'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'GreedyGreedy'); } ConsiderResponse(player[0], player[1], 1500,1);//reject } } elseif (first_type==23 || first_type==24) { if(IsHumanPlayer(player[0])) { message(player[0],'WantMoreGold'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } } else{ int_t rnd; rnd=Random(3); ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetDesireWarWith(player[1],player[0])) {//we want war if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'SeeThroughYouTrade'); } } } elseif (TradeRank(player[1])>(90+PersBonus+ NDM_ToneMod)-10*NDM_DIFF_LEVEL) { if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'NothingtoOfferUsTrade'); } } } elseif (TradeRank(player[0])>(90+ NDM_ToneMod)-10*NDM_DIFF_LEVEL ) { if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'EconomicImperialism'); } } } } } messagebox 'SeeThroughYouTrade' { show(); Text (ID_SeeThroughYouTradeM) ; Button(ID_OK){ Kill(); } } messagebox 'NothingtoOfferUsTrade' { show(); Text (ID_NothingtoOfferUsTradeM) ; Button(ID_OK){ Kill(); } } messagebox 'EconomicImperialism' { show(); Text (ID_EconomicImperialismM) ; Button(ID_OK){ Kill(); } } // research pact responses start here: // same types of responses as for trade pact, but we want more gold void_f AI_Responses_to_Human_Proposals_research_pact(int_t first_type, int_t second_type){ int_t PersBonus; //bonus given dependent on AI RECEIVER personality, increases chances of him accepting proposal int_t term; int_t termPen; int_t hisGold; int_t amtGold; int_t baseGoldPC; NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; if (GetPersonalityType(player[1])==6 || GetPersonalityType(player[1])==7) {//scientist PersBonus=5; } else{ PersBonus=0; } if (!GetDesireWarWith(player[1],player[0]) //we don't want to be at war with him && KnowledgeRank(player[1])< ((35+PersBonus+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)//AI RECEIVER && KnowledgeRank(player[0])< ((35+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)){ //40/55% at impossible to 80/85% at easy // these are the same conditions as when we offer him the deal // so, we're both behind the Knowledge leader and we dont DesireWarWith the Human sender //response depends on 1) what he offers and 2) how long he wants the treaty to last SetString(1,ID_ResearchPact); if ( (KnowledgeRank(player[1])+KnowledgeRank(player[0]))/2 <50 ){//our average Knowledge rank is <50% that of the Knowledge leader's //=> this should depend on NDM_DIFF_LEVEL? term=60; baseGoldPC=0; SetString(0,ID_medium); } else{ term=30; baseGoldPC=5; SetString(0,ID_short); } termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;//0-10% of his gold if (hisGold<100) { hisGold=100; } if (second_type==0 //unacompanied || second_type==23 ||second_type==24) {//maps if (KnowledgeRank(player[1])< ((30+PersBonus+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)//AI RECEIVER &&KnowledgeRank(player[0])< ((30+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)){ // these conditions can be improved by additional offers NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } elseif (KnowledgeRank(player[1])< ((45+PersBonus+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)//AI RECEIVER &&KnowledgeRank(player[0])<((45+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)){ //40/45% at impossible to 80/85% at easy // but we can sometimes be bribed if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, 3*hisGold);//counter with request for gold } else{ ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (second_type==2 ) {//proposes research pact and requests a city ConsiderResponse(player[0], player[1], 1500, 1); //just reject } elseif (second_type==3) { if (HasAgreement(player[1],player[0],3) ){ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif(NDM_GetTrespassingBy(player[1], player[0]) ){ setstring(2,ID_withdraw); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithShowGoodIntentions'); } ConsiderResponse(player[0], player[1],1500,1);//reject } else{ } } elseif (second_type==4) { if(HasAgreement(player[0],player[1],4) ){//if we have the agreement if(NDM_GetTrespassingBy(player[0], player[1]) ){ //and we've been breaking our word, we apologize and accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithApologeticMessage'); } } // else he's bluffing, so else{//otherwise he's bluffing, and if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } } //maybe too easy else{//if we don't have the agreement we accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (second_type==5) {//offers to stop piracy amtGold=3*GetPiracyIncomeFrom(player[0],player[1]); if (amtGold<100) { amtGold=100; } if (amtGoldGetPiracyIncomeFrom(player[0],player[1])) {//we're better pirates than he is amtGold=5*GetPiracyIncomeFrom(player[1],player[0]); if (amtGold<100) { amtGold=100; } if (amtGold ? } elseif (second_type==19) { if (hisGoldPlayerGold(player[0])) {//if we've got more gold than him amtGold=(1500*PlayerGold(player[1]) )/10000;//15% of our gold if (amtGold<100) { amtGold=100; } if (NDM_sender_gold_result<=amtGold) { ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 20, amtGold);//counter with offer of 15% of our gold, } } else{//he's being greedy if (hisGold((90+PersBonus+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)) {//we're advanced if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'NothingtoOfferUsResearch'); } } } elseif (KnowledgeRank(player[0])>((90+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)) {//he's advanced if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'ScientificImperialism'); } } } } } messagebox 'SeeThroughYouResearch' { show(); Text (ID_SeeThroughYouResearchM) ; Button(ID_OK){ Kill(); } } messagebox 'NothingtoOfferUsResearch' { show(); Text (ID_NothingtoOfferUsResearchM) ; Button(ID_OK){ Kill(); } } messagebox 'ScientificImperialism' { show(); Text (ID_ScientificImperialismM) ; Button(ID_OK){ Kill(); } } void_f AI_Responses_to_Human_Proposals_research_pact_second(int_t first_type, int_t second_type){ int_t PersBonus; //bonus given dependent on AI RECEIVER personality, increases chances of him accepting proposal int_t term; int_t termPen; int_t hisGold; int_t ourGold; int_t amtGold; int_t baseGoldPC; NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; if (GetPersonalityType(player[1])==6 || GetPersonalityType(player[1])==7) {//scientist PersBonus=5; } else{ PersBonus=0; } if (!GetDesireWarWith(player[1],player[0]) //we don't want to be at war with him && KnowledgeRank(player[1])< ((35+PersBonus+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)//AI RECEIVER && KnowledgeRank(player[0])< ((35+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)){ // these are the same conditions as when we offer him the deal // so, we're both behind the Knowledge leader and we dont DesireWarWith the Human sender //response depends on 1) what he offers and 2) how long he wants the treaty to last SetString(1,ID_ResearchPact); if ( (KnowledgeRank(player[1])+KnowledgeRank(player[0]))/2 <50 ){//our average Knowledge rank is <50% that of the Knowledge leader's //=> this should depend on NDM_DIFF_LEVEL? term=60; baseGoldPC=0; SetString(0,ID_medium); } else{ term=30; baseGoldPC=5; SetString(0,ID_short); } termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;//0-10% of his gold if (hisGold<100) { hisGold=100; } if (first_type==0 //unacompanied || first_type==23 ||second_type==24) {//maps if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (KnowledgeRank(player[1])< ((30+PersBonus+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)//AI RECEIVER &&KnowledgeRank(player[0])< ((30+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)){ // these conditions can be improved by additional offers NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'WantMoreGold'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (first_type==1) { ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TREATY_LENGTH=0; } elseif (first_type==2) {//proposes research pact and requests a city ConsiderResponse(player[0], player[1], 1500, 1); //just reject } elseif (first_type==3) { if (HasAgreement(player[1],player[0],3) ){ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif(NDM_GetTrespassingBy(player[1], player[0]) ){ setstring(2,ID_withdraw); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithShowGoodIntentions'); } ConsiderResponse(player[0], player[1],1500,1);//reject } } elseif (first_type==4) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif(HasAgreement(player[0],player[1],4) ){//if we have the agreement if(NDM_GetTrespassingBy(player[0], player[1]) ){ //and we've been breaking our word, we apologize and accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithApologeticMessage'); } } // else he's bluffing, so else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithNoTroopsThere'); } ConsiderResponse(player[0], player[1],1500,1);//reject } } else{//if we don't have the agreement we accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60;//!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==5) { if(IsHumanPlayer(player[0])) { message(player[0],'CleanUpYourAct'); } ConsiderResponse(player[0], player[1], 1500, 1); } elseif (first_type==6 ) {//wants us to stop piracy if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } if (GetPiracyIncomeFrom(player[1],player[0])>GetPiracyIncomeFrom(player[0],player[1])) {//we're better pirates than he is amtGold=5*GetPiracyIncomeFrom(player[1],player[0]); if (amtGold<100) { amtGold=100; } if (amtGoldPlayerGold(player[0])) {//if we've got more gold than him ourGold=((15-(termPen+baseGoldPC))*100*PlayerGold(player[1]) )/10000;//5 to 15% of our gold if (NDM_sender_gold_result<=ourGold) { ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'AskingTooMuch'); } ConsiderResponse(player[0], player[1], 1500, 1); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'GreedyGreedy'); } ConsiderResponse(player[0], player[1], 1500,1); } } } else{ int_t rnd; rnd=Random(3); ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetDesireWarWith(player[1],player[0])) {//we want war if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'SeeThroughYouResearch'); } } } if (KnowledgeRank(player[1])>((90+PersBonus+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)) {//we're advanced if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'NothingtoOfferUsResearch'); } } } if (KnowledgeRank(player[0])>((90+ NDM_ToneMod)-10*NDM_DIFF_LEVEL)) {//he's advanced if (rnd<1) { if(IsHumanPlayer(player[0])) { message(player[0],'ScientificImperialism'); } } } } } //MILITARY PACTS: If the Human offers us a military pact, we almost always accept. But if we go to war with someone and he doesn't // join in, he suffers a BIG, global regard loss. Possibly with messages from others. Remember to generate AI proposals (26/27) for this. void_f AI_Responses_to_Human_Proposals_military_pact(int_t first_type, int_t second_type){ // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] int_t PersBonus; //bonus given dependent on AI RECEIVER personality, increases chances of him accepting proposal int_t MilitaryLeader;//the player whose military rank ==100 int_t term; int_t amtGold; int_t baseGoldPC; NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; MilitaryLeader=NDM_GetMilitaryLeader(); if (GetPersonalityType(player[1])==2 || GetPersonalityType(player[1])==3 || GetPersonalityType(player[1])==4 ){//militarist PersBonus=5; } else{ PersBonus=0; } if(!AtWarWith(player[0],MilitaryLeader) && !AtWarWith(player[1],MilitaryLeader) && MilitaryRank(player[0])< ((45+PersBonus+ NDM_ToneMod)-5*NDM_DIFF_LEVEL) && MilitaryRank(player[1])<((45+ NDM_ToneMod)-5*NDM_DIFF_LEVEL)){ SetString(1,ID_MilitaryPact); if ( (MilitaryRank(player[1])+MilitaryRank(player[0]))/2 <50 ){//our average Military rank is <50% that of the Military leader's //=> this should depend on NDM_DIFF_LEVEL term=60; SetString(0,ID_medium); } else{ term=30; SetString(0,ID_short); } if (second_type==0 || second_type==1 || second_type==5 || second_type==6 || second_type==17 ||second_type==18 || second_type==23 ||second_type==24) { NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } elseif (second_type==2) { ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (second_type==3) { NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; //!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } elseif (second_type==4) { NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; //!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0], player[1]); NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } elseif (second_type==19) { if (PlayerGold(player[0])>PlayerGold(player[1])) {//if he's got more gold than us NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ amtGold=(1500*PlayerGold(player[1]))/10000;//15% of our gold if (amtGold<100) { amtGold=100; } //such a surprise! send messages here if (NDM_receiver_gold_resultPlayerGold(player[0])) {//if we've got more gold than him amtGold=(1500*PlayerGold(player[1]))/10000;//15% of our gold if (amtGold<100) { amtGold=100; } if (NDM_sender_gold_result this should depend on NDM_DIFF_LEVEL term=60; baseGoldPC=0; SetString(0,ID_medium); } else{ term=30; baseGoldPC=5; SetString(0,ID_short); } termPen=0; if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term termPen=5; } hisGold=((termPen+baseGoldPC)*100*PlayerGold(player[0]))/10000;//0-10% of his gold if (hisGold<100) { hisGold=100; } if (first_type==0 || first_type==1 || first_type==5 || first_type==6 || first_type==17 ||first_type==18 || first_type==23 ||first_type==24) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==2) { ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (first_type==3) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; //!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==4) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; //!60 here NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0], player[1]); NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==19) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } else{ NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[0], player[1], 1500, 2); //2=accept if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } elseif (first_type==20) { if (termPen) {//if he's chosen the wrong term, we can't counter. So we have to tell him to try again. if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (PlayerGold(player[1])>PlayerGold(player[0])) {//if we've got more gold than him amtGold=(1500*PlayerGold(player[1]))/10000;//15% of our gold if (amtGold<100) { amtGold=100; } if (NDM_sender_gold_result TBD } // else reject? } void_f AI_Responses_to_Human_Proposals_request_cities(int_t first_type, int_t second_type){ int_t EffReg;// Effective Regard NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; EffReg=GetEffectiveRegard(player[1],player[0]); if (second_type==0) {//Human requests city (unaccompanied) // => default: counters with request for most at risk city(?) if (EffReg-5*NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5*NDM_Tone,0,ID_NONE);//how did AI like the human's offering it (displeased) } elseif (second_type==3){//Human requests city but offers no trespassing ConsiderResponse(player[0], player[1], 1500, 1); //reject if (EffReg-5*NDM_Tone<100){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5*NDM_Tone,0,ID_NONE,0);//how did AI like the human's offering it (displeased) } elseif (second_type==5){//Human requests city but offers cease piracy ConsiderResponse(player[0], player[1], 1500, 1); //reject if (EffReg-5*NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5*NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } elseif (second_type==17){//Human requests city but offers an advance // maybe: if it's a small city and he's strong and scientifically powerful, counter with a research treaty ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (second_type==19){//Human requests city but offers gold (wants to buy the city!) // ??? ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (second_type==23){//Human requests city but offers map ConsiderResponse(player[0], player[1], 1500, 1); //reject if(IsHumanPlayer(player[0])) { message(player[0],'YouMustBeMad'); } } } void_f AI_Responses_to_Human_Proposals_exchange_withdraw_troops(int_t first_type, int_t second_type){//Human wants mutual withdraw //reject conditions: if (GetDesireWarWith(player[1], player[0])//we want to be at war with him || GetEffectiveRegard(player[1],player[0])<400-5* NDM_ToneMod ){ //we don't really like him if (GetEffectiveRegard(player[1],player[0])-10* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) ConsiderResponse(player[0], player[1], 1500, 1); //reject } else{ if (HasAgreement(player[0], player[1],3)) {//we've already accepted his offer not to trespass if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif (!NDM_GetTrespassingBy(player[1],player[0])) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage3'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } if(HasAgreement(player[0],player[1],4) ){//we've already agreed not to tresspass on him if(NDM_GetTrespassingBy(player[0], player[1]) ){ //and we've been breaking our word, we apologize and withdraw (and extend the agreement) NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; ConsiderResponse(player[0], player[1], 1500, 2);//accept if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithApologeticMessage'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage4'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } } else{//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; ConsiderResponse(player[0], player[1], 1500, 2);//accept } } } void_f AI_Responses_to_Human_Proposals_offer_withdraw_troops(int_t first_type, int_t second_type){ // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; SetString(0,ID_medium); SetString(1,ID_TrespassingAgmt); //Human offers to withdraw troops (no trespassing) if (HasAgreement(player[0], player[1],3)) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif (!NDM_GetTrespassingBy(player[1].owner,player[0].owner)) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage3'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (second_type==0) {//unaccompanied ConsiderResponse(player[0], player[1], 1500, 2);//it's a freebe, accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } elseif (second_type==2) {//Human offers to withdraw troops and requests our city ConsiderResponse(player[0], player[1], 1500, 1); //reject //=> message? if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,0);//how did AI like the human's offering it (displeased) } elseif ( second_type==6){ //Human offers to withdraw troops and requests our cease piracy if((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<400-5* NDM_ToneMod) //we don't really like him, ){ ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,0);//how did AI like the human's offering it (displeased) } else{//we're borderline friendly, so ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } } elseif ( second_type==18){ //Human offers to withdraw troops but requests an advance if(GetDesireWarWith(player[1], player[0]) ){ //we want to be at war with him ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } else{ if (!HasAgreement(player[0], player[1],4) ) { ConsiderResponse(player[0], player[1], 1500, 3, 4); //initially, counter with reciprocal offer } elseif(GetEffectiveRegard(player[1],player[0])>375-5* NDM_ToneMod) { //if we really like him ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ // could use show good intentions here ConsiderResponse(player[0], player[1], 1500, 1); //reject } } } elseif (second_type==20){//Human offers to withdraw troops but requests gold ConsiderResponse(player[0], player[1], 1500, 1);//1=reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } elseif (GetEffectiveRegard(player[1],player[0])>300) { if(IsHumanPlayer(player[0])) { message(player[0],'SoundsLikeBlackmail'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5); } elseif (second_type==24 ){//Human offers to withdraw troops and requests our map ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } void_f AI_Responses_to_Human_Proposals_request_withdraw_troops(int_t first_type, int_t second_type){ // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] int_t amtGold; int_t hisGold;//an amt of his gold that we want (usually to make us accept a request) int_t baseGoldPC;//base gold percentage for calculating AI counters int_t term; int_t termPen; //penalty given to Human for choosing the wrong term NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; SetString(0,ID_medium);//all no trespassing agreements are medium term SetString(1,ID_TrespassingAgmt); NDM_TREATY_LENGTH=60; if (MilitaryRank(player[0])>MilitaryRank(player[1])+10- NDM_ToneMod) {//Human stronger and maybe asks properly baseGoldPC=5; } else{ baseGoldPC=15; } hisGold=(baseGoldPC*100*PlayerGold(player[0]))/10000;//5-15% of his gold if (hisGold<100) { hisGold=100; } // This means we accept any accompanying offer. But we already have the agreement, so the sender is being dumb. // // make sure the treaty log doesn't get updated when the human accepts!!! if(HasAgreement(player[0],player[1],4) ){//if we have the agreement if(NDM_GetTrespassingBy(player[0], player[1]) ){ //and we've been breaking our word, we apologize and accept ConsiderResponse(player[0], player[1], 1500, 2); //2=accept NDM_WithdrawNow(player[0], player[1]); if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithApologeticMessage'); } } else{ if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage4'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (second_type==0) {//Human requests withdraw troops (unaccompanied) if (!GetDesireWarWith(player[1], player[0]) // we don't want to be at war with him && GetEffectiveRegard(player[1],player[0])>250-5* NDM_ToneMod ){// and we don't really dislike him if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3,3);//counter with mutual withdraw } elseif (!GetDesireWarWith(player[1], player[0]) // we don't want to be at war with him && GetEffectiveRegard(player[1],player[0])<250-5* NDM_ToneMod ){// but we do really dislike him //maybe 2*hisGold here if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithFixedTermAgreement'); } ConsiderResponse(player[0], player[1], 1500, 3, 19, hisGold);//counter with request for gold } else{ ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (second_type==1){//Human requests withdraw troops but offers a city ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); } elseif (second_type==5){//Human requests withdraw troops but offers cease piracy //reject conditions: if((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<200-5* NDM_ToneMod) //we really don't like him, || GetPiracyIncomeFrom(player[1],player[0])>GetPiracyIncomeFrom(player[0],player[1]) //we're better pirates than he is ){ LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[0], player[1], 1500, 1); //reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); } } elseif (second_type==17){//Human requests withdraw troops but offers an advance if((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<200-5* NDM_ToneMod) //we really don't like him, ){ LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) //=>message ConsiderResponse(player[0], player[1], 1500, 2); //reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); } } elseif (second_type==19){//Human requests withdraw troops but offers gold if (!GetDesireWarWith(player[1], player[0]) // we don't want to be at war with him && GetEffectiveRegard(player[1],player[0])>250-5* NDM_ToneMod ){// and we don't really dislike him if (PlayerGold(player[0])>PlayerGold(player[1])) { amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1500*amtGold )/10000; if (amtGold accept if Human is bigger pirate } void_f AI_Responses_to_Human_Proposals_offer_no_piracy(int_t first_type, int_t second_type){//Human offers to cease piracy // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] if(second_type==0){//unaccompanied ConsiderResponse(player[0], player[1], 1500, 2);//it's a freebe, accept } elseif (second_type==2){//Human offers cease piracy but requests city //=> LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (second_type==4){//Human offers cease piracy but requests withdraw troops //reject conditions: if((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<200-5* NDM_ToneMod) //we really don't like him, || GetPiracyIncomeFrom(player[1],player[0])>GetPiracyIncomeFrom(player[0],player[1]) //we're better pirates than he is ){ //=> LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[0], player[1], 1500, 1); //reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); } } elseif (second_type==18){//Human offers cease piracy but requests an advance if(IsHumanPlayer(player[0])) { message(player[0],'CleanUpYourAct'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject // => this should be linked in the first message if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } elseif (second_type==20){//Human offers cease piracy but requests gold if (NDM_sender_gold_result < 3*GetPiracyIncomeFrom(player[0],player[1]) ){//it costs less than we lose from 3 turns of piracy if(IsHumanPlayer(player[0])) { message(player[0],'BaseCounterToOfferStopPiracy'); } ConsiderResponse(player[0], player[1], 1500, 3,0); //counter with null } else{ if(IsHumanPlayer(player[0])) { message(player[0],'AskingTooMuch'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (second_type==24){//Human offers cease piracy but requests map ConsiderResponse(player[0], player[1], 1500, 2);//accept } } void_f AI_Responses_to_Human_Proposals_request_no_piracy(int_t first_type, int_t second_type){//Human requests that we cease piracy // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] int_t amtGold; int_t hisGold;//an amt of his gold that we want (usually to make us accept a request) int_t baseGoldPC;//base gold percentage for calculating AI counters int_t term; int_t termPen; //penalty given to Human for choosing the wrong term NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; if (second_type==0) {//Human requests cease piracy, unaccompanied //reject conditions: if((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<200-5* NDM_ToneMod) //we really don't like him, ){ LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[0], player[1], 1500, 1); //reject } else{//we must be pirating him, so counter with request for gold //=> message ConsiderResponse(player[0], player[1], 1500, 3,19,7*GetPiracyIncomeFrom(player[1],player[0]),4); } } elseif (second_type==1){//Human requests cease piracy but offers a city ConsiderResponse(player[0], player[1], 1500, 2);//accept (it's gotta be worth it) } elseif (second_type==3){//Human requests cease piracy but offers no trespassing if (HasAgreement(player[0], player[1],3)) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif (!NDM_GetTrespassingBy(player[1],player[0])) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage3'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<400-5* NDM_ToneMod) //we don't really like him, ){ ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,0);//how did AI like the human's offering it (displeased) } else{//we're borderline friendly, so ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } } elseif (second_type==17){//Human requests cease piracy but offers an advance //reject conditions: if((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<200-5* NDM_ToneMod) //we really don't like him, ){ //=> maybe LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (5*GetPiracyIncomeFrom(player[1],player[0])2*PlayerGold(player[1])) { // he's got much more gold than us amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1000*amtGold )/10000; if (amtGold 5*GetPiracyIncomeFrom(player[1],player[0]) ){//he offered more than we gain from 5 turns of piracy ConsiderResponse(player[0], player[1], 1500, 2);//accept } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) } } elseif (second_type==23){//Human requests cease piracy but offers map ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,0);//how did AI like the human's offering it (displeased) } } void_f AI_Responses_to_Human_Proposals_embassy_agreements(int_t first_type, int_t second_type){ // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] //Embassy agreements 7+8 : int_t amtGold; int_t PersBonus; //bonus given dependent on AI RECEIVER personality, increases chances of him accepting proposal int_t MilitaryLeader;//the player whose military rank ==100 NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; //check prerequisites first if (AtWarWith(player[0],player[1])) { if(IsHumanPlayer(player[0])) { message(player[0].owner,'NotWhenAtWar'); } ConsiderResponse(player[0], player[1], 9999, 0);//0=invalid } elseif (!HasAdvance(player[0], ID_ADVANCE_BUREAUCRACY)) { if(IsHumanPlayer(player[0])) { message(player[0].owner,'WeNeedBureaucracy');// Dynasty for Cradle } ConsiderResponse(player[0], player[1], 9999, 0);//0=invalid } elseif (!HasAdvance(player[1], ID_ADVANCE_BUREAUCRACY)) { if(IsHumanPlayer(player[0])) { message(player[0].owner,'TheyNeedBureaucracy');// Dynasty for Cradle } ConsiderResponse(player[0], player[1], 9999, 0);//0=invalid } elseif ((first_type==7 || second_type==7) && NDM_HasEmbassy(player[1],player[0]) ) { ConsiderResponse(player[0], player[1], 9999, 0);//invalid if(IsHumanPlayer(player[0])) { message(player[0],'AlreadyHaveEmbassyHere'); } } elseif ((first_type==8 || second_type==8) && NDM_HasEmbassy(player[0],player[1]) ) { ConsiderResponse(player[0], player[1], 9999, 0);//invalid if(IsHumanPlayer(player[0])) { message(player[0],'AlreadyHaveEmbassyThere'); } } elseif ((first_type==7 && second_type==8) || (first_type==8 && second_type==7) ){//Human wants mutual embassy exchange if (GetEffectiveRegard(player[1],player[0])>400-5* NDM_ToneMod) { //if we don't dislike him, accept ConsiderResponse(player[0], player[1], 1500, 2);// accept event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif (first_type==8 && 1002*PlayerGold(player[1])) {//if he's rich amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1000*amtGold )/10000; if (amtGold<100) { amtGold=100; } ConsiderResponse(player[0], player[1], 1500, 3, 19, amtGold);//counter with reciprocal request for gold } else{ ConsiderResponse(player[0], player[1], 1500, 1); //reject } } else{ ConsiderResponse(player[0], player[1], 1500, 1); //reject } } //Human offers embassy, elseif (first_type==7 && second_type==0) { //unaccompanied ConsiderResponse(player[0], player[1], 1500, 2);//it's a freebe, accept event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif ((first_type==2 && second_type==7)||(first_type==7 && second_type==2)){//Human requests city but offers an embassy in his land ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif ((first_type==4 && second_type==7)||(first_type==7 && second_type==4)) {//Human requests withdraw troops but offers us an embassy in his land ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif ((first_type==6 && second_type==7) || (first_type==7 && second_type==6)) {//Human requests cease piracy but offers an embassy in his land ConsiderResponse(player[0], player[1], 1500, 1);//reject } // elseif ((first_type==7 && second_type==18) || (first_type==18 && second_type==7)) {//Human offers embassy but requests advance //NOT POSSIBLE // ConsiderResponse(player[0], player[1], 9999, 0);//invalid // message(player[0],'AlreadyHaveEmbassyHere'); // } elseif ((first_type==7 && second_type==20) || (first_type==20 && second_type==7)) {//Human offers embassy but requests gold ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif ((first_type==7 && second_type==24) || (first_type==24 && second_type==7)) {//Human offers embassy but requests map ConsiderResponse(player[0], player[1], 1500, 2);//accept event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } //Human requests embassy elseif (first_type==8 && second_type==0){// unaccompanied if (GetEffectiveRegard(player[1],player[0])<500-5* NDM_ToneMod){//if we don't really like him //=> this is evil: we might take his cash and then go to war on the next turn if (PlayerGold(player[1])>PlayerGold(player[0]) ){//reject if he's poor ConsiderResponse(player[0], player[1], 1500, 1); } else { //else sometimes we can be bought amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1000*amtGold )/10000; if (amtGold<100) { amtGold=100; } ConsiderResponse(player[0], player[1], 1500, 3, 19, amtGold);//counter with reciprocal request for gold } } else{//if we really like him ConsiderResponse(player[0], player[1], 1500, 2);//accept event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } } elseif ((first_type==1 && second_type==8) || (first_type==8 && second_type==1)) {//Human offers city but requests an embassy in our land ConsiderResponse(player[0], player[1], 1500, 2);//accept event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif ((first_type==3 && second_type==8)||(first_type==8 && second_type==3)){//Human offers to withdraw troops but wants an embassy in our land if (HasAgreement(player[0], player[1],3)) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif (!NDM_GetTrespassingBy(player[1],player[0])) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage3'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);// accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } } elseif ((first_type==5 && second_type==8) || (first_type==8 && second_type==5)) {//Human offers cease piracy but requests an embassy in our land ConsiderResponse(player[0], player[1], 1500, 2);//2=accept event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } // elseif ((first_type==8 && second_type==17) || (first_type==17 && second_type==8)){//Human requests embassy but offers an advance //NOT POSSIBLE: // ConsiderResponse(player[0], player[1], 9999, 0);//invalid // message(player[0],'AlreadyHaveEmbassyThere'); // } elseif((first_type==8 && second_type==19) || (first_type==19 && second_type==8) //Human requests embassy but offers gold || (first_type==8 && second_type==23) || (first_type==23 && second_type==8) ){//Human requests embassy but offers map if (PlayerGold(player[1])>2*PlayerGold(player[0]) ){//accept if he's poor ConsiderResponse(player[0], player[1], 1500, 2);//2=accept event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif ( first_type==8 && GetEffectiveRegard(player[1],player[0])>100 && GetEffectiveRegard(player[1],player[0])<400-5* NDM_ToneMod ){ amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1000*amtGold )/10000; if (second_type==19) { if (amtGoldmessage ConsiderResponse(player[0], player[1], 1500, 1); //reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); } } } elseif (second_type==6){ //Human wants to exchange advance for cease piracy //reject conditions: if((GetDesireWarWith(player[1], player[0]) //we want to be at war with him || GetEffectiveRegard(player[1],player[0])<200-5* NDM_ToneMod) //we really don't like him, ){ LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) //=>message? ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif (5*GetPiracyIncomeFrom(player[1],player[0])3*NDM_sender_gold_result) {//we've got lots of gold if (GetEffectiveRegard(player[1],player[0])>800-5* NDM_ToneMod ){//we love him if (NDM_receiver_science_result > NDM_sender_gold_result) {//he's got a deal ConsiderResponse(player[0], player[1], 1500, 2);//accept } else{//he's being greedy, so: ConsiderResponse(player[0], player[1], 1500, 3, 19, NDM_receiver_science_result/2); } } elseif(GetEffectiveRegard(player[1],player[0])>500-5* NDM_ToneMod ){//we really like him if (NDM_receiver_science_result/2 > NDM_sender_gold_result) {//he's asking less than half what it's worth ConsiderResponse(player[0], player[1], 1500, 2);//accept } elseif(NDM_receiver_science_result > NDM_sender_gold_result) { ConsiderResponse(player[0], player[1], 1500, 3, 19, NDM_receiver_science_result/2 );//offer half what it's worth } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject if(IsHumanPlayer(player[0])) { message(player[0],'AskingTooMuch'); } } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject if(IsHumanPlayer(player[0])) { message(player[0],'AskingTooMuch'); } } } elseif(second_type==24 ){//Human wants to sell advance for a map ConsiderResponse(player[0], player[1], 1500, 2);//accept } } void_f AI_Responses_to_Human_Proposals_request_advance(int_t first_type, int_t second_type){//Human requests an advance // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] int_t receiver_regard_result; NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; if (second_type==0) {//Human requests advance (unaccompanied) if (KnowledgeRank(player[0])>KnowledgeRank(player[1]) ){ if(IsHumanPlayer(player[0])) { message(player[0],'WantSomethingBack'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif (PlayerGold(player[0])>PlayerGold(player[1])) { ConsiderResponse(player[0], player[1], 1500, 3,19,NDM_sender_science_result); } else{ ConsiderResponse(player[0], player[1],1500,1);//reject } } elseif (second_type==1){//Human requests advance but offers a city ConsiderResponse(player[0], player[1], 1500, 2);//accept } elseif (second_type==3){//Human requests advance but offers no trespassing if (HasAgreement(player[0], player[1],3)) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithPuzzledMessage3'); } ConsiderResponse(player[0], player[1],1500,1);//reject } elseif (!NDM_GetTrespassingBy(player[1],player[0])) { if(IsHumanPlayer(player[0])) { message(player[0],'CounterWithReallyPuzzledMessage3'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } elseif(GetDesireWarWith(player[1], player[0]) ){ //we want to be at war with him ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } elseif(GetEffectiveRegard(player[1],player[0])>375-5* NDM_ToneMod) { //if we really like him ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; SetString(0,ID_medium); SetString(1,ID_TrespassingAgmt); if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } else{ // could use show good intentions here ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (second_type==5){//Human requests advance but offers cease piracy if(IsHumanPlayer(player[0])) { message(player[0],'CleanUpYourAct'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject if (GetEffectiveRegard(player[1],player[0])-5* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } elseif (second_type==19){//Human requests advance but offers gold if (GetEffectiveRegard(player[1],player[0])>500-5* NDM_ToneMod ){//we really like him if (NDM_sender_science_result < NDM_receiver_gold_result) {//he's got a deal ConsiderResponse(player[0], player[1], 1500, 2);//accept receiver_regard_result = GetNewProposalResult(player[0], player[1], player[1], 3); LogRegardEvent(player[1],player[0],-receiver_regard_result,0,ID_NONE,0);//but business is business } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject if(IsHumanPlayer(player[0])) { message(player[0],'WantMoreGold'); } } } elseif(GetEffectiveRegard(player[1],player[0])>350-5* NDM_ToneMod ){//we like him if ((12*NDM_sender_science_result)/10 > NDM_receiver_gold_result) { ConsiderResponse(player[0], player[1], 1500, 3,19,(1200*NDM_sender_science_result)/1000); //counter with request for 20% more than what it costs } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept receiver_regard_result = GetNewProposalResult(player[0], player[1], player[1], 3); LogRegardEvent(player[1],player[0],-receiver_regard_result,0,ID_NONE,5);//but business is business } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject if (random(3)<1) { if(IsHumanPlayer(player[0])) { message(player[0],'NotInterestedNow'); } } } } elseif (second_type==23){//Human requests advance but offers map ConsiderResponse(player[0], player[1], 1500, 1);//1=reject LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) } } void_f AI_Responses_to_Human_Proposals_offer_gold(int_t first_type, int_t second_type){//Human offers gold // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] int_t amtGold; int_t receiver_regard_result; int_t hisGold;//an amt of his gold that we want (usually to make us accept a request) int_t baseGoldPC;//base gold percentage for calculating AI counters NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; // Human offers gold (remember: if accompanied, can't counter with request for more gold) if (MilitaryRank(player[0])>MilitaryRank(player[1])+10- NDM_ToneMod) {//Human stronger and maybe asks properly baseGoldPC=5; } else{ baseGoldPC=15; } hisGold=(baseGoldPC*100*PlayerGold(player[0]))/10000;//5-15% of his gold if (hisGold<100) { hisGold=100; } if ( second_type==0 ){ //unaccompanied ConsiderResponse(player[0], player[1], 1500, 2);//accept } elseif ( second_type==2){ //Human wants to exchange gold for city //TBD ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif ( second_type==4){//Human wants to exchange gold for no trespassing if (!GetDesireWarWith(player[1], player[0]) // we don't want to be at war with him && GetEffectiveRegard(player[1],player[0])>250-5* NDM_ToneMod ){// and we don't really dislike him if (PlayerGold(player[0])>PlayerGold(player[1])) { amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1500*amtGold )/10000; if (amtGold message here } } elseif (second_type==6){ //Human offers gold and requests our cease piracy if(PlayerGold(player[0])>2*PlayerGold(player[1])) { // he's got much more gold than us amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1000*amtGold )/10000; if (amtGold 5*GetPiracyIncomeFrom(player[1],player[0]) ){//he offered more than we gain from 5 turns of piracy ConsiderResponse(player[0], player[1], 1500, 2);//accept } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) } } elseif (second_type==18) {//Human wants to exchange gold for our advance (like 18-19, but can't counter) if (GetEffectiveRegard(player[1],player[0])>500-5* NDM_ToneMod ){//we really like him if (NDM_sender_science_result < (12*NDM_receiver_gold_result)/10) {//he's got a deal ConsiderResponse(player[0], player[1], 1500, 2);//accept receiver_regard_result = GetNewProposalResult(player[0], player[1], player[1], 3); LogRegardEvent(player[1],player[0],-receiver_regard_result,0,ID_NONE,0);//business is business } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject if(IsHumanPlayer(player[0])) { message(player[0],'WantMoreGold'); } } } elseif(GetEffectiveRegard(player[1],player[0])>350-5* NDM_ToneMod ){//we like him if (NDM_sender_science_result > NDM_receiver_gold_result) { if(IsHumanPlayer(player[0])) { message(player[0],'WantMoreGold'); } ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } else{ ConsiderResponse(player[0], player[1], 1500, 2);//accept receiver_regard_result = GetNewProposalResult(player[0], player[1], player[1], 3); LogRegardEvent(player[1],player[0],-receiver_regard_result,0,ID_NONE,0);//business is business } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject if (random(3)<1) { if(IsHumanPlayer(player[0])) { message(player[0],'NotInterestedNow'); } } } } elseif (second_type==24){ //Human offers gold for a map //accept if at least 5% of his gold amtGold=(500*PlayerGold(player[0]))/10000;//5% of his gold if (amtGold<100) { amtGold=100; } if (amtGold message ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } } elseif (second_type==5){//Human requests gold but offers cease piracy if (NDM_sender_gold_result < 3*GetPiracyIncomeFrom(player[0],player[1]) ){//it costs less than we lose from 3 turns of piracy if(IsHumanPlayer(player[0])) { message(player[0],'BaseCounterToOfferStopPiracy'); } ConsiderResponse(player[0], player[1], 1500, 3,0); //counter with null } else{ if(IsHumanPlayer(player[0])) { message(player[0],'AskingTooMuch'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (second_type==17){//Human requests gold but offers advance (like 17-20, but can't counter) if (PlayerGold(player[1])>3*NDM_sender_gold_result) {//we've got lots of gold if (GetEffectiveRegard(player[1],player[0])>800-5* NDM_ToneMod ){//we love him if (NDM_receiver_science_result>NDM_sender_gold_result) {//he's got a deal ConsiderResponse(player[0], player[1], 1500, 2);//accept } else{//he's being greedy, so: if(IsHumanPlayer(player[0])) { message(player[0],'AskingTooMuch'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif(GetEffectiveRegard(player[1],player[0])>500-5* NDM_ToneMod ){//we really like him if (NDM_receiver_science_result/2 < NDM_sender_gold_result) { if(IsHumanPlayer(player[0])) { message(player[0],'RephraseTheOffer'); } ConsiderResponse(player[0], player[1], 1500, 1); //reject } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } } elseif (second_type==23){//Human requests gold but offers map if(GetAgreementDuration(player[0],player[1],23)>50 && PlayerGold(player[1])>2*PlayerGold(player[0])) { //if he hasn't asked for >50 turns and we've got much more gold than him amtGold=PlayerGold(player[1])-PlayerGold(player[0]); amtGold=(500*amtGold )/10000; if (amtGold<100) { amtGold=100; } if (amtGold>=NDM_sender_gold_result) {//and he wants less than about 5% of our surplus over him ConsiderResponse(player[0], player[1], 1500, 2);//accept } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//reject } } } // NO SEPARATE EXCHANGE MAPS: done below void_f AI_Responses_to_Human_Proposals_offer_map(int_t first_type, int_t second_type){ // player[0] is human sender and player[1] is AI RECEIVER // so ConsiderResponse(player[0], player[1], 1500, 2); //player[1] accepts player[0]'s proposal // but event:EstablishEmbassy(player[1],player[0]); //player[1] establishes an embassy in the land of player[0] int_t amtGold; int_t EffReg;// Effective Regard int_t hisGold;//an amt of his gold that we want (usually to make us accept a request) int_t baseGoldPC;//base gold percentage for calculating AI counters int_t term; int_t termPen; //penalty given to Human for choosing the wrong term NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; if ( second_type==0 ){ //unaccompanied ConsiderResponse(player[0], player[1], 1500, 2);//accept } elseif (second_type==2){//Human offers map but requests city ConsiderResponse(player[0], player[1], 1500, 1);//reject EffReg=GetEffectiveRegard(player[1],player[0]); if (EffReg-20* NDM_Tone<100 && !AtWarWith(player[0], player[1])){ if(IsHumanPlayer(player[0])) { message(player[0],'RegardWarning'); } } LogRegardEvent(player[1],player[0],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } elseif (second_type==4){//Human offers map but requests no trespassing ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif ( second_type==6 //Human offers map but requests cease piracy || second_type==18 //Human offers map but requests an advance ){ ConsiderResponse(player[0], player[1], 1500, 1);//reject } elseif (second_type==20) {//Human offers map but requests gold if(GetAgreementDuration(player[0],player[1],23)>20 && PlayerGold(player[1])>2*PlayerGold(player[0])) { //if he hasn't asked for >20 turns and we've got much more gold than him amtGold=PlayerGold(player[1])-PlayerGold(player[0]); amtGold=(500*amtGold )/10000; if (amtGold<100) { amtGold=100; } if (NDM_sender_gold_result<=amtGold) {//and he wants less than about 5% of our surplus over him ConsiderResponse(player[0], player[1], 1500, 2);//accept } } else{ ConsiderResponse(player[0], player[1], 1500, 1);//reject } } elseif (second_type==24 ){//Human offers his map and requests ours if (//reject conditions GetTrust(player[1],player[0])<325-5* NDM_ToneMod //we don't trust him || GetEffectiveRegard(player[1],player[0])<225-5* NDM_ToneMod //we dislike him || GetAgreementDuration(player[0],player[1],23)<20 //he asked within the past 20 turns <=test 5 ) { ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } elseif(MilitaryRank(player[0])-MilitaryRank(player[1])>10 && !HasAgreement(player[1], player[0],4) ){ // if the human is stronger and we don't have a no trespassing agreement, ask for one (and his map!) ConsiderResponse(player[0], player[1], 1500, 3, 3); } else{ if(IsHumanPlayer(player[0])) { message(player[0],'WantMoreGold'); } ConsiderResponse(player[0], player[1], 1500, 1);//reject } } } void_f AI_Responses_to_Human_Proposals_request_map(int_t first_type, int_t second_type){ // player[0] is human sender and player[1] is AI RECEIVER int_t amtGold; if (second_type==0 || second_type==23) {//Human requests map and possibly offers his if (//reject conditions GetTrust(player[1],player[0])<325-5* NDM_ToneMod //we don't trust him || GetEffectiveRegard(player[1],player[0])<225-5* NDM_ToneMod //we dislike him ) { ConsiderResponse(player[0], player[1], 1500, 1);//1=reject } elseif ( MilitaryRank(player[0])-MilitaryRank(player[1])>10 && !HasAgreement(player[1], player[0],4) ){ // if the human is stronger and we don't have a no trespassing agreement, ask for one ConsiderResponse(player[0], player[1], 1500, 3, 3); } elseif(HasAgreement(player[1], player[0],4) && PlayerGold(player[0])>2*PlayerGold(player[1])) { // we have a no trespassing agreement and he's got much more gold than us amtGold=PlayerGold(player[0])-PlayerGold(player[1]); amtGold=(1000*amtGold )/10000; if (amtGold<100) { amtGold=100; } ConsiderResponse(player[0], player[1], 1500, 3, 19, amtGold);//counter with request for gold } elseif(GetAgreementDuration(player[0], player[1],24)<20){//ask for 10% amtGold=PlayerGold(player[1]); amtGold=(1000*amtGold )/10000; if (amtGold<100) { amtGold=100; } ConsiderResponse(player[0], player[1], 1500, 3, 19, amtGold);//counter with request for gold } elseif (second_type==23) { ConsiderResponse(player[0], player[1], 1500, 2);//just be a nice guy, accept } elseif (second_type==0) {//ask for 5% amtGold=PlayerGold(player[1]); amtGold=(500*amtGold )/10000; if (amtGold<100) { amtGold=100; } ConsiderResponse(player[0], player[1], 1500, 3, 19, amtGold);//counter with request for gold } } elseif (second_type==1){//Human requests map but offers a city ConsiderResponse(player[0], player[1], 1500, 2);//accept } elseif (second_type==3){//Human requests map but offers no trespassing ConsiderResponse(player[0], player[1], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; SetString(0,ID_medium); SetString(1,ID_TrespassingAgmt); if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } elseif (second_type==5){//Human requests map but offers cease piracy ConsiderResponse(player[0], player[1], 1500, 2);//accept } elseif (second_type==17){//Human requests map but offers an advance ConsiderResponse(player[0], player[1], 1500, 2);//accept } elseif (second_type==19){//Human requests map but offers gold if (!HasAgreement(player[0], player[1],19)) {// accept first time ConsiderResponse(player[0], player[1], 1500, 2);//accept } else{//ask for at least 5% amtGold=(500*PlayerGold(player[0]))/10000;//5% of his gold if (amtGold<100) { amtGold=100; } if (amtGoldor setstrings if(IsHumanPlayer(player[1])) { message(player[1],'AgreedShortTermAgreement'); } } } void_f AI_response_to_Human_Counter_research_pact(int_t first_type, int_t second_type){ int_t PersBonus; int_t ToneMod; ToneMod=NDM_SetToneModifier(player[0], player[1]); //check if treaty length is set by human when countering NDM_TREATY_LENGTH=30; //Human counters with offer of research pact if (GetPersonalityType(player[0])==6 || GetPersonalityType(player[0])==7) {//scientist PersBonus=5; } else{ PersBonus=0; } if(KnowledgeRank(player[0])< ((35+PersBonus+ToneMod)-5*NDM_DIFF_LEVEL) && KnowledgeRank(player[1])< ((35+ToneMod)-5*NDM_DIFF_LEVEL) ){//45/50% at impossible to 85/90% at easy NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; ConsiderResponse(player[1], player[0], 1500, 2); //2=AI accepts human counter //=>or setstrings if(IsHumanPlayer(player[1])) { message(player[1],'AgreedShortTermAgreement'); } } } void_f AI_response_to_Human_Counter_military_pact(int_t first_type, int_t second_type){ int_t PersBonus; int_t ToneMod; int_t MilitaryLeader; ToneMod=NDM_SetToneModifier(player[0], player[1]); //check if treaty length is set by human when countering NDM_TREATY_LENGTH=30; //Human counters with offer of military pact MilitaryLeader=NDM_GetMilitaryLeader(); if (GetPersonalityType(player[0])==2 || GetPersonalityType(player[0])==3 || GetPersonalityType(player[0])==4 ){//militarist PersBonus=5; } else{ PersBonus=0; } if(!AtWarWith(player[0],MilitaryLeader) && !AtWarWith(player[1],MilitaryLeader) && !AtWarWith(player[0],player[1]) && MilitaryRank(player[0])< ((45+PersBonus+ToneMod)-5*NDM_DIFF_LEVEL) && MilitaryRank(player[1])< ((45+ToneMod)-5*NDM_DIFF_LEVEL)){ NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; ConsiderResponse(player[1], player[0], 1500, 2); //2=AI accepts human counter //=>or setstrings if(IsHumanPlayer(player[1])) { message(player[1],'AgreedShortTermAgreement'); } } } // alliance left to default void_f AI_response_to_Human_Counter_ceasefire(int_t first_type, int_t second_type){ // I don't think this will happen with the default set-up, the only proposal the AI will send, when at war, is a ceasefire // Anyway, if the human gets lucky he sometimes has a 50% chance of getting a ceasefire int_t term; SetString(0,ID_medium); SetString(1,ID_CeasefireAgmt); NDM_TREATY_LENGTH=60; if (MilitaryRank(player[0])>MilitaryRank(player[1])+30) {//Human much stronger NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; ConsiderResponse(player[1], player[0], 1500, 2); //2=accept anything? if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } //message hope that we can put our previous differences behind us ...blah blah blah } elseif(MilitaryRank(player[0])>MilitaryRank(player[1])- NDM_ToneMod ){ if (MilitaryRank(player[0])>MilitaryRank(player[1])+10- NDM_ToneMod) {//Human stronger and maybe asks properly term=60; SetString(0,ID_medium); } elseif (MilitaryRank(player[0])>MilitaryRank(player[1])- NDM_ToneMod) {//Human just stronger and maybe asks properly term=30; SetString(0,ID_short); } if (NDM_TREATY_LENGTH!=term ) { NDM_TREATY_LENGTH=term; //set the acceptable term } if (random(100)<50) { ConsiderResponse(player[1], player[0], 1500, 2);//accept NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; if(IsHumanPlayer(player[0])) { message(player[0],'AgreedFixedTermAgreement1'); } } } // if the AI is winning it will only accept a short term ceasefire elseif (MilitaryRank(player[0])+30 TBD } } elseif (first_type==4) {//AI requested that Human withdraw (so Human can trigger this by trespassing) if(HasAgreement(player[0],player[1],4) ){//he's already agreed not to trespass on us ConsiderResponse(player[1], player[0], 1500, 1);//reject if(IsHumanPlayer(player[1])) { message(player[1],'KeepYourWord'); } } elseif (second_type==1) {//Human wants city ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==3) {//Human wants mutual withdraw if(HasAgreement(player[1],player[0],4) ){//we've already agreed not to trespass on him if(NDM_GetTrespassingBy(player[1], player[0]) ){ //and we've been breaking our word, we apologize and withdraw (and extend the agreement) NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; ConsiderResponse(player[1], player[0], 1500, 2);//accept if(IsHumanPlayer(player[1])) { message(player[1],'CounterWithApologeticMessage'); } } else{ if(IsHumanPlayer(player[1])) { message(player[1],'CounterWithReallyPuzzledMessage4'); } ConsiderResponse(player[1], player[0], 1500, 1); //reject } } else{ //=> maybe too harsh if (!GetDesireWarWith(player[0], player[1])//we don't want to be at war with him || GetEffectiveRegard(player[0],player[1])>600-5* NDM_ToneMod ){ //we really like him ConsiderResponse(player[1], player[0], 1500, 2); //accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[1],player[0]); NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } else{ LogRegardEvent(player[0],player[1],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[1], player[0], 1500, 1); //reject //=> message ? } } } elseif (second_type==5) {//We want him to withdraw, he wants us to cease piracy if((GetDesireWarWith(player[0], player[1]) //we want to be at war with him || GetEffectiveRegard(player[0],player[1])<200-5* NDM_ToneMod) ){ //we really don't like him, LogRegardEvent(player[0],player[1],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[1], player[0], 1500, 1); //reject } else{ //=> message ? ConsiderResponse(player[1], player[0], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } } elseif (second_type==7) {//We want him to withdraw, he wants to establish an embassy in our land ConsiderResponse(player[1], player[0], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; if(IsHumanPlayer(player[1])) { message(player[1],'CounterAccepted'); } } elseif (second_type==17) {//We want him to withdraw, he wants an advance ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==19) {//We want him to withdraw, he wants gold ConsiderResponse(player[1], player[0], 1500, 1);//reject //message? } elseif (second_type==23) {//We want him to withdraw, he wants our map //??? } } elseif (first_type==6) {//AI requested that Human cease piracy (he can influence this) if (second_type==1) {//He wants our city ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==3) {//He wants us to withdraw if((GetDesireWarWith(player[0], player[1]) //we want to be at war with him || GetEffectiveRegard(player[0],player[1])<200-5* NDM_ToneMod) //we really don't like him, || GetPiracyIncomeFrom(player[0],player[1])>GetPiracyIncomeFrom(player[1],player[0]) ){ //we're better pirates than he is LogRegardEvent(player[0],player[1],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (irritated) ConsiderResponse(player[1], player[0], 1500, 1); //reject } else{ ConsiderResponse(player[1], player[0], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[1],player[0]); } } elseif (second_type==5) {//We want him to cease piracy, he wants us to cease piracy //=> } elseif (second_type==7) {//We want him to cease piracy, he wants to establish an embassy in our land ConsiderResponse(player[1], player[0], 1500, 1); //reject } elseif (second_type==17) {//We want him to cease piracy, he wants an advance if(IsHumanPlayer(player[1])) { message(player[1],'CleanUpYourAct'); } ConsiderResponse(player[1], player[0], 1500, 1); //reject // => this should be linked in the first message if (GetEffectiveRegard(player[0],player[1])-5* NDM_Tone<100 && !AtWarWith(player[1], player[0])){ if(IsHumanPlayer(player[1])) { message(player[1],'RegardWarning'); } } LogRegardEvent(player[0],player[1],-5* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } elseif (second_type==19) {//We want him to cease piracy, he wants gold ConsiderResponse(player[0], player[1], 1500, 1); //reject message(player[1],'CounterToGoldRequestToCeasePiracy'); if (GetEffectiveRegard(player[0],player[1])-10* NDM_Tone<100 && !AtWarWith(player[1], player[0])){ if(IsHumanPlayer(player[1])) { message(player[1],'RegardWarning'); } } LogRegardEvent(player[0],player[1],-10* NDM_Tone,0,ID_NONE,5);//how did AI like the human's offering it (displeased) } elseif (second_type==23) {//We want him to cease piracy, he wants our map if (random(2)<2) {//usually ConsiderResponse(player[1], player[0], 1500, 2);//accept LogRegardEvent(player[0],player[1],-10* NDM_Tone,0,ID_NONE,5); //but we don't like it } else{ ConsiderResponse(player[0], player[1], 1500, 1); //reject } } } elseif (first_type==8) {//AI requested embassy in Human's land if (second_type==1) {//He wants our city ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==3) {//He wants us to withdraw ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==5) {//We want an embassy, he wants us to cease piracy ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==7) {//We want an embassy, he wants to establish an embassy in our land //=> maybe make this dependent on whether we desire war, and if we reject tell him we don't trust him or something if (Random(3)<1) { ConsiderResponse(player[1], player[0], 1500, 2);//accept event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; if(IsHumanPlayer(player[1])) { message(player[1],'EmbassyCounterAccepted'); } } else{ ConsiderResponse(player[0], player[1], 1500, 1); //reject } } elseif (second_type==17) {//We want an embassy, he wants an advance ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==19) {//We want an embassy, he wants gold ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==23) {//We want an embassy, he wants our map if (random(2)<2) {//usually ConsiderResponse(player[1], player[0], 1500, 2);//accept event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; if(IsHumanPlayer(player[1])) { message(player[1],'CounterAccepted'); } } else{ ConsiderResponse(player[0], player[1], 1500, 1); //reject } } } elseif (first_type==18) {//AI requested an advance if (second_type==1) {//He wants our city ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==3) {//He wants us to withdraw if((GetDesireWarWith(player[0], player[1]) //we want to be at war with him || GetEffectiveRegard(player[0],player[1])<200-5* NDM_ToneMod) //we really don't like him, || GetPiracyIncomeFrom(player[0],player[1])>GetPiracyIncomeFrom(player[1],player[0]) ){ //we're better pirates than he is LogRegardEvent(player[0],player[1],-5* NDM_Tone,0,ID_NONE,0);//how did AI like the human's offering it (irritated) ConsiderResponse(player[1], player[0], 1500, 1); //reject } else{ ConsiderResponse(player[1], player[0], 1500, 2);//accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[1],player[0]); } } elseif (second_type==5) {//We want an advance, he wants us to cease piracy ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==7) {//We want an advance, he wants to establish an embassy in our land ConsiderResponse(player[1], player[0], 1500, 2);//accept event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; if(IsHumanPlayer(player[1])) { message(player[1],'CounterAccepted'); } } elseif (second_type==17) {//We want an advance, he wants an advance // leave to default } elseif (second_type==19) {//We want an advance, he wants gold //default is prob reject } elseif (second_type==23) {//We want an advance, he wants our map // usually accept //"We gave you our map recently. Why are you so interested in our troop dispositions?" } } elseif (first_type==20) {//AI requested gold if (second_type==1) {//He wants our city ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==3) {//He wants us to withdraw ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==5) {//We want gold, he wants us to cease piracy ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==7) {//We want gold, he wants to establish an embassy in our land //=> this should depend on how much // and if the Human is rich the AI should bug him } elseif (second_type==17) {//We want gold, he wants an advance ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==19) {//We want gold, he wants gold (!!!) // ??? if he 'offers' less, we say thanks but ... // else some sort of regard warning } elseif (second_type==23) {//We want gold , he wants our map // usually accept //"We gave you our map recently. Why are you so interested in our troop dispositions?" } } elseif (first_type==24) {//AI requested his map if (second_type==1) {//He wants our city ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==3) {//He wants us to withdraw ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==5) {//We want his map, he wants us to cease piracy ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==7) {//We want his map, he wants to establish an embassy in our land //=> } elseif (second_type==17) {//We want his map, he wants an advance ConsiderResponse(player[1], player[0], 1500, 1);//reject } elseif (second_type==19) {//We want his map, he wants gold //how much? } elseif (second_type==23) {//We want his map, he wants our map //=> } } } void_f Human_Counters_Treaty_With_Request (int_t first_type, int_t second_type){ if (second_type==1) {//Human requested city ConsiderResponse(player[1], player[0], 1500, 1);//always reject for now (but remember ceasefire possibility) } elseif (second_type==7) {//Human requested embassy in our land if (AtWarWith(player[0],player[1])) { if(IsHumanPlayer(player[1])) { message(player[1].owner,'NotWhenAtWar'); } ConsiderResponse(player[1], player[0], 9999, 0);//0=invalid } elseif (!HasAdvance(player[1], ID_ADVANCE_BUREAUCRACY)) { if(IsHumanPlayer(player[1])) { message(player[1].owner,'WeNeedBureaucracy');// Dynasty for Cradle } ConsiderResponse(player[1], player[0], 9999, 0);//0=invalid } elseif (!HasAdvance(player[0], ID_ADVANCE_BUREAUCRACY)) { if(IsHumanPlayer(player[1])) { message(player[1].owner,'TheyNeedBureaucracy');// Dynasty for Cradle } ConsiderResponse(player[1], player[0], 9999, 0);//0=invalid } elseif ( NDM_HasEmbassy(player[0],player[1]) ) { ConsiderResponse(player[1], player[0], 9999, 0);//invalid if(IsHumanPlayer(player[1])) { message(player[1],'AlreadyHaveEmbassyHere'); } } elseif ( NDM_HasEmbassy(player[1],player[0]) ) { ConsiderResponse(player[1], player[0], 9999, 0);//invalid if(IsHumanPlayer(player[1])) { message(player[1],'AlreadyHaveEmbassyThere'); } } else{//Human requests embassy: accept (only viable for peace treaty) event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; ConsiderResponse(player[1], player[0], 1500, 2); //2= AI accepts human counter if(IsHumanPlayer(player[1])) { message(player[1],'CounterAccepted'); } } } elseif (second_type==3) {//Human requested withdraw NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; ConsiderResponse(player[1], player[0], 1500, 2); //2=AI accepts human counter if(IsHumanPlayer(player[1])) { message(player[1],'CounterAccepted'); } } elseif (second_type==5) {//Human requested cease piracy if (first_type==34) {//AI proposes trade pact: special message ConsiderResponse(player[1], player[0], 1500, 2);//accept } else{ ConsiderResponse(player[1], player[0], 1500, 2);//accept } } elseif (second_type==23) {//Human requested map ConsiderResponse(player[1], player[0], 1500, 2);//accept } elseif (first_type==32) {//AI proposes ceasefire // ConsiderResponse(player[1], player[0], 1500, 2);//accept // cities covered above, maps ok //what about gold? } elseif (first_type==33) {//AI proposes peace treaty // default, probably all rejects ? } elseif (first_type==34) {//AI proposes trade pact if (second_type==17) {//Human requested an advance //maybe } elseif (second_type==19) {//Human requested gold // probably, if not too much } } elseif (first_type==35) {//AI proposes research pact if (second_type==17) {//Human requested an advance ConsiderResponse(player[1], player[0], 1500, 2);//accept } elseif (second_type==19) {//Human requested gold //?? } } elseif (first_type==36) {//AI proposes military pact if (second_type==17) {//Human requested an advance } elseif (second_type==19) {//Human requested gold } } elseif (first_type==38) {//AI proposes alliance // default, probably all rejects } } void_f Human_Counters_Request_With_Treaty (int_t first_type, int_t second_type){ if (second_type==32) {//Human proposes ceasefire AI_response_to_Human_Counter_ceasefire(first_type, second_type); } elseif (second_type==33) {//Human proposes peace treaty //default, but pick this up post event } elseif (second_type==34) {//Human proposes trade pact AI_response_to_Human_Counter_trade_pact(first_type, second_type); } elseif (second_type==35) {//Human proposes research pact AI_response_to_Human_Counter_research_pact(first_type, second_type); } elseif (second_type==36) {//Human proposes military pact AI_response_to_Human_Counter_military_pact(first_type, second_type); } elseif (second_type==38) {//Human proposes alliance //default, but pick this up post event } } void_f Human_Counters_Treaty_With_Treaty (int_t first_type, int_t second_type){ if (second_type==32) {//Human proposes ceasefire AI_response_to_Human_Counter_ceasefire(first_type, second_type); } elseif (second_type==33) {//Human proposes peace treaty //default, but pick this up post event } elseif (second_type==34) {//Human proposes trade pact AI_response_to_Human_Counter_trade_pact(first_type, second_type); } elseif (second_type==35) {//Human proposes research pact AI_response_to_Human_Counter_research_pact(first_type, second_type); } elseif (second_type==36) {//Human proposes military pact AI_response_to_Human_Counter_military_pact(first_type, second_type); } elseif (second_type==38) {//Human proposes alliance //default, but pick this up post event } } // HANDLERS: HandleEvent(BeginTurn)'NewDipNumofPlayers' pre { NDM_MAX_PLAYERS= preference("MaxPlayers"); NDM_NUM_PLAYERS=preference("NumPlayers"); NDM_DIFF_LEVEL=preference("Difficulty"); if (NDM_NUM_PLAYERS< NDM_MAX_PLAYERS) { NDM_PLAYER_COUNT=NDM_MAX_PLAYERS; } else{ NDM_PLAYER_COUNT=NDM_NUM_PLAYERS; } DisableTrigger('FollowUpToRequestStopPiracy'); DisableTrigger('BaseFollowUpToOfferStopPiracy'); DisableTrigger('FollowUpToOfferStopPiracy'); DisableTrigger('NewDipNumofPlayers'); } HandleEvent(BeginTurn) 'CleanUpAgreementLogs' post { int_t i; int_t num_treaties; int_t copy1[]; int_t copy2[]; int_t copyValue[]; if (player[0].owner==0) {//on the Barb's turn if (NDM_NUM_EMBASSY_TREATIES>0) {//there were some EMBASSY_TREATIES last turn num_treaties=0; for (i=0;iceasefire on same turn? if(00) {//there were some TRESPASSING_TREATIES last turn num_treaties=0; for (i=0;i0) {//there were some CEASEFIRE_TREATIES last turn num_treaties=0; for (i=0;i0) {//there were some PEACE_TREATIES last turn num_treaties=0; for (i=0;i0) {//there were some TRADE_TREATIES last turn num_treaties=0; for (i=0;i0) {//there were some RESEARCH_TREATIES last turn num_treaties=0; for (i=0;i0) {//there were some MILITARY_TREATIES last turn num_treaties=0; for (i=0;i0) {//there were some ALLIANCE_TREATIES last turn num_treaties=0; for (i=0;i0) { for (i=0;i=NDM_TEMP_TRESPASSING_VALUE[i] ){ CancelAgreement(player[0],NDM_TEMP_TRESPASSING1[i],4); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_TRESPASSING1[i]; message(player[0],'OurTreatyExpired'); } } } if (player[0].owner==NDM_TEMP_TRESPASSING1[i]){ CurrentDuration=GetAgreementDuration(NDM_TEMP_TRESPASSING0[i],player[0],4); //they agreed not to trespass on us if (CurrentDuration==NDM_TEMP_TRESPASSING_VALUE[i]-3 && IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_TRESPASSING0[i]; message(player[0],'TheirTreatyToExpire'); } if (CurrentDuration>=NDM_TEMP_TRESPASSING_VALUE[i] ){ CancelAgreement(NDM_TEMP_TRESPASSING0[i],player[0],4); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_TRESPASSING0[i]; message(player[0],'TheirTreatyExpired'); } } } } } if (NDM_NUM_CEASEFIRE_TREATIES>0) { for (i=0;i=NDM_TEMP_CEASEFIRE_VALUE[i] ){ CancelAgreement(player[0],NDM_TEMP_CEASEFIRE1[i],32); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_CEASEFIRE1[i]; message(player[0],'OurTreatyExpired'); } } } } } if (NDM_NUM_PEACE_TREATIES>0) { for (i=0;i=NDM_TEMP_PEACE_VALUE[i] ){ CancelAgreement(player[0],NDM_TEMP_PEACE1[i],33); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_PEACE1[i]; message(player[0],'OurTreatyExpired'); } } } } } if (NDM_NUM_TRADE_TREATIES>0) { for (i=0;i=NDM_TEMP_TRADE_VALUE[i] ){ CancelAgreement(player[0],NDM_TEMP_TRADE1[i],34); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_TRADE1[i]; message(player[0],'OurTreatyExpired'); } } } } } if (NDM_NUM_RESEARCH_TREATIES>0) { for (i=0;i=NDM_TEMP_RESEARCH_VALUE[i]){ CancelAgreement(player[0],NDM_TEMP_RESEARCH1[i],35); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_RESEARCH1[i]; message(player[0],'OurTreatyExpired'); } } } } } if (NDM_NUM_MILITARY_TREATIES>0) { for (i=0;i=NDM_TEMP_MILITARY_VALUE[i] ){ CancelAgreement(player[0],NDM_TEMP_MILITARY1[i],36); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_MILITARY1[i]; message(player[0],'OurTreatyExpired'); } } } } } if (NDM_NUM_ALLIANCE_TREATIES>0) { for (i=0;i=NDM_TEMP_ALLIANCE_VALUE[i] ){ CancelAgreement(player[0],NDM_TEMP_ALLIANCE1[i],38); if (IsHumanPlayer(player[0]) ){ player[2]=NDM_TEMP_ALLIANCE1[i]; message(player[0],'OurTreatyExpired'); } } } } } } } //////////////////////////////// // // Regard Modifiers // //////////////////////////////// int_t SL; int_t ML; int_t TL; int_t PL; int_t GL; int_t CL; HandleEvent(BeginTurn) 'ShowLeaders' pre { if (player[0]==1) { SL=NDM_GetScienceLeader(); ML=NDM_GetMilitaryLeader(); TL=NDM_GetTradeLeader(); PL=NDM_GetPopulationLeader(); GL=NDM_GetGeographicLeader(); CL=NDM_GetCitiesLeader(); // message(1,'ReportLeaders'); } } messagebox 'ReportLeaders' { Text (ID_ReportLeadersM) ; } //maybe this should also be a function of the game turn HandleEvent(NextDiplomaticState)'AI_Regard_Modifiers' pre { if (!IsHumanPlayer(player[0]) && player[0]>0) { if (player[1]==NDM_GetScienceLeader()) { LogRegardEvent(player[0],player[1], -10, 0, ID_NONE, 0); //Increased by Pedrunn: from -2 to -10 if (IsHumanPlayer(player[1])) { LogRegardEvent(player[0],player[1], -10, 0, ID_NONE, 0); //Increased by Pedrunn: from -2 to -10 } } if (player[1]==NDM_GetMilitaryLeader()) { LogRegardEvent(player[0],player[1], -10, 0, ID_NONE, 0); //Increased by Pedrunn: from -2 to -10 if (IsHumanPlayer(player[1])) { LogRegardEvent(player[0],player[1], -10, 0, ID_NONE, 0); //Increased by Pedrunn: from -2 to -10 } } if (player[1]==NDM_GetTradeLeader()) { LogRegardEvent(player[0],player[1], -10, 0, ID_NONE, 0); //Increased by Pedrunn: from -2 to -10 if (IsHumanPlayer(player[1])) { LogRegardEvent(player[0],player[1], -10, 0, ID_NONE, 0); //Increased by Pedrunn: from -2 to -10 } } if (player[1]==NDM_GetPopulationLeader()) { LogRegardEvent(player[0],player[1], -2, 0, ID_NONE, 0); if (IsHumanPlayer(player[1])) { LogRegardEvent(player[0],player[1], -2, 0, ID_NONE, 0); } } if (player[1]==NDM_GetGeographicLeader()) { LogRegardEvent(player[0],player[1], -2, 0, ID_NONE, 0); if (IsHumanPlayer(player[1])) { LogRegardEvent(player[0],player[1], -2, 0, ID_NONE, 0); } } if (player[1]==NDM_GetCitiesLeader()) { LogRegardEvent(player[0],player[1], -2, 0, ID_NONE, 0); if (IsHumanPlayer(player[1])) { LogRegardEvent(player[0],player[1], -2, 0, ID_NONE, 0); } } } } //////////////////////////////// // AI INITIATES A NEW PROPOSAL: //////////////////////////////// //AI sends to AI: HandleEvent(NextDiplomaticState)'AI_to_AI_Proposal_Generator' pre { int_t MilitaryLeader; int_t tmpPlayer; int_t PersBonus; int_t CommonHumanEnemy; int_t i; if (!IsHumanPlayer(player[0]) && 0 60-(8*NDM_DIFF_LEVEL) ){ // so max turns at war =52 at easy to 20 at impossible LogRegardEvent(player[0],player[1], 400, 0, ID_NONE, 0); SetTrust(player[0],player[1], 500); ConsiderNewProposal(player[0],player[1], 2000,32,0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0],player[1]); } } // request no trespassing (withdraw troops) if (!HasAgreement(player[0], player[1], 4) && !AtWarWith(player[0],player[1]) ){ // if first AIciv is much stronger than second AIciv if (MilitaryRank(player[0])-MilitaryRank(player[1])>40) { ConsiderNewProposal(player[0],player[1], 2000,4,0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0],player[1]); } } // request establish embassy // as soon as the first civ gets Bureaucracy it will try to establish an embassy //in the territory of every other AIciv with which it's made contact //can't get an AIciv to respond to 8 if (!AtWarWith(player[0],player[1]) && !NDM_HasEmbassy(player[0],player[1]) && HasAdvance(player[0], ID_ADVANCE_BUREAUCRACY) && HasAdvance(player[1], ID_ADVANCE_BUREAUCRACY)){ //DYNASTY for Cradle Event:EstablishEmbassy(player[0], player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } // offer honor military agreement //maybe have to load special dip state so they won't accept a cease fire //also make this a function of game turn MilitaryLeader=NDM_GetMilitaryLeader(); if(!AtWarWith(player[0],MilitaryLeader) && AtWarWith(player[1],MilitaryLeader) && HasAgreement(player[0], player[1], 36) && IsHumanPlayer(MilitaryLeader)){ if (TurnsAtWar(player[1],MilitaryLeader)>30-(4*NDM_DIFF_LEVEL)) {//wait till warturn 26 at easy to warturn 10 at impossible LogRegardEvent(player[0],player[1], 400, 0, ID_NONE, 0); SetTrust(player[0],player[1], 500); // ConsiderNewProposal(player[0],player[1], 2000,25,0,ID_NONE,ID_NONE,ID_NONE); // Event:NewProposal(player[0],player[1]); } } if (HasAgreement(player[0], player[1],32) && !HasAgreement(player[0], player[1],33) ) { //if they have a cease-fire but not a peace treaty, offer one if (TurnsSinceLastWar(player[0], player[1])> 41-(8*NDM_DIFF_LEVEL) ){//wait till peaceturn 52 at easy to peaceturn 20 at impossible LogRegardEvent(player[0],player[1], 400, 0, ID_NONE, 0); SetTrust(player[0],player[1], 500); ConsiderNewProposal(player[0], player[1], 2000, 33, 0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0], player[1]); } } // offer military pact in the following circumstances: //leave AI-AI with old function if(!AtWarWith(player[0],MilitaryLeader) && !AtWarWith(player[1],MilitaryLeader) && !AtWarWith(player[0],player[1]) && MilitaryRank(player[0])< (90-10*NDM_DIFF_LEVEL) && MilitaryRank(player[1])< (90-10*NDM_DIFF_LEVEL) //=>? //&& IsHumanPlayer(MilitaryLeader) ){ if (!HasAgreement(player[0], player[1],33) ) { LogRegardEvent(player[0],player[1], 400, 0, ID_NONE, 0); SetTrust(player[0],player[1], 500); ConsiderNewProposal(player[0], player[1], 2000, 33, 0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0], player[1]); } if(HasAgreement(player[0], player[1],33) && !HasAgreement(player[0], player[1],36)){ //if they have a peace treaty but not a military pact, offer one LogRegardEvent(player[0],player[1], 400, 0, ID_NONE, 0); SetTrust(player[0],player[1], 800); ConsiderNewProposal(player[0], player[1], 2000, 36, 0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0], player[1]); } } //offer trade pact if (!HasAgreement(player[0], player[1],34) ){//trade pact if (GetPersonalityType(player[0])==5) {//Medici (economic) PersBonus=5; } else{ PersBonus=0; } if ( !AtWarWith(player[0],player[1]) && TradeRank(player[0])< (40+PersBonus+10*NDM_DIFF_LEVEL)//50% at easy to 90% at impossible && TradeRank(player[1])< (40+10*NDM_DIFF_LEVEL) //=>? // && IsHumanPlayer(NDM_GetTradeLeader()) ) { // if they're both behind a human in trade and he is #1 // LogRegardEvent(player[0],player[1], 400, 0, ID_NONE, 0); // SetTrust(player[0],player[1], 600); ConsiderNewProposal(player[0], player[1], 2000, 34, 0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0], player[1]); } } // offer research pact if (!HasAgreement(player[0], player[1],35)) {//research pact if (GetPersonalityType(player[0])==6 || GetPersonalityType(player[0])==7) {//scientist PersBonus=5; } else{ PersBonus=0; } if ( !AtWarWith(player[0],player[1]) && KnowledgeRank(player[0])< (35+PersBonus-10*NDM_DIFF_LEVEL) && KnowledgeRank(player[1])< (35-10*NDM_DIFF_LEVEL) && NDM_HasEmbassy(player[0],player[1]) //=>? // && IsHumanPlayer(NDM_GetScienceLeader()) ) { // if they're both behind a human in science and he is #1 // LogRegardEvent(player[0],player[1], 400, 0, ID_NONE, 0); // SetTrust(player[0],player[1], 600); ConsiderNewProposal(player[0], player[1], 2000, 35, 0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0], player[1]); } } // form alliance: CommonHumanEnemy=0; for (i=1;i0){ //if both sender and recipient are at war with a Human if (!HasAgreement(player[0], player[1],33) ) { // UNUSED: Pedrunn kept the idea of making treats but removed the idea of making them totally love each other. //=> test // LogRegardEvent(player[0],player[1], 100, 0, ID_NONE, 0);// make them love each other // LogRegardEvent(player[1],player[0], 100, 0, ID_NONE, 0); // SetTrust(player[0],player[1], 900); //and trust each other // SetTrust(player[0],player[1], 900); ConsiderNewProposal(player[0], player[1], 2000, 33, 0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0], player[1]); } if(HasAgreement(player[0], player[1],33) && !HasAgreement(player[0], player[1],38)){ //if they have a peace treaty but not an alliance, offer one ConsiderNewProposal(player[0], player[1], 2000, 38, 0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0], player[1]); } } } } // UNUSED: Pedrunn Thought it looked a test code. // AI responds to AI: HandleEvent(NewProposal) 'AI_Responses_to_AI_Proposals' pre { // player[0] is sender // player[1] is receiver int_t first_type; //initial proposal first_type = GetLastNewProposalType(player[0], player[1], 0); // player[0] and player[1] reversed in ConsiderResponse if(!IsHumanPlayer(player[0]) && !IsHumanPlayer(player[1])) { if (first_type==4) { //WHENEVER an AI civ requests a no trespassing agreement from another if (GetEffectiveRegard(player[1], player[0])>300) { ConsiderResponse(player[1], player[0], 3000, 2);//2=accept NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0],player[1]); } } if (first_type==8){ // WHENEVER an AIciv requests of another that it be allowed to establish an embassy // It won't do this, i.e., consider this response (maybe because 7 and 8 were disabled): if (GetEffectiveRegard(player[1], player[0])>300) { ConsiderResponse(player[1], player[0], 3000, 2);//2=accept //So the embassy was established when they sent the proposal. Remember that HasAgreement(...,8) //and HasAgreement(...,7) always ==0 for AI civs } } if (first_type==32) {//WHENEVER an AI civ offers a cease fire to another if (GetEffectiveRegard(player[1], player[0])>150) { ConsiderResponse(player[1], player[0], 3000, 2);//2=accept NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0].owner; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1].owner; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=60; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; //=>now that 7/8 have NoHotWar flag, have to put these in post? Event:EstablishEmbassy(player[0], player[1]);//ceasefires entail mutual diplomatic relations NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; Event:EstablishEmbassy(player[1], player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } } elseif (first_type==33) {//WHENEVER an AI civ offers a peace treaty to another if (GetEffectiveRegard(player[1], player[0])>400) { //ADDED: by Pedrunn ConsiderResponse(player[1], player[0], 3000, 2);//2=accept NDM_TEMP_PEACE0[NDM_NUM_PEACE_TREATIES]=player[0].owner; NDM_TEMP_PEACE1[NDM_NUM_PEACE_TREATIES]=player[1].owner; NDM_TEMP_PEACE_VALUE[NDM_NUM_PEACE_TREATIES]=60; NDM_NUM_PEACE_TREATIES=NDM_NUM_PEACE_TREATIES+1; } } elseif (first_type==34) {//trade pact, just accept from any AI if (GetEffectiveRegard(player[1], player[0])>550) { //ADDED: by Pedrunn ConsiderResponse(player[1], player[0], 3000, 2);//2=accept NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=60; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; } } elseif (first_type==35) {//research pact, just accept from any AI if (GetEffectiveRegard(player[1], player[0])>650) { //ADDED: by Pedrunn ConsiderResponse(player[1], player[0], 3000, 2);//2=accept NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=60; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; } } elseif (first_type==36) {//military pact, just accept from any AI if (GetEffectiveRegard(player[1], player[0])>500) { //ADDED: by Pedrunn ConsiderResponse(player[1], player[0], 3000, 2);//2=accept NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=60; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; } } elseif (first_type==38) { //alliance (note short term) if (GetEffectiveRegard(player[1], player[0])>700) { //ADDED: by Pedrunn ConsiderResponse(player[1], player[0], 3000, 2);//2=accept NDM_TEMP_ALLIANCE0[NDM_NUM_ALLIANCE_TREATIES]=player[0].owner; NDM_TEMP_ALLIANCE1[NDM_NUM_ALLIANCE_TREATIES]=player[1].owner; NDM_TEMP_ALLIANCE_VALUE[NDM_NUM_ALLIANCE_TREATIES]=30; NDM_NUM_ALLIANCE_TREATIES=NDM_NUM_ALLIANCE_TREATIES+1; } } } } // AI sends to Human: //0: initialize handler HandleEvent(ContinueDiplomacy) 'ReEnable_AI_to_Human_Proposal_Generator' pre{ if (!IsHumanPlayer(player[0]) && player[0]>0 && IsHumanPlayer(player[1]) && NDM_DIFF_LEVEL!=0 ){ // CantEndTurn(0); //EnableTrigger('AI_to_Human_Proposal_Generator'); } } //1: create new proposals (consider at most one of these per turn) HandleEvent(ReactionMotivation)'AI_to_Human_Proposal_Generator' pre { int_t MilitaryLeader;// the player whose MilitaryRank==100 int_t PersBonus;//bonus given, dependent on sender personality int_t Rnd; if (!IsHumanPlayer(player[0]) && player[0]>0 && IsHumanPlayer(player[1]) && NDM_DIFF_LEVEL!=0 ){ //=> for testing responses to counters: // ConsiderNewProposal(player[0].owner,player[1].owner,2000,8,0,ID_NONE,ID_NONE,ID_NONE); Rnd=Random(100); if (Rnd<5) { // 7: offer establish embassy in AI's land if ( !AtWarWith(player[0],player[1]) && !NDM_HasEmbassy(player[1],player[0]) && HasAdvance(player[0], ID_ADVANCE_BUREAUCRACY) && HasAdvance(player[1], ID_ADVANCE_BUREAUCRACY) && GetEffectiveRegard(player[0], player[1])>400){//if we don't dislike him, offer him the chance of // establishing an embassy in our empire ConsiderNewProposal(player[0],player[1],2000,7,0,ID_NONE,ID_NONE,ID_NONE); CantEndTurn(1); } } elseif (Rnd<15) { // 8: request establish embassy in Human's land if (!AtWarWith(player[0],player[1]) && !NDM_HasEmbassy(player[0],player[1]) && HasAdvance(player[0], ID_ADVANCE_BUREAUCRACY) && HasAdvance(player[1], ID_ADVANCE_BUREAUCRACY) ){ ConsiderNewProposal(player[0],player[1],2000,8,0,ID_NONE,ID_NONE,ID_NONE); CantEndTurn(1); } } elseif (Rnd<25) { // 34: offer trade pact if (!HasAgreement(player[0], player[1],34) && !AtWarWith(player[0],player[1])) {//trade pact if (GetPersonalityType(player[0])==5) {//Medici (economic) PersBonus=5; } else{ PersBonus=0; } if ( TradeRank(player[0])< (90+PersBonus-10*NDM_DIFF_LEVEL)/100 && TradeRank(player[1])< (90-10*NDM_DIFF_LEVEL)){ //40% at impossible to 80% at easy // message(player[1],'ShortTermAgreement'); ConsiderNewProposal(player[0], player[1], 1500, 34, 0,ID_NONE,ID_NONE,ID_NONE); CantEndTurn(1); } } } elseif (Rnd<35) { // 35: offer research pact if (!HasAgreement(player[0], player[1],35) && !AtWarWith(player[0],player[1])) {//research pack if (GetPersonalityType(player[0])==6 || GetPersonalityType(player[0])==7) {//scientist PersBonus=5; } else{ PersBonus=0; } if ( KnowledgeRank(player[0])< (35+PersBonus-5*NDM_DIFF_LEVEL) && KnowledgeRank(player[1])< (35-5*NDM_DIFF_LEVEL) && NDM_HasEmbassy(player[0],player[1]) && NDM_HasEmbassy(player[1],player[0]) ){ // message(player[1],'ShortTermAgreement'); ConsiderNewProposal(player[0], player[1], 1500, 35, 0,ID_NONE,ID_NONE,ID_NONE); CantEndTurn(1); } } } elseif (Rnd<40) { // 36: offer military pact MilitaryLeader=NDM_GetMilitaryLeader(); if (GetPersonalityType(player[0])==2 || GetPersonalityType(player[0])==3 || GetPersonalityType(player[0])==4 ){//militarist PersBonus=5; } else{ PersBonus=0; } if(!AtWarWith(player[0],MilitaryLeader) && !AtWarWith(player[1],MilitaryLeader) && !AtWarWith(player[0],player[1]) && MilitaryRank(player[0])< (45+PersBonus-5*NDM_DIFF_LEVEL) && MilitaryRank(player[1])< (45-5*NDM_DIFF_LEVEL) && HasAgreement(player[0], player[1],33) //must have peace treaty && !HasAgreement(player[0], player[1],36)){ ConsiderNewProposal(player[0], player[1], 1500, 36, 0,ID_NONE,ID_NONE,ID_NONE); CantEndTurn(1); } } } } //since the reaction motivation event can occur more than once, these may need tweaking: HandleEvent(ReactionMotivation) 'FollowUpToRequestStopPiracy' pre { if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && NDM_DIFF_LEVEL!=0 && HasAgreement(player[0], player[1],6) && !HasAgreement(player[1], player[0],6) ){ PIRACY_FLG_34_6=1; ConsiderNewProposal(player[0], player[1], 2000, 5, 0,ID_NONE,ID_NONE,ID_NONE); message(player[1],'FollowUpRequestStopPiracy'); } } HandleEvent(ReactionMotivation) 'FollowUpToOfferStopPiracy' pre { // sometimes a civ will keep after a human to sign a no piracy agreement if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && NDM_DIFF_LEVEL!=0 && HasAgreement(player[0], player[1],6) && !HasAgreement(player[1], player[0],6) ){ if (HasAgreement(player[0], player[1],34)) { setstring(0,ID_TradePact); if (PIRACY_FLG_34_5==1) {//on the next turn ConsiderNewProposal(player[0], player[1], 2000, 6, 0,ID_NONE,ID_NONE,ID_NONE); message(player[1],'FollowUpOfferStopPiracyFirst'); PIRACY_FLG_34_5=2; } elseif (PIRACY_FLG_34_5 >1){ if (Random(2)<1) {//and randomly thereafter ConsiderNewProposal(player[0], player[1], 2000, 6, 0,ID_NONE,ID_NONE,ID_NONE); message(player[1],'FollowUpOfferStopPiracyNext'); } } } } } HandleEvent(ReactionMotivation) 'BaseFollowUpToOfferStopPiracy' pre { if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && NDM_DIFF_LEVEL!=0 && GetLastColdwarAttack(player[0], player[1]) >3 ){ message(player[1],'HeresTheGold'); ConsiderNewProposal(player[0], player[1], 2000, 19, PIRACY_FLG_5_20,ID_NONE,ID_NONE,ID_NONE); } } // 2: send New Proposal HandleEvent(NewProposal) 'Disable_AI_Proposal_generator' pre { if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && NDM_DIFF_LEVEL!=0 ) { // CantEndTurn(1);//don't end this AI turn until the Human responds } // DisableTrigger('AI_to_Human_Proposal_Generator');//try tp give the human time to respond } HandleEvent(NewProposalReady) 'AINewProposalReady' post { //use this event to pick up default SENDER/RECEIVER values when AI sends proposal outside of AI_to_Human proposal generators // and to deal with AI to human No Trespassing int_t first_type; //initial proposal int_t second_type; // following proposal int_t i; first_type = GetLastNewProposalType(player[0], player[1], 0); second_type= GetLastNewProposalType(player[0], player[1], 1); NP_FIRST_TYPE=first_type; NP_SECOND_TYPE=second_type; if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && NDM_DIFF_LEVEL!=0 ){ if (32<=first_type && first_type <=38) { message(player[1],'ShortTermAgreement'); } if (first_type==3) { message(player[1],'ShortTermAgreement'); } if (first_type==4) { message(player[1],'RequestShortTermAgreement'); } } } //2.1 Human accepts AI's proposal HandleEvent(NewNegotiationEvent) 'Human_Accepts_AI_Embassy_or_Treaty_Proposal' pre {//pre? //this is AI, there is no second type int_t first_type; //initial new proposal type int_t Response_type; // response type (accept/reject, etc) first_type = GetLastNewProposalType(player[0], player[1], 0); Response_type=GetLastResponseType(player[1], player[0],0); if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) ) { CantEndTurn(0); if (Response_type==2 ) {//Human accepted proposal if (first_type==7 ) { event:EstablishEmbassy(player[1], player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif (first_type==8) { event:EstablishEmbassy(player[0], player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif (first_type==3) { NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=30; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } elseif (first_type==4) { NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=30; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } elseif (first_type==32) { NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[1]; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[0]; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=30; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; Event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; Event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif (first_type==33) { NDM_TEMP_PEACE0[NDM_NUM_PEACE_TREATIES]=player[1]; NDM_TEMP_PEACE1[NDM_NUM_PEACE_TREATIES]=player[0]; NDM_TEMP_PEACE_VALUE[NDM_NUM_PEACE_TREATIES]=30; NDM_NUM_PEACE_TREATIES=NDM_NUM_PEACE_TREATIES+1; } elseif (first_type==34) { NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[1]; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[0]; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=30; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; } elseif (first_type==35) { NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[1]; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[0]; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=30; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; } elseif (first_type==36) { NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[1]; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[0]; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=30; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; } elseif (first_type==38) { NDM_TEMP_ALLIANCE0[NDM_NUM_ALLIANCE_TREATIES]=player[1]; NDM_TEMP_ALLIANCE1[NDM_NUM_ALLIANCE_TREATIES]=player[0]; NDM_TEMP_ALLIANCE_VALUE[NDM_NUM_ALLIANCE_TREATIES]=30; NDM_NUM_ALLIANCE_TREATIES=NDM_NUM_ALLIANCE_TREATIES+1; } } } } //not very efficient: HandleEvent(NewNegotiationEvent) 'Human_Accepts_AI_Piracy_Followup' pre { int_t first_type; //initial proposal int_t Response_type; // response type (accept/reject, etc) int_t i; Response_type=GetLastResponseType(player[1], player[0],0); if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && Response_type==2 ) { first_type = GetLastNewProposalType(player[0], player[1], 0); if (first_type==5 && PIRACY_FLG_34_5 >0) { DisableTrigger('FollowUpToRequestStopPiracy'); PIRACY_FLG_34_5=0; } if (first_type==6 && PIRACY_FLG_34_6 >0) { DisableTrigger('FollowUpToOfferStopPiracy'); PIRACY_FLG_34_6=0; } if (first_type==5 && PIRACY_FLG_5_20 >0) { DisableTrigger('BaseFollowUpToOfferStopPiracy'); PIRACY_FLG_5_20=0; } } } //2.2: AI sent New Proposal, Human countered, and now the AI is considering how to respond: HandleEvent(Counter) 'Switch_for_AI_Responses_to_Human_Counters' pre { // player[0] is AI SENDER and player[1] is human RECEIVER, who countered SENDER's new proposal //can't choose treaty length, so: NDM_TREATY_LENGTH=30; if (CR_first_type==2 || CR_first_type==4 || CR_first_type==6 || CR_first_type==8 || CR_first_type==18 || CR_first_type==20 || CR_first_type==24) {// AI made request: if (CR_second_type==1 || CR_second_type==3 || CR_second_type==5 || CR_second_type==7 || CR_second_type==17 || CR_second_type==19 || CR_second_type==21 || CR_second_type==23) {// Human countered with request, the second_type indices are the reciprocals: if (CR_second_type==3) { if(IsHumanPlayer(player[1])) { message(player[1],'TreatyLength'); } } Human_Counters_Request_With_Request(CR_first_type,CR_second_type); } elseif (CR_second_type==32 || CR_second_type==33 || CR_second_type==34 || CR_second_type==35 || CR_second_type==36 || CR_second_type==38) { //Human countered with treaty: if(IsHumanPlayer(player[1])) { message(player[1],'TreatyLength'); } Human_Counters_Request_With_Treaty(CR_first_type,CR_second_type); } } elseif (CR_first_type==1 || CR_first_type==3 || CR_first_type==5 || CR_first_type==7 || CR_first_type==17 || CR_first_type==19 || CR_first_type==21 || CR_first_type==23) {// AI made offer: if (CR_second_type==2 || CR_second_type==4 || CR_second_type==6 || CR_second_type==8 || CR_second_type==18 || CR_second_type==20 || CR_second_type==24) {// Human countered with offer: the second_type indices are the reciprocals if (CR_second_type==4) { if(IsHumanPlayer(player[1])) { message(player[1],'TreatyLength'); } } Human_Counters_Treaty_or_Offer_With_Offer(CR_first_type,CR_second_type); } elseif (CR_second_type==32 || CR_second_type==33 || CR_second_type==34 || CR_second_type==35 || CR_second_type==36 || CR_second_type==38) { if(IsHumanPlayer(player[1])) { message(player[1],'TreatyLength'); } Human_Counters_Offer_With_Treaty(CR_first_type,CR_second_type); } } elseif (CR_first_type==32 || CR_first_type==33 || CR_first_type==34 || CR_first_type==35 || CR_first_type==36 || CR_first_type==38) { //AI proposed treaty if (CR_second_type==1 || CR_second_type==3 || CR_second_type==5 || CR_second_type==7 || CR_second_type==17 || CR_second_type==19 || CR_second_type==21 || CR_second_type==23) { //Human countered with request: the second_type indices are the reciprocals if (CR_second_type==3) { if(IsHumanPlayer(player[1])) { message(player[1],'TreatyLength'); } } Human_Counters_Treaty_With_Request(CR_first_type,CR_second_type); } elseif (CR_second_type==2 || CR_second_type==4 || CR_second_type==6 || CR_second_type==8 || CR_second_type==18 || CR_second_type==20 || CR_second_type==24) {// Human countered with offer: the second_type indices are the reciprocals if (CR_second_type==4) { if(IsHumanPlayer(player[1])) { message(player[1],'TreatyLength'); } } Human_Counters_Treaty_or_Offer_With_Offer(CR_first_type,CR_second_type); } elseif (CR_second_type==32 || CR_second_type==33 || CR_second_type==34 || CR_second_type==35 || CR_second_type==36 || CR_second_type==38) { if(IsHumanPlayer(player[1])) { message(player[1],'TreatyLength'); Human_Counters_Treaty_With_Treaty(CR_first_type,CR_second_type); } } } } HandleEvent(Counter) 'Results_of_AI_Responses_to_Human_Counters' post { // player[0] is AI SENDER and player[1] is human RECEIVER, who countered SENDER's new proposal if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && GetLastResponseType(player[0], player[1],0)==2) { //AI SENDER to Human RECEIVER AI accepts Human counter NP_FIRST_TYPE=GetLastNewProposalType(player[0], player[1], 0); NP_SECOND_TYPE=GetLastNewProposalType(player[0], player[1], 1); CR_first_type=GetLastCounterResponseType(player[1], player[0],0); CR_second_type=GetLastCounterResponseType(player[1], player[0],1); if ( //Human countered with treaty: CR_second_type==32 || CR_second_type==33 || CR_second_type==34 || CR_second_type==35 || CR_second_type==36 || CR_second_type==38 //Human countered with offer: || CR_second_type==2 || CR_second_type==4 || CR_second_type==6 || CR_second_type==8 || CR_second_type==18 || CR_second_type==20 || CR_second_type==24 ){ if (CR_first_type==4 || CR_second_type==4) {// AI requested withdraw or Human counter offered withdraw NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } elseif (CR_first_type==8 || CR_second_type==8) {// AI requested embassy or Human counter offered embassy event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif (CR_first_type==3) {// AI offered to withdraw NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1].owner; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0].owner; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[1],player[0]); } elseif (CR_first_type==7) {// AI offered embassy event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif (CR_first_type==32) {//AI proposed ceasefire NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[1]; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[0]; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; //=> CounterOffer message(player[0],'OfferAccepted'); } elseif (CR_first_type==33) {//AI proposed peace treaty //=> this is handled by the temporary NewNegotiationEvent handler 'AI_Accepts_Peace_Treaty' } elseif (CR_first_type==34) {//AI proposed trade pact NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[1].owner; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[0].owner; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; } elseif (CR_first_type==35) {//AI proposed research pact NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[1].owner; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[0].owner; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; } elseif (CR_first_type==36) {//AI proposed military pact NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[1].owner; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[0].owner; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; } elseif (CR_first_type==38) {//AI proposed alliance //=>see above } } } } // end of handlers for when AI sends a proposal //////////////////////////////// // // HUMAN INITIATES NEW PROPOSAL: // //////////////////////////////// // these two set a treaty length when the human offers a treaty: trigger 'NewTreatyDataInitialProp' on "DipWizard.Stage1.Tabs.Treaty.TabPanel" when (1) {//initial proposal message(g.player,'TreatyLength'); } trigger 'NewTreatyDataFollowingProp' on "DipWizard.Stage2.Tabs.Treaty.TabPanel" when (1) {//secondary proposal int_t second_type; // following proposal message(g.player,'TreatyLength'); } alertbox 'TreatyLength' { Text (ID_TreatyTypeM); Button(ID_unlimited){ NDM_TREATY_LENGTH=999; kill(); } Button(ID_medium){ NDM_TREATY_LENGTH=60; kill(); } Button(ID_short){ NDM_TREATY_LENGTH=30; kill(); } } ////////////////////////////////////////////////////////////////////////// // // A Human has sent a New Proposal to an AIciv; here's how it responds: // ////////////////////////////////////////////////////////////////////////// HandleEvent(NewProposal) 'Switch_AI_Responses_On' pre { int_t first_type; //initial proposal int_t second_type; // following proposal if ( IsHumanPlayer(player[0]) && !IsHumanPlayer(player[1])){ //the same way to both human and others AI // set parameters: NDM_ToneMod=NDM_SetToneModifier(player[0], player[1]); NDM_Tone=GetLastNewProposalTone(player[0], player[1]); NDM_sender_gold_result = GetNewProposalResult(player[0], player[1], player[0], 1); NDM_receiver_gold_result = GetNewProposalResult(player[0], player[1], player[1], 1); NDM_sender_science_result = GetNewProposalResult(player[0], player[1], player[0], 0); NDM_receiver_science_result = GetNewProposalResult(player[0], player[1], player[1], 0); first_type = GetLastNewProposalType(player[0], player[1], 0); second_type= GetLastNewProposalType(player[0], player[1], 1); // first check special treaty responses if (second_type==32) { AI_Responses_to_Human_Proposals_ceasefire_second(first_type,32); } elseif (second_type==33) { AI_Responses_to_Human_Proposals_peace_treaty(first_type,33); } elseif (second_type==34) { AI_Responses_to_Human_Proposals_trade_pact_second(first_type,34); } elseif (second_type==35) { AI_Responses_to_Human_Proposals_research_pact_second(first_type,35); } elseif (second_type==36) { AI_Responses_to_Human_Proposals_military_pact_second(first_type,36); } elseif (second_type==38) { AI_Responses_to_Human_Proposals_alliance(first_type,37); } //otherwise proceed normally elseif ((first_type==1 && second_type==2) || (first_type==2 && second_type==1)) { AI_Responses_to_Human_Proposals_exchange_cities(1,2); } elseif(first_type==1 ){ AI_Responses_to_Human_Proposals_offer_cities(first_type,second_type); } elseif(first_type==2) { AI_Responses_to_Human_Proposals_request_cities(first_type,second_type); } elseif((first_type==3 && second_type==4) || (first_type==4 && second_type==3)) { AI_Responses_to_Human_Proposals_exchange_withdraw_troops(first_type,second_type); } elseif(first_type==3 ){ AI_Responses_to_Human_Proposals_offer_withdraw_troops(first_type,second_type); } elseif(first_type==4 ) { AI_Responses_to_Human_Proposals_request_withdraw_troops(first_type,second_type); } elseif((first_type==5 && second_type==6) || (first_type==6 && second_type==5)) { AI_Responses_to_Human_Proposals_exchange_no_piracy(first_type,second_type); } elseif(first_type==5 ){ AI_Responses_to_Human_Proposals_offer_no_piracy(first_type,second_type); } elseif(first_type==6 ) { AI_Responses_to_Human_Proposals_request_no_piracy(first_type,second_type); } elseif(first_type==7 || second_type==7 || first_type==8 || second_type==8) {//special case AI_Responses_to_Human_Proposals_embassy_agreements(first_type,second_type); } elseif((first_type==17 && second_type==18) || (first_type==18 && second_type==17)) { AI_Responses_to_Human_Proposals_exchange_advances(first_type,second_type); } elseif(first_type==17 ){ AI_Responses_to_Human_Proposals_offer_advance(first_type,second_type); } elseif(first_type==18) { AI_Responses_to_Human_Proposals_request_advance(first_type,second_type); } //no exchange gold, it's too dumb elseif(first_type==19){ AI_Responses_to_Human_Proposals_offer_gold(first_type,second_type); } elseif(first_type==20) { AI_Responses_to_Human_Proposals_request_gold(first_type,second_type); } //no exchange maps, done separately elseif(first_type==23){ AI_Responses_to_Human_Proposals_offer_map(first_type,second_type); } elseif(first_type==24) { AI_Responses_to_Human_Proposals_request_map(first_type,second_type); } elseif(first_type==32) { AI_Responses_to_Human_Proposals_ceasefire(first_type,second_type); } elseif(first_type==33) { AI_Responses_to_Human_Proposals_peace_treaty(first_type,second_type); } elseif(first_type==34) { AI_Responses_to_Human_Proposals_trade_pact(first_type,second_type); } elseif(first_type==35) { AI_Responses_to_Human_Proposals_research_pact(first_type,second_type); } elseif(first_type==36) { AI_Responses_to_Human_Proposals_military_pact(first_type,second_type); } elseif(first_type==38) { AI_Responses_to_Human_Proposals_alliance(first_type,second_type); } } } // TEMPORARY: HandleEvent(NewNegotiationEvent) 'AI_Accepts_Peace_Treaty' post { int_t first_type; //initial proposal int_t second_type; // following proposal int_t Response_type; // response type (accept/reject, etc) Response_type=GetLastResponseType(player[1], player[0],0); if (!IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && Response_type==2) { first_type = GetLastNewProposalType(player[0], player[1], 0); second_type= GetLastNewProposalType(player[0], player[1], 1); if( first_type ==33 || second_type==33 ){ NDM_TREATY_LENGTH=30; NDM_TEMP_PEACE0[NDM_NUM_PEACE_TREATIES]=player[0].owner; NDM_TEMP_PEACE1[NDM_NUM_PEACE_TREATIES]=player[1].owner; NDM_TEMP_PEACE_VALUE[NDM_NUM_PEACE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_PEACE_TREATIES=NDM_NUM_PEACE_TREATIES+1; } } } // when the AIciv countered the Human's proposal, // here's what happens if the Human accepts the counter HandleEvent(NewNegotiationEvent) 'HumanAcceptsAICounter' pre { //int_t CR_first_type; //int_t CR_second_type; //int_t RES_first_type; RES_first_type=GetLastResponseType(player[0], player[1],0); CR_first_type=GetLastCounterResponseType(player[1],player[0],0); CR_second_type=GetLastCounterResponseType(player[1],player[0],1); if (IsHumanPlayer(player[0]) && !IsHumanPlayer(player[1]) && RES_first_type==2) { if ((CR_first_type==3 && CR_second_type==4) || (CR_first_type==4 && CR_second_type==3) ) {//mutual withdraw NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0] ; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0].owner,player[1].owner); NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } elseif (CR_first_type==3 && CR_second_type==33) {//Human offered to withdraw & AI countered by requesting peace treaty NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_TEMP_PEACE0[NDM_NUM_PEACE_TREATIES]=player[1]; NDM_TEMP_PEACE1[NDM_NUM_PEACE_TREATIES]=player[0]; NDM_TEMP_PEACE_VALUE[NDM_NUM_PEACE_TREATIES]=30; NDM_NUM_PEACE_TREATIES=NDM_NUM_PEACE_TREATIES+1; } elseif (CR_first_type==4 && CR_second_type==19) {//Human requested withdraw && AI countered with request for gold NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0] ; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[0].owner,player[1].owner); } elseif (CR_first_type==5) {//Human offered cease piracy if (NP_second_type==20 && CR_second_type==0) {//AI countered his offer to stop piracy PIRACY_FLG_5_20= NDM_sender_gold_result ; // the gold he wanted EnableTrigger('BaseFollowUpToOfferStopPiracy'); } } elseif ((CR_first_type==8 && CR_second_type==7)||(CR_first_type==7 && CR_second_type==8)) {// embassy exchange event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1]; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0]; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0]; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1]; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } elseif (CR_first_type==7) {//Human offered embassy if (CR_second_type==19) {//AI countered by reciprocally requesting gold ! event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1]; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0]; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } } elseif (CR_first_type==8) {//Human requested embassy if (CR_second_type==19) {//AI countered by reciprocally requesting gold event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0]; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1]; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } } elseif (CR_first_type==23 || CR_first_type==24) {//Human offered or requested map if (CR_second_type==3) {//AI countered by reciprocally requesting no trespassing agreement NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]= player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=60; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } } elseif (CR_first_type==32) {//Human requested ceasefire if (CR_second_type==32 || CR_second_type==1 || CR_second_type==19) { // AI countered with shorter term agreement or requested city or requested gold NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[0]; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[1]; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; NDM_TREATY_LENGTH=0; event:EstablishEmbassy(player[1],player[0]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1]; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0]; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; event:EstablishEmbassy(player[0],player[1]); NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0]; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1]; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; //maybe special message here } } elseif (CR_first_type==34) {//Human requested trade pact if (CR_second_type==34 || CR_second_type==19) { //AI countered with shorter term agreement or by reciprocally requesting gold NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[0]; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[1]; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; NDM_TREATY_LENGTH=0; } if (NP_second_type==5 && CR_second_type==19) {//AI countered his offer to stop piracy PIRACY_FLG_34_5=0; EnableTrigger('FollowUpToOfferStopPiracy'); } if (NP_second_type==6 && CR_second_type==19) {//AI countered his request to stop piracy PIRACY_FLG_34_6=0; EnableTrigger('FollowUpToRequestStopPiracy'); } } elseif (CR_first_type==35) {//Human requested research pact if (CR_second_type==35 ||CR_second_type==19) { //AI countered with shorter term agreement or by reciprocally requesting gold NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[0]; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[1]; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=NDM_TREATY_LENGTH; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; NDM_TREATY_LENGTH=0; } } } } HandleEvent(Reject) 'AI_Responses_to_Human_Rejections' pre { //This is from the patch 1.1. What IS it doing??? // do not threaten by default ConsiderResponse(player[0].owner, player[1].owner, 10, 1, 1, 1, 1);//? why all the 1's ? } HandleEvent(Threaten)'AI_Responses_To_Human_Threats' post { int_t first_type; // initial proposal int_t second_type; // following proposal int_t Response_type; // response type (accept/reject, etc) first_type = GetLastNewProposalType(player[0], player[1], 0); Response_type=GetLastResponseType(player[1], player[0],0); if (IsHumanPlayer(player[0]) && !IsHumanPlayer(player[1]) ) { LogRegardEvent(player[1],player[0],-40,0,ID_NONE,0);//AIciv's don't like being threatened if (Response_type==2) { if (first_type==3 ) { //this would be weird NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=30; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; } if (first_type==4 ) { NDM_TEMP_TRESPASSING0[NDM_NUM_TRESPASSING_TREATIES]=player[1]; NDM_TEMP_TRESPASSING1[NDM_NUM_TRESPASSING_TREATIES]=player[0]; NDM_TEMP_TRESPASSING_VALUE[NDM_NUM_TRESPASSING_TREATIES]=30; NDM_NUM_TRESPASSING_TREATIES=NDM_NUM_TRESPASSING_TREATIES+1; NDM_WithdrawNow(player[1],player[0]); } if (first_type==7 ) {//weird response, this will never happen NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } if (first_type==8 ) { NDM_TEMP_EMBASSY0[NDM_NUM_EMBASSY_TREATIES]=player[1].owner; NDM_TEMP_EMBASSY1[NDM_NUM_EMBASSY_TREATIES]=player[0].owner; NDM_TEMP_EMBASSY_VALUE[NDM_NUM_EMBASSY_TREATIES]=0; NDM_NUM_EMBASSY_TREATIES=NDM_NUM_EMBASSY_TREATIES+1; } if (first_type==32 ) { NDM_TEMP_CEASEFIRE0[NDM_NUM_CEASEFIRE_TREATIES]=player[1]; NDM_TEMP_CEASEFIRE1[NDM_NUM_CEASEFIRE_TREATIES]=player[0]; NDM_TEMP_CEASEFIRE_VALUE[NDM_NUM_CEASEFIRE_TREATIES]=30; NDM_NUM_CEASEFIRE_TREATIES=NDM_NUM_CEASEFIRE_TREATIES+1; } if (first_type==33 ) { NDM_TEMP_PEACE0[NDM_NUM_PEACE_TREATIES]=player[1]; NDM_TEMP_PEACE1[NDM_NUM_PEACE_TREATIES]=player[0]; NDM_TEMP_PEACE_VALUE[NDM_NUM_PEACE_TREATIES]=30; NDM_NUM_PEACE_TREATIES=NDM_NUM_PEACE_TREATIES+1; } if (first_type==34 ) { NDM_TEMP_TRADE0[NDM_NUM_TRADE_TREATIES]=player[1]; NDM_TEMP_TRADE1[NDM_NUM_TRADE_TREATIES]=player[0]; NDM_TEMP_TRADE_VALUE[NDM_NUM_TRADE_TREATIES]=30; NDM_NUM_TRADE_TREATIES=NDM_NUM_TRADE_TREATIES+1; } if (first_type==35) { NDM_TEMP_RESEARCH0[NDM_NUM_RESEARCH_TREATIES]=player[1]; NDM_TEMP_RESEARCH1[NDM_NUM_RESEARCH_TREATIES]=player[0]; NDM_TEMP_RESEARCH_VALUE[NDM_NUM_RESEARCH_TREATIES]=30; NDM_NUM_RESEARCH_TREATIES=NDM_NUM_RESEARCH_TREATIES+1; } if (first_type==36 ) { NDM_TEMP_MILITARY0[NDM_NUM_MILITARY_TREATIES]=player[1]; NDM_TEMP_MILITARY1[NDM_NUM_MILITARY_TREATIES]=player[0]; NDM_TEMP_MILITARY_VALUE[NDM_NUM_MILITARY_TREATIES]=30; NDM_NUM_MILITARY_TREATIES=NDM_NUM_MILITARY_TREATIES+1; } if (first_type==38) { NDM_TEMP_ALLIANCE0[NDM_NUM_ALLIANCE_TREATIES]=player[1]; NDM_TEMP_ALLIANCE1[NDM_NUM_ALLIANCE_TREATIES]=player[0]; NDM_TEMP_ALLIANCE_VALUE[NDM_NUM_ALLIANCE_TREATIES]=30; NDM_NUM_ALLIANCE_TREATIES=NDM_NUM_ALLIANCE_TREATIES+1; } //=> do we need second_types? } } // reject threat by default ConsiderResponse(player[0].owner, player[1].owner, 10, 1, 1, 1, 1);//? why all the 1's ? if (GetPersonalityType(player[1])==personalityDB(PERSONALITY_CEASAR) && Response_type!=2) { message(player[0],'DoNotThreatenMilitarists'); } if (GetPersonalityType(player[1])==personalityDB(PERSONALITY_STALIN)&& Response_type!=2) { message(player[0],'DoNotThreatenMilitarists1'); } } // end of handlers for when Human sends a proposal /////////////////////////////////// // // Message boxes // /////////////////////////////////// messagebox 'LeaningTowardsCeasefire' { show(); Text (ID_LeaningTowardsCeasefireM) ; } messagebox 'RephraseTheOffer' { show(); Text(ID_RephraseTheOfferM); } messagebox 'WhataStupidOffer' { show(); Text (ID_WhataStupidOfferM) ; } messagebox 'YouMustBeMad' { show(); Text (ID_YouMustBeMadM) ; } messagebox 'AskingTooMuch' { show(); Text (ID_AskingTooMuchM) ; //AskingTooMuchM "Friends, your proposal is interesting but you ask too much of us." } messagebox 'GreedyGreedy' { show(); Text (ID_GreedyGreedyM) ; } messagebox 'SoundsLikeBlackmail' { show(); Text (ID_SoundsLikeBlackmailM) ; } messagebox 'RegardWarning' { show(); Text (ID_RegardWarningM) ; } messagebox 'OurTreatyToExpire' { show(); Text (ID_OurTreatyToExpireM) ; } messagebox 'OurTreatyExpired' { show(); Text (ID_OurTreatyExpiredM) ; } messagebox 'TheirTreatyToExpire' { show(); Text (ID_TheirTreatyToExpireM) ; } messagebox 'TheirTreatyExpired' { show(); Text (ID_TheirTreatyExpiredM) ; } messagebox 'ShortTermAgreement' {// try to fix this via SetString and action array show(); Text(ID_ShortTermAgreementM); Button(ID_OK){ Kill(); } UseDirector(); } messagebox 'RequestShortTermAgreement' {// try to fix this via SetString and action array show(); Text(ID_RequestShortTermAgreementM); Button(ID_OK){ Kill(); } UseDirector(); } messagebox 'AgreedShortTermAgreement' { show(); Text(ID_AgreedShortTermAgreementM); } messagebox 'AgreedFixedTermAgreement1' { show(); Text(ID_AgreedFixedTermAgreementM1); Button(ID_OK){ Kill(); } UseDirector(); } messagebox 'CounterWithFixedTermAgreement' { show(); Text(ID_CounterWithFixedTermAgreementM); } messagebox 'CounterAccepted' { show(); Text (ID_CounterAcceptedM) ; } messagebox 'NotWhenAtWar' { show(); Text (ID_NotWhenAtWarM) ; } messagebox 'WeNeedBureaucracy' {//actually Dynasty for Cradle show(); Text (ID_WeNeedBureaucracyM) ; } messagebox 'TheyNeedBureaucracy' {//actually Dynasty for Cradle show(); Text (ID_TheyNeedBureaucracyM) ; } messagebox 'AlreadyHaveEmbassyThere' { show(); Text(ID_AlreadyHaveEmbassyThereM); } messagebox 'AlreadyHaveEmbassyHere' { show(); Text(ID_AlreadyHaveEmbassyHereM); } messagebox 'DoNotThreatenMilitarists' { show(); Text (ID_DoNotThreatenMilitaristsM) ; } messagebox 'DoNotThreatenMilitarists1' { show(); Text (ID_DoNotThreatenMilitarists1M) ; } messagebox 'WithdrawMessage' { show(); Text (ID_WithdrawM) ; } messagebox 'CounterWithPuzzledMessage3' { show(); Text (ID_PuzzledMessage3); } messagebox 'CounterWithReallyPuzzledMessage3' { show(); Text (ID_ReallyPuzzledMessage3); } messagebox 'CounterWithReallyPuzzledMessage4' { show(); Text (ID_ReallyPuzzledMessage4); } messagebox 'CounterWithApologeticMessage' { show(); Text (ID_ApologeticMessage); } messagebox 'CounterWithApologeticTradeMessage' { show(); Text (ID_ApologeticTradeMessage); } messagebox 'CounterWithApologeticResearchMessage' { show(); Text (ID_ApologeticResearchMessage); } messagebox 'CounterWithShowGoodIntentions' { show(); Text (ID_CounterWithShowGoodIntentionsM); } messagebox 'CounterWithNoTroopsThere' { show(); Text (ID_CounterWithNoTroopsThereM) ; } messagebox 'CounterToOfferStopPiracy' { show(); Text (ID_CounterToOfferStopPiracyM) ; } messagebox 'FollowUpOfferStopPiracyFirst' { show(); Text (ID_FollowUpOfferStopPiracyFirstM) ; } messagebox 'FollowUpOfferStopPiracyNext' { show(); Text (ID_FollowUpOfferStopPiracyNextM) ; } messagebox 'CounterToRequestStopPiracy' { show(); Text (ID_CounterToRequestStopPiracyM) ; } messagebox 'FollowUpRequestStopPiracy' { show(); Text (ID_FollowUpRequestStopPiracyM) ; } messagebox 'WantMoreGold' { show(); Text (ID_WantMoreGoldM) ; } messagebox 'BaseCounterToOfferStopPiracy' { show(); Text (ID_BaseCounterToOfferStopPiracyM) ; } messagebox 'HeresTheGold' { show(); Text (ID_HeresTheGoldM) ; } messagebox 'WantSomethingBack' { show(); Text (ID_WantSomethingBackM) ; } messagebox 'BonusOffer' { show(); Text (ID_BonusOfferM) ; } messagebox 'KeepYourWord' { Show(); Text (ID_KeepYourWordM); //KeepYourWordM "You have already agreed not to trespass on our territory. We call upon you to keep your word." } messagebox 'CounterToGoldRequestToCeasePiracy' { show(); Text (ID_CounterToGoldRequestToCeasePiracyM) ; } messagebox 'EmbassyCounterAccepted' { show(); Text (ID_EmbassyCounterAcceptedM) ; Button(ID_OK){ Kill(); } } messagebox 'NeverPartWithHolyCity' { show(); Text (ID_NeverPartWithHolyCityM) ; } messagebox 'NotInterestedNow' { show(); Text (ID_NotInterestedNowM) ; } /////////////////////////////////// // Greeting message /////////////////////////////////// MessageBox 'DIPLOMACY_POPUP_GREETING' { Text(ID_ACTION_STRING); Show(); } /////////////////////////////////// // Declare war message /////////////////////////////////// MessageBox 'DIPLOMACY_POPUP_DECLARE_WAR' { Text(ID_POPUP_DECLARE_WAR_ANNC); Show(); } /////////////////////////