Freeciv-3.2: /fast/freeciv/nightly/S3_2/server/barbarian.c File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Macros | Functions
barbarian.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "fcintl.h"`
`#include "log.h"`
`#include "rand.h"`
`#include "support.h"`
`#include "effects.h"`
`#include "events.h"`
`#include "game.h"`
`#include "government.h"`
`#include "map.h"`
`#include "movement.h"`
`#include "nation.h"`
`#include "research.h"`
`#include "tech.h"`
`#include "terrain.h"`
`#include "unitlist.h"`
`#include "aiiface.h"`
`#include "citytools.h"`
`#include "diplhand.h"`
`#include "gamehand.h"`
`#include "maphand.h"`
`#include "notify.h"`
`#include "plrhand.h"`
`#include "srv_main.h"`
`#include "stdinhand.h"`
`#include "techtools.h"`
`#include "unithand.h"`
`#include "unittools.h"`
`#include "advdata.h"`
`#include "difficulty.h"`
`#include "barbarian.h"`

Go to the source code of this file.

## Macros

#define | BARBARIAN_INITIAL_VISION_RADIUS 3
#define | BARBARIAN_INITIAL_VISION_RADIUS_SQ 9

## Functions

bool | is_land_barbarian (struct player *pplayer)
bool | is_sea_barbarian (struct player *pplayer)
struct player * | create_barbarian_player (enum barbarian_type type)
static void | init_dir_checked_status (bool *checked, enum terrain_class *terrainc, enum terrain_class tclass)
static int | random_unchecked_direction (int possibilities, const bool *checked)
static void | unit_move_pay (struct unit *punit, struct tile *pdesttile)
bool | unleash_barbarians (struct tile *ptile)
static bool | is_near_land (struct tile *tile0)
static struct tile * | find_empty_tile_nearby (struct tile *ptile)
static void | try_summon_barbarians (void)
void | summon_barbarians (void)
void | barbarian_initial_wars (struct player *barbarians)

## Macro Definition Documentation

## ◆ BARBARIAN_INITIAL_VISION_RADIUS

#define BARBARIAN_INITIAL_VISION_RADIUS 3

Definition at line 69 of file barbarian.c.

## ◆ BARBARIAN_INITIAL_VISION_RADIUS_SQ

#define BARBARIAN_INITIAL_VISION_RADIUS_SQ 9

Definition at line 70 of file barbarian.c.

## Function Documentation

## ◆ barbarian_initial_wars()

void barbarian_initial_wars | ( | struct player * | barbarians | ) |

Set new barbarian player to war with everyone.

Definition at line 765 of file barbarian.c.

Referenced by create_animals(), and create_barbarian_player().

## ◆ create_barbarian_player()

struct player * create_barbarian_player | ( | enum barbarian_type | type | ) |

Creates the land/sea barbarian player and inits some stuff. If barbarian player already exists, return player pointer. If barbarians are dead, revive them with a new leader :-)

Dead barbarians forget the map and lose the money.

Definition at line 97 of file barbarian.c.

Referenced by kill_player(), try_summon_barbarians(), and unleash_barbarians().

## ◆ find_empty_tile_nearby()

static struct tile * find_empty_tile_nearby | ( | struct tile * | ptile | ) |

static

Return this or a neighboring tile that is free of any units

Definition at line 504 of file barbarian.c.

Referenced by try_summon_barbarians().

## ◆ init_dir_checked_status()

static void init_dir_checked_status | ( | bool * | checked,
|  | enum terrain_class * | terrainc,
|  | enum terrain_class | tclass
| ) |  |

static

(Re)initialize direction checked status array based on terrain class.

Definition at line 207 of file barbarian.c.

Referenced by unleash_barbarians().

## ◆ is_land_barbarian()

bool is_land_barbarian | ( | struct player * | pplayer | ) |

Is player a land barbarian?

Definition at line 75 of file barbarian.c.

Referenced by create_barbarian_player(), dai_military_findjob(), raze_city(), and try_summon_barbarians().

## ◆ is_near_land()

static bool is_near_land | ( | struct tile * | tile0 | ) |

static

Is sea not further than a couple of tiles away from land?

Definition at line 490 of file barbarian.c.

Referenced by try_summon_barbarians().

## ◆ is_sea_barbarian()

bool is_sea_barbarian | ( | struct player * | pplayer | ) |

Is player a sea barbarian?

Definition at line 84 of file barbarian.c.

Referenced by create_barbarian_player().

## ◆ random_unchecked_direction()

static int random_unchecked_direction | ( | int | possibilities,
|  | const bool * | checked
| ) |  |

static

Return random directory from not yet checked ones.

Definition at line 225 of file barbarian.c.

Referenced by unleash_barbarians().

## ◆ summon_barbarians()

void summon_barbarians | ( | void |  | ) |

Summon barbarians out of the blue. Try more times for more difficult levels - which means there can be more than one uprising in one year!

Definition at line 738 of file barbarian.c.

Referenced by end_turn().

## ◆ try_summon_barbarians()

static void try_summon_barbarians | ( | void |  | ) |

static

The barbarians are summoned at a randomly chosen place if:

1. It's not closer than MIN_UNREST_DIST and not further than MAX_UNREST_DIST from the nearest city. City owner is called 'victim' here.
2. The place or a neighboring tile must be empty to deploy the units.
3. If it's the sea it shouldn't be far from the land. (questionable)
4. Place must be known to the victim
5. The uprising chance depends also on the victim empire size, its government (civil_war_chance) and barbarian difficulty level.
6. The number of land units also depends slightly on victim's empire size and barbarian difficulty level. Q: The empire size is used so there are no uprisings in the beginning of the game (year is not good as it can be customized), but it seems a bit unjust if someone is always small. So maybe it should rather be an average number of cities (all cities/player num)? Depending on the victim government type is also questionable.

Definition at line 533 of file barbarian.c.

Referenced by summon_barbarians().

## ◆ unit_move_pay()

static void unit_move_pay | ( | struct unit * | punit,
|  | struct tile * | pdesttile
| ) |  |

static

Move to the tile pdesttile.

Definition at line 245 of file barbarian.c.

Referenced by unleash_barbarians().

## ◆ unleash_barbarians()

bool unleash_barbarians | ( | struct tile * | ptile | ) |

Unleash barbarians means give barbarian player some units and move them out of the hut, unless there's no place to go.

Barbarian unit deployment algorithm: If enough free land around, deploy on land, if not enough land but some sea free, load some of them on boats, otherwise (not much land and no sea) kill enemy unit and stay in a village. The return value indicates if the explorer survived entering the vilage.

Definition at line 272 of file barbarian.c.

Referenced by api_edit_unleash_barbarians().