Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/diplomats.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Functions
diplomats.c File Reference
`#include <stdio.h>`
`#include "bitvector.h"`
`#include "capability.h"`
`#include "fcintl.h"`
`#include "log.h"`
`#include "rand.h"`
`#include "base.h"`
`#include "combat.h"`
`#include "events.h"`
`#include "game.h"`
`#include "government.h"`
`#include "map.h"`
`#include "movement.h"`
`#include "player.h"`
`#include "research.h"`
`#include "unitlist.h"`
`#include "actiontools.h"`
`#include "aiiface.h"`
`#include "citytools.h"`
`#include "cityturn.h"`
`#include "diplhand.h"`
`#include "diplomats.h"`
`#include "maphand.h"`
`#include "notify.h"`
`#include "plrhand.h"`
`#include "techtools.h"`
`#include "unithand.h"`
`#include "unittools.h"`
`#include "script_server.h"`

Go to the source code of this file.

## Functions

static void | diplomat_charge_movement (struct unit *pdiplomat, struct tile *ptile)
static bool | diplomat_success_vs_defender (struct unit *patt, struct unit *pdef, struct tile *pdefender_tile, int *att_vet, int *def_vet)
static bool | diplomat_may_lose_gold (struct player *dec_player, struct player *inc_player, int revolt_gold)
static bool | diplomat_infiltrate_tile (struct player *pplayer, struct player *cplayer, const struct action *paction, struct unit *pdiplomat, struct unit *pvictim, struct tile *ptile, struct player **defender_owner)
static void | diplomat_escape (struct player *pplayer, struct unit *pdiplomat, const struct city *pcity, const struct action *paction)
static void | diplomat_escape_full (struct player *pplayer, struct unit *pdiplomat, bool city_related, struct tile *ptile, const char *vlink, const struct action *paction)
bool | spy_poison (struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
bool | spy_spread_plague (struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
bool | diplomat_investigate (struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
void | spy_send_sabotage_list (struct connection *pc, struct unit *pdiplomat, struct city *pcity, const struct action *paction, int request_kind)
bool | diplomat_embassy (struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
bool | spy_sabotage_unit (struct player *pplayer, struct unit *pdiplomat, struct unit *pvictim, const struct action *paction)
bool | diplomat_bribe (struct player *pplayer, struct unit *pdiplomat, struct unit *pvictim, const struct action *paction)
bool | spy_attack (struct player *act_player, struct unit *act_unit, struct tile *tgt_tile, const struct action *paction)
int | diplomats_unignored_tech_stealings (struct unit *pdiplomat, struct city *pcity)
bool | diplomat_get_tech (struct player *pplayer, struct unit *pdiplomat, struct city *pcity, Tech_type_id technology, const struct action *paction)
bool | diplomat_incite (struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
bool | diplomat_sabotage (struct player *pplayer, struct unit *pdiplomat, struct city *pcity, Impr_type_id improvement, const struct action *paction)
bool | spy_steal_gold (struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
bool | spy_steal_some_maps (struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
bool | spy_nuke_city (struct player *act_player, struct unit *act_unit, struct city *tgt_city, const struct action *paction)
int | count_diplomats_on_tile (struct tile *ptile)

## Function Documentation

## ◆ count_diplomats_on_tile()

int count_diplomats_on_tile | ( | struct tile * | ptile | ) |

Return number of diplomats on this square. AJS 20000130

Definition at line 2346 of file diplomats.c.

Referenced by dai_diplomat_defend(), dai_manage_diplomat(), and find_city_to_diplomat().

## ◆ diplomat_bribe()

bool diplomat_bribe | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct unit * | pvictim,
|  | const struct action * | paction
| ) |  |

Bribe an enemy unit.

- Can't bribe a unit if:
  - Player doesn't have enough gold.
- Otherwise, the unit will be bribed.
- A successful briber will try to move onto the victim's square.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 648 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ diplomat_charge_movement()

static void diplomat_charge_movement | ( | struct unit * | pdiplomat,
|  | struct tile * | ptile
| ) |  |

static

This subtracts the destination movement cost from a diplomat/spy.

Definition at line 1943 of file diplomats.c.

Referenced by diplomat_get_tech(), and diplomat_sabotage().

## ◆ diplomat_embassy()

bool diplomat_embassy | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct city * | pcity,
|  | const struct action * | paction
| ) |  |

Establish an embassy.

- Always success; the embassy is created.
- It costs some minimal movement to establish an embassy.
- The actor unit always survives establishing the embassy unless the action being performed is configured to always consume the actor unit.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 488 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ diplomat_escape()

static void diplomat_escape | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | const struct city * | pcity,
|  | const struct action * | paction
| ) |  |

static

This determines if a diplomat/spy survives and escapes. If "pcity" is NULL, assume action was in the field.

Spies have a game.server.diplchance specified chance of survival (better if veteran):

- Diplomats always die.
- Escapes to home city.
- Escapee may become a veteran.

Definition at line 2241 of file diplomats.c.

Referenced by diplomat_get_tech(), diplomat_sabotage(), and spy_sabotage_unit().

## ◆ diplomat_escape_full()

static void diplomat_escape_full | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | bool | city_related,
|  | struct tile * | ptile,
|  | const char * | vlink,
|  | const struct action * | paction
| ) |  |

static

This determines if a diplomat/spy survives and escapes.

Spies have a game.server.diplchance specified chance of survival (better if veteran):

- Diplomats always die.
- Escapes to home city.
- Escapee may become a veteran.

Definition at line 2269 of file diplomats.c.

Referenced by diplomat_escape(), diplomat_incite(), spy_nuke_city(), spy_poison(), spy_spread_plague(), spy_steal_gold(), and spy_steal_some_maps().

## ◆ diplomat_get_tech()

bool diplomat_get_tech | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct city * | pcity,
|  | Tech_type_id | technology,
|  | const struct action * | paction
| ) |  |

Try to steal a technology from an enemy city. If paction results in ACTION_SPY_STEAL_TECH or ACTION_SPY_STEAL_TECH_ESC, steal a random technology. Otherwise, steal the technology whose ID is "technology". (Note: Only Spies can select what to steal.)

- Check for infiltration success. Our thief may not survive this.
- Check for basic success. Again, our thief may not survive this.
- If a technology has already been stolen from this city at any time:
  - Diplomats will be caught and executed.
  - Spies will have an increasing chance of being caught and executed.
- Steal technology!
- The thief may be captured and executed, or escape to its home town.

FIXME: It should give a loss of reputation to steal from a player you are not at war with

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 896 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ diplomat_incite()

bool diplomat_incite | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct city * | pcity,
|  | const struct action * | paction
| ) |  |

Incite a city to disaffect.

- Can't incite a city to disaffect if:
  - Player doesn't have enough gold.
- Check for infiltration success. Our provocateur may not survive this.
- Check for basic success. Again, our provocateur may not survive this.
- Otherwise, the city will disaffect:
  - Player gets the city.
  - Player gets certain of the city's present/supported units.
  - Player gets a technology advance, if any were unknown.
- The provocateur may be captured and executed, or escape to its home town.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 1140 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ diplomat_infiltrate_tile()

static bool diplomat_infiltrate_tile | ( | struct player * | pplayer,
|  | struct player * | cplayer,
|  | const struct action * | paction,
|  | struct unit * | pdiplomat,
|  | struct unit * | pvictim,
|  | struct tile * | ptile,
|  | struct player ** | defender_owner
| ) |  |

static

This determines if a diplomat/spy succeeds in infiltrating a tile.

- The infiltrator must go up against each defender.
- The victim unit won't defend. (NULL if everyone should defend)
- One or the other is eliminated in each contest.
- Return TRUE if the infiltrator succeeds.

'pplayer' is the player who tries to do a spy/diplomat action on 'ptile' with the unit 'pdiplomat' against 'cplayer'. If 'cplayer' is NULL the owner of the chosen defender, if a defender can be chosen, gets its role. 'defender_owner' is, if non NULL, set to the owner of the unit that defended.

Definition at line 2041 of file diplomats.c.

Referenced by diplomat_bribe(), diplomat_get_tech(), diplomat_incite(), diplomat_sabotage(), spy_attack(), spy_nuke_city(), spy_poison(), spy_sabotage_unit(), spy_spread_plague(), spy_steal_gold(), and spy_steal_some_maps().

## ◆ diplomat_investigate()

bool diplomat_investigate | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct city * | pcity,
|  | const struct action * | paction
| ) |  |

