69#define BARBARIAN_INITIAL_VISION_RADIUS 3
70#define BARBARIAN_INITIAL_VISION_RADIUS_SQ 9
106 if (!old_barbs->is_alive) {
107 old_barbs->economic.gold = 0;
108 old_barbs->is_alive =
TRUE;
114 old_barbs->name[0] =
'\0';
118 old_barbs->unassigned_user =
TRUE;
124 old_barbs->economic.gold += 100;
137 if (
type == LAND_BARBARIAN ||
type == SEA_BARBARIAN) {
142 if (nation != NULL) {
143 type = LAND_AND_SEA_BARBARIAN;
147 if (nation == NULL) {
190 _(
"%s gain a leader by the name %s. Dangerous "
191 "times may lie ahead."),
207 enum terrain_class *terrainc,
208 enum terrain_class tclass)
212 for (dir = 0; dir < 8; dir++) {
213 if (terrainc[dir] == tclass) {
214 checked[dir] =
FALSE;
229 int num =
fc_rand(possibilities);
230 for (i = 0; i <= num; i++) {
273 struct player *barbarians;
277 enum terrain_class terrainc[8];
278 struct tile *dir_tiles[8];
284 bool barbarian_stays =
FALSE;
309 for (i = 0; i < unit_cnt; i++) {
318 struct unit *barb_unit;
320 barb_unit =
create_unit(barbarians, ptile, punittype, 0, 0, -1);
328 for (dir = 0; dir < 8; dir++) {
329 dir_tiles[dir] =
mapstep(nmap, ptile, dir);
330 if (dir_tiles[dir] == NULL) {
331 terrainc[dir] = terrain_class_invalid();
334 terrainc[dir] = TC_OCEAN;
337 terrainc[dir] = TC_LAND;
341 terrainc[dir] = terrain_class_invalid();
345 if (land_tiles >= 3) {
349 bool dest_found =
FALSE;
355 for (checked_count = 0; !dest_found && checked_count < land_tiles;
363 log_debug(
"Moved barbarian unit from (%d, %d) to (%d, %d)",
368 checked[rdir] =
TRUE;
372 barbarian_stays =
TRUE;
378 if (ocean_tiles > 0) {
380 struct unit *boat = NULL;
386 for (checked_count = 0; boat == NULL && checked_count < ocean_tiles;
394 boat =
create_unit(barbarians, dir_tiles[rdir], candidate,
398 checked[rdir] =
TRUE;
409 0,
"", ACTION_TRANSPORT_EMBARK);
414 0,
"", ACTION_TRANSPORT_EMBARK2);
419 0,
"", ACTION_TRANSPORT_EMBARK3);
428 bool dest_found =
FALSE;
434 for (checked_count = 0; !dest_found && checked_count < land_tiles;
447 checked[rdir] =
TRUE;
451 barbarian_stays =
TRUE;
457 barbarian_stays =
TRUE;
461 if (barbarian_stays) {
465 wipe_unit(punit2, ULR_BARB_UNLEASH, NULL);
501 if (unit_list_size(tile1->units) == 0) {
529 struct tile *ptile, *utile;
533 struct player *barbarians, *victim;
535 int barb_count, really_created = 0;
536 bool hut_present =
FALSE;
561 log_debug(
"Closest city (to %d,%d) is %s (at %d,%d) distance %d.",
583 log_debug(
"Barbarians are willing to fight");
598 city_count = city_list_size(victim->
cities);
602 while (city_max <= city_count) {
616 for (i = 0; i < barb_count; i++) {
625 (void)
create_unit(barbarians, utile, punittype, 0, 0, -1);
634 leader_type, 0, 0, -1);
669 ptrans =
create_unit(barbarians, utile, boat, 0, 0, -1);
674 for (i = 0; i < cap - 1 && i < barb_count; i++) {
701 if (really_created == 0) {
718 _(
"Native unrest near %s led by %s."),
723 _(
"Sea raiders seen near %s!"),
771 if (pplayer != barbarians) {
bool is_action_enabled_unit_on_unit(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
void adv_data_phase_done(struct player *pplayer)
#define CALL_PLR_AI_FUNC(_func, _player,...)
const char * default_ai_type_name(void)
static struct tile * find_empty_tile_nearby(struct tile *ptile)
static void try_summon_barbarians(void)
void barbarian_initial_wars(struct player *barbarians)
bool unleash_barbarians(struct tile *ptile)
void summon_barbarians(void)
#define BARBARIAN_INITIAL_VISION_RADIUS_SQ
static void init_dir_checked_status(bool *checked, enum terrain_class *terrainc, enum terrain_class tclass)
bool is_sea_barbarian(struct player *pplayer)
static bool is_near_land(struct tile *tile0)
static void unit_move_pay(struct unit *punit, struct tile *pdesttile)
bool is_land_barbarian(struct player *pplayer)
static int random_unchecked_direction(int possibilities, const bool *checked)
struct player * create_barbarian_player(enum barbarian_type type)
const char * city_name_get(const struct city *pcity)
#define city_owner(_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 * punit
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
void set_diplstate_type(struct player_diplstate *state1, struct player_diplstate *state2, enum diplstate_type type)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
const struct ft_color ftc_server
const char * city_link(const struct city *pcity)
#define log_verbose(message,...)
#define fc_assert(condition)
#define log_debug(message,...)
struct tile * rand_map_pos(const struct civ_map *nmap)
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define square_iterate_end
static int map_move_cost_unit(const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
void update_tile_knowledge(struct tile *ptile)
void map_clear_known(struct tile *ptile, struct player *pplayer)
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
bool unit_can_move_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool igzoc, bool enter_transport, bool enter_enemy_city)
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
struct nation_type * nation_of_player(const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
struct government * init_government_of_nation(const struct nation_type *pnation)
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
#define players_iterate_end
#define players_iterate(_pplayer)
void server_player_set_name(struct player *pplayer, const char *name)
void send_player_all_c(struct player *src, struct conn_list *dest)
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
void player_status_reset(struct player *plr)
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
void assign_player_colors(void)
struct research * research_get(const struct player *pplayer)
const char * pick_random_player_name(const struct nation_type *pnation)
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
bool game_was_started(void)
enum barbarians_rate barbarianrate
struct civ_game::@30::@34 server
struct packet_game_info info
enum ai_level skill_level
enum barbarian_type barbarian_type
struct city_list * cities
struct player_ai ai_common
char username[MAX_LEN_NAME]
struct government * government
struct player_economic economic
struct player::@69::@71 server
#define sz_strlcpy(dest, src)
#define is_ocean_tile(ptile)
#define terrain_has_flag(terr, flag)
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)
int get_transporter_capacity(const struct unit *punit)
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
void unit_do_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
struct unit_type * get_role_unit(int role, int role_index)
int num_role_units(int role)
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
const char * utype_rule_name(const struct unit_type *punittype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)