68#define LOG_DIPL LOG_DEBUG
69#define LOG_DIPL2 LOG_DEBUG
73#define BIG_NUMBER 100000
79#define TURNS_BEFORE_TARGET 15
160 int bulbs, tech_want, worth;
225 int tech_id,
bool *is_dangerous)
231 *is_dangerous =
FALSE;
259 *is_dangerous =
TRUE;
275static const struct player *
389 if (
adip->is_allied_with_enemy
392 "distance from %s for some time, %s."),
411 "ceasefire for a bit longer first, %s."),
415 }
else if (
adip->countdown >= 0 ||
adip->countdown < -1) {
426 if (
adip->countdown >= 0 ||
adip->countdown < -1) {
434 "alliance yet, %s."),
462 if (
adip->is_allied_with_ally) {
558 _(
"*%s (AI)* Sorry, sharing vision with you "
710 if (
adip->is_allied_with_ally) {
814 want += pcity->surplus[
O_SHIELD] * 8;
815 want += pcity->surplus[
O_TRADE] * 6;
885 if (
adv->dipl.spacerace_leader == target) {
905 want -=
abs(want) / 10;
907 want -=
abs(want) / 7;
909 want -=
abs(want) / 5;
911 want -=
abs(want) / 3;
934 return (want -
fear);
981 clause.
from = pplayer;
994 _(
"*%s (AI)* Greetings %s! May we suggest a ceasefire "
995 "while we get to know each other better?"),
1002 _(
"*%s (AI)* I found you %s! Now make it worth my "
1003 "letting you live, or be crushed."),
1063 &&
adip->countdown == -1
1064 && !
adip->is_allied_with_enemy
1065 && !
adip->at_war_with_ally
1067 &&
adip->ally_patience >= 0) {
1111 * ((
adip->is_allied_with_enemy !=
NULL) + 1));
1202 if (worth[tech] <= 0) {
1208 if (worth[
tech2] >= 0) {
1212 diff = worth[tech] + worth[
tech2];
1213 if ((diff > 0 &&
player1->economic.gold >= diff)
1220 }
else if (diff < 0) {
1322 "Wanted to cancel treaty but was unable to.");
1323 adip->countdown = -1;
1358 adip->countdown = -10;
1362 _(
"*%s (AI)* I have tolerated your vicious antics "
1363 "long enough! To war!"),
1365 adip->countdown = -20;
1370 adip->countdown = -10;
1374 _(
"*%s (AI)* Finally I get around to you! Did "
1375 "you really think you could get away with your crimes?"),
1377 adip->countdown = -20;
1381 _(
"*%s (AI)* Your covert hostilities brought "
1382 "this war upon you!"),
1384 adip->countdown = -20;
1387 if (
adip->at_war_with_ally) {
1389 _(
"*%s (AI)* Your aggression against %s was "
1390 "your last mistake!"),
1393 adip->countdown = -3;
1397 "for their war against an ally, but can no longer find "
1398 "this ally! War declaration aborted.");
1399 adip->countdown = -1;
1427 adip->countdown = -1;
1430 "Not revolting, as there would be Senate regardless.");
1474 int countdown,
enum war_reason
reason)
1496 PL_(
"*%s (AI)* We will be launching an all-out war "
1497 "against %s in %d turn to stop the spaceship "
1499 "*%s (AI)* We will be launching an all-out war "
1500 "against %s in %d turns to stop the spaceship "
1507 _(
"*%s (AI)* Your aid in this matter will be expected. "
1508 "Long live our glorious alliance!"),
1514 PL_(
"*%s (AI)* %s has grossly violated their treaties "
1515 "with us for own gain. We will answer in force in "
1516 "%d turn and expect you to honor your alliance "
1517 "with us and do likewise!",
1518 "*%s (AI)* %s has grossly violated their treaties "
1519 "with us for own gain. We will answer in force in "
1520 "%d turns and expect you to honor your alliance "
1528 PL_(
"*%s (AI)* We intend to pillage and plunder the rich "
1529 "civilization of %s. We declare war in %d turn.",
1530 "*%s (AI)* We intend to pillage and plunder the rich "
1531 "civilization of %s. We declare war in %d turns.",
1537 _(
"*%s (AI)* If you want a piece of the loot, feel "
1538 "free to join in the action!"),
1543 PL_(
"*%s (AI)* We have had it with %s. Let us tear this "
1544 "pathetic civilization apart. We declare war in "
1546 "*%s (AI)* We have had it with %s. Let us tear this "
1547 "pathetic civilization apart. We declare war in "
1554 _(
"*%s (AI)* As our glorious allies, we expect your "
1555 "help in this war."),
1561 PL_(
"*%s (AI)* We will honor our alliance and declare "
1562 "war on %s in %d turn. Hold on - we are coming!",
1563 "*%s (AI)* We will honor our alliance and declare "
1564 "war on %s in %d turns. Hold on - we are coming!",
1569 }
else if (
adip->at_war_with_ally) {
1571 PL_(
"*%s (AI)* We will honor our alliance with %s and "
1572 "declare war on %s in %d turns. We expect you to "
1574 "*%s (AI)* We will honor our alliance with %s and "
1575 "declare war on %s in %d turns. We expect you to "
1640 ||
adip->countdown >= 0
1652 _(
"*%s (AI)* Your attempt to conquer space for "
1653 "yourself alone betrays your true intentions, and I "
1654 "will have no more of our alliance!"),
1664 &&
adip->warned_about_space == 0) {
1668 _(
"*%s (AI)* Your attempt to unilaterally "
1669 "dominate outer space is highly offensive."),
1672 _(
"*%s (AI)* If you do not stop constructing your "
1673 "spaceship, I may be forced to take action!"),
1714 enum war_reason war_reason;
1738 if (
adip->at_war_with_ally
1739 &&
adip->countdown == -1
1740 && !
adip->is_allied_with_ally
1758 adip->countdown = -1;
1761 if (
adip->countdown > 0) {
1763 }
else if (
adip->countdown == 0) {
1768 }
else if (
adip->countdown < -1) {
1785 clause.
from = pplayer;
1795 _(
"*%s (AI)* Sorry, sharing vision with you "
1796 "is no longer safe."),
1806 ||
adip->countdown >= 0
1812 adip->asked_about_peace =
MAX(
adip->asked_about_peace - 1, 0);
1813 adip->asked_about_alliance =
MAX(
adip->asked_about_alliance - 1, 0);
1814 adip->asked_about_ceasefire =
MAX(
adip->asked_about_ceasefire - 1, 0);
1815 adip->warned_about_space =
MAX(
adip->warned_about_space - 1, 0);
1825 if (
adip->spam <= 0) {
1839 if (
adip->at_war_with_ally) {
1856 if (!target || !target->
is_alive) {
1857 adip->ally_patience = 0;
1861 if (
adip->spam <= 0) {
1864 if (
adip->ally_patience == 0) {
1866 _(
"*%s (AI)* Greetings our most trustworthy "
1867 "ally. We call upon you to destroy our enemy, %s."),
1870 adip->ally_patience--;
1871 }
else if (
adip->ally_patience == -1) {
1874 _(
"*%s (AI)* Greetings ally, I see you have not yet "
1875 "made war with our enemy, %s. Why do I need to remind "
1876 "you of your promises?"),
1879 adip->ally_patience--;
1884 _(
"*%s (AI)* Dishonored one, we made a pact of "
1885 "alliance, and yet you remain at peace with our mortal "
1886 "enemy, %s! This is unacceptable; our alliance is no "
1891 "breaking useless alliance");
1908 if (
adip->at_war_with_ally
1918 _(
"*%s (AI)* Greetings friend, may we suggest "
1919 "making a common cause and join in an alliance?"),
1925 if (
adip->at_war_with_ally
1935 _(
"*%s (AI)* Greetings neighbor, may we suggest "
1936 "more peaceful relations?"),
1952 _(
"*%s (AI)* We grow weary of this constant "
1953 "bloodshed. May we suggest a cessation of hostilities?"),
2008 if (receiver ==
victim) {
2120 if (receiver ==
victim) {
2191 if (
victim == receiver) {
2216 if (!
is_ai(pplayer)) {
2240 _(
"*%s (AI)* We have been savagely attacked by "
2241 "%s, and we need your help! Honor our glorious "
2242 "alliance and your name will never be forgotten!"),
#define ASSERT_UNUSED_ACTRES_CASES
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
int player_distance_to_player(struct player *pplayer, struct player *target)
int city_gold_worth(struct city *pcity)
int ai_trait_get_value(enum trait tr, struct player *pplayer)
bool is_capital(const struct city *pcity)
const char * city_name_get(const struct city *pcity)
struct city * city_list_find_number(struct city_list *This, int id)
#define city_list_iterate(citylist, pcity)
static citizens city_size_get(const struct city *pcity)
#define city_owner(_pcity_)
#define city_list_iterate_end
#define city_built_iterate(_pcity, _p)
#define city_built_iterate_end
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
struct ai_dip_intel * dai_diplomacy_get(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer)
void dai_treaty_accepted(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
static void dai_incident_nuclear_not_target(struct player *receiver, const struct player *violator, const struct player *victim)
void dai_incident(struct ai_type *ait, enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *receiver, struct player *violator, struct player *victim)
bool dai_on_war_footing(struct ai_type *ait, struct player *pplayer)
void dai_revolution_start(struct ai_type *ait, struct player *pplayer)
void dai_diplomacy_actions(struct ai_type *ait, struct player *pplayer)
static int dai_goldequiv_clause(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Clause *pclause, bool verbose, enum diplstate_type ds_after)
static const struct player * get_allied_with_enemy_player(const struct player *us, const struct player *them)
static void dai_incident_simple(struct player *receiver, const struct player *violator, const struct player *victim, enum casus_belli_range scope, int how_bad)
static void dai_incident_nuclear_self(struct player *receiver, const struct player *violator, const struct player *victim)
void dai_diplomacy_begin_new_phase(struct ai_type *ait, struct player *pplayer)
static void suggest_tech_exchange(struct ai_type *ait, struct player *player1, struct player *player2)
void dai_treaty_evaluate(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
static int greed(int missing_love)
static bool dai_players_can_agree_on_ceasefire(struct ai_type *ait, struct player *player1, struct player *player2)
static void dai_go_to_war(struct ai_type *ait, struct player *pplayer, struct player *target, enum war_reason reason)
static int dai_goldequiv_tech(struct ai_type *ait, struct player *pplayer, Tech_type_id tech)
static enum diplstate_type pact_clause_to_diplstate_type(enum clause_type type)
static void dai_diplomacy_suggest(struct player *pplayer, struct player *aplayer, enum clause_type what, bool to_pplayer, int value)
static void dai_treaty_react(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Clause *pclause)
static int compute_tech_sell_price(struct ai_type *ait, struct player *giver, struct player *taker, int tech_id, bool *is_dangerous)
static void dai_declare_war(struct ai_type *ait, struct player *pplayer, struct player *target)
static void clear_old_treaty(struct player *pplayer, struct player *aplayer)
static void dai_diplo_notify(struct player *pplayer, const char *text,...)
static void dai_incident_nuclear(struct player *receiver, const struct player *violator, const struct player *victim)
static void dai_incident_war(struct player *violator, struct player *victim)
static void war_countdown(struct ai_type *ait, struct player *pplayer, struct player *target, int countdown, enum war_reason reason)
static void dai_share(struct ai_type *ait, struct player *pplayer, struct player *aplayer)
static bool shared_vision_is_safe(struct player *pplayer, struct player *aplayer)
static int dai_war_desire(struct ai_type *ait, struct player *pplayer, struct player *target)
#define TURNS_BEFORE_TARGET
static bool diplomacy_verbose
void dai_diplomacy_first_contact(struct ai_type *ait, struct player *pplayer, struct player *aplayer)
#define DIPLO_LOG(ait, loglevel, pplayer, aplayer, msg,...)
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
#define NEVER_MET(plr1, plr2)
#define ATTACK_POWER(ptype)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
void handle_diplomacy_create_clause_req(struct player *pplayer, int counterpart, int giver, enum clause_type type, int value)
void handle_diplomacy_init_meeting_req(struct player *pplayer, int counterpart)
void handle_diplomacy_accept_treaty_req(struct player *pplayer, int counterpart)
bool diplomacy_possible(const struct player *pplayer1, const struct player *pplayer2)
struct Treaty * find_treaty(struct player *plr0, struct player *plr1)
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
#define clause_list_iterate_end
#define clause_list_iterate(clauselist, pclause)
#define is_pact_clause(x)
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
#define PL_(String1, String2, n)
const struct ft_color ftc_chat_private
void handle_player_change_government(struct player *pplayer, Government_type_id government)
void handle_diplomacy_cancel_pact(struct player *pplayer, int other_player_id, enum clause_type clause)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
bool is_small_wonder(const struct impr_type *pimprove)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_base(level, message,...)
#define log_error(message,...)
#define map_size_checked()
void remove_shared_vision(struct player *pfrom, struct player *pto)
void vpackage_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format, va_list vargs)
void event_cache_add_for_player(const struct packet_chat_msg *packet, const struct player *pplayer)
void lsend_packet_chat_msg(struct conn_list *dest, const struct packet_chat_msg *packet)
void dlsend_packet_diplomacy_remove_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
struct city_list * cities
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
int player_slot_count(void)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
int player_index(const struct player *pplayer)
int player_in_territory(const struct player *pplayer, const struct player *pplayer2)
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, const struct player *p2)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
bool gives_shared_vision(const struct player *me, const struct player *them)
bool pplayers_in_peace(const struct player *pplayer, const struct player *pplayer2)
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
int player_tech_upkeep(const struct player *pplayer)
int research_goal_bulbs_required(const struct research *presearch, Tech_type_id goal)
struct research * research_get(const struct player *pplayer)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
struct clause_list * clauses
struct adv_data::@92 dipl
struct player * spacerace_leader
enum war_reason war_reason
adv_want tech_want[A_LAST+1]
struct ai_plr::@254 diplomacy
int req_love_for_alliance
struct player * war_target
enum winning_strategy strategy
struct packet_game_info info
struct civ_game::@31::@35 server
struct government * government_during_revolution
Government_type_id government_during_revolution_id
enum tech_upkeep_style tech_upkeep_style
enum tech_leakage_style tech_leakage
bool tech_trade_allow_holes
enum tech_cost_style tech_cost_style
int love[MAX_NUM_PLAYER_SLOTS]
char has_reason_to_cancel
struct city_list * cities
struct player_ai ai_common
struct government * government
const struct ai_type * ai
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
struct player::@70::@72 server
struct unit_type::@87 adv
struct advance * advance_by_number(const Tech_type_id atype)
const char * advance_rule_name(const struct advance *padvance)
#define advance_index_iterate_max(_start, _index, _max)
#define advance_index_iterate_end
#define advance_index_iterate_max_end
static Tech_type_id advance_count(void)
#define advance_index_iterate(_start, _index)
#define TRAIT_MAX_VALUE_SR
bool unit_is_cityfounder(const struct unit *punit)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
bool utype_is_cityfounder(const struct unit_type *utype)