Investigate a city.

- It costs some minimal movement to investigate a city.
- The actor unit always survives the investigation unless the action being performed is configured to always consume the actor unit.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 325 of file diplomats.c.

Referenced by receive_packet_city_info_100(), receive_packet_city_info_101(), receive_packet_city_info_102(), receive_packet_city_info_103(), and unit_perform_action().

## ◆ diplomat_may_lose_gold()

bool diplomat_may_lose_gold | ( | struct player * | dec_player,
|  | struct player * | inc_player,
|  | int | revolt_gold
| ) |  |

static

Gold for inciting might get lost.

- If the provocateur is captured and executed, there is probability that they were carrying bag with some gold, which will be lost.
- There is chance, that this gold will be transferred to nation which successfully defended against inciting revolt.

Returns TRUE if money is lost, FALSE if not.

Definition at line 1086 of file diplomats.c.

Referenced by diplomat_incite().

## ◆ diplomat_sabotage()

bool diplomat_sabotage | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct city * | pcity,
|  | Impr_type_id | improvement,
|  | const struct action * | paction
| ) |  |

Sabotage enemy city's improvement or production. If this is untargeted sabotage city a random improvement or production is targeted. Targeted sabotage city lets the value of "improvement" decide the target. If "improvement" is -1, sabotage current production. Otherwise, sabotage the city improvement whose ID is "improvement".

