//----- Begin of function Nation::think_trade_treaty -----// // int Nation::think_trade_treaty() { Nation* nationPtr; NationRelation *ourRelation; for( int i=1 ; i<=nation_array.size() ; i++ ) { if( nation_array.is_deleted(i) || i==nation_recno ) continue; nationPtr = nation_array[i]; ourRelation = get_relation(i); if( !ourRelation->has_contact ) continue; //------- propose a trade treaty --------// if( !ourRelation->trade_treaty ) { if( consider_trade_treaty(i) > 0 ) { if( should_diplomacy_retry(TALK_PROPOSE_TRADE_TREATY, i) ) { talk_res.ai_send_talk_msg(i, nation_recno, TALK_PROPOSE_TRADE_TREATY); ourRelation->ai_demand_trade_treaty = 0; return 1; } } } } return 0; }
//----- Begin of function Nation::consider_talk_msg -----// // int Nation::consider_talk_msg(TalkMsg* talkMsg) { //--------------------------------------------// // Whether the nation has already sent out a // message that is the same as the one it received. // If so, accept the message right now. //--------------------------------------------// switch( talkMsg->talk_id ) { case TALK_PROPOSE_TRADE_TREATY: case TALK_PROPOSE_FRIENDLY_TREATY: case TALK_PROPOSE_ALLIANCE_TREATY: case TALK_REQUEST_TRADE_EMBARGO: case TALK_REQUEST_CEASE_WAR: case TALK_REQUEST_DECLARE_WAR: if( has_sent_same_msg(talkMsg) ) return 1; }; //-------------------------------// NationRelation* nationRelation = get_relation(talkMsg->from_nation_recno); //--- if the AI should not accept this treaty ---// if( info.game_date < nationRelation->never_accept_until_date_array[talkMsg->talk_id-1] ) return 0; if( nationRelation->ai_never_consider[talkMsg->talk_id-1] ) return 0; //-------------------------------// switch( talkMsg->talk_id ) { case TALK_PROPOSE_TRADE_TREATY: //--- if the AI will never propose an alliance treaty to this nation, then it will also never accept an alliance treaty from it ---// return consider_trade_treaty(talkMsg->from_nation_recno) >= 0; // the returned value is the curRating - acceptRating, if >=0, means it accepts case TALK_PROPOSE_FRIENDLY_TREATY: return consider_friendly_treaty(talkMsg->from_nation_recno) >= 0; case TALK_PROPOSE_ALLIANCE_TREATY: return consider_alliance_treaty(talkMsg->from_nation_recno) >= 0; case TALK_REQUEST_MILITARY_AID: return consider_military_aid(talkMsg); case TALK_REQUEST_TRADE_EMBARGO: return consider_trade_embargo(talkMsg); case TALK_REQUEST_CEASE_WAR: return consider_cease_war(talkMsg->from_nation_recno) >= 0; case TALK_REQUEST_DECLARE_WAR: // a nation demands you to declare war with another nation return consider_declare_war(talkMsg); case TALK_REQUEST_BUY_FOOD: return consider_sell_food(talkMsg); case TALK_GIVE_TRIBUTE: return consider_take_tribute(talkMsg); case TALK_DEMAND_TRIBUTE: return consider_give_tribute(talkMsg); case TALK_GIVE_AID: return consider_take_aid(talkMsg); case TALK_DEMAND_AID: return consider_give_aid(talkMsg); case TALK_EXCHANGE_TECH: return consider_exchange_tech(talkMsg); case TALK_REQUEST_SURRENDER: return consider_accept_surrender_request(talkMsg); default: err_here(); return 0; } }