File: combat.h

package info (click to toggle)
freeciv 2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 212,508 kB
  • sloc: ansic: 443,831; cpp: 29,541; sh: 7,982; makefile: 7,886; python: 1,933; xml: 945
file content (95 lines) | stat: -rw-r--r-- 3,618 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/********************************************************************** 
 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
***********************************************************************/
#ifndef FC__COMBAT_H
#define FC__COMBAT_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include "fc_types.h"
#include "unittype.h"

/*
 * attack_strength and defense_strength are multiplied by POWER_FACTOR
 * to yield the base of attack_power and defense_power.
 *
 * The constant may be changed since it isn't externally visible used.
 */
#define POWER_FACTOR	10

enum unit_attack_result {
  ATT_OK,
  ATT_NON_ATTACK,
  ATT_UNREACHABLE,
  ATT_NONNATIVE_SRC,
  ATT_NONNATIVE_DST
};

bool is_unit_reachable_at(const struct unit *defender,
                          const struct unit *attacker,
                          const struct tile *location);
bool can_player_attack_tile(const struct player *pplayer,
			    const struct tile *ptile);
enum unit_attack_result unit_attack_unit_at_tile_result(const struct unit *punit,
                                                        const struct unit *pdefender,
                                                        const struct tile *dest_tile);
enum unit_attack_result unit_attack_units_at_tile_result(const struct unit *punit,
                                                         const struct tile *ptile);
bool can_unit_attack_tile(const struct unit *punit,
			  const struct tile *ptile);

double win_chance(int as, int ahp, int afp, int ds, int dhp, int dfp);

void get_modified_firepower(const struct unit *attacker,
			    const struct unit *defender,
			    int *att_fp, int *def_fp);
double unit_win_chance(const struct unit *attacker,
		       const struct unit *defender);

bool unit_really_ignores_citywalls(const struct unit *punit);
struct city *sdi_try_defend(const struct player *owner,
			       const struct tile *ptile);

int get_attack_power(const struct unit *punit);
int base_get_attack_power(const struct unit_type *punittype,
			  int veteran, int moves_left);
int base_get_defense_power(const struct unit *punit);
int get_total_defense_power(const struct unit *attacker,
			    const struct unit *defender);
int get_fortified_defense_power(const struct unit *attacker,
                                const struct unit *defender);
int get_virtual_defense_power(const struct unit_type *attacker,
			      const struct unit_type *defender,
			      const struct player *defending_player,
			      const struct tile *ptile,
			      bool fortified, int veteran);
int get_total_attack_power(const struct unit *attacker,
			   const struct unit *defender);

struct unit *get_defender(const struct unit *attacker,
			  const struct tile *ptile);
struct unit *get_attacker(const struct unit *defender,
			  const struct tile *ptile);

bool is_stack_vulnerable(const struct tile *ptile);

int combat_bonus_against(const struct combat_bonus_list *list,
                         const struct unit_type *enemy,
                         enum combat_bonus_type type);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* FC__COMBAT_H */