Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions
aiair.c File Reference
#include "log.h"
#include "combat.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "player.h"
#include "pf_tools.h"
#include "unit.h"
#include "citytools.h"
#include "maphand.h"
#include "srv_log.h"
#include "unithand.h"
#include "unittools.h"
#include "advbuilding.h"
#include "advgoto.h"
#include "handicaps.h"
#include "aitools.h"
#include "daicity.h"
#include "daiplayer.h"
#include "aiair.h"

Go to the source code of this file.

Macros

#define PROB_MULTIPLIER   100 /* Should unify with those in combat.c */
 

Functions

static int regen_turns (struct unit *punit, struct tile *ptile, int lost_hp)
 
static struct tilefind_nearest_airbase (struct unit *punit, struct pf_path **path)
 
static bool dai_should_we_air_attack_tile (struct ai_type *ait, struct unit *punit, struct tile *ptile)
 
static adv_want dai_evaluate_tile_for_air_attack (struct unit *punit, struct tile *dst_tile)
 
static adv_want find_something_to_bomb (struct ai_type *ait, struct unit *punit, struct pf_path **path, struct tile **pptile)
 
static struct tiledai_find_strategic_airbase (struct ai_type *ait, struct unit *punit, struct pf_path **path)
 
void dai_manage_airunit (struct ai_type *ait, struct player *pplayer, struct unit *punit)
 
bool dai_choose_attacker_air (struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
 

Macro Definition Documentation

◆ PROB_MULTIPLIER

#define PROB_MULTIPLIER   100 /* Should unify with those in combat.c */

Function Documentation

◆ dai_choose_attacker_air()

bool dai_choose_attacker_air ( struct ai_type ait,
struct player pplayer,
struct city pcity,
struct adv_choice choice,
bool  allow_gold_upkeep 
)

Chooses the best available and usable air unit and records it in choice, if it's better than previous choice The interface is somewhat different from other ai_choose, but that's what it should be like, I believe – GB

Definition at line 582 of file aiair.c.

Referenced by military_advisor_choose_build().

◆ dai_evaluate_tile_for_air_attack()

static adv_want dai_evaluate_tile_for_air_attack ( struct unit punit,
struct tile dst_tile 
)
static

Returns an estimate for the profit gained through attack. Assumes that the victim is within one day's flight

Definition at line 163 of file aiair.c.

Referenced by find_something_to_bomb().

◆ dai_find_strategic_airbase()

static struct tile * dai_find_strategic_airbase ( struct ai_type ait,
struct unit punit,
struct pf_path **  path 
)
static

Iterates through reachable refuel points and appraises them as a possible base for air operations by (air)unit punit. Returns NULL if not found (or we just should stay here). The path is stored in the path argument if not NULL.

  1. If the unit is damaged, looks for the fastest full regeneration. (Should we set the unit task to AIUNIT_RECOVER? Currently, no gain)
  2. Goes to the nearest city that needs a defender immediately.
  3. Evaluates bombing targets from the bases and chooses the best. FIXME: consider airbase safety! Don't be lured to enemy airbases!

Definition at line 317 of file aiair.c.

Referenced by dai_manage_airunit().

◆ dai_manage_airunit()

void dai_manage_airunit ( struct ai_type ait,
struct player pplayer,
struct unit punit 
)

Trying to manage bombers and stuff. If we are in the open { if moving intelligently on a valid GOTO, { carry on doing it. } else { go refuel } } else { try to attack something } TODO: distant target selection, support for fuel > 2

Definition at line 486 of file aiair.c.

Referenced by dai_manage_airunit(), and dai_manage_unit().

◆ dai_should_we_air_attack_tile()

static bool dai_should_we_air_attack_tile ( struct ai_type ait,
struct unit punit,
struct tile ptile 
)
static

Very preliminary estimate for our intent to attack the tile (x, y). Used by bombers only.

Definition at line 138 of file aiair.c.

Referenced by find_something_to_bomb().

◆ find_nearest_airbase()

static struct tile * find_nearest_airbase ( struct unit punit,
struct pf_path **  path 
)
static

Looks for nearest airbase for punit reachable immediately. Returns NULL if not found. The path is stored in the path argument if not NULL. If the unit is damaged, flies to an airbase that can repair the unit in a minimal number of turns. FIXME: consider airdrome safety. Can lure enemy bombers to a spare airdrome next to our rifles. TODO: Special handicaps for planes running out of fuel IMO should be less restrictive than general H_MAP, H_FOG

Definition at line 86 of file aiair.c.

Referenced by dai_manage_airunit().

◆ find_something_to_bomb()

static adv_want find_something_to_bomb ( struct ai_type ait,
struct unit punit,
struct pf_path **  path,
struct tile **  pptile 
)
static

Find something to bomb Air-units specific victim search Returns the want for the best target. The targets are stored in the path and pptile arguments if not NULL. TODO: take counterattack dangers into account TODO: make separate handicaps for air units seeing targets IMO should be more restrictive than general H_MAP, H_FOG

Definition at line 247 of file aiair.c.

Referenced by dai_choose_attacker_air(), dai_find_strategic_airbase(), and dai_manage_airunit().

◆ regen_turns()

static int regen_turns ( struct unit punit,
struct tile ptile,
int  lost_hp 
)
inlinestatic

How fast does a unit regenerate at another tile after moves to it. Kludgy function worth some generalization.

Definition at line 55 of file aiair.c.

Referenced by dai_find_strategic_airbase(), and find_nearest_airbase().