Freeciv-3.1
Loading...
Searching...
No Matches
advgoto.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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/* common */
19#include "ai.h"
20#include "combat.h"
21#include "game.h"
22#include "movement.h"
23#include "unit.h"
24#include "tile.h"
25
26/* aicore */
27#include "path_finding.h"
28
29/* server */
30#include "maphand.h"
31#include "srv_log.h"
32#include "unithand.h"
33#include "unittools.h"
34
35/* server/advisors */
36#include "advtools.h"
37
38#include "advgoto.h"
39
40static bool adv_unit_move(struct unit *punit, struct tile *ptile);
41
42/**********************************************************************/
47bool adv_follow_path(struct unit *punit, struct pf_path *path,
48 struct tile *ptile)
49{
50 struct tile *old_tile = punit->goto_tile;
51 enum unit_activity activity = punit->activity;
52 struct extra_type *tgt = punit->activity_target;
53 bool alive;
54
55 if (punit->moves_left <= 0) {
56 return TRUE;
57 }
58 punit->goto_tile = ptile;
59 unit_activity_handling(punit, ACTIVITY_GOTO);
60 alive = adv_unit_execute_path(punit, path);
61 if (alive) {
62 if (activity != ACTIVITY_GOTO) {
63 /* Only go via ACTIVITY_IDLE if we are actually changing the activity */
64 unit_activity_handling(punit, ACTIVITY_IDLE);
65 send_unit_info(NULL, punit); /* FIXME: probably duplicate */
67 }
68 punit->goto_tile = old_tile; /* May be NULL. */
69 send_unit_info(NULL, punit);
70 }
71 return alive;
72}
73
74
75/**********************************************************************/
82bool adv_unit_execute_path(struct unit *punit, struct pf_path *path)
83{
84 const bool is_plr_ai = is_ai(unit_owner(punit));
85 int i;
86
87 /* We start with i = 1 for i = 0 is our present position */
88 for (i = 1; i < path->length; i++) {
89 struct tile *ptile = path->positions[i].tile;
90 int id = punit->id;
91
92 if (same_pos(unit_tile(punit), ptile)) {
93#ifdef PF_WAIT_DEBUG
95#if PF_WAIT_DEBUG & 1
97#if PF_WAIT_DEBUG & (2 | 4)
98 ||
99#endif
100#endif
101#if PF_WAIT_DEBUG & 2
103#if PF_WAIT_DEBUG & 4
104 ||
105#endif
106#endif
107#if PF_WAIT_DEBUG & 4
109#endif
110 , "%s waits at %d,%d for no visible profit",
111 unit_rule_name(punit), TILE_XY(ptile));
112#endif
113 UNIT_LOG(LOG_DEBUG, punit, "execute_path: waiting this turn");
114 return TRUE;
115 }
116
117 /* We use ai_unit_move() for everything but the last step
118 * of the way so that we abort if unexpected opposition
119 * shows up. Any enemy on the target tile is expected to
120 * be our target and any attack there intentional.
121 * However, do not annoy human players by automatically attacking
122 * using units temporarily under AI control (such as auto-explorers)
123 */
124
125 if (is_plr_ai) {
126 CALL_PLR_AI_FUNC(unit_move, unit_owner(punit), punit, ptile, path, i);
127 } else {
128 (void) adv_unit_move(punit, ptile);
129 }
130 if (!game_unit_by_number(id)) {
131 /* Died... */
132 return FALSE;
133 }
134
135 if (!same_pos(unit_tile(punit), ptile) || punit->moves_left <= 0) {
136 /* Stopped (or maybe fought) or ran out of moves */
137 return TRUE;
138 }
139 }
140
141 return TRUE;
142}
143
144/**********************************************************************/
152static bool adv_unit_move(struct unit *punit, struct tile *ptile)
153{
154 struct action *paction;
155 struct player *pplayer = unit_owner(punit);
156 struct unit *ptrans = NULL;
157 const struct civ_map *nmap = &(wld.map);
158
159 /* If enemy, stop and give a chance for the human player to
160 handle this case */
161 if (is_enemy_unit_tile(ptile, pplayer)
162 || is_enemy_city_tile(ptile, pplayer)) {
163 UNIT_LOG(LOG_DEBUG, punit, "movement halted due to enemy presence");
164 return FALSE;
165 }
166
167 /* Select move kind. */
168 if (!can_unit_survive_at_tile(nmap, punit, ptile)
169 && ((ptrans = transporter_for_unit_at(punit, ptile)))
170 && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK,
171 punit, ptrans)) {
172 /* "Transport Embark". */
173 paction = action_by_number(ACTION_TRANSPORT_EMBARK);
174 } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
175 && ptrans != NULL
176 && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK2,
177 punit, ptrans)) {
178 /* "Transport Embark 2". */
179 paction = action_by_number(ACTION_TRANSPORT_EMBARK2);
180 } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
181 && ptrans != NULL
182 && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK3,
183 punit, ptrans)) {
184 /* "Transport Embark 3". */
185 paction = action_by_number(ACTION_TRANSPORT_EMBARK3);
186 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK1,
187 punit, ptile, NULL)) {
188 /* "Transport Disembark". */
189 paction = action_by_number(ACTION_TRANSPORT_DISEMBARK1);
190 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK2,
191 punit, ptile, NULL)) {
192 /* "Transport Disembark 2". */
193 paction = action_by_number(ACTION_TRANSPORT_DISEMBARK2);
194 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK3,
195 punit, ptile, NULL)) {
196 /* "Transport Disembark 3". */
197 paction = action_by_number(ACTION_TRANSPORT_DISEMBARK3);
198 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK4,
199 punit, ptile, NULL)) {
200 /* "Transport Disembark 4". */
201 paction = action_by_number(ACTION_TRANSPORT_DISEMBARK4);
202 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER,
203 punit, ptile, NULL)) {
204 /* "Enter Hut". */
205 paction = action_by_number(ACTION_HUT_ENTER);
206 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER2,
207 punit, ptile, NULL)) {
208 /* "Enter Hut 2". */
209 paction = action_by_number(ACTION_HUT_ENTER2);
210 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER3,
211 punit, ptile, NULL)) {
212 /* "Enter Hut 3". */
213 paction = action_by_number(ACTION_HUT_ENTER3);
214 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER4,
215 punit, ptile, NULL)) {
216 /* "Enter Hut 4". */
217 paction = action_by_number(ACTION_HUT_ENTER4);
218 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN,
219 punit, ptile, NULL)) {
220 /* "Frighten Hut". */
221 paction = action_by_number(ACTION_HUT_FRIGHTEN);
222 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN2,
223 punit, ptile, NULL)) {
224 /* "Frighten Hut 2". */
225 paction = action_by_number(ACTION_HUT_FRIGHTEN2);
226 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN3,
227 punit, ptile, NULL)) {
228 /* "Frighten Hut 3". */
229 paction = action_by_number(ACTION_HUT_FRIGHTEN3);
230 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN4,
231 punit, ptile, NULL)) {
232 /* "Frighten Hut 4". */
233 paction = action_by_number(ACTION_HUT_FRIGHTEN4);
234 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE,
235 punit, ptile, NULL)) {
236 /* "Unit Move". */
237 paction = action_by_number(ACTION_UNIT_MOVE);
238 } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE2,
239 punit, ptile, NULL)) {
240 /* "Unit Move 2". */
241 paction = action_by_number(ACTION_UNIT_MOVE2);
242 } else {
243 /* "Unit Move 3". */
244 paction = action_by_number(ACTION_UNIT_MOVE3);
245 }
246
247 /* Try not to end move next to an enemy if we can avoid it by waiting */
248 if (action_has_result(paction, ACTRES_UNIT_MOVE)
249 || action_has_result(paction, ACTRES_TRANSPORT_DISEMBARK)) {
250 /* The unit will have to move it self rather than being moved. */
251 int mcost = map_move_cost_unit(nmap, punit, ptile);
252
253 if (paction) {
254 struct tile *from_tile;
255
256 /* Ugly hack to understand the OnNativeTile unit state requirements
257 * used in the Action_Success_Actor_Move_Cost effect. */
260 from_tile = unit_tile(punit);
261 punit->tile = ptile;
262
263 mcost += unit_pays_mp_for_action(paction, punit);
264
265 punit->tile = from_tile;
266 }
267
268 if (punit->moves_left <= mcost
269 && unit_move_rate(punit) > mcost
270 && adv_danger_at(punit, ptile)
273 "ending move early to stay out of trouble");
274 return FALSE;
275 }
276 }
277
278 /* go */
279 unit_activity_handling(punit, ACTIVITY_IDLE);
280 /* Move */
281 /* TODO: Differentiate (server side AI) player from server side agent
282 * working for (possibly AI) player by using ACT_REQ_PLAYER and
283 * ACT_REQ_SS_AGENT */
284 if (paction && ptrans
285 && action_has_result(paction, ACTRES_TRANSPORT_EMBARK)) {
286 /* "Transport Embark". */
288 0, "", action_number(paction));
289 } else if (paction
290 && (action_has_result(paction,
291 ACTRES_TRANSPORT_DISEMBARK)
292 || action_has_result(paction,
293 ACTRES_HUT_ENTER)
294 || action_has_result(paction,
295 ACTRES_HUT_FRIGHTEN)
296 || action_has_result(paction,
297 ACTRES_UNIT_MOVE))) {
298 /* "Transport Disembark", "Transport Disembark 2", "Enter Hut",
299 * "Frighten Hut" or "Unit Move". */
301 0, "", action_number(paction));
302 }
303
304 return TRUE;
305}
306
307/**********************************************************************/
314static bool adv_could_be_my_zoc(struct unit *myunit, struct tile *ptile)
315{
316 struct tile *utile = unit_tile(myunit);
317 struct player *owner;
318 struct civ_map *cmap = &(wld.map);
319
320 if (same_pos(ptile, utile)) {
321 return FALSE; /* Can't be my zoc */
322 }
323
324 owner = unit_owner(myunit);
325 if (is_tiles_adjacent(ptile, utile)
326 && !is_non_allied_unit_tile(ptile, owner)) {
327 return FALSE;
328 }
329
330 adjc_iterate(cmap, ptile, atile) {
331 if (!terrain_has_flag(tile_terrain(atile), TER_NO_ZOC)
332 && is_non_allied_unit_tile(atile, owner)) {
333 return FALSE;
334 }
336
337 return TRUE;
338}
339
340/**********************************************************************/
348int adv_could_unit_move_to_tile(struct unit *punit, struct tile *dest_tile)
349{
350 enum unit_move_result reason =
351 unit_move_to_tile_test(&(wld.map), punit, ACTIVITY_IDLE, unit_tile(punit),
352 dest_tile, unit_has_type_flag(punit, UTYF_IGZOC),
353 TRUE, NULL, FALSE);
354
355 switch (reason) {
356 case MR_OK:
357 return 1;
358
359 case MR_ZOC:
361 return -1;
362 }
363 break;
364
365 default:
366 break;
367 };
368 return 0;
369}
370
371/**********************************************************************/
374int adv_unittype_att_rating(const struct unit_type *punittype, int veteran,
375 int moves_left, int hp)
376{
377 return base_get_attack_power(punittype, veteran, moves_left) * hp
378 * punittype->firepower / POWER_DIVIDER;
379}
380
381/**********************************************************************/
390
391/**********************************************************************/
400
401/**********************************************************************/
405{
407
408 return v * v;
409}
410
411/**********************************************************************/
414bool adv_danger_at(struct unit *punit, struct tile *ptile)
415{
416 int a = 0, d, db;
417 struct player *pplayer = unit_owner(punit);
418 struct city *pcity = tile_city(ptile);
419 enum override_bool dc = NO_OVERRIDE;
420 int extras_bonus = 0;
421
422 /* Give AI code possibility to decide itself */
423 CALL_PLR_AI_FUNC(consider_tile_dangerous, unit_owner(punit), ptile, punit, &dc);
424 if (dc == OVERRIDE_TRUE) {
425 return TRUE;
426 } else if (dc == OVERRIDE_FALSE) {
427 return FALSE;
428 }
429
430 if (pcity && pplayers_allied(city_owner(pcity), unit_owner(punit))
431 && !is_non_allied_unit_tile(ptile, pplayer)) {
432 /* We will be safe in a friendly city */
433 return FALSE;
434 }
435
436 /* Calculate how well we can defend at (x,y) */
437 db = 10 + tile_terrain(ptile)->defense_bonus / 10;
438 extras_bonus += tile_extras_defense_bonus(ptile, unit_type_get(punit));
439 db += (db * extras_bonus) / 100;
441
442 adjc_iterate(&(wld.map), ptile, ptile1) {
443 if (!map_is_known_and_seen(ptile1, unit_owner(punit), V_MAIN)) {
444 /* We cannot see danger at (ptile1) => assume there is none */
445 continue;
446 }
447 unit_list_iterate(ptile1->units, enemy) {
449 && (unit_attack_unit_at_tile_result(enemy, NULL, punit, ptile)
450 == ATT_OK)
451 && (unit_attack_units_at_tile_result(enemy, NULL, ptile)
452 == ATT_OK)) {
453 a += adv_unit_att_rating(enemy);
454 if ((a * a * 10) >= d) {
455 /* The enemies combined strength is too big! */
456 return TRUE;
457 }
458 }
461
462 return FALSE; /* as good a quick'n'dirty should be -- Syela */
463}
464
465/**********************************************************************/
468static int stack_value(const struct tile *ptile,
469 const struct player *pplayer)
470{
471 int cost = 0;
472
473 if (is_stack_vulnerable(ptile)) {
474 unit_list_iterate(ptile->units, punit) {
475 if (unit_owner(punit) == pplayer) {
477 }
479 }
480
481 return cost;
482}
483
484/**********************************************************************/
494static double chance_killed_at(const struct tile *ptile,
495 struct adv_risk_cost *risk_cost,
496 const struct pf_parameter *param)
497{
498 double db;
499 int extras_bonus = 0;
500 /* Compute the basic probability */
501 /* WAG */
502 /* In the early stages of a typical game, ferries
503 * are effectively invulnerable (not until Frigates set sail),
504 * so we make seas appear safer.
505 * If we don't do this, the amphibious movement code has too strong a
506 * desire to minimise the length of the path,
507 * leading to poor choice for landing beaches */
508 double p = is_ocean_tile(ptile)? 0.05: 0.15;
509
510 /* If we are on defensive terrain, we are more likely to survive */
511 db = 10 + tile_terrain(ptile)->defense_bonus / 10;
512 extras_bonus += tile_extras_class_defense_bonus(ptile,
513 utype_class(param->utype));
514 db += (extras_bonus) / 100;
515 p *= 10.0 / db;
516
517 return p;
518}
519
520/**********************************************************************/
535static unsigned stack_risk(const struct tile *ptile,
536 struct adv_risk_cost *risk_cost,
537 const struct pf_parameter *param)
538{
539 double risk = 0;
540 /* Compute the risk of destruction, assuming we will stop at this tile */
541 const double value = risk_cost->base_value
542 + stack_value(ptile, param->owner);
543 const double p_killed = chance_killed_at(ptile, risk_cost, param);
544 double danger = value * p_killed;
545
546 /* Adjust for the fact that we might not stop at this tile,
547 * and for our fearfulness */
548 risk += danger * risk_cost->fearfulness;
549
550 /* Adjust for the risk that we might become stuck (for an indefinite period)
551 * if we enter or try to enter the tile. */
552 if (risk_cost->enemy_zoc_cost != 0
553 && (is_non_allied_city_tile(ptile, param->owner)
554 || !is_plr_zoc_srv(param->owner, ptile, param->map)
555 || is_non_allied_unit_tile(ptile, param->owner))) {
556 /* We could become stuck. */
557 risk += risk_cost->enemy_zoc_cost;
558 }
559
560 return risk;
561}
562
563/**********************************************************************/
570static unsigned prefer_short_stacks(const struct tile *ptile,
571 enum known_type known,
572 const struct pf_parameter *param)
573{
574 return stack_risk(ptile, (struct adv_risk_cost *)param->data, param);
575}
576
577/**********************************************************************/
581void adv_avoid_risks(struct pf_parameter *parameter,
582 struct adv_risk_cost *risk_cost,
583 struct unit *punit,
584 const double fearfulness)
585{
586 /* If we stay a short time on each tile, the danger of each individual tile
587 * is reduced. If we do not do this,
588 * we will not favour longer but faster routs. */
589 const double linger_fraction = (double)SINGLE_MOVE / parameter->move_rate;
590
591 parameter->data = risk_cost;
592 parameter->get_EC = prefer_short_stacks;
594 risk_cost->fearfulness = fearfulness * linger_fraction;
595
596 risk_cost->enemy_zoc_cost = PF_TURN_FACTOR * 20;
597}
int action_number(const struct action *action)
Definition actions.c:1868
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
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
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
#define action_has_result(_act_, _res_)
Definition actions.h:448
bool adv_follow_path(struct unit *punit, struct pf_path *path, struct tile *ptile)
Definition advgoto.c:47
int adv_unit_def_rating_basic_squared(const struct unit *punit)
Definition advgoto.c:404
static int stack_value(const struct tile *ptile, const struct player *pplayer)
Definition advgoto.c:468
int adv_unit_def_rating_basic(const struct unit *punit)
Definition advgoto.c:395
static unsigned prefer_short_stacks(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
Definition advgoto.c:570
static unsigned stack_risk(const struct tile *ptile, struct adv_risk_cost *risk_cost, const struct pf_parameter *param)
Definition advgoto.c:535
bool adv_danger_at(struct unit *punit, struct tile *ptile)
Definition advgoto.c:414
static bool adv_unit_move(struct unit *punit, struct tile *ptile)
Definition advgoto.c:152
static double chance_killed_at(const struct tile *ptile, struct adv_risk_cost *risk_cost, const struct pf_parameter *param)
Definition advgoto.c:494
int adv_unittype_att_rating(const struct unit_type *punittype, int veteran, int moves_left, int hp)
Definition advgoto.c:374
int adv_unit_att_rating(const struct unit *punit)
Definition advgoto.c:385
static bool adv_could_be_my_zoc(struct unit *myunit, struct tile *ptile)
Definition advgoto.c:314
int adv_could_unit_move_to_tile(struct unit *punit, struct tile *dest_tile)
Definition advgoto.c:348
void adv_avoid_risks(struct pf_parameter *parameter, struct adv_risk_cost *risk_cost, struct unit *punit, const double fearfulness)
Definition advgoto.c:581
bool adv_unit_execute_path(struct unit *punit, struct pf_path *path)
Definition advgoto.c:82
#define POWER_DIVIDER
Definition advtools.h:32
#define CALL_PLR_AI_FUNC(_func, _player,...)
Definition ai.h:374
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:748
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
Definition city.h:712
#define city_owner(_pcity_)
Definition city.h:543
bool is_stack_vulnerable(const struct tile *ptile)
Definition combat.c:930
enum unit_attack_result unit_attack_units_at_tile_result(const struct unit *punit, const struct action *paction, const struct tile *ptile)
Definition combat.c:256
int base_get_attack_power(const struct unit_type *punittype, int veteran, int moves_left)
Definition combat.c:504
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
int base_get_defense_power(const struct unit *punit)
Definition combat.c:528
@ ATT_OK
Definition combat.h:35
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
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 int cost
Definition dialogs_g.h:73
override_bool
Definition fc_types.h:84
@ OVERRIDE_TRUE
Definition fc_types.h:84
@ NO_OVERRIDE
Definition fc_types.h:84
@ OVERRIDE_FALSE
Definition fc_types.h:84
struct world wld
Definition game.c:58
struct unit * game_unit_by_number(int id)
Definition game.c:111
struct city * owner
Definition citydlg.c:219
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert(condition)
Definition log.h:176
@ LOG_DEBUG
Definition log.h:34
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Definition map.c:929
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:938
#define adjc_iterate_end
Definition map.h:427
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:422
static int map_move_cost_unit(const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
Definition map.h:287
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Definition maphand.c:900
enum unit_move_result unit_move_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool igzoc, bool enter_transport, struct unit *embark_to, bool enter_enemy_city)
Definition movement.c:595
int unit_move_rate(const struct unit *punit)
Definition movement.c:90
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:476
#define SINGLE_MOVE
Definition movement.h:24
unit_move_result
Definition movement.h:32
@ MR_OK
Definition movement.h:33
@ MR_ZOC
Definition movement.h:38
#define PF_TURN_FACTOR
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1364
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1381
#define is_ai(plr)
Definition player.h:234
#define UNIT_LOG(loglevel, punit, msg,...)
Definition srv_log.h:98
double enemy_zoc_cost
Definition advgoto.h:29
double base_value
Definition advgoto.h:27
double fearfulness
Definition advgoto.h:28
Definition city.h:309
const struct civ_map * map
const struct player * owner
unsigned(* get_EC)(const struct tile *ptile, enum known_type known, const struct pf_parameter *param)
const struct unit_type * utype
unsigned length
struct pf_position * positions
struct tile * tile
Definition tile.h:49
struct unit_list * units
Definition tile.h:57
int firepower
Definition unittype.h:506
Definition unit.h:138
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
int id
Definition unit.h:145
int hp
Definition unit.h:151
int fuel
Definition unit.h:153
struct tile * tile
Definition unit.h:140
struct extra_type * activity_target
Definition unit.h:164
struct tile * goto_tile
Definition unit.h:155
int veteran
Definition unit.h:152
struct civ_map map
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define is_ocean_tile(ptile)
Definition terrain.h:289
#define terrain_has_flag(terr, flag)
Definition terrain.h:269
int tile_extras_class_defense_bonus(const struct tile *ptile, const struct unit_class *pclass)
Definition tile.c:236
int tile_extras_defense_bonus(const struct tile *ptile, const struct unit_type *punittype)
Definition tile.c:227
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:87
known_type
Definition tile.h:34
#define tile_terrain(_tile)
Definition tile.h:109
#define TILE_XY(ptile)
Definition tile.h:42
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2119
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1906
bool is_plr_zoc_srv(const struct player *pplayer, const struct tile *ptile0, const struct civ_map *zmap)
Definition unit.c:1413
#define unit_tile(_pu)
Definition unit.h:395
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:418
#define unit_owner(_pu)
Definition unit.h:394
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:430
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
Definition unithand.c:6179
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:3155
bool unit_activity_handling_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type **new_target)
Definition unithand.c:6246
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2794
bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost, struct unit *embark_to, bool find_embark_target, bool conquer_city_allowed, bool conquer_extras_allowed, bool enter_hut, bool frighten_hut)
Definition unittools.c:3884
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
Definition unittype.c:1301
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_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:184
#define utype_class(_t_)
Definition unittype.h:736
#define utype_fuel(ptype)
Definition unittype.h:825