Freeciv-3.1
Loading...
Searching...
No Matches
aihunt.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2003 - 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 "bitvector.h"
20#include "log.h"
21
22/* common */
23#include "city.h"
24#include "combat.h"
25#include "game.h"
26#include "map.h"
27#include "movement.h"
28#include "player.h"
29#include "unit.h"
30#include "unitlist.h"
31
32/* aicore */
33#include "pf_tools.h"
34
35/* server */
36#include "citytools.h"
37#include "srv_log.h"
38#include "unithand.h"
39#include "unittools.h"
40
41/* server/advisors */
42#include "advdata.h"
43#include "advgoto.h"
44#include "advtools.h"
45#include "autosettlers.h"
46
47/* ai */
48#include "handicaps.h"
49
50/* ai/default */
51#include "ailog.h"
52#include "aiplayer.h"
53#include "aitools.h"
54#include "aiunit.h"
55#include "daicity.h"
56
57#include "aihunt.h"
58
59
60/**********************************************************************/
64static struct unit *dai_hunter_find(struct player *pplayer,
65 struct city *pcity)
66{
68 if (dai_hunter_qualify(pplayer, punit)) {
69 return punit;
70 }
73 if (dai_hunter_qualify(pplayer, punit)) {
74 return punit;
75 }
77
78 return NULL;
79}
80
81/**********************************************************************/
84static struct unit_type *dai_hunter_guess_best(struct city *pcity,
85 enum terrain_class tc,
86 struct ai_type *ait,
87 bool allow_gold_upkeep)
88{
89 struct unit_type *bestid = NULL;
90 int best = 0;
91 struct player *pplayer = city_owner(pcity);
92
94 struct unit_type_ai *utai = utype_ai_data(ut, ait);
95 int desire;
96
97 if (!allow_gold_upkeep && utype_upkeep_cost(ut, pplayer, O_GOLD) > 0) {
98 continue;
99 }
100
101 if (!can_city_build_unit_now(pcity, ut)
102 || ut->attack_strength < ut->transport_capacity
103 || (tc == TC_OCEAN && utype_class(ut)->adv.sea_move == MOVE_NONE)
104 || (tc == TC_LAND && utype_class(ut)->adv.land_move == MOVE_NONE)) {
105 continue;
106 }
107
108 desire = (ut->hp
109 * ut->attack_strength
110 * ut->firepower
111 * ut->move_rate
112 + ut->defense_strength) / MAX(UNITTYPE_COSTS(ut), 1);
113
114 if (utai->missile_platform) {
115 desire += desire / 6;
116 }
117
118 if (utype_has_flag(ut, UTYF_IGTER)) {
119 desire += desire / 2;
120 }
121 if (ut->vlayer == V_INVIS) {
122 desire += desire / 4;
123 }
124 if (!can_attack_non_native(ut)) {
125 desire -= desire / 4; /* less flexibility */
126 }
127 /* Causes continual unhappiness */
128 if (utype_has_flag(ut, UTYF_FIELDUNIT)) {
129 desire /= 2;
130 }
131
132 desire = amortize(desire,
133 (utype_build_shield_cost(pcity, NULL, ut)
134 / MAX(pcity->surplus[O_SHIELD], 1)));
135
136 if (desire > best) {
137 best = desire;
138 bestid = ut;
139 }
141
142 return bestid;
143}
144
145/**********************************************************************/
148static void dai_hunter_missile_want(struct player *pplayer,
149 struct city *pcity,
150 struct adv_choice *choice)
151{
152 adv_want best = -1;
153 struct unit_type *best_unit_type = NULL;
154 struct unit *hunter = NULL;
155
157 if (dai_hunter_qualify(pplayer, punit)) {
158 unit_type_iterate(pcargo) {
160 utype_class(pcargo))
161 && utype_can_do_action(pcargo, ACTION_SUICIDE_ATTACK)) {
162 hunter = punit;
163 break;
164 }
166 if (hunter) {
167 break;
168 }
169 }
171
172 if (!hunter) {
173 return;
174 }
175
177 int desire;
178
179 if (!utype_can_do_action(ut, ACTION_SUICIDE_ATTACK)
180 || !can_city_build_unit_now(pcity, ut)) {
181 continue;
182 }
183
185 continue;
186 }
187
188 /* FIXME: We need to store some data that can tell us if
189 * enemy transports are protected by anti-missile technology.
190 * In this case, want nuclear much more! */
191 desire = (ut->hp
192 * MIN(ut->attack_strength, 30) /* nuke fix */
193 * ut->firepower
194 * ut->move_rate) / UNITTYPE_COSTS(ut) + 1;
195
196 /* Causes continual unhappiness */
197 if (utype_has_flag(ut, UTYF_FIELDUNIT)) {
198 desire /= 2;
199 }
200
201 desire = amortize(desire,
202 (utype_build_shield_cost(pcity, NULL, ut)
203 / MAX(pcity->surplus[O_SHIELD], 1)));
204
205 if (desire > best) {
206 best = desire;
207 best_unit_type = ut;
208 }
210
211 if (best > choice->want) {
212 CITY_LOG(LOGLEVEL_HUNT, pcity,
213 "pri missile w/ want " ADV_WANT_PRINTF, best);
214 choice->value.utype = best_unit_type;
215 choice->want = best;
216 choice->type = CT_ATTACKER;
217 choice->need_boat = FALSE;
218 adv_choice_set_use(choice, "missile");
219 } else if (best >= 0) {
220 CITY_LOG(LOGLEVEL_HUNT, pcity, "not pri missile w/ want " ADV_WANT_PRINTF
221 "(old want " ADV_WANT_PRINTF ")", best, choice->want);
222 }
223}
224
225/**********************************************************************/
228static void eval_hunter_want(struct ai_type *ait, struct player *pplayer,
229 struct city *pcity,
230 struct adv_choice *choice,
231 struct unit_type *best_type,
232 int veteran)
233{
234 struct unit *virtualunit;
235 int want = 0;
236
237 virtualunit = unit_virtual_create(pplayer, pcity, best_type, veteran);
238 want = dai_hunter_manage(ait, pplayer, virtualunit);
239 unit_virtual_destroy(virtualunit);
240 if (want > choice->want) {
241 CITY_LOG(LOGLEVEL_HUNT, pcity, "pri hunter w/ want %d", want);
242 choice->value.utype = best_type;
243 choice->want = want;
244 choice->type = CT_ATTACKER;
245 choice->need_boat = FALSE;
246 adv_choice_set_use(choice, "hunter");
247 }
248}
249
250/**********************************************************************/
253void dai_hunter_choice(struct ai_type *ait, struct player *pplayer,
254 struct city *pcity, struct adv_choice *choice,
255 bool allow_gold_upkeep)
256{
257 struct unit_type *best_land_hunter
258 = dai_hunter_guess_best(pcity, TC_LAND, ait, allow_gold_upkeep);
259 struct unit_type *best_sea_hunter
260 = dai_hunter_guess_best(pcity, TC_OCEAN, ait, allow_gold_upkeep);
261 struct unit *hunter = dai_hunter_find(pplayer, pcity);
262
263 if ((!best_land_hunter && !best_sea_hunter)
264 || is_barbarian(pplayer) || !pplayer->is_alive
265 || has_handicap(pplayer, H_TARGETS)) {
266 return; /* None available */
267 }
268 if (hunter) {
269 /* Maybe want missiles to go with a hunter instead? */
270 dai_hunter_missile_want(pplayer, pcity, choice);
271 return;
272 }
273
274 if (best_sea_hunter) {
276 ait, pplayer, pcity, choice, best_sea_hunter,
277 city_production_unit_veteran_level(pcity, best_sea_hunter));
278 }
279 if (best_land_hunter) {
281 ait, pplayer, pcity, choice, best_land_hunter,
282 city_production_unit_veteran_level(pcity, best_land_hunter));
283 }
284}
285
286/**********************************************************************/
289bool dai_hunter_qualify(struct player *pplayer, struct unit *punit)
290{
291 if (is_barbarian(pplayer) || unit_owner(punit) != pplayer) {
292 return FALSE;
293 }
294 if (unit_has_type_role(punit, L_HUNTER)) {
295 return TRUE;
296 }
297 return FALSE;
298}
299
300/**********************************************************************/
305static void dai_hunter_try_launch(struct ai_type *ait,
306 struct player *pplayer,
307 struct unit *punit,
308 struct unit *target)
309{
310 int target_sanity = target->id;
311 struct pf_parameter parameter;
312 struct pf_map *pfm;
313 const struct civ_map *nmap = &(wld.map);
314
315 /* Only directly transported units. Not launching cargo of cargo */
317 struct unit *sucker = NULL;
318
319 if (unit_owner(missile) == pplayer
321 ACTION_SUICIDE_ATTACK)) {
322 UNIT_LOG(LOGLEVEL_HUNT, missile, "checking for hunt targets");
323 pft_fill_unit_parameter(&parameter, nmap, punit);
324 parameter.omniscience = !has_handicap(pplayer, H_MAP);
325 pfm = pf_map_new(&parameter);
326
327 pf_map_move_costs_iterate(pfm, ptile, move_cost, FALSE) {
328 if (move_cost > missile->moves_left / SINGLE_MOVE) {
329 break;
330 }
331 if (tile_city(ptile)
332 || !can_unit_attack_tile(punit, NULL, ptile)) {
333 continue;
334 }
335 unit_list_iterate(ptile->units, victim) {
336 enum diplstate_type ds =
337 player_diplstate_get(pplayer, unit_owner(victim))->type;
338 const struct unit_type *ptype;
339 const struct unit_type *victim_type;
340
341 if (ds != DS_WAR) {
342 continue;
343 }
344 if (victim == target) {
345 sucker = victim;
346 UNIT_LOG(LOGLEVEL_HUNT, missile, "found primary target %d(%d, %d)"
347 " dist %d", victim->id, TILE_XY(unit_tile(victim)),
348 move_cost);
349 break; /* Our target! Get it!!! */
350 }
351
352 victim_type = unit_type_get(victim);
353 ptype = unit_type_get(punit);
354
355 if (ATTACK_POWER(victim_type) > DEFENSE_POWER(ptype)
357 sucker = victim;
358 UNIT_LOG(LOGLEVEL_HUNT, missile, "found aux target %d(%d, %d)",
359 victim->id, TILE_XY(unit_tile(victim)));
360 break;
361 }
363 if (sucker) {
364 break; /* Found something - kill it! */
365 }
367 pf_map_destroy(pfm);
368
369 if (sucker) {
370 if (unit_transported(missile)) {
371 struct unit *ptrans = unit_transport_get(missile);
372
373 if (is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_ALIGHT,
374 missile, ptrans)) {
376 0, "", ACTION_TRANSPORT_ALIGHT);
377 }
378 }
379
380 missile->goto_tile = unit_tile(sucker);
381 if (dai_unit_goto(ait, missile, unit_tile(sucker))) {
382 /* We survived; did they? */
383 sucker = game_unit_by_number(target_sanity); /* Sanity */
384 if (sucker && is_tiles_adjacent(unit_tile(sucker),
385 unit_tile(missile))) {
386 dai_unit_attack(ait, missile, unit_tile(sucker));
387 }
388 }
389 if (game_unit_by_number(target_sanity) == NULL) {
390 return; /* Target killed */
391 }
392 }
393 } /* if */
395}
396
397/**********************************************************************/
400static void dai_hunter_juiciness(struct player *pplayer, struct unit *punit,
401 struct unit *target, unsigned *stackthreat,
402 unsigned *stackcost)
403{
404 *stackthreat = 0;
405 *stackcost = 0;
406
407 unit_list_iterate(unit_tile(target)->units, sucker) {
408 const struct unit_type *suck_type = unit_type_get(sucker);
409
410 *stackthreat += ATTACK_POWER(suck_type);
411 if (unit_has_type_flag(sucker, UTYF_GAMELOSS)) {
412 *stackcost += 1000;
413 *stackthreat += 5000;
414 }
415 if (utype_acts_hostile(unit_type_get(sucker))) {
416 *stackthreat += 500; /* Extra threatening */
417 }
418 *stackcost += unit_build_shield_cost_base(sucker);
420
421 *stackthreat *= 9; /* WAG - reduced by distance later */
422 *stackthreat += *stackcost;
423}
424
425/**********************************************************************/
437int dai_hunter_manage(struct ai_type *ait, struct player *pplayer,
438 struct unit *punit)
439{
440 bool is_virtual = (punit->id == 0);
441 struct pf_parameter parameter;
442 struct pf_map *pfm;
443 int limit = unit_move_rate(punit) * 6;
444 struct unit_ai *unit_data = def_ai_unit_data(punit, ait);
445 struct unit *original_target = game_unit_by_number(unit_data->target);
446 unsigned original_threat = 0, original_cost = 0;
447 struct civ_map *nmap = &(wld.map);
448
449 fc_assert_ret_val(!is_barbarian(pplayer), 0);
450 fc_assert_ret_val(pplayer->is_alive, 0);
451
452 pft_fill_unit_parameter(&parameter, nmap, punit);
453 parameter.omniscience = !has_handicap(pplayer, H_MAP);
454 pfm = pf_map_new(&parameter);
455
456 if (original_target) {
457 dai_hunter_juiciness(pplayer, punit, original_target,
458 &original_threat, &original_cost);
459 }
460
461 pf_map_move_costs_iterate(pfm, ptile, move_cost, FALSE) {
462 /* End faster if we have a target */
463 if (move_cost > limit) {
464 UNIT_LOG(LOGLEVEL_HUNT, punit, "gave up finding hunt target");
465 pf_map_destroy(pfm);
466 return 0;
467 }
468
469 if (tile_city(ptile)
470 || !can_unit_attack_tile(punit, NULL, ptile)) {
471 continue;
472 }
473
474 unit_list_iterate_safe(ptile->units, target) {
475 struct player *aplayer = unit_owner(target);
476 int dist1, dist2;
477 unsigned stackthreat = 0, stackcost = 0;
478 int sanity_target = target->id;
479 struct pf_path *path;
480 struct unit_ai *target_data;
481 struct tile *target_tile;
482 struct unit *defender;
483
484 /* Note that we need not (yet) be at war with aplayer */
485 if (!adv_is_player_dangerous(pplayer, aplayer)) {
486 continue;
487 }
488
489 target_data = def_ai_unit_data(target, ait);
490 if (BV_ISSET(target_data->hunted, player_index(pplayer))) {
491 /* Can't hunt this one. The bit is cleared in the beginning
492 * of each turn. */
493 continue;
494 }
496 && get_transporter_capacity(target) == 0
497 && !unit_has_type_flag(target, UTYF_GAMELOSS)) {
498 /* Won't hunt this one. */
499 continue;
500 }
501
502 target_tile = unit_tile(target);
504 /* We can't attack the target */
505 continue;
506 }
507
508 /* Figure out whether unit is coming closer */
509 if (target_data->cur_pos && target_data->prev_pos) {
510 dist1 = real_map_distance(unit_tile(punit), *target_data->cur_pos);
511 dist2 = real_map_distance(unit_tile(punit), *target_data->prev_pos);
512 } else {
513 dist1 = dist2 = 0;
514 }
515 UNIT_LOG(LOGLEVEL_HUNT, punit, "considering chasing %s[%d](%d, %d) "
516 "dist1 %d dist2 %d",
517 unit_rule_name(target), target->id, TILE_XY(target_tile),
518 dist1, dist2);
519
520 /* We can't chase if we aren't faster or on intercept vector */
521 if (unit_type_get(punit)->move_rate < unit_type_get(target)->move_rate
522 && dist1 >= dist2) {
524 "giving up racing %s (%d, %d)->(%d, %d)",
525 unit_rule_name(target),
526 target_data->prev_pos
527 ? index_to_map_pos_x(tile_index(*target_data->prev_pos))
528 : -1,
529 target_data->prev_pos
530 ? index_to_map_pos_y(tile_index(*target_data->prev_pos))
531 : -1,
533 continue;
534 }
535
536 /* Calculate juiciness of target, compare with existing target,
537 * if any. */
538 dai_hunter_juiciness(pplayer, punit, target, &stackthreat, &stackcost);
539 defender = get_defender(nmap, punit, target_tile);
540 if (defender != NULL) {
541 stackcost *= unit_win_chance(nmap, punit, defender);
542 }
543 if (stackcost < unit_build_shield_cost_base(punit)) {
544 UNIT_LOG(LOGLEVEL_HUNT, punit, "%d is too expensive (it %d vs us %d)",
545 target->id, stackcost,
547 continue; /* Too expensive */
548 }
549 stackthreat /= move_cost + 1;
550 if (!is_virtual
551 && original_target != target
552 && original_threat > stackthreat) {
553 UNIT_LOG(LOGLEVEL_HUNT, punit, "Unit %d is not worse than %d",
554 target->id, original_target->id);
555 continue; /* The threat we found originally was worse than this! */
556 }
557 if (stackthreat < unit_build_shield_cost_base(punit)) {
558 UNIT_LOG(LOGLEVEL_HUNT, punit, "%d is not worth it", target->id);
559 continue; /* Not worth it */
560 }
561
562 UNIT_LOG(LOGLEVEL_HUNT, punit, "hunting %s %s[%d](%d,%d) "
563 "with want %d, dist1 %d, dist2 %d",
565 unit_rule_name(target),
566 target->id,
568 stackthreat,
569 dist1,
570 dist2);
571 /* Ok, now we FINALLY have a target worth destroying! */
572 unit_data->target = target->id;
573 if (is_virtual) {
574 pf_map_destroy(pfm);
575 return stackthreat;
576 }
577
578 /* This assigns missiles to us */
580
581 /* Check if we can nuke it */
582 dai_hunter_try_launch(ait, pplayer, punit, target);
583
584 /* Check if we have nuked it */
585 if (target != game_unit_by_number(sanity_target)) {
586 UNIT_LOG(LOGLEVEL_HUNT, punit, "mission accomplished by cargo (pre)");
588 pf_map_destroy(pfm);
589 return -1; /* try again */
590 }
591
592 /* Go towards it. */
593 path = pf_map_path(pfm, target_tile);
594 if (!adv_unit_execute_path(punit, path)) {
595 pf_path_destroy(path);
596 pf_map_destroy(pfm);
597 return 0;
598 }
599 pf_path_destroy(path);
600
601 if (target != game_unit_by_number(sanity_target)) {
602 UNIT_LOG(LOGLEVEL_HUNT, punit, "mission accomplished");
604 pf_map_destroy(pfm);
605 return -1; /* try again */
606 }
607
608 /* Check if we can nuke it now */
609 dai_hunter_try_launch(ait, pplayer, punit, target);
610 if (target != game_unit_by_number(sanity_target)) {
611 UNIT_LOG(LOGLEVEL_HUNT, punit, "mission accomplished by cargo (post)");
613 pf_map_destroy(pfm);
614 return -1; /* try again */
615 }
616
617 pf_map_destroy(pfm);
618 unit_data->done = TRUE;
619 return stackthreat; /* still have work to do */
622
623 UNIT_LOG(LOGLEVEL_HUNT, punit, "ran out of map finding hunt target");
624 pf_map_destroy(pfm);
625 return 0; /* found nothing */
626}
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)
Definition actions.c:4832
#define adv_choice_set_use(_choice, _use)
Definition advchoice.h:85
@ CT_ATTACKER
Definition advchoice.h:40
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
Definition advdata.c:1087
bool adv_unit_execute_path(struct unit *punit, struct pf_path *path)
Definition advgoto.c:82
adv_want amortize(adv_want benefit, int delay)
Definition advtools.c:29
static void dai_hunter_juiciness(struct player *pplayer, struct unit *punit, struct unit *target, unsigned *stackthreat, unsigned *stackcost)
Definition aihunt.c:400
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)
Definition aihunt.c:228
static struct unit * dai_hunter_find(struct player *pplayer, struct city *pcity)
Definition aihunt.c:64
bool dai_hunter_qualify(struct player *pplayer, struct unit *punit)
Definition aihunt.c:289
static void dai_hunter_missile_want(struct player *pplayer, struct city *pcity, struct adv_choice *choice)
Definition aihunt.c:148
static struct unit_type * dai_hunter_guess_best(struct city *pcity, enum terrain_class tc, struct ai_type *ait, bool allow_gold_upkeep)
Definition aihunt.c:84
void dai_hunter_choice(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
Definition aihunt.c:253
int dai_hunter_manage(struct ai_type *ait, struct player *pplayer, struct unit *punit)
Definition aihunt.c:437
static void dai_hunter_try_launch(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct unit *target)
Definition aihunt.c:305
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
Definition aiplayer.h:48
bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile)
Definition aitools.c:816
bool dai_unit_goto(struct ai_type *ait, struct unit *punit, struct tile *ptile)
Definition aitools.c:604
void dai_unit_new_task(struct ai_type *ait, struct unit *punit, enum ai_unit_task task, struct tile *ptile)
Definition aitools.c:642
bool dai_unit_can_strike_my_unit(const struct unit *attacker, const struct unit *defender)
Definition aiunit.c:3441
@ AIUNIT_NONE
Definition aiunit.h:27
@ AIUNIT_HUNTER
Definition aiunit.h:29
#define DEFENSE_POWER(ptype)
Definition aiunit.h:66
#define ATTACK_POWER(ptype)
Definition aiunit.h:68
#define UNITTYPE_COSTS(ut)
Definition aiunit.h:75
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
Definition city.c:789
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:928
#define city_owner(_pcity_)
Definition city.h:543
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
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender)
Definition combat.c:438
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
Definition combat.c:271
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile)
Definition combat.c:781
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:56
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
float adv_want
Definition fc_types.h:1206
#define ADV_WANT_PRINTF
Definition fc_types.h:1207
@ O_SHIELD
Definition fc_types.h:91
@ O_GOLD
Definition fc_types.h:91
struct world wld
Definition game.c:58
struct unit * game_unit_by_number(int id)
Definition game.c:111
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
Definition handicaps.c:66
@ H_MAP
Definition handicaps.h:28
@ H_TARGETS
Definition handicaps.h:24
#define fc_assert_ret_val(condition, val)
Definition log.h:194
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:929
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:628
static int index_to_map_pos_y(int mindex)
Definition map.h:696
static int index_to_map_pos_x(int mindex)
Definition map.h:687
int unit_move_rate(const struct unit *punit)
Definition movement.c:90
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:826
bool can_attack_non_native(const struct unit_type *utype)
Definition movement.c:202
#define SINGLE_MOVE
Definition movement.h:24
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:462
void pf_path_destroy(struct pf_path *path)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
struct pf_path * pf_map_path(struct pf_map *pfm, struct tile *ptile)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
void pft_fill_unit_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:840
int player_index(const struct player *pplayer)
Definition player.c:820
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
static bool is_barbarian(const struct player *pplayer)
Definition player.h:488
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
#define CITY_LOG(loglevel, pcity, msg,...)
Definition srv_log.h:83
#define LOGLEVEL_HUNT
Definition srv_log.h:35
#define UNIT_LOG(loglevel, punit, msg,...)
Definition srv_log.h:98
enum choice_type type
Definition advchoice.h:46
adv_want want
Definition advchoice.h:48
universals_u value
Definition advchoice.h:47
bool need_boat
Definition advchoice.h:49
Definition ai.h:50
Definition city.h:309
int surplus[O_LAST]
Definition city.h:343
struct tile * tile
Definition city.h:311
struct unit_list * units_supported
Definition city.h:391
enum diplstate_type type
Definition player.h:201
bool is_alive
Definition player.h:268
Definition tile.h:49
struct unit_list * units
Definition tile.h:57
struct tile ** prev_pos
Definition aiunit.h:40
bv_player hunted
Definition aiunit.h:43
bool done
Definition aiunit.h:44
struct tile ** cur_pos
Definition aiunit.h:40
int target
Definition aiunit.h:42
bool missile_platform
Definition aiunit.h:53
Definition unit.h:138
int id
Definition unit.h:145
struct unit_list * transporting
Definition unit.h:184
int veteran
Definition unit.h:152
struct civ_map map
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:87
#define TILE_XY(ptile)
Definition tile.h:42
const struct unit_type * utype
Definition fc_types.h:604
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2427
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1619
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:302
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1715
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2411
#define unit_tile(_pu)
Definition unit.h:388
#define unit_owner(_pu)
Definition unit.h:387
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)
Definition unithand.c:3153
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_safe(unitlist, _unit)
Definition unitlist.h:39
#define unit_list_iterate_end
Definition unitlist.h:33
#define unit_list_iterate_safe_end
Definition unitlist.h:61
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Definition unittype.c:132
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1639
int unit_build_shield_cost_base(const struct unit *punit)
Definition unittype.c:1536
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
Definition unittype.c:202
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:184
void * utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai)
Definition unittype.c:2741
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1490
bool utype_acts_hostile(const struct unit_type *putype)
Definition unittype.c:515
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:443
#define utype_class(_t_)
Definition unittype.h:736
@ MOVE_NONE
Definition unittype.h:131
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
#define unit_type_iterate(_p)
Definition unittype.h:838
#define unit_type_iterate_end
Definition unittype.h:845