2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2009, 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-2009
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) */
55 time_t lnd_timestamp; /* Last time this unit was touched */
56 natid lnd_own; /* owner's country num */
57 coord lnd_x; /* x location in abs coords */
58 coord lnd_y; /* y location in abs coords */
59 signed char lnd_type; /* index in lchr[] */
60 signed char lnd_effic; /* 0% to 100% */
61 signed char lnd_mobil; /* mobility units */
62 unsigned char lnd_off; /* repairs stopped? */
63 short lnd_tech; /* tech level ship was built at */
64 char lnd_army; /* group membership */
65 coord lnd_opx, lnd_opy; /* Op sector coords */
66 short lnd_mission; /* mission code */
67 short lnd_radius; /* mission radius */
68 /* end of part matching struct empobj */
69 signed char lnd_flags; /* unit flags (unused) */
70 short lnd_ship; /* pointer to transporting ship */
71 signed char lnd_harden; /* fortification */
72 short lnd_retreat; /* retreat percentage */
73 int lnd_rflags; /* When do I retreat? */
74 char lnd_rpath[RET_LEN]; /* retreat path */
75 unsigned char lnd_scar; /* how experienced the unit is (not used) */
76 short lnd_item[I_MAX+1]; /* amount of items on board */
77 short lnd_pstage; /* plague stage */
78 short lnd_ptime; /* how many etus remain in this stage */
79 short lnd_land; /* pointer to transporting unit */
80 short lnd_access; /* Last tick mob was updated (MOB_ACCESS) */
84 short l_item[I_MAX+1]; /* load limit */
85 char *l_name; /* full name of type of land unit */
86 int l_lcm; /* units of lcm to build */
87 int l_hcm; /* units of hcm to build */
88 int l_mil; /* how many mil it takes to build (unused) */
89 int l_gun; /* how many guns it takes to build (unused) */
90 int l_shell; /* #shells it takes to build (unused) */
91 int l_tech; /* tech required to build */
92 int l_cost; /* how much it costs to build */
93 float l_att; /* attack multiplier */
94 float l_def; /* defense multiplier */
95 int l_vul; /* vulnerability (0-100) */
96 int l_spd; /* speed */
97 int l_vis; /* visibility */
98 int l_spy; /* Seeing distance */
99 int l_rad; /* reaction radius */
100 int l_frg; /* firing range */
101 int l_acc; /* firing accuracy */
102 int l_dam; /* # of guns firing */
103 int l_ammo; /* firing ammu used per shot */
104 int l_aaf; /* aa fire */
105 unsigned char l_nxlight; /* maximum number of xlight planes */
106 unsigned char l_nland; /* maximum number of units */
107 signed char l_type; /* index in lchr[] */
108 long l_flags; /* what special things can this unit do */
111 /* Land unit ability flags */
112 #define L_ENGINEER bit(1) /* Do engineering things */
113 #define L_SUPPLY bit(2) /* supply other units/sects */
114 #define L_SECURITY bit(3) /* anti-terrorist troops */
115 #define L_LIGHT bit(4) /* can go on ships */
116 #define L_MARINE bit(5) /* marine units, good at assaulting */
117 #define L_RECON bit(6) /* recon units, good at spying */
118 #define L_RADAR bit(7) /* radar unit */
119 #define L_ASSAULT bit(8) /* can assault */
120 #define L_FLAK bit(9) /* flak unit */
121 #define L_SPY bit(10) /* spy unit - way cool */
122 #define L_TRAIN bit(11) /* train unit - neato */
123 #define L_HEAVY bit(12) /* heavy unit - can't go on trains */
125 /* Work required for building 100% */
126 #define LND_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
128 /* Chance to detect L_SPY unit (percent) */
129 #define LND_SPY_DETECT_CHANCE(eff) ((110-(eff))/100.0)
131 #define getland(n, p) ef_read(EF_LAND, (n), (p))
132 #define putland(n, p) ef_write(EF_LAND, (n), (p))
133 #define getlandp(n) ((struct lndstr *)ef_ptr(EF_LAND, (n)))
135 extern struct lchrstr lchr[LND_TYPE_MAX + 2];
138 LND_AIROPS_EFF = 50 /* min. efficiency for air ops */
141 extern float l_att(struct lchrstr *, int);
142 extern float l_def(struct lchrstr *, int);
143 extern int l_vul(struct lchrstr *, int);
144 extern int l_spd(struct lchrstr *, int);
145 extern int l_frg(struct lchrstr *, int);
146 extern int l_acc(struct lchrstr *, int);
147 extern int l_dam(struct lchrstr *, int);
148 extern int l_aaf(struct lchrstr *, int);
149 extern float lnd_att(struct lndstr *);
150 extern float lnd_def(struct lndstr *);
151 extern int lnd_vul(struct lndstr *);
152 extern int lnd_spd(struct lndstr *);
153 extern int lnd_vis(struct lndstr *);
154 extern int lnd_frg(struct lndstr *);
155 extern int lnd_acc(struct lndstr *);
156 extern int lnd_dam(struct lndstr *);
157 extern int lnd_aaf(struct lndstr *);
159 /* src/lib/common/cargo.c */
160 extern void lnd_carrier_change(struct lndstr *, int, int, int);
161 extern int lnd_first_on_ship(struct shpstr *);
162 extern int lnd_first_on_land(struct lndstr *);
163 extern int lnd_next_on_unit(int);
164 extern int lnd_nxlight(struct lndstr *);
165 extern int lnd_nland(struct lndstr *);
167 extern int lnd_fire(struct lndstr *);
168 extern int lnd_sabo(struct lndstr *, short *);
169 extern double lnd_fire_range(struct lndstr *);
171 /* src/lib/subs/lndsub.c */
172 extern void lnd_sweep(struct emp_qelem *, int, int, natid);
173 extern int lnd_interdict(struct emp_qelem *, coord, coord, natid);
174 extern void lnd_sel(struct nstr_item *, struct emp_qelem *);
175 extern int lnd_check_mines(struct emp_qelem *);
176 extern double lnd_pathcost(struct lndstr *, double);
177 extern int lnd_mobtype(struct lndstr *);
178 extern double lnd_mobcost(struct lndstr *, struct sctstr *);
180 extern double attack_val(int, struct lndstr *);
181 extern double defense_val(struct lndstr *);
182 extern int lnd_reaction_range(struct lndstr *);
183 extern void lnd_print(struct ulist *, char *);
184 extern void lnd_delete(struct ulist *, char *);
185 extern int lnd_take_casualty(int, struct ulist *, int);
186 extern void lnd_submil(struct lndstr *, int);
187 extern void lnd_takemob(struct emp_qelem *, double);
188 extern int lnd_spyval(struct lndstr *);
189 extern void intelligence_report(int, struct lndstr *, int, char *);
190 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
191 extern int lnd_hardtarget(struct lndstr *);
192 extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
193 extern int lnd_support(natid, natid, coord, coord, int);
194 extern int lnd_can_attack(struct lndstr *);
195 extern int lnd_fortify (struct lndstr *lp, int hard_amt);
196 extern void lnd_set_tech(struct lndstr *, int);