![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "bitvector.h"#include "log.h"#include "shared.h"#include "timing.h"#include "actions.h"#include "city.h"#include "combat.h"#include "game.h"#include "government.h"#include "map.h"#include "movement.h"#include "nation.h"#include "packets.h"#include "player.h"#include "research.h"#include "unit.h"#include "unitlist.h"#include "aiactions.h"#include "pf_tools.h"#include "citytools.h"#include "cityturn.h"#include "diplomats.h"#include "maphand.h"#include "srv_log.h"#include "unithand.h"#include "advbuilding.h"#include "advdata.h"#include "advgoto.h"#include "handicaps.h"#include "aidata.h"#include "aiguard.h"#include "aihand.h"#include "ailog.h"#include "aiplayer.h"#include "aitools.h"#include "aiunit.h"#include "daiactions.h"#include "daicity.h"#include "aidiplomat.h"
Include dependency graph for aidiplomat.cpp:Go to the source code of this file.
Macros | |
| #define | LOG_DIPLOMAT LOG_DEBUG |
| #define | LOG_DIPLOMAT_BUILD LOG_DEBUG |
| #define | DIPLO_DEFENSE_WANT 3000 |
Functions | |
| static bool | is_city_surrounded_by_our_spies (struct player *pplayer, struct city *enemy_city) |
| Check if we have a diplomat / spy near a given city. More... | |
| static void | find_city_to_diplomat (struct player *pplayer, struct unit *punit, struct city **ctarget, int *move_dist, struct pf_map *pfm) |
| Returns (in ctarget) the closest city to send diplomats against, or nullptr if none available on this continent. More... | |
| static int | count_stealable_techs (struct player *pplayer, struct player *tplayer) |
| Number of techs that we don't have and the enemy (tplayer) does. More... | |
| void | dai_choose_diplomat_defensive (struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, int def) |
| Calculates our need for diplomats as defensive units. More... | |
| void | dai_choose_diplomat_offensive (struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice) |
| Calculates our need for diplomats as offensive units. More... | |
| static void | dai_diplomat_city (struct ai_type *ait, struct unit *punit, struct city *ctarget) |
| Check if something is on our receiving end for some nasty diplomat business! Note that punit may die or be moved during this function. More... | |
| static struct city * | dai_diplomat_defend (struct ai_type *ait, struct player *pplayer, struct unit *punit, const struct unit_type *utype, struct pf_map *pfm) |
| Go to nearest/most threatened city (can be the current city too). More... | |
| static bool | dai_diplomat_bribe_nearby (struct ai_type *ait, struct player *pplayer, struct unit *punit, struct pf_map *pfm) |
| Find units that we can reach, and bribe them. More... | |
| void | dai_manage_diplomat (struct ai_type *ait, struct player *pplayer, struct unit *punit) |
| If we are the only diplomat in a threatened city, defend against enemy actions. More... | |
| #define DIPLO_DEFENSE_WANT 3000 |
Definition at line 70 of file aidiplomat.cpp.
| #define LOG_DIPLOMAT LOG_DEBUG |
Definition at line 65 of file aidiplomat.cpp.
| #define LOG_DIPLOMAT_BUILD LOG_DEBUG |
Definition at line 66 of file aidiplomat.cpp.
Number of techs that we don't have and the enemy (tplayer) does.
Definition at line 84 of file aidiplomat.cpp.
Referenced by dai_diplomat_city().
| void dai_choose_diplomat_defensive | ( | struct ai_type * | ait, |
| struct player * | pplayer, | ||
| struct city * | pcity, | ||
| struct adv_choice * | choice, | ||
| int | def | ||
| ) |
Calculates our need for diplomats as defensive units.
May replace values in choice. The values 16000 and 3000 used below are totally arbitrary but seem to work.
Definition at line 108 of file aidiplomat.cpp.
Referenced by military_advisor_choose_build().
| void dai_choose_diplomat_offensive | ( | struct ai_type * | ait, |
| struct player * | pplayer, | ||
| struct city * | pcity, | ||
| struct adv_choice * | choice | ||
| ) |
Calculates our need for diplomats as offensive units.
May replace values in choice.
Definition at line 155 of file aidiplomat.cpp.
Referenced by military_advisor_choose_build().
|
static |
Find units that we can reach, and bribe them.
Returns TRUE if survived the ordeal, FALSE if not or we expended all our movement. Will try to bribe a ship on the coast as well as land stuff.
Definition at line 570 of file aidiplomat.cpp.
Referenced by dai_manage_diplomat().
|
static |
Check if something is on our receiving end for some nasty diplomat business! Note that punit may die or be moved during this function.
We must be adjacent to target city.
We try to make embassy first, and abort if we already have one and target is allied. Then we steal, incite, sabotage or poison the city, in that order of priority.
Definition at line 305 of file aidiplomat.cpp.
Referenced by dai_manage_diplomat().
|
static |
Go to nearest/most threatened city (can be the current city too).
Definition at line 501 of file aidiplomat.cpp.
Referenced by dai_manage_diplomat().
If we are the only diplomat in a threatened city, defend against enemy actions.
The passive defense is set by game.diplchance. The active defense is to bribe units which end their move nearby. Our next trick is to look for enemy cities on our continent and do our diplomat things.
FIXME: It is important to establish contact with all civilizations, so we should send diplomats by boat eventually. I just don't know how that part of the code works, yet - Per
Definition at line 696 of file aidiplomat.cpp.
Referenced by dai_manage_unit().
|
static |
Returns (in ctarget) the closest city to send diplomats against, or nullptr if none available on this continent.
punit can be virtual.
Definition at line 420 of file aidiplomat.cpp.
Referenced by dai_choose_diplomat_offensive(), and dai_manage_diplomat().
|
static |
Check if we have a diplomat / spy near a given city.
This is used to prevent a stack of such units next to a foreign city.
Definition at line 392 of file aidiplomat.cpp.
Referenced by find_city_to_diplomat().