Freeciv-3.1: /fast/freeciv/nightly/S3_1/ai/default/aiparatrooper.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
aiparatrooper.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "log.h"
20
21/* common */
22#include "city.h"
23#include "game.h"
24#include "player.h"
25#include "research.h"
26#include "unit.h"
27#include "unitlist.h"
28
29/* common/aicore */
30#include "pf_tools.h"
31
32/* server */
33#include "citytools.h"
34#include "maphand.h"
35#include "srv_log.h"
36#include "unithand.h"
37#include "unittools.h"
38
39/* server/advisors */
40#include "advdata.h"
41
42/* server/generator */
43#include "mapgen_utils.h"
44
45/* ai */
46#include "handicaps.h"
47
48/* ai/default */
49#include "aidata.h"
50#include "ailog.h"
51#include "aiplayer.h"
52#include "aiunit.h"
53#include "aitools.h"
54#include "daicity.h"
55
56#include "aiparatrooper.h"
57
58
59#define LOGLEVEL_PARATROOPER LOG_DEBUG
60
61/*************************************************************************/
64 static struct tile *find_best_tile_to_paradrop_to(struct ai_type *ait,
65 struct unit *punit)
66{
67 int best = 0;
68 int val;
69 struct tile* best_tile = NULL;
70 int range = unit_type_get(punit)->paratroopers_range;
71 struct city* acity;
72 struct player* pplayer = unit_owner(punit);
73 struct civ_map *nmap = &(wld.map);
74
75 /* First, we search for undefended cities in danger */
76 square_iterate(nmap, unit_tile(punit), range, ptile) {
77 if (!map_is_known(ptile, pplayer)) {
78 continue;
79 }
80
81 acity = tile_city(ptile);
82 if (acity && city_owner(acity) == unit_owner(punit)
83 && unit_list_size(ptile->units) == 0) {
84 val = city_size_get(acity) * def_ai_city_data(acity, ait)->urgency;
85 if (val > best) {
86 best = val;
87 best_tile = ptile;
88 }
89 }
90 } square_iterate_end;
91
92 if (best_tile != NULL) {
93 acity = tile_city(best_tile);
94 UNIT_LOG(LOGLEVEL_PARATROOPER, punit,
95 "Choose to jump in order to protect allied city %s (%d %d). "
96 "Benefit: %d",
97 city_name_get(acity), TILE_XY(best_tile), best);
98 return best_tile;
99 }
100
101 /* Second, we search for undefended enemy cities */
102 square_iterate(nmap, unit_tile(punit), range, ptile) {
103 acity = tile_city(ptile);
104 if (acity && pplayers_at_war(unit_owner(punit), city_owner(acity))
105 && (unit_list_size(ptile->units) == 0)) {
106 if (!map_is_known_and_seen(ptile, pplayer, V_MAIN)
107 && has_handicap(pplayer, H_FOG)) {
108 continue;
109 }
110 /* Prefer big cities on other continents */
111 val = city_size_get(acity)
112 + (tile_continent(unit_tile(punit)) != tile_continent(ptile));
113 if (val > best) {
114 best = val;
115 best_tile = ptile;
116 }
117 }
118 } square_iterate_end;
119
120 if (best_tile != NULL) {
121 acity = tile_city(best_tile);
122 UNIT_LOG(LOGLEVEL_PARATROOPER, punit,
123 "Choose to jump into enemy city %s (%d %d). Benefit: %d",
124 city_name_get(acity), TILE_XY(best_tile), best);
125 return best_tile;
126 }
127
128 /* Jump to kill adjacent units */
129 square_iterate(nmap, unit_tile(punit), range, ptile) {
130 struct terrain *pterrain = tile_terrain(ptile);
131 if (is_ocean(pterrain)) {
132 continue;
133 }
134 if (has_handicap(pplayer, H_FOG)) {
135 if (!map_is_known_and_seen(ptile, pplayer, V_MAIN)) {
136 continue;
137 }
138 } else {
139 if (!map_is_known(ptile, pplayer)) {
140 continue;
141 }
142 }
143 acity = tile_city(ptile);
144 if (acity && !pplayers_allied(city_owner(acity), pplayer)) {
145 continue;
146 }
147 if (!acity && unit_list_size(ptile->units) > 0) {
148 continue;
149 }
150
151 /* Iterate over adjacent tile to find good victim */
152 adjc_iterate(nmap, ptile, target) {
153 if (unit_list_size(target->units) == 0
154 || !can_unit_attack_tile(punit, NULL, target)
155 || is_ocean_tile(target)
156 || (has_handicap(pplayer, H_FOG)
157 && !map_is_known_and_seen(target, pplayer, V_MAIN))) {
158 continue;
159 }
160 val = 0;
161 if (is_stack_vulnerable(target)) {
162 unit_list_iterate(target->units, victim) {
163 if ((!has_handicap(pplayer, H_FOG)
164 || can_player_see_unit(pplayer, victim))
165 && (unit_attack_unit_at_tile_result(punit, NULL,
166 victim, target)
167 == ATT_OK)) {
168 val += victim->hp * 100;
169 }
170 } unit_list_iterate_end;
171 } else {
172 val += get_defender(nmap, punit, target)->hp * 100;
173 }
174 val *= unit_win_chance(nmap, punit,
175 get_defender(nmap, punit, target));
176 val += pterrain->defense_bonus / 10;
177 val -= punit->hp * 100;
178
179 if (val > best) {
180 best = val;
181 best_tile = ptile;
182 }
183 } adjc_iterate_end;
184 } square_iterate_end;
185
186 if (best_tile != NULL) {
187 UNIT_LOG(LOG_DEBUG, punit, "Choose to jump at (%d, %d) to attack "
188 "adjacent units. Benefit: %d",
189 TILE_XY(best_tile), best);
190 }
191
192 return best_tile;
193}
194
195/*************************************************************************/
198 void dai_manage_paratrooper(struct ai_type *ait, struct player *pplayer,
199 struct unit *punit)
200{
201 struct city *pcity = tile_city(unit_tile(punit));
202 struct tile *ptile_dest = NULL;
203 const struct civ_map *nmap = &(wld.map);
204 int sanity = punit->id;
205
206 /* Defend attacking (and be opportunistic too) */
207 if (!dai_military_rampage(punit, RAMPAGE_ANYTHING,
208 RAMPAGE_FREE_CITY_OR_BETTER)) {
209 /* Dead */
210 return;
211 }
212
213 /* Check to recover hit points */
214 if ((punit->hp < unit_type_get(punit)->hp / 2) && pcity) {
215 UNIT_LOG(LOGLEVEL_PARATROOPER, punit, "Recovering hit points.");
216 return;
217 }
218
219 /* Nothing to do! */
220 if (punit->moves_left == 0) {
221 return;
222 }
223
224 if (pcity && unit_list_size(unit_tile(punit)->units) == 1) {
225 UNIT_LOG(LOGLEVEL_PARATROOPER, punit, "Defending the city.");
226 return;
227 }
228
229 if (can_unit_paradrop(nmap, punit)) {
230 ptile_dest = find_best_tile_to_paradrop_to(ait, punit);
231
232 if (ptile_dest) {
233 bool jump_performed = FALSE;
234
235 action_iterate(act_id) {
236 struct action *paction = action_by_number(act_id);
237 bool possible;
238
239 if (!(action_has_result(paction, ACTRES_PARADROP)
240 || action_has_result(paction, ACTRES_PARADROP_CONQUER))) {
241 /* Not relevant. */
242 continue;
243 }
244
245 if (has_handicap(pplayer, H_FOG)) {
246 possible = action_prob_possible(
247 action_prob_unit_vs_tgt(paction, punit,
248 tile_city(ptile_dest), NULL,
249 ptile_dest, NULL));
250 } else {
251 possible = is_action_enabled_unit_on_tile(nmap, paction->id, punit,
252 ptile_dest, NULL);
253 }
254
255 if (possible) {
256 jump_performed
257 = unit_perform_action(unit_owner(punit), punit->id,
258 tile_index(ptile_dest), NO_TARGET, "",
259 paction->id, ACT_REQ_PLAYER);
260 }
261
262 if (jump_performed || NULL == game_unit_by_number(sanity)) {
263 /* Finished or finished. */
264 break;
265 }
266 } action_iterate_end;
267
268 if (jump_performed) {
269 /* Successful! */
270 if (NULL == game_unit_by_number(sanity)) {
271 /* The unit did not survive the move */
272 return;
273 }
274 /* We attack the target */
275 (void) dai_military_rampage(punit, RAMPAGE_ANYTHING,
276 RAMPAGE_ANYTHING);
277 }
278 }
279 } else {
280 /* We can't paradrop :-( */
281 struct city *acity = NULL;
282
283 /* We are in a city, so don't try to find another */
284 if (pcity) {
285 UNIT_LOG(LOGLEVEL_PARATROOPER, punit,
286 "waiting in a city for next turn.");
287 return;
288 }
289
290 /* Find a city to go to recover and paradrop from */
291 acity = find_nearest_safe_city(punit);
292
293 if (acity) {
294 UNIT_LOG(LOGLEVEL_PARATROOPER, punit, "Going to %s", city_name_get(acity));
295 if (!dai_unit_goto(ait, punit, acity->tile)) {
296 /* Died or unsuccessful move */
297 return;
298 }
299 } else {
300 UNIT_LOG(LOGLEVEL_PARATROOPER, punit,
301 "didn't find city to go and recover.");
302 dai_manage_military(ait, pplayer, punit);
303 }
304 }
305}
306
307/*************************************************************************/
311 static int calculate_want_for_paratrooper(struct unit *punit,
312 struct tile *ptile_city)
313{
314 const struct unit_type* u_type = unit_type_get(punit);
315 int range = u_type->paratroopers_range;
316 int profit = 0;
317 struct player* pplayer = unit_owner(punit);
318 int total, total_cities;
319 struct civ_map *nmap = &(wld.map);
320
321 profit += u_type->defense_strength
322 + u_type->move_rate
323 + u_type->attack_strength;
324
325 square_iterate(nmap, ptile_city, range, ptile) {
326 int multiplier;
327 struct city *pcity = tile_city(ptile);
328
329 if (!pcity) {
330 continue;
331 }
332
333 if (!map_is_known(ptile, pplayer)) {
334 continue;
335 }
336
337 /* We prefer jumping to other continents. On the same continent we
338 * can fight traditionally.
339 * FIXME: Handle ocean cities we can attack. */
340 if (!is_ocean_tile(ptile)
341 && tile_continent(ptile_city) != tile_continent(ptile)) {
342 if (get_continent_size(tile_continent(ptile)) < 3) {
343 /* Tiny island are hard to conquer with traditional units */
344 multiplier = 10;
345 } else {
346 multiplier = 5;
347 }
348 } else {
349 multiplier = 1;
350 }
351
352 /* There are lots of units, the city will be safe against paratroopers. */
353 if (unit_list_size(ptile->units) > 2) {
354 continue;
355 }
356
357 /* Prefer long jumps.
358 * If a city is near we can take/protect it with normal units */
359 if (pplayers_allied(pplayer, city_owner(pcity))) {
360 profit += city_size_get(pcity)
361 * multiplier * real_map_distance(ptile_city, ptile) / 2;
362 } else {
363
364 profit += city_size_get(pcity) * multiplier
365 * real_map_distance(ptile_city, ptile);
366 }
367 } square_iterate_end;
368
369 total = adv_data_get(pplayer, NULL)->stats.units.paratroopers;
370 total_cities = city_list_size(pplayer->cities);
371
372 if (total > total_cities) {
373 profit = profit * total_cities / total;
374 }
375
376 return profit;
377}
378
379/*************************************************************************/
382 void dai_choose_paratrooper(struct ai_type *ait,
383 struct player *pplayer, struct city *pcity,
384 struct adv_choice *choice, bool allow_gold_upkeep)
385{
386 const struct research *presearch;
387 int profit;
388 Tech_type_id tech_req;
389 Tech_type_id requirements[A_LAST];
390 int num_requirements = 0;
391 int i;
392 struct ai_plr *plr_data = def_ai_player_data(pplayer, ait);
393
394 /* military_advisor_choose_build() does something idiotic,
395 * this function should not be called if there is danger... */
396 if (choice->want >= 100 && choice->type != CT_ATTACKER) {
397 return;
398 }
399
400 unit_type_iterate(u_type) {
401 struct unit *virtual_unit;
402
403 if (!utype_can_do_action(u_type, ACTION_PARADROP)
404 && !utype_can_do_action(u_type, ACTION_PARADROP_CONQUER)) {
405 continue;
406 }
407 if (A_NEVER == u_type->require_advance) {
408 continue;
409 }
410
411 if (!allow_gold_upkeep && utype_upkeep_cost(u_type, pplayer, O_GOLD) > 0) {
412 continue;
413 }
414
415 /* Temporary hack before we are smart enough to return such units */
416 if (!utype_is_consumed_by_action_result(ACTRES_ATTACK, u_type)
417 && 1 == utype_fuel(u_type)) {
418 continue;
419 }
420
421 /* Assign tech for paratroopers */
422 tech_req = advance_index(u_type->require_advance);
423 if (tech_req != A_NONE && tech_req != A_UNSET) {
424 for (i = 0; i < num_requirements; i++) {
425 if (requirements[i] == tech_req) {
426 break;
427 }
428 }
429 if (i == num_requirements) {
430 requirements[num_requirements++] = tech_req;
431 }
432 }
433
434 /* we only update choice struct if we can build it! */
435 if (!can_city_build_unit_now(pcity, u_type)) {
436 continue;
437 }
438
439 /* it's worth building that unit? */
440 virtual_unit = unit_virtual_create(
441 pplayer, pcity, u_type,
442 city_production_unit_veteran_level(pcity, u_type));
443 profit = calculate_want_for_paratrooper(virtual_unit, pcity->tile);
444 unit_virtual_destroy(virtual_unit);
445
446 /* update choice struct if it's worth */
447 if (profit > choice->want) {
448 /* Update choice */
449 choice->want = profit;
450 choice->value.utype = u_type;
451 choice->type = CT_ATTACKER;
452 choice->need_boat = FALSE;
453 adv_choice_set_use(choice, "paratrooper");
454 log_base(LOGLEVEL_PARATROOPER, "%s wants to build %s (want=%d)",
455 city_name_get(pcity), utype_rule_name(u_type), profit);
456 }
457 } unit_type_iterate_end;
458
459 /* we raise want if the required tech is not known */
460 presearch = research_get(pplayer);
461 for (i = 0; i < num_requirements; i++) {
462 tech_req = requirements[i];
463 plr_data->tech_want[tech_req] += 2;
464 log_base(LOGLEVEL_PARATROOPER, "Raising tech want in city %s for %s "
465 "stimulating %s with %d (" ADV_WANT_PRINTF ") and req",
466 city_name_get(pcity),
467 player_name(pplayer),
468 advance_rule_name(advance_by_number(tech_req)),
469 2,
470 plr_data->tech_want[tech_req]);
471
472 /* now, we raise want for prerequisites */
473 advance_index_iterate(A_FIRST, k) {
474 if (research_goal_tech_req(presearch, tech_req, k)) {
475 plr_data->tech_want[k] += 1;
476 }
477 } advance_index_iterate_end;
478 }
479 return;
480}
action_prob_possible
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:6709
action_prob_unit_vs_tgt
struct act_prob action_prob_unit_vs_tgt(const struct action *paction, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct extra_type *extra_tgt)
Definition actions.c:6405
is_action_enabled_unit_on_tile
bool is_action_enabled_unit_on_tile(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:4996
action_by_number
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
action_has_result
#define action_has_result(_act_, _res_)
Definition actions.h:448
action_iterate_end
#define action_iterate_end
Definition actions.h:472
action_iterate
#define action_iterate(_act_)
Definition actions.h:467
adv_choice_set_use
#define adv_choice_set_use(_choice, _use)
Definition advchoice.h:85
CT_ATTACKER
@ CT_ATTACKER
Definition advchoice.h:40
adv_data_get
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Definition advdata.c:593
advdata.h
aidata.h
ailog.h
find_best_tile_to_paradrop_to
static struct tile * find_best_tile_to_paradrop_to(struct ai_type *ait, struct unit *punit)
Definition aiparatrooper.c:64
dai_manage_paratrooper
void dai_manage_paratrooper(struct ai_type *ait, struct player *pplayer, struct unit *punit)
Definition aiparatrooper.c:198
dai_choose_paratrooper
void dai_choose_paratrooper(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
Definition aiparatrooper.c:382
LOGLEVEL_PARATROOPER
#define LOGLEVEL_PARATROOPER
Definition aiparatrooper.c:59
calculate_want_for_paratrooper
static int calculate_want_for_paratrooper(struct unit *punit, struct tile *ptile_city)
Definition aiparatrooper.c:311
aiparatrooper.h
aiplayer.h
def_ai_player_data
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
Definition aiplayer.h:54
def_ai_city_data
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
Definition aiplayer.h:42
dai_unit_goto
bool dai_unit_goto(struct ai_type *ait, struct unit *punit, struct tile *ptile)
Definition aitools.c:604
aitools.h
dai_manage_military
void dai_manage_military(struct ai_type *ait, struct player *pplayer, struct unit *punit)
Definition aiunit.c:2497
find_nearest_safe_city
struct city * find_nearest_safe_city(struct unit *punit)
Definition aiunit.c:1630
dai_military_rampage
bool dai_military_rampage(struct unit *punit, int thresh_adj, int thresh_move)
Definition aiunit.c:599
aiunit.h
RAMPAGE_ANYTHING
#define RAMPAGE_ANYTHING
Definition aiunit.h:85
RAMPAGE_FREE_CITY_OR_BETTER
#define RAMPAGE_FREE_CITY_OR_BETTER
Definition aiunit.h:87
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1106
city_production_unit_veteran_level
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
Definition city.c:788
can_city_build_unit_now
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:925
city.h
city_size_get
static citizens city_size_get(const struct city *pcity)
Definition city.h:549
city_owner
#define city_owner(_pcity_)
Definition city.h:543
citytools.h
is_stack_vulnerable
bool is_stack_vulnerable(const struct tile *ptile)
Definition combat.c:928
unit_attack_unit_at_tile_result
enum unit_attack_result unit_attack_unit_at_tile_result(const struct unit *punit, const struct action *paction, const struct unit *pdefender, const struct tile *dest_tile)
Definition combat.c:122
unit_win_chance
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender)
Definition combat.c:438
can_unit_attack_tile
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
Definition combat.c:271
get_defender
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile)
Definition combat.c:781
ATT_OK
@ ATT_OK
Definition combat.h:35
daicity.h
punit
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
Definition dialogs_g.h:73
NO_TARGET
#define NO_TARGET
Definition fc_types.h:324
Tech_type_id
int Tech_type_id
Definition fc_types.h:347
ADV_WANT_PRINTF
#define ADV_WANT_PRINTF
Definition fc_types.h:1207
O_GOLD
@ O_GOLD
Definition fc_types.h:91
wld
struct world wld
Definition game.c:58
game_unit_by_number
struct unit * game_unit_by_number(int id)
Definition game.c:111
game.h
has_handicap
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
Definition handicaps.c:66
handicaps.h
H_FOG
@ H_FOG
Definition handicaps.h:26
log.h
log_base
#define log_base(level, message,...)
Definition log.h:94
LOG_DEBUG
@ LOG_DEBUG
Definition log.h:34
real_map_distance
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:628
adjc_iterate_end
#define adjc_iterate_end
Definition map.h:427
square_iterate
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:385
adjc_iterate
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:422
square_iterate_end
#define square_iterate_end
Definition map.h:388
get_continent_size
int get_continent_size(Continent_id id)
Definition mapgen_utils.c:425
mapgen_utils.h
map_is_known
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Definition maphand.c:886
map_is_known_and_seen
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Definition maphand.c:900
maphand.h
pf_tools.h
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:886
can_player_see_unit
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Definition player.c:1084
pplayers_at_war
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1364
pplayers_allied
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1381
player.h
research_goal_tech_req
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
Definition research.c:797
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research.h
srv_log.h
UNIT_LOG
#define UNIT_LOG(loglevel, punit, msg,...)
Definition srv_log.h:98
action
Definition actions.h:379
action::id
action_id id
Definition actions.h:380
adv_choice
Definition advchoice.h:45
adv_choice::type
enum choice_type type
Definition advchoice.h:46
adv_choice::want
adv_want want
Definition advchoice.h:48
adv_choice::value
universals_u value
Definition advchoice.h:47
adv_choice::need_boat
bool need_boat
Definition advchoice.h:49
adv_data::stats
struct adv_data::@92 stats
adv_data::units
struct adv_data::@92::@95 units
adv_data::paratroopers
int paratroopers
Definition advdata.h:83
ai_city::urgency
unsigned int urgency
Definition daicity.h:49
ai_plr
Definition aidata.h:71
ai_plr::tech_want
adv_want tech_want[A_LAST+1]
Definition aidata.h:103
ai_type
Definition ai.h:50
city
Definition city.h:309
city::tile
struct tile * tile
Definition city.h:311
civ_map
Definition map_types.h:71
multiplier
Definition multipliers.h:31
player
Definition player.h:249
player::cities
struct city_list * cities
Definition player.h:281
range
Definition unittype.c:931
research
Definition research.h:39
terrain
Definition terrain.h:176
terrain::defense_bonus
int defense_bonus
Definition terrain.h:193
tile
Definition tile.h:49
unit_type
Definition unittype.h:481
unit_type::defense_strength
int defense_strength
Definition unittype.h:496
unit_type::paratroopers_range
int paratroopers_range
Definition unittype.h:522
unit_type::move_rate
int move_rate
Definition unittype.h:497
unit_type::attack_strength
int attack_strength
Definition unittype.h:495
unit
Definition unit.h:138
unit::moves_left
int moves_left
Definition unit.h:150
unit::id
int id
Definition unit.h:145
unit::hp
int hp
Definition unit.h:151
world::map
struct civ_map map
Definition world_object.h:38
FALSE
#define FALSE
Definition support.h:47
advance_by_number
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
advance_rule_name
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:299
advance_index
Tech_type_id advance_index(const struct advance *padvance)
Definition tech.c:89
A_NEVER
#define A_NEVER
Definition tech.h:51
advance_index_iterate_end
#define advance_index_iterate_end
Definition tech.h:248
tech_req
tech_req
Definition tech.h:110
A_FIRST
#define A_FIRST
Definition tech.h:44
A_NONE
#define A_NONE
Definition tech.h:43
A_UNSET
#define A_UNSET
Definition tech.h:48
A_LAST
#define A_LAST
Definition tech.h:45
advance_index_iterate
#define advance_index_iterate(_start, _index)
Definition tech.h:244
is_ocean
#define is_ocean(pterrain)
Definition terrain.h:287
is_ocean_tile
#define is_ocean_tile(ptile)
Definition terrain.h:289
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_index
#define tile_index(_pt_)
Definition tile.h:87
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:109
TILE_XY
#define TILE_XY(ptile)
Definition tile.h:42
tile_continent
#define tile_continent(_tile)
Definition tile.h:91
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:604
unit_virtual_create
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1613
can_unit_paradrop
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:823
unit_virtual_destroy
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1709
unit.h
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
unit_perform_action
bool unit_perform_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id_incoming, const char *name, const action_id action_type, const enum action_requester requester)
Definition unithand.c:3173
unithand.h
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unittools.h
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
utype_upkeep_cost
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Definition unittype.c:132
utype_is_consumed_by_action_result
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
Definition unittype.c:1281
utype_rule_name
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
utype_can_do_action
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:443
utype_fuel
#define utype_fuel(ptype)
Definition unittype.h:822
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845