2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * land.h: Definitions for land units
30 * Known contributors to this file:
31 * Thomas Rushack, 1992
46 #define LAND_MINEFF 10
47 #define LAND_MINFIREEFF 40 /* arty must be this effic to fire */
48 #define LND_MINMOBCOST 0.200
52 natid lnd_own; /* owner's country num */
53 short lnd_uid; /* unit id (land unit) */
54 coord lnd_x; /* x location in abs coords */
55 coord lnd_y; /* y location in abs coords */
56 s_char lnd_type; /* index in lchr[] */
57 s_char lnd_effic; /* 0% to 100% */
58 s_char lnd_mobil; /* mobility units made int for RS/6000 */
59 short lnd_tech; /* tech level ship was built at */
60 s_char lnd_army; /* group membership */
61 coord lnd_opx, lnd_opy; /* Op sector coords */
62 short lnd_mission; /* mission code */
63 short lnd_radius; /* mission radius */
64 s_char lnd_flags; /* unit flags */
65 short lnd_ship; /* pointer to transporting ship */
66 s_char lnd_harden; /* for missiles */
67 short lnd_retreat; /* retreat percentage */
68 u_char lnd_fuel; /* How much fuel do we have */
69 u_char lnd_nxlight; /* How many xlight planes on board? */
70 int lnd_rflags; /* When do I retreat? */
71 s_char lnd_rpath[RET_LEN]; /* retreat path */
72 u_char lnd_rad_max; /* max radius for this unit */
73 u_char lnd_scar; /* how experienced the unit is (not used) */
74 u_short lnd_item[I_MAX+1]; /* amount of items on board */
75 u_short lnd_pstage; /* plague stage */
76 u_short lnd_ptime; /* how many etus remain in this stage */
77 short lnd_land; /* pointer to transporting unit */
79 time_t lnd_access; /* Last time mob was updated (MOB_ACCESS) */
80 float lnd_att; /* attack multiplier */
81 float lnd_def; /* defense multiplier */
82 int lnd_vul; /* vulnerability (0-100) */
83 int lnd_spd; /* speed */
84 int lnd_vis; /* visibility */
85 int lnd_spy; /* Seeing distance */
86 int lnd_rad; /* reaction radius */
87 int lnd_frg; /* firing range */
88 int lnd_acc; /* firing accuracy */
89 int lnd_dam; /* # of guns firing */
90 int lnd_ammo; /* firing ammu used per shot */
91 int lnd_aaf; /* aa fire */
92 u_char lnd_fuelc; /* fuel capacity */
93 u_char lnd_fuelu; /* fuel used per 10 mob */
94 u_char lnd_maxlight; /* maximum number of xlight planes */
95 u_char lnd_maxland; /* maximum number of units */
96 time_t lnd_timestamp; /* Last time this unit was touched */
99 #define LND_NOTANY bit(0) /* Just a placeholder, not used */
102 u_char l_nv; /* number of variables it can hold */
103 u_char l_vtype[MAXCHRNV];
104 u_short l_vamt[MAXCHRNV];
105 s_char *l_name; /* full name of type of land unit */
106 int l_lcm; /* units of lcm to build */
107 int l_hcm; /* units of hcm to build */
108 int l_mil; /* how many mil it takes to build */
109 int l_gun; /* how many guns it takes to build */
110 int l_shell; /* how many shells it takes to build */
111 int l_tech; /* tech required to build */
112 int l_cost; /* how much it costs to build */
113 float l_att; /* attack multiplier */
114 float l_def; /* defense multiplier */
115 int l_vul; /* vulnerability (0-100) */
116 int l_spd; /* speed */
117 int l_vis; /* visibility */
118 int l_spy; /* Seeing distance */
119 int l_rad; /* reaction radius */
120 int l_frg; /* firing range */
121 int l_acc; /* firing accuracy */
122 int l_dam; /* # of guns firing */
123 int l_ammo; /* firing ammu used per shot */
124 int l_aaf; /* aa fire */
125 u_char l_fuelc; /* fuel capacity */
126 u_char l_fuelu; /* fuel used per 10 mob */
127 u_char l_nxlight; /* maximum number of xlight planes */
128 u_char l_mxland; /* maximum number of units */
129 long l_flags; /* what special things can this unit do */
132 /* Land unit ability flags */
133 #define L_XLIGHT bit(0) /* Hold xlight planes */
134 #define L_ENGINEER bit(1) /* Do engineering things */
135 #define L_SUPPLY bit(2) /* supply other units/sects */
136 #define L_SECURITY bit(3) /* anti-terrorist troops */
137 #define L_LIGHT bit(4) /* can go on ships */
138 #define L_MARINE bit(5) /* marine units, good at assaulting */
139 #define L_RECON bit(6) /* recon units, good at spying */
140 #define L_RADAR bit(7) /* radar unit */
141 #define L_ASSAULT bit(8) /* can assault */
142 #define L_FLAK bit(9) /* flak unit */
143 #define L_SPY bit(10) /* spy unit - way cool */
144 #define L_TRAIN bit(11) /* train unit - neato */
145 #define L_HEAVY bit(12) /* heavy unit - can't go on trains */
147 #define LND_ATTDEF(b, t) (((b) * (1.0 + ((sqrt((double)(t)) / 100.0) * 4.0))) \
149 ((b) * (1.0 + ((sqrt((double)(t)) / 100.0) * 4.0))))
150 #define LND_SPD(b, t) ((b * (1.0 + ((sqrt((double)t) / 100.0) * 2.1))) > 127\
151 ? 127 : (b * (1.0 + ((sqrt((double)t) / 100.0) * 2.1))))
152 #define LND_VUL(b, t) ((b * (1.0 - ((sqrt((double)t) / 100.0) * 1.1))) < 0\
153 ? 0 : (b * (1.0 - ((sqrt((double)t) / 100.0) * 1.1))))
154 #define LND_VIS(b, t) (b)
155 #define LND_SPY(b, t) (b)
156 #define LND_RAD(b, t) (b)
157 #define LND_FRG(b, t) ((t) ? \
158 ((b) * (logx((double)(t), (double)35.0) < 1.0 ? 1.0 : \
159 logx((double)(t), (double)35.0))) : (b))
160 #define LND_DAM(b, t) ((t) ? \
161 ((b) * (logx((double)(t), (double)60.0) < 1.0 ? 1.0 : \
162 logx((double)(t), (double)60.0))) : (b))
163 #define LND_ACC(b, t) ((b * (1.0 - ((sqrt((double)t) / 100.0) * 1.1))) < 0\
164 ? 0 : (b * (1.0 - ((sqrt((double)t) / 100.0) * 1.1))))
165 #define LND_AMM(b, d, t) ((b) ? ((LND_DAM((d), (t)) / 2) + 1) : 0)
166 #define LND_AAF(b, t) ((b * (1.0 + ((sqrt((double)t) / 100.0) * 3.0))) > 127\
167 ? 127 : (b * (1.0 + ((sqrt((double)t) / 100.0) * 3.0))))
168 #define LND_FC(b, t) (b)
169 #define LND_FU(b, t) (b)
170 #define LND_XPL(b, t) (b)
171 #define LND_MXL(b, t) (b)
172 #define LND_COST(b, t) ((b) * (1.0 + (sqrt((double)(t)) / 100.0)))
174 /* Chance to detect L_SPY unit (percent) */
175 #define LND_SPY_DETECT_CHANCE(eff) ((110-(eff))/100.0)
177 #define getland(n, p) \
178 ef_read(EF_LAND, n, (caddr_t)p)
179 #define putland(n, p) \
180 ef_write(EF_LAND, n, (caddr_t)p)
181 #define getlandp(n) \
182 (struct lndstr *) ef_ptr(EF_LAND, n)
184 extern struct lchrstr lchr[];
185 extern int lnd_maxno;
188 struct emp_qelem queue; /* list of units */
189 coord x, y; /* x,y it came from */
190 struct lchrstr *lcp; /* pointer to desc of land unit */
191 struct lndstr land; /* struct land unit */
197 /* src/lib/subs/lndsub.c */
198 extern void lnd_sweep(struct emp_qelem *, int, int, natid);
199 extern int lnd_interdict(struct emp_qelem *, coord, coord, natid);
200 extern void lnd_sel(struct nstr_item *, struct emp_qelem *);
201 extern void lnd_mess(s_char *, struct llist *);
202 extern int lnd_check_mines(struct emp_qelem *);
203 extern double lnd_mobcost(struct lndstr *, struct sctstr *, int);
204 extern s_char *lnd_path(int, struct lndstr *, s_char *);
206 extern int attack_val(int, struct lndstr *);
207 extern int total_mil(struct lndstr *);
208 extern int defense_val(struct lndstr *);
209 extern int lnd_getmil(struct lndstr *);
210 extern void lnd_print(struct llist *, s_char *);
211 extern void lnd_delete(struct llist *, s_char *);
212 extern int lnd_take_casualty(int, struct llist *, int);
213 extern void lnd_submil(struct lndstr *, int);
214 extern void lnd_takemob(struct emp_qelem *, double);
215 extern int lnd_spyval(struct lndstr *);
216 extern int intelligence_report(int, struct lndstr *, int, s_char *);
217 extern int count_sect_units(struct sctstr *);
218 extern void count_units(struct shpstr *);
219 extern void lnd_count_units(struct lndstr *);
220 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
221 extern void lnd_put(struct emp_qelem *, natid);
222 extern int lnd_hit_mine(struct lndstr *, struct lchrstr *);
223 extern void lnd_list(struct emp_qelem *);
224 extern int lnd_hardtarget(struct lndstr *);
225 extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
226 extern int lnd_support(natid, natid, coord, coord);
227 extern int lnd_can_attack(struct lndstr *);
228 extern int lnd_fortify (struct lndstr *lp, int hard_amt);
230 #endif /* _LAND_H_ */