2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * land.h: Definitions for land units
30 * Known contributors to this file:
31 * Thomas Ruschak, 1992
34 * Markus Armbruster, 2004-2008
46 #define LND_TYPE_MAX 30
47 #define LAND_MINEFF 10
48 #define LAND_MINFIREEFF 40 /* arty must be this effic to fire */
51 /* initial part must match struct empobj */
53 short lnd_uid; /* unit id (land unit) */
54 time_t lnd_timestamp; /* Last time this unit was touched */
55 natid lnd_own; /* owner's country num */
56 coord lnd_x; /* x location in abs coords */
57 coord lnd_y; /* y location in abs coords */
58 signed char lnd_type; /* index in lchr[] */
59 signed char lnd_effic; /* 0% to 100% */
60 signed char lnd_mobil; /* mobility units */
61 unsigned char lnd_off; /* repairs stopped? */
62 short lnd_tech; /* tech level ship was built at */
63 char lnd_army; /* group membership */
64 coord lnd_opx, lnd_opy; /* Op sector coords */
65 short lnd_mission; /* mission code */
66 short lnd_radius; /* mission radius */
67 /* end of part matching struct empobj */
68 signed char lnd_flags; /* unit flags (unused) */
69 short lnd_ship; /* pointer to transporting ship */
70 signed char lnd_harden; /* fortification */
71 short lnd_retreat; /* retreat percentage */
72 unsigned char lnd_fuel; /* How much fuel do we have */
73 unsigned char lnd_nxlight; /* How many xlight planes on board? */
74 int lnd_rflags; /* When do I retreat? */
75 char lnd_rpath[RET_LEN]; /* retreat path */
76 unsigned char lnd_rad_max; /* max radius for this unit */
77 unsigned char lnd_scar; /* how experienced the unit is (not used) */
78 short lnd_item[I_MAX+1]; /* amount of items on board */
79 short lnd_pstage; /* plague stage */
80 short lnd_ptime; /* how many etus remain in this stage */
81 short lnd_land; /* pointer to transporting unit */
82 unsigned char lnd_nland;
83 short lnd_access; /* Last tick mob was updated (MOB_ACCESS) */
87 short l_item[I_MAX+1]; /* load limit */
88 char *l_name; /* full name of type of land unit */
89 int l_lcm; /* units of lcm to build */
90 int l_hcm; /* units of hcm to build */
91 int l_mil; /* how many mil it takes to build (unused) */
92 int l_gun; /* how many guns it takes to build (unused) */
93 int l_shell; /* #shells it takes to build (unused) */
94 int l_tech; /* tech required to build */
95 int l_cost; /* how much it costs to build */
96 float l_att; /* attack multiplier */
97 float l_def; /* defense multiplier */
98 int l_vul; /* vulnerability (0-100) */
99 int l_spd; /* speed */
100 int l_vis; /* visibility */
101 int l_spy; /* Seeing distance */
102 int l_rad; /* reaction radius */
103 int l_frg; /* firing range */
104 int l_acc; /* firing accuracy */
105 int l_dam; /* # of guns firing */
106 int l_ammo; /* firing ammu used per shot */
107 int l_aaf; /* aa fire */
108 unsigned char l_fuelc; /* fuel capacity */
109 unsigned char l_fuelu; /* fuel used per 10 mob */
110 unsigned char l_nxlight; /* maximum number of xlight planes */
111 unsigned char l_nland; /* maximum number of units */
112 signed char l_type; /* index in lchr[] */
113 long l_flags; /* what special things can this unit do */
116 /* Land unit ability flags */
117 #define L_ENGINEER bit(1) /* Do engineering things */
118 #define L_SUPPLY bit(2) /* supply other units/sects */
119 #define L_SECURITY bit(3) /* anti-terrorist troops */
120 #define L_LIGHT bit(4) /* can go on ships */
121 #define L_MARINE bit(5) /* marine units, good at assaulting */
122 #define L_RECON bit(6) /* recon units, good at spying */
123 #define L_RADAR bit(7) /* radar unit */
124 #define L_ASSAULT bit(8) /* can assault */
125 #define L_FLAK bit(9) /* flak unit */
126 #define L_SPY bit(10) /* spy unit - way cool */
127 #define L_TRAIN bit(11) /* train unit - neato */
128 #define L_HEAVY bit(12) /* heavy unit - can't go on trains */
130 /* Work required for building 100% */
131 #define LND_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
133 /* Chance to detect L_SPY unit (percent) */
134 #define LND_SPY_DETECT_CHANCE(eff) ((110-(eff))/100.0)
136 #define getland(n, p) ef_read(EF_LAND, (n), (p))
137 #define putland(n, p) ef_write(EF_LAND, (n), (p))
138 #define getlandp(n) ((struct lndstr *)ef_ptr(EF_LAND, (n)))
140 extern struct lchrstr lchr[LND_TYPE_MAX + 2];
143 LND_AIROPS_EFF = 50 /* min. efficiency for air ops */
146 extern float l_att(struct lchrstr *, int);
147 extern float l_def(struct lchrstr *, int);
148 extern int l_vul(struct lchrstr *, int);
149 extern int l_spd(struct lchrstr *, int);
150 extern int l_frg(struct lchrstr *, int);
151 extern int l_acc(struct lchrstr *, int);
152 extern int l_dam(struct lchrstr *, int);
153 extern int l_aaf(struct lchrstr *, int);
154 extern float lnd_att(struct lndstr *);
155 extern float lnd_def(struct lndstr *);
156 extern int lnd_vul(struct lndstr *);
157 extern int lnd_spd(struct lndstr *);
158 extern int lnd_vis(struct lndstr *);
159 extern int lnd_frg(struct lndstr *);
160 extern int lnd_acc(struct lndstr *);
161 extern int lnd_dam(struct lndstr *);
162 extern int lnd_aaf(struct lndstr *);
164 extern int lnd_fire(struct lndstr *);
165 extern double lnd_fire_range(struct lndstr *);
167 /* src/lib/subs/lndsub.c */
168 extern void lnd_sweep(struct emp_qelem *, int, int, natid);
169 extern int lnd_interdict(struct emp_qelem *, coord, coord, natid);
170 extern void lnd_sel(struct nstr_item *, struct emp_qelem *);
171 extern int lnd_check_mines(struct emp_qelem *);
172 extern double lnd_pathcost(struct lndstr *, double);
173 extern int lnd_mobtype(struct lndstr *);
174 extern double lnd_mobcost(struct lndstr *, struct sctstr *);
176 extern double attack_val(int, struct lndstr *);
177 extern double defense_val(struct lndstr *);
178 extern void lnd_print(struct ulist *, char *);
179 extern void lnd_delete(struct ulist *, char *);
180 extern int lnd_take_casualty(int, struct ulist *, int);
181 extern void lnd_submil(struct lndstr *, int);
182 extern void lnd_takemob(struct emp_qelem *, double);
183 extern int lnd_spyval(struct lndstr *);
184 extern void intelligence_report(int, struct lndstr *, int, char *);
185 extern int count_sect_units(struct sctstr *);
186 extern void count_units(struct shpstr *);
187 extern void lnd_count_units(struct lndstr *);
188 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
189 extern int lnd_hardtarget(struct lndstr *);
190 extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
191 extern int lnd_support(natid, natid, coord, coord, int);
192 extern int lnd_can_attack(struct lndstr *);
193 extern int lnd_fortify (struct lndstr *lp, int hard_amt);
194 extern void lnd_set_tech(struct lndstr *, int);