aboutsummaryrefslogtreecommitdiff
path: root/src/libparsec/include/g_emp.h
blob: e0879a96247115e3a8ed83e6e45d06e8fc7021e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
 * PARSEC HEADER: s_emp.h
 */

#ifndef _S_EMP_H_
#define _S_EMP_H_




// use emp as duration weapon
#define EMP_FIRE_CONTINUOUSLY





#define EMP_MAX_TEX_NAME 128
// emp custom type structure --------------------------------------------------
//
struct Emp : CustomObject {

	int			upgradelevel;
	Xmatrx		WorldXmatrx;	// object- to worldspace matrix
	Vertex3*	ObjVtxs;
	Vertex3*	WorldVtxs;		// vertices in worldspace
	TextureMap*	texmap;
	char		texname[ EMP_MAX_TEX_NAME + 1 ];
	dword		OwnerHostObjno;		// needed for animation calculation
	GenObject*	ownerpo;
	int			Owner;
	int			vtxsnr;
	int			lod;
	bams_t		lat;
	bams_t		rot;
	long		alive;
	int			delay;
	int			red;
	int			green;
	int			blue;
	int			alpha;
	dword		damage;			// hitpoints fractional per refframe
};

// number of upgrade levels ---------------------------------------------------
//
#define EMP_UPGRADES		3


// preset emp type property values --------------------------------------------
//
#define EMP_MAX_LIFETIME		6000
#define EMP_MIN_LIFETIME		60
#define EMP_MAX_WAVES			100
#define EMP_MIN_WAVES			1
#define EMP_MAX_DELAY			2400
#define EMP_MIN_DELAY			0

// emp standard property values
#define EMP_TEXNAME				"in01_00a.3df"
#define EMP_LOD					16
#define EMP_MAX_WIDTH			200.0f
#define EMP_LAT					0x2000		// 45 deg
#define EMP_RED           		220
#define EMP_GREEN				220
#define EMP_BLUE				220
#define EMP_ALPHA				255
#define EMP_LIFETIME			400
#define EMP_FADEOUT       		400
#define EMP_LAMBDA				0.2
#define EMP_ROT					32
#define EMP_DELAY				200
#define EMP_WAVES				1
#define EMP_ENERGY				0
#define EMP_DAMAGE				2000

// emp upgrade level 1 property values
#define EMP_UP1_TEXNAME			"in01_00a.3df"
#define EMP_UP1_LOD				16
#define EMP_UP1_MAX_WIDTH		200.0f
#define EMP_UP1_LAT				0x2000		// 45 deg
#define EMP_UP1_RED           	220
#define EMP_UP1_GREEN			220
#define EMP_UP1_BLUE			220
#define EMP_UP1_ALPHA			180
#define EMP_UP1_LIFETIME		200
#define EMP_UP1_FADEOUT       	200
#define EMP_UP1_LAMBDA			2.0
#define EMP_UP1_ROT				( BAMS_DEG45 / 16 )
#define EMP_UP1_DELAY			40
#define EMP_UP1_WAVES			6
#define EMP_UP1_ENERGY			6
#define EMP_UP1_DAMAGE			1000

// emp upgrade level 2 property values
#define EMP_UP2_TEXNAME			"in01_00a.3df"
#define EMP_UP2_LOD				16
#define EMP_UP2_MAX_WIDTH		200.0f
#define EMP_UP2_LAT				0x2000		// 45 deg
#define EMP_UP2_RED           	220
#define EMP_UP2_GREEN			200
#define EMP_UP2_BLUE			0
#define EMP_UP2_ALPHA			90
#define EMP_UP2_LIFETIME		800
#define EMP_UP2_FADEOUT       	800
#define EMP_UP2_LAMBDA			4.0
#define EMP_UP2_ROT				16
#define EMP_UP2_DELAY			80
#define EMP_UP2_WAVES			6
#define EMP_UP2_ENERGY			40
#define EMP_UP2_DAMAGE			2000



#define OFS_TEXNAME			offsetof( Emp, texname )
#define OFS_LOD				offsetof( Emp, lod )
#define OFS_LAT				offsetof( Emp, lat )
#define OFS_ROT				offsetof( Emp, rot )
#define OFS_RED				offsetof( Emp, red )
#define OFS_GREEN			offsetof( Emp, green )
#define OFS_BLUE			offsetof( Emp, blue )
#define OFS_ALPHA			offsetof( Emp, alpha )
#define OFS_DAMAGE			offsetof( Emp, damage )


