]> git.pond.sub.org Git - empserver/blob - include/land.h
Update copyright notice
[empserver] / include / land.h
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                Ken Stevens, Steve McClure, Markus Armbruster
5  *
6  *  Empire 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 3 of the License, or
9  *  (at your option) any later version.
10  *
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.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  *  ---
20  *
21  *  See files README, COPYING and CREDITS in the root of the source
22  *  tree for related information and legal notices.  It is expected
23  *  that future projects/authors will amend these files as needed.
24  *
25  *  ---
26  *
27  *  land.h: Definitions for land units
28  *
29  *  Known contributors to this file:
30  *     Thomas Ruschak, 1992
31  *     Ken Stevens, 1995
32  *     Steve McClure, 1998
33  *     Markus Armbruster, 2004-2010
34  */
35
36 #ifndef LAND_H
37 #define LAND_H
38
39 #include <time.h>
40 #include "item.h"
41 #include "retreat.h"
42 #include "types.h"
43
44 #define LND_TYPE_MAX    30
45 #define LAND_MINEFF     10
46 #define LAND_MINFIREEFF 40      /* arty must be this effic to fire */
47
48 struct lndstr {
49     /* initial part must match struct empobj */
50     signed ef_type: 8;
51     unsigned lnd_seqno: 12;
52     unsigned lnd_generation: 12;
53     int lnd_uid;                /* unit id (land #) */
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     int lnd_ship;               /* uid of transporting ship, or -1 */
69     signed char lnd_harden;     /* fortification */
70     short lnd_retreat;          /* retreat percentage */
71     int lnd_rflags;             /* When do I retreat? */
72     char lnd_rpath[RET_LEN];    /* retreat path */
73     unsigned char lnd_scar;     /* how experienced the unit is (not used) */
74     short lnd_item[I_MAX+1];    /* amount of items on board */
75     short lnd_pstage;           /* plague stage */
76     short lnd_ptime;            /* how many etus remain in this stage */
77     int lnd_land;               /* uid of transporting land unit, or -1 */
78     short lnd_access;           /* Last tick mob was updated (MOB_ACCESS) */
79 };
80
81 struct lchrstr {
82     short l_item[I_MAX+1];      /* load limit */
83     char *l_name;               /* full name of type of land unit */
84     int l_lcm;                  /* units of lcm to build */
85     int l_hcm;                  /* units of hcm to build */
86     int l_mil;                  /* how many mil it takes to build (unused) */
87     int l_gun;                  /* how many guns it takes to build (unused) */
88     int l_shell;                /* #shells it takes to build (unused) */
89     int l_tech;                 /* tech required to build */
90     int l_cost;                 /* how much it costs to build */
91     float l_att;                /* attack multiplier */
92     float l_def;                /* defense multiplier */
93     int l_vul;                  /* vulnerability (0-100) */
94     int l_spd;                  /* speed */
95     int l_vis;                  /* visibility */
96     int l_spy;                  /* Seeing distance */
97     int l_rad;                  /* reaction radius */
98     int l_frg;                  /* firing range */
99     int l_acc;                  /* firing accuracy */
100     int l_dam;                  /* # of guns firing */
101     int l_ammo;                 /* firing ammu used per shot */
102     int l_aaf;                  /* aa fire */
103     unsigned char l_nxlight;    /* maximum number of xlight planes */
104     unsigned char l_nland;      /* maximum number of units */
105     signed char l_type;         /* index in lchr[] */
106     long l_flags;               /* what special things can this unit do */
107 };
108
109 /* Land unit ability flags */
110 #define L_ENGINEER      bit(1)  /* Do engineering things */
111 #define L_SUPPLY        bit(2)  /* supply other units/sects */
112 #define L_SECURITY      bit(3)  /* anti-terrorist troops */
113 #define L_LIGHT         bit(4)  /* can go on ships */
114 #define L_MARINE        bit(5)  /* marine units, good at assaulting */
115 #define L_RECON         bit(6)  /* recon units, good at spying */
116 #define L_RADAR         bit(7)  /* radar unit */
117 #define L_ASSAULT       bit(8)  /* can assault */
118 #define L_FLAK          bit(9)  /* flak unit */
119 #define L_SPY           bit(10) /* spy unit - way cool */
120 #define L_TRAIN         bit(11) /* train unit - neato */
121 #define L_HEAVY         bit(12) /* heavy unit - can't go on trains */
122
123 /* Work required for building 100% */
124 #define LND_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
125
126 /* Chance to detect L_SPY unit (percent) */
127 #define LND_SPY_DETECT_CHANCE(eff) ((110-(eff))/100.0)
128
129 #define getland(n, p) ef_read(EF_LAND, (n), (p))
130 #define putland(n, p) ef_write(EF_LAND, (n), (p))
131 #define getlandp(n) ((struct lndstr *)ef_ptr(EF_LAND, (n)))
132
133 extern struct lchrstr lchr[LND_TYPE_MAX + 2];
134
135 enum {
136     LND_AIROPS_EFF = 50         /* min. efficiency for air ops */
137 };
138
139 extern float l_att(struct lchrstr *, int);
140 extern float l_def(struct lchrstr *, int);
141 extern int l_vul(struct lchrstr *, int);
142 extern int l_spd(struct lchrstr *, int);
143 extern int l_frg(struct lchrstr *, int);
144 extern int l_acc(struct lchrstr *, int);
145 extern int l_dam(struct lchrstr *, int);
146 extern int l_aaf(struct lchrstr *, int);
147 extern float lnd_att(struct lndstr *);
148 extern float lnd_def(struct lndstr *);
149 extern int lnd_vul(struct lndstr *);
150 extern int lnd_spd(struct lndstr *);
151 extern int lnd_vis(struct lndstr *);
152 extern int lnd_frg(struct lndstr *);
153 extern int lnd_acc(struct lndstr *);
154 extern int lnd_dam(struct lndstr *);
155 extern int lnd_aaf(struct lndstr *);
156
157 /* src/lib/common/cargo.c */
158 extern void lnd_carrier_change(struct lndstr *, int, int, int);
159 extern int lnd_first_on_ship(struct shpstr *);
160 extern int lnd_first_on_land(struct lndstr *);
161 extern int lnd_next_on_unit(int);
162 extern int lnd_nxlight(struct lndstr *);
163 extern int lnd_nland(struct lndstr *);
164
165 extern int lnd_fire(struct lndstr *);
166 extern int lnd_sabo(struct lndstr *, short *);
167 extern double lnd_fire_range(struct lndstr *);
168
169 /* src/lib/subs/lndsub.c */
170 extern void lnd_sweep(struct emp_qelem *, int, int, natid);
171 extern int lnd_interdict(struct emp_qelem *, coord, coord, natid);
172 extern void lnd_sel(struct nstr_item *, struct emp_qelem *);
173 extern int lnd_check_mines(struct emp_qelem *);
174 extern double lnd_pathcost(struct lndstr *, double);
175 extern int lnd_mobtype(struct lndstr *);
176 extern double lnd_mobcost(struct lndstr *, struct sctstr *);
177
178 extern double attack_val(int, struct lndstr *);
179 extern double defense_val(struct lndstr *);
180 extern int lnd_reaction_range(struct lndstr *);
181 extern void lnd_print(natid, struct ulist *, char *);
182 extern void lnd_delete(struct ulist *);
183 extern int lnd_take_casualty(int, struct ulist *, int);
184 extern void lnd_submil(struct lndstr *, int);
185 extern void lnd_takemob(struct emp_qelem *, double);
186 extern int lnd_spyval(struct lndstr *);
187 extern void intelligence_report(int, struct lndstr *, int, char *);
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);
195
196 #endif