1 /*
2 	This file is part of Warzone 2100.
3 	Copyright (C) 1999-2004  Eidos Interactive
4 	Copyright (C) 2005-2020  Warzone 2100 Project
5 
6 	Warzone 2100 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 	Warzone 2100 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 Warzone 2100; if not, write to the Free Software
18 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef __INCLUDED_SRC_EFFECTS_H__
22 #define __INCLUDED_SRC_EFFECTS_H__
23 
24 /*
25 	All singing, all dancing new effects code. Does all the stuff
26 	that explosion.c and most of particle.c used to do as well as
27 	all the construction dust clouds, body parts and all other
28 	temporary world 'effects
29 	Alex McLean, Pumpkin Studios, EIDOS Interactive, 1998.
30 */
31 #include "lib/ivis_opengl/piedef.h"
32 #include "lib/framework/fixedpoint.h"
33 #include "lib/ivis_opengl/pietypes.h"
34 
35 #define SHOCK_WAVE_HEIGHT	(64)
36 
37 
38 /* All the effect groups */
39 enum EFFECT_GROUP
40 {
41 	EFFECT_EXPLOSION,
42 	EFFECT_CONSTRUCTION,
43 	EFFECT_SMOKE,
44 	EFFECT_GRAVITON,
45 	EFFECT_WAYPOINT,
46 	EFFECT_BLOOD,
47 	EFFECT_DESTRUCTION,
48 	EFFECT_SAT_LASER,
49 	EFFECT_FIRE,
50 	EFFECT_FIREWORK,
51 
52 	EFFECT_FREED,
53 };
54 
55 
56 /* Might not even need this */
57 enum EFFECT_TYPE
58 {
59 	EXPLOSION_TYPE_SMALL,
60 	EXPLOSION_TYPE_VERY_SMALL,
61 	EXPLOSION_TYPE_MEDIUM,
62 	EXPLOSION_TYPE_LARGE,
63 	EXPLOSION_TYPE_SPECIFIED,	// superfluous?
64 	EXPLOSION_TYPE_NOT_FACING,
65 	EXPLOSION_TYPE_SPECIFIED_SOLID,
66 	EXPLOSION_TYPE_SPECIFIED_FIXME,
67 	EXPLOSION_TYPE_FLAMETHROWER,
68 	EXPLOSION_TYPE_LASER,
69 	EXPLOSION_TYPE_TESLA,
70 	EXPLOSION_TYPE_DISCOVERY,
71 	EXPLOSION_TYPE_FLARE,
72 	EXPLOSION_TYPE_PLASMA,
73 	EXPLOSION_TYPE_KICKUP,
74 	EXPLOSION_TYPE_LAND_LIGHT,
75 	EXPLOSION_TYPE_SHOCKWAVE,
76 
77 	//EXPLOSION_TYPE_SKYSCRAPER,
78 
79 	GRAVITON_TYPE_STANDARD,
80 	GRAVITON_TYPE_EMITTING_DR,
81 	GRAVITON_TYPE_EMITTING_ST,
82 	GRAVITON_TYPE_GIBLET,
83 
84 	SMOKE_TYPE_DRIFTING,
85 	SMOKE_TYPE_DRIFTING_HIGH,
86 	SMOKE_TYPE_DRIFTING_SMALL,
87 	SMOKE_TYPE_BILLOW,
88 	SMOKE_TYPE_STEAM,
89 	SMOKE_TYPE_TRAIL,
90 	FIRE_TYPE_LOCALISED,
91 	FIRE_TYPE_SMOKY,
92 	FIRE_TYPE_SMOKY_BLUE,
93 	CONSTRUCTION_TYPE_DRIFTING,
94 
95 	BLOOD_TYPE_NORMAL,
96 
97 	DUST_TYPE_NORMAL,
98 	DESTRUCTION_TYPE_DROID,
99 	DESTRUCTION_TYPE_STRUCTURE,
100 	DESTRUCTION_TYPE_POWER_STATION,
101 	DESTRUCTION_TYPE_WALL_SECTION,
102 	DESTRUCTION_TYPE_FEATURE,
103 	DESTRUCTION_TYPE_SKYSCRAPER,
104 
105 	SAT_LASER_STANDARD,
106 
107 	WAYPOINT_TYPE,
108 
109 	FIREWORK_TYPE_STARBURST,
110 	FIREWORK_TYPE_LAUNCHER,
111 };
112 
113 
114 enum LAND_LIGHT_SPEC
115 {
116 	LL_MIDDLE,
117 	LL_INNER,
118 	LL_OUTER
119 };
120 
121 
122 struct EFFECT
123 {
124 	uint8_t           player;      //	when the effect in question needs a player's color
125 	uint8_t           control;     // Controls the bits above - essential,flips etc
126 	EFFECT_GROUP      group;       // what group is it - explosion, building effect etc....
127 	EFFECT_TYPE       type;        // what type is it within the group?
128 	uint8_t           frameNumber; // what frame number is the imd on?
129 	uint16_t          size;        // Size in terms of percent of original imd.
130 	uint8_t           baseScale;   // if scaled, what's bottom line?
131 	uint8_t           specific;    // how many times has it bounced?
132 	Vector3f          position;    // world coordinates of the effect - floats on the PC.
133 	Vector3f          velocity;    // movement values per update
134 	Vector3i          rotation;    // current rotation - only for gravitons
135 	Vector3i          spin;        // rotation info for spinning things.
136 	uint32_t          birthTime;   // what time was it introduced into the world?
137 	uint32_t          lastFrame;   // when did we last update the frame?
138 	uint16_t          frameDelay;  // how many game ticks between each frame?
139 	uint16_t          lifeSpan;    // what is it's life expectancy?
140 	uint16_t          radius;      // Used for area effects
141 	iIMDShape         *imd;        // pointer to the imd the effect uses.
142 	EFFECT *prev, *next; // Previous and next element in linked list
143 
EFFECTEFFECT144 	EFFECT() : player(MAX_PLAYERS), control(0), group(EFFECT_FREED), type(EXPLOSION_TYPE_SMALL), frameNumber(0), size(0),
145 	           baseScale(0), specific(0), position(0.f, 0.f, 0.f), velocity(0.f, 0.f, 0.f), rotation(0, 0, 0), spin(0, 0, 0), birthTime(0), lastFrame(0), frameDelay(0), lifeSpan(0), radius(0),
146 	           imd(nullptr), prev(nullptr), next(nullptr) {}
147 };
148 
149 /* Maximum number of effects in the world - need to investigate what this should be */
150 /* EXTERNAL REFERENCES */
151 void	effectGiveAuxVar(UDWORD var);		// naughty
152 void	effectGiveAuxVarSec(UDWORD var);	// and so's this
153 
154 void	initEffectsSystem();
155 void	shutdownEffectsSystem();
156 void	processEffects(const glm::mat4 &viewMatrix);
157 void 	addEffect(const Vector3i *pos, EFFECT_GROUP group, EFFECT_TYPE type, bool specified, iIMDShape *imd, int lit);
158 void    addEffect(const Vector3i *pos, EFFECT_GROUP group, EFFECT_TYPE type, bool specified, iIMDShape *imd, int lit, unsigned effectTime);
159 void    addMultiEffect(const Vector3i *basePos, Vector3i *scatter, EFFECT_GROUP group, EFFECT_TYPE type, bool specified, iIMDShape *imd, unsigned int number, bool lit, unsigned int size, unsigned effectTime);
160 
161 void	renderEffect(const EFFECT *psEffect, const glm::mat4 &viewMatrix);
162 void	effectResetUpdates();
163 
164 void	initPerimeterSmoke(iIMDShape *pImd, Vector3i base);
165 
166 bool	readFXData(const char *fileName);
167 bool	writeFXData(const char *fileName);
168 void	effectSetSize(UDWORD size);
169 void	effectSetLandLightSpec(LAND_LIGHT_SPEC spec);
170 void	SetEffectForPlayer(uint8_t player);
171 
172 #endif // __INCLUDED_SRC_EFFECTS_H__
173