// assigned type id for emp type ----------------------------------------------
//
extern dword emp_type_id[ EMP_UPGRADES ];


// full table for emp expansion -----------------------------------------------
//
static float *emp_expansion_tab[ EMP_UPGRADES ] = {
	NULL, NULL, NULL,
};


// emp behaviour properties ---------------------------------------------------
//
static int			emp_lifetime[ EMP_UPGRADES ]	= {
		EMP_LIFETIME,
		EMP_UP1_LIFETIME,
		EMP_UP2_LIFETIME,
};
static geomv_t		emp_max_width[ EMP_UPGRADES ]	= {
		FLOAT_TO_GEOMV( EMP_MAX_WIDTH ),
		FLOAT_TO_GEOMV( EMP_UP1_MAX_WIDTH ),
		FLOAT_TO_GEOMV( EMP_UP2_MAX_WIDTH ),
};

static float		emp_lambda[ EMP_UPGRADES ]		= {
		EMP_LAMBDA,
		EMP_UP1_LAMBDA,
		EMP_UP2_LAMBDA,
};

static int          emp_fadeout[ EMP_UPGRADES ]		= {
		EMP_FADEOUT,
		EMP_UP1_FADEOUT,
		EMP_UP2_FADEOUT,
};

static int          emp_waves[ EMP_UPGRADES ]		= {
		EMP_WAVES,
		EMP_UP1_WAVES,
		EMP_UP2_WAVES,
};

static int          emp_delay[ EMP_UPGRADES ]		= {
		EMP_DELAY,
		EMP_UP1_DELAY,
		EMP_UP2_DELAY,
};

static int          emp_energy[ EMP_UPGRADES ]		= {
		EMP_ENERGY,
		EMP_UP1_ENERGY,
		EMP_UP2_ENERGY,
};


// macro to set the properties of a itervertex --------------------------------
//
#define SET_ITER_VTX( itvtx, vtx, u, v, r, g, b, a ) \
	(itvtx)->X = (vtx)->X;	\
	(itvtx)->Y = (vtx)->Y;	\
	(itvtx)->Z = (vtx)->Z;	\
	(itvtx)->W = GEOMV_1;	\
	(itvtx)->U = (u);		\
	(itvtx)->V = (v);		\
	(itvtx)->R = (r);		\
	(itvtx)->G = (g);		\
	(itvtx)->B = (b);		\
	(itvtx)->A = (a);


// color combination macro ----------------------------------------------------
//
#define COLOR_MUL(t,a,b)	{ \
	int tmp; \
	tmp = ( (int)(a) * (int)(b) ) / 255; \
	if ( tmp > 255 ) \
		tmp = 255; \
	(t) = tmp; \
}

#ifdef PARSEC_SERVER

// mathematics header
#include "utl_math.h"

// local module header
#include "e_gameserver.h"

// proprietary module headers
#include "con_arg.h"
#include "con_aux_sv.h"
#include "con_com_sv.h"
#include "con_main_sv.h"
#include "e_colldet.h"
#include "g_extra.h"

#include "obj_clas.h"
//#include "e_stats.h"
#include "g_main_sv.h"
#include "e_simulator.h"
#include "sys_refframe_sv.h"
#include "sys_util_sv.h"
#endif

void	CreateEmp( GenObject *ownerpo, int delay, int alive, int upgradelevel, int nClientID=0 );
// external functions
#ifndef PARSEC_SERVER
void	WFX_EmpBlast( ShipObject *shippo );
void	WFX_RemoteEmpBlast( ShipObject *shippo, int curupgrade );
void	WFX_CreateEmpWaves( ShipObject *shippo );
int     WFX_ActivateEmp( ShipObject *shippo );
void    WFX_DeactivateEmp( ShipObject *shippo );
void    WFX_RemoteActivateEmp( int playerid );
void    WFX_RemoteDeactivateEmp( int playerid );
#else

int 	EmpShipCollision( Emp *emp, ShipObject* shippo );
int 	EmpAnimate( CustomObject *base );
#endif

#endif // _S_EMP_H_