Freeciv21
Develop your civilization from humble roots to a global empire
aihunt.cpp File Reference
#include "bitvector.h"
#include "log.h"
#include "city.h"
#include "combat.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "nation.h"
#include "player.h"
#include "unit.h"
#include "unitlist.h"
#include "pf_tools.h"
#include "srv_log.h"
#include "unithand.h"
#include "unittools.h"
#include "advdata.h"
#include "advgoto.h"
#include "advtools.h"
#include "handicaps.h"
#include "ailog.h"
#include "aiplayer.h"
#include "aitools.h"
#include "aiunit.h"
#include "daicity.h"
#include "aihunt.h"
+ Include dependency graph for aihunt.cpp:

Go to the source code of this file.

Functions

static struct unitdai_hunter_find (struct player *pplayer, struct city *pcity)
 We don't need a hunter in this city if we already have one. More...
 
static struct unit_typedai_hunter_guess_best (struct city *pcity, enum terrain_class tc, struct ai_type *ait, bool allow_gold_upkeep)
 Guess best hunter unit type. More...
 
static void dai_hunter_missile_want (struct player *pplayer, struct city *pcity, struct adv_choice *choice)
 Check if we want to build a missile for our hunter. More...
 
static void eval_hunter_want (struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, struct unit_type *best_type, int veteran)
 Support function for ai_hunter_choice() More...
 
void dai_hunter_choice (struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
 Check if we want to build a hunter. More...
 
bool dai_hunter_qualify (struct player *pplayer, struct unit *punit)
 Does this unit qualify as a hunter? More...
 
static void dai_hunter_try_launch (struct ai_type *ait, struct player *pplayer, struct unit *punit, struct unit *target)
 Try to shoot our target with a missile. More...
 
static void dai_hunter_juiciness (struct player *pplayer, struct unit *punit, struct unit *target, int *stackthreat, int *stackcost)
 Calculate desire to crush this target. More...
 
int dai_hunter_manage (struct ai_type *ait, struct player *pplayer, struct unit *punit)
 Manage a (possibly virtual) hunter. More...
 

Function Documentation

◆ dai_hunter_choice()

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

Check if we want to build a hunter.

Definition at line 262 of file aihunt.cpp.

Referenced by military_advisor_choose_build().

◆ dai_hunter_find()

static struct unit* dai_hunter_find ( struct player pplayer,
struct city pcity 
)
static

We don't need a hunter in this city if we already have one.

Return existing hunter if any.

Definition at line 58 of file aihunt.cpp.

Referenced by dai_hunter_choice().

◆ dai_hunter_guess_best()

static struct unit_type* dai_hunter_guess_best ( struct city pcity,
enum terrain_class  tc,
struct ai_type ait,
bool  allow_gold_upkeep 
)
static

Guess best hunter unit type.

Definition at line 82 of file aihunt.cpp.

Referenced by dai_hunter_choice().

◆ dai_hunter_juiciness()

static void dai_hunter_juiciness ( struct player pplayer,
struct unit punit,
struct unit target,
int *  stackthreat,
int *  stackcost 
)
static

Calculate desire to crush this target.

Definition at line 406 of file aihunt.cpp.

Referenced by dai_hunter_manage().

◆ dai_hunter_manage()

int dai_hunter_manage ( struct ai_type ait,
struct player pplayer,
struct unit punit 
)

Manage a (possibly virtual) hunter.

Return the want for building a hunter like this. If we return 0, then we have nothing to do with the hunter. If we return -1, then we succeeded, and can try again. If we return > 0 then we are hunting but ran out of moves (this is also used for construction want).

We try to keep track of our original target, but also opportunistically snatch up closer targets if they are better.

We set punit->server.ai->target to target's id.

Definition at line 445 of file aihunt.cpp.

Referenced by dai_manage_military(), and eval_hunter_want().

◆ dai_hunter_missile_want()

static void dai_hunter_missile_want ( struct player pplayer,
struct city pcity,
struct adv_choice choice 
)
static

Check if we want to build a missile for our hunter.

Definition at line 152 of file aihunt.cpp.

Referenced by dai_hunter_choice().

◆ dai_hunter_qualify()

bool dai_hunter_qualify ( struct player pplayer,
struct unit punit 
)

Does this unit qualify as a hunter?

Definition at line 297 of file aihunt.cpp.

Referenced by dai_hunter_find(), dai_hunter_missile_want(), and dai_manage_military().

◆ dai_hunter_try_launch()

static void dai_hunter_try_launch ( struct ai_type ait,
struct player pplayer,
struct unit punit,
struct unit target 
)
static

Try to shoot our target with a missile.

Also shoot down anything that might attempt to intercept us. We assign missiles to a hunter in ai_unit_new_role().

Definition at line 310 of file aihunt.cpp.

Referenced by dai_hunter_manage().

◆ eval_hunter_want()

static void eval_hunter_want ( struct ai_type ait,
struct player pplayer,
struct city pcity,
struct adv_choice choice,
struct unit_type best_type,
int  veteran 
)
static

Support function for ai_hunter_choice()

Definition at line 239 of file aihunt.cpp.

Referenced by dai_hunter_choice().