- Check for infiltration success. Our saboteur may not survive this.
- Check for basic success. Again, our saboteur may not survive this.
- Determine target, given arguments and constraints.
- If specified, city walls and anything in a capital are 50% likely to fail.
- Do sabotage!
- The saboteur may be captured and executed, or escape to its home town.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 1289 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ diplomat_success_vs_defender()

static bool diplomat_success_vs_defender | ( | struct unit * | pattacker,
|  | struct unit * | pdefender,
|  | struct tile * | pdefender_tile,
|  | int * | att_vet,
|  | int * | def_vet
| ) |  |

static

This determines if a diplomat/spy succeeds against some defender, who is also a diplomat or spy. Note: a superspy defender always succeeds, otherwise a superspy attacker always wins.

Return TRUE if the "attacker" succeeds.

Definition at line 1959 of file diplomats.c.

Referenced by diplomat_infiltrate_tile().

## ◆ diplomats_unignored_tech_stealings()

int diplomats_unignored_tech_stealings | ( | struct unit * | pdiplomat,
|  | struct city * | pcity
| ) |  |

Returns the amount of tech thefts from a city not ignored by the EFT_STEALINGS_IGNORE effect.

Definition at line 855 of file diplomats.c.

Referenced by dai_action_value_unit_vs_city(), diplomat_get_tech(), and find_city_to_diplomat().

## ◆ spy_attack()

bool spy_attack | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct tile * | tgt_tile,
|  | const struct action * | paction
| ) |  |

Diplomatic battle.

- Check for infiltration success. The entire point of this action.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 812 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ spy_nuke_city()

bool spy_nuke_city | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | const struct action * | paction
| ) |  |

Hide a suitcase nuke in a city and detonate it.

- Check for infiltration success. Our thief may not survive this.
- Check for basic success. Again, our thief may not survive this.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 1839 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ spy_poison()

bool spy_poison | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct city * | pcity,
|  | const struct action * | paction
| ) |  |

Poison a city's water supply.

- Check for infiltration success. Our poisoner may not survive this.
- Check for basic success. Again, our poisonner may not survive this.
- If successful, reduces population by one point.
- The poisoner may be captured and executed, or escape to its home town.

'pplayer' is the player who tries to poison 'pcity' with its unit 'pdiplomat'.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 98 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ spy_sabotage_unit()

bool spy_sabotage_unit | ( | struct player * | pplayer,
|  | struct unit * | pdiplomat,
|  | struct unit * | pvictim,
|  | const struct action * | paction
| ) |  |

Sabotage an enemy unit.

- If successful, reduces hit points by half of those remaining.
- The saboteur may be captured and executed, or escape to its home town.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 553 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ spy_send_sabotage_list()

void spy_send_sabotage_list | ( | struct connection * | pc,
|  | struct unit * | pdiplomat,
|  | struct city * | pcity,
|  | const struct action * | paction,
|  | int | request_kind
| ) |  |

Get list of improvements from city (for purposes of sabotage).

- Always successful; returns list.

Only send back to the originating connection, if there is one. (?)

Definition at line 432 of file diplomats.c.

Referenced by handle_unit_action_query().

## ◆ spy_spread_plague()

bool spy_spread_plague | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | const struct action * | paction
| ) |  |

Spread a plague to the target city.

- Check for infiltration success. Our infector may not survive this.
- Check for basic success. Again, our infector may not survive this.
- If successful, strikes the city with illness.
- The infector may be captured and executed, or escape to a nearby city.

'act_player' is the player who tries to infect 'tgt_city' with its unit 'act_unit'.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 215 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ spy_steal_gold()

bool spy_steal_gold | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | const struct action * | paction
| ) |  |

Steal gold from another player. The amount stolen is decided randomly. Not everything stolen reaches the player that ordered it stolen.

- Check for infiltration success. Our thief may not survive this.
- Check for basic success. Again, our thief may not survive this.
- Can't steal if there is no money to take.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 1561 of file diplomats.c.

Referenced by unit_perform_action().

## ◆ spy_steal_some_maps()

bool spy_steal_some_maps | ( | struct player * | act_player,
|  | struct unit * | act_unit,
|  | struct city * | tgt_city,
|  | const struct action * | paction
| ) |  |

Steal part of another player's map.

- Check for infiltration success. Our thief may not survive this.
- Check for basic success. Again, our thief may not survive this.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 1703 of file diplomats.c.

Referenced by unit_perform_action().