]> git.pond.sub.org Git - empserver/blob - include/plane.h
Don't declare things in more than one place. Move some declarations
[empserver] / include / plane.h
1 /*
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
5  *
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.
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, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
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.
25  *
26  *  ---
27  *
28  *  plane.h: Definitions for planes and plane types
29  * 
30  *  Known contributors to this file:
31  *     Dave Pare, 1986
32  *     Ken Stevens, 1995
33  *     Steve McClure, 1998
34  */
35
36 #ifndef _PLANE_H_
37 #define _PLANE_H_
38
39 #include "queue.h"
40 #include "sect.h"
41
42 #define PLANE_MINEFF    10
43
44 /*
45  * some routines assume that from pln_x to pln_wing remains
46  * exactly equivalent with shp_x to shp_fleet
47  */
48 struct plnstr {
49     short ef_type;
50     natid pln_own;              /* owning country */
51     short pln_uid;              /* plane unit id */
52     coord pln_x;                /* plane x-y */
53     coord pln_y;
54     s_char pln_type;            /* fighter, bomber, etc */
55     s_char pln_effic;           /* actually "training" */
56     s_char pln_mobil;           /* plane mobility */
57     short pln_sell;             /* index into trade file */
58     short pln_tech;             /* plane's tech level */
59     s_char pln_wing;            /* like fleet */
60     coord pln_opx;              /* Op sector coords */
61     coord pln_opy;              /* Op sector coords */
62     short pln_mission;          /* mission code */
63     short pln_radius;           /* mission radius */
64     u_char pln_range;           /* total distance, not radius */
65     u_char pln_range_max;       /* max range for this plane */
66     short pln_ship;             /* pointer to carrier */
67     short pln_land;             /* pointer to carrier */
68     int pln_att;                /* plane air-air attack/defense values */
69     int pln_def;
70     int pln_acc;
71     int pln_load;
72     int pln_fuel;
73     s_char pln_harden;          /* for missiles */
74     s_char pln_nuketype;        /* type of nuclear armament (if any) */
75     s_char pln_flags;           /* State of the plane */
76     time_t pln_access;          /* Last time mob was updated (MOB_ACCESS) */
77     time_t pln_timestamp;       /* Last time this plane was touched */
78     float pln_theta;            /* position in orbital sine wave */
79 };
80
81 #define PLN_LAUNCHED    bit(0)  /* A satellite that's in orbit */
82 #define PLN_SYNCHRONOUS bit(1)  /* A satellite in geo-synchronous orbit */
83 #define PLN_AIRBURST    bit(2)  /* Airburst the nuke we're armed with */
84
85 struct plchrstr {
86     s_char *pl_name;            /* plane vanilla unit name */
87     s_char *pl_planename;       /* plane real name */
88     int pl_lcm;                 /* costs to build */
89     int pl_hcm;
90     int pl_cost;
91     int pl_tech;                /* tech needed to build */
92     int pl_acc;                 /* bombing accuracy (higher the better) */
93     int pl_load;                /* bomb load, also for carrying cargo */
94     int pl_att;                 /* air-air attack/defense strengths */
95     int pl_def;
96     int pl_range;               /* how many sectors it can fly */
97     int pl_crew;                /* number of mil to crew it */
98     int pl_fuel;                /* fuel consumption */
99     int pl_stealth;             /* how stealthy is it? */
100     int pl_flags;               /* description of capability */
101 };
102
103 #define P_B     bit(0)          /* bombing factor only for bombing */
104 #define P_T     bit(1)          /* tactical bombing ability */
105 #define P_F     bit(2)          /* interceptor/escort */
106 #define P_C     bit(3)          /* bombing factor for transport only */
107 #define P_V     bit(4)          /* vtol ability */
108 #define P_M     bit(5)          /* missile, used only once, can't be intercepted */
109 #define P_L     bit(6)          /* light plane, lands on carriers */
110 #define P_S     bit(7)          /* Spy ability */
111 #define P_I     bit(8)          /* Imaging ability (advanced spying) */
112 #define P_O     bit(9)          /* Orbital ability (a satellite) */
113 #define P_X     bit(10)         /* Stealth ability */
114 #define P_N     bit(11)         /* Nuclear RV interceptor (abm) */
115 #define P_H     bit(12)         /* Half stealthy */
116 #define P_E     bit(13)         /* extra light */
117 #define P_K     bit(14)         /* chopper */
118 #define P_A     bit(15)         /* ASW (Anti-Sub Warfare) */
119 #define P_P     bit(16)         /* paradropping */
120 #define P_ESC   bit(17)         /* escort */
121 #define P_MINE  bit(18)         /* can lay mines */
122 #define P_SWEEP bit(19)         /* can sweep mines */
123 #define P_MAR   bit(20)         /* missile can hit ships */
124
125 #define PM_R    bit(0)          /* Recon mission */
126 #define PM_S    bit(1)          /* Mine-sweeping mission */
127
128 #define PLN_MAXDEF      50
129
130         /* internal to "fly" module -- really shouldn't be here */
131
132 struct plist {
133     struct emp_qelem queue;     /* list of planes */
134     int state;                  /* state of plane */
135     int bombs;                  /* bombs carried for bombing mission */
136     int misc;                   /* amount of random item being transported */
137     struct plchrstr *pcp;       /* pointer to desc of plane */
138     struct plnstr plane;        /* struct plane */
139 };
140
141 #define P_OK            0
142 #define P_FIRED         1
143 #define P_DEL           2
144
145 #define getplane(n, p) \
146         ef_read(EF_PLANE, n, (caddr_t)p)
147 #define putplane(n, p) \
148         ef_write(EF_PLANE, n, (caddr_t)p)
149 #define getplanep(n) \
150         (struct plnstr *) ef_ptr(EF_PLANE, n)
151
152 extern struct plchrstr plchr[];
153 extern int pln_maxno;
154
155 struct shiplook {
156     short uid;
157     u_char looked;
158     u_char found;
159     struct shiplook *next;
160 };
161
162 #define PLN_ATTDEF(b, t) (b + ((b?1:0) * ((t/20)>10?10:(t/20))))
163 #define PLN_ACC(b, t) (b * (1.0 - (sqrt((double)t) / 50.)))
164 #define PLN_RAN(b, t) (t ? (b + (logx((double)t, (double)2.0))) : b)
165 #define PLN_LOAD(b, t) (t ? (b * (logx((double)t, (double)50.0) < 1.0 ? 1.0 : \
166                                   logx((double)t, (double)50.0))) : b)
167
168
169 /* src/lib/subs/aircombat.c */
170 extern void ac_planedamage(struct plist *, natid, int, natid, int,
171                            int, s_char *);
172 extern void ac_intercept(struct emp_qelem *, struct emp_qelem *,
173                          struct emp_qelem *, natid, coord, coord);
174 extern void ac_combat_headers(natid, natid);
175 extern void ac_airtoair(struct emp_qelem *, struct emp_qelem *, natid);
176 extern void ac_doflak(struct emp_qelem *, struct sctstr *);
177 extern void ac_shipflak(struct emp_qelem *, coord, coord);
178 extern void ac_landflak(struct emp_qelem *, coord, coord);
179 extern void ac_fireflak(struct emp_qelem *, natid, natid, int);
180 extern void ac_encounter(struct emp_qelem *, struct emp_qelem *, coord,
181                          coord, s_char *, int, int,
182                          struct emp_qelem *, struct emp_qelem *);
183 extern int ac_isflying(struct plnstr *, struct emp_qelem *);
184 extern int do_evade(struct emp_qelem *, struct emp_qelem *);
185 extern void sam_intercept(struct emp_qelem *, struct emp_qelem *,
186                           natid, natid, coord, coord, int);
187 extern int all_missiles(struct emp_qelem *);
188 extern int can_fly(int);
189
190 /* src/lib/subs/aswplnsubs.c */
191 extern int have_looked(u_char, struct shiplook *);
192 extern int have_found(u_char, struct shiplook *);
193 extern void set_have_looked(u_char, struct shiplook *);
194 extern void set_have_found(u_char, struct shiplook *);
195 extern int print_found(struct shiplook *);
196
197 #endif /* _PLANE_H_ */