68#define LOG_DIPL LOG_DEBUG
69#define LOG_DIPL2 LOG_DEBUG
73#define BIG_NUMBER 100000
79#define TURNS_BEFORE_TARGET 15
161 int bulbs, tech_want, worth;
228 int tech_id,
bool *is_dangerous)
234 *is_dangerous =
FALSE;
262 *is_dangerous =
TRUE;
278static const struct player *
377 _(
"*%s (AI)* In away mode AI can't sign such a treaty."),
395 if (
adip->is_allied_with_enemy
398 "distance from %s for some time, %s."),
413 _(
"*%s (AI)* Let us first cease hostilities, %s."),
419 _(
"*%s (AI)* I wish to see you keep the current "
420 "ceasefire for a bit longer first, %s."),
424 }
else if (
adip->countdown >= 0 ||
adip->countdown < -1) {
435 if (
adip->countdown >= 0 ||
adip->countdown < -1) {
443 "alliance yet, %s."),
471 if (
adip->is_allied_with_ally) {
537 _(
"*%s (AI)* I do not know the city you mention."),
541 "city destroyed during negotiations");
557 if (
offer !=
nullptr) {
569 _(
"*%s (AI)* Sorry, sharing vision with you "
701 _(
"*%s (AI)* This deal was not very good for us, %s!"),
723 if (
adip->is_allied_with_ally) {
898 if (
adv->dipl.spacerace_leader == target) {
919 want -=
abs(want) / 10;
921 want -=
abs(want) / 7;
923 want -=
abs(want) / 5;
925 want -=
abs(want) / 3;
948 return (want -
fear);
995 clause.
from = pplayer;
1008 _(
"*%s (AI)* Greetings %s! May we suggest a ceasefire "
1009 "while we get to know each other better?"),
1016 _(
"*%s (AI)* I found you %s! Now make it worth my "
1017 "letting you live, or be crushed."),
1077 &&
adip->countdown == -1
1078 && !
adip->is_allied_with_enemy
1079 && !
adip->at_war_with_ally
1081 &&
adip->ally_patience >= 0) {
1125 * ((
adip->is_allied_with_enemy !=
nullptr) + 1));
1216 if (worth[tech] <= 0) {
1222 if (worth[
tech2] >= 0) {
1226 diff = worth[tech] + worth[
tech2];
1227 if ((diff > 0 &&
player1->economic.gold >= diff)
1234 }
else if (diff < 0) {
1336 "Wanted to cancel treaty but was unable to.");
1337 adip->countdown = -1;
1372 adip->countdown = -10;
1376 _(
"*%s (AI)* I have tolerated your vicious antics "
1377 "long enough! To war!"),
1379 adip->countdown = -20;
1384 adip->countdown = -10;
1388 _(
"*%s (AI)* Finally I get around to you! Did "
1389 "you really think you could get away with your crimes?"),
1391 adip->countdown = -20;
1395 _(
"*%s (AI)* Your covert hostilities brought "
1396 "this war upon you!"),
1398 adip->countdown = -20;
1401 if (
adip->at_war_with_ally) {
1403 _(
"*%s (AI)* Your aggression against %s was "
1404 "your last mistake!"),
1407 adip->countdown = -3;
1411 "for their war against an ally, but can no longer find "
1412 "this ally! War declaration aborted.");
1413 adip->countdown = -1;
1441 adip->countdown = -1;
1444 "Not revolting, as there would be Senate regardless.");
1488 int countdown,
enum war_reason
reason)
1510 PL_(
"*%s (AI)* We will be launching an all-out war "
1511 "against %s in %d turn to stop the spaceship "
1513 "*%s (AI)* We will be launching an all-out war "
1514 "against %s in %d turns to stop the spaceship "
1521 _(
"*%s (AI)* Your aid in this matter will be expected. "
1522 "Long live our glorious alliance!"),
1528 PL_(
"*%s (AI)* %s has grossly violated their treaties "
1529 "with us for own gain. We will answer in force in "
1530 "%d turn and expect you to honor your alliance "
1531 "with us and do likewise!",
1532 "*%s (AI)* %s has grossly violated their treaties "
1533 "with us for own gain. We will answer in force in "
1534 "%d turns and expect you to honor your alliance "
1542 PL_(
"*%s (AI)* We intend to pillage and plunder the rich "
1543 "civilization of %s. We declare war in %d turn.",
1544 "*%s (AI)* We intend to pillage and plunder the rich "
1545 "civilization of %s. We declare war in %d turns.",
1551 _(
"*%s (AI)* If you want a piece of the loot, feel "
1552 "free to join in the action!"),
1557 PL_(
"*%s (AI)* We have had it with %s. Let us tear this "
1558 "pathetic civilization apart. We declare war in "
1560 "*%s (AI)* We have had it with %s. Let us tear this "
1561 "pathetic civilization apart. We declare war in "
1568 _(
"*%s (AI)* As our glorious allies, we expect your "
1569 "help in this war."),
1575 PL_(
"*%s (AI)* We will honor our alliance and declare "
1576 "war on %s in %d turn. Hold on - we are coming!",
1577 "*%s (AI)* We will honor our alliance and declare "
1578 "war on %s in %d turns. Hold on - we are coming!",
1583 }
else if (
adip->at_war_with_ally) {
1585 PL_(
"*%s (AI)* We will honor our alliance with %s and "
1586 "declare war on %s in %d turns. We expect you to "
1588 "*%s (AI)* We will honor our alliance with %s and "
1589 "declare war on %s in %d turns. We expect you to "
1614 struct player *target =
nullptr;
1654 ||
adip->countdown >= 0
1666 _(
"*%s (AI)* Your attempt to conquer space for "
1667 "yourself alone betrays your true intentions, and I "
1668 "will have no more of our alliance!"),
1678 &&
adip->warned_about_space == 0) {
1682 _(
"*%s (AI)* Your attempt to unilaterally "
1683 "dominate outer space is highly offensive."),
1686 _(
"*%s (AI)* If you do not stop constructing your "
1687 "spaceship, I may be forced to take action!"),
1728 enum war_reason war_reason;
1752 if (
adip->at_war_with_ally
1753 &&
adip->countdown == -1
1754 && !
adip->is_allied_with_ally
1772 adip->countdown = -1;
1775 if (
adip->countdown > 0) {
1777 }
else if (
adip->countdown == 0) {
1782 }
else if (
adip->countdown < -1) {
1799 clause.
from = pplayer;
1809 _(
"*%s (AI)* Sorry, sharing vision with you "
1810 "is no longer safe."),
1820 ||
adip->countdown >= 0
1826 adip->asked_about_peace =
MAX(
adip->asked_about_peace - 1, 0);
1827 adip->asked_about_alliance =
MAX(
adip->asked_about_alliance - 1, 0);
1828 adip->asked_about_ceasefire =
MAX(
adip->asked_about_ceasefire - 1, 0);
1829 adip->warned_about_space =
MAX(
adip->warned_about_space - 1, 0);
1839 if (
adip->spam <= 0) {
1853 if (
adip->at_war_with_ally) {
1870 if (!target || !target->
is_alive) {
1871 adip->ally_patience = 0;
1875 if (
adip->spam <= 0) {
1878 if (
adip->ally_patience == 0) {
1880 _(
"*%s (AI)* Greetings our most trustworthy "
1881 "ally. We call upon you to destroy our enemy, %s."),
1884 adip->ally_patience--;
1885 }
else if (
adip->ally_patience == -1) {
1888 _(
"*%s (AI)* Greetings ally, I see you have not yet "
1889 "made war with our enemy, %s. Why do I need to remind "
1890 "you of your promises?"),
1893 adip->ally_patience--;
1898 _(
"*%s (AI)* Dishonored one, we made a pact of "
1899 "alliance, and yet you remain at peace with our mortal "
1900 "enemy, %s! This is unacceptable; our alliance is no "
1905 "breaking useless alliance");
1922 if (
adip->at_war_with_ally
1932 _(
"*%s (AI)* Greetings friend, may we suggest "
1933 "making a common cause and join in an alliance?"),
1939 if (
adip->at_war_with_ally
1949 _(
"*%s (AI)* Greetings neighbor, may we suggest "
1950 "more peaceful relations?"),
1966 _(
"*%s (AI)* We grow weary of this constant "
1967 "bloodshed. May we suggest a cessation of hostilities?"),
2022 if (receiver ==
victim) {
2135 if (receiver ==
victim) {
2206 if (
victim == receiver) {
2231 if (!
is_ai(pplayer)) {
2255 _(
"*%s (AI)* We have been savagely attacked by "
2256 "%s, and we need your help! Honor our glorious "
2257 "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(const struct civ_map *nmap, 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)
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_treaty_accepted(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct treaty *ptreaty)
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)
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)
void dai_treaty_evaluate(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct treaty *ptreaty)
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 const struct action *paction struct unit struct city * pcity
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
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,...)
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)
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)
#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)
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 adv_data::@95 dipl
struct player * spacerace_leader
enum war_reason war_reason
struct ai_plr::@283 diplomacy
adv_want tech_want[A_LAST+1]
int req_love_for_alliance
struct player * war_target
enum winning_strategy strategy
struct packet_game_info info
struct civ_game::@32::@36 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::@73::@75 server
struct player_economic economic
struct player_spaceship spaceship
struct clause_list * clauses
struct unit_type::@90 adv
const struct unit_type * utype
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)