1 /*KJL****************************************************************************************
2 *                                         	hud.c                                           *
3 ****************************************************************************************KJL*/
4 
5 #include "3dc.h"
6 #include "module.h"
7 #include "inline.h"
8 #include "stratdef.h"
9 #include "gamedef.h"
10 #include "bh_types.h"
11 #include "huddefs.h"
12 #include "opengl.h"
13 
14 /* patrick's sound include */
15 #include "psnd.h"
16 #include "psndplat.h"
17 
18 #define UseLocalAssert Yes
19 #include "ourasert.h"
20 
21 /*KJL****************************************************************************************
22 *                                    P R O T O T Y P E S	                                *
23 ****************************************************************************************KJL*/
24 #include "vision.h"
25 #include "frustum.h"
26 #include "avpview.h"
27 #include "game_statistics.h"
28 
29 /*KJL****************************************************************************************
30 *  										G L O B A L S 	            					    *
31 ****************************************************************************************KJL*/
32 enum VISION_MODE_ID CurrentVisionMode;
33 
34 static int visionModeDebounced=0;
35 
36 extern ACTIVESOUNDSAMPLE ActiveSounds[];
37 int predOVision_SoundHandle;
38 
39 extern int FMVParticleColour;
40 extern int LogosAlphaLevel;
41 int PredatorVisionChangeCounter;
42 
43 static struct PredOVisionDescriptor PredOVision;
44 static struct MarineOVisionDescriptor MarineOVision;
45 extern VIEWDESCRIPTORBLOCK *ActiveVDBList[];
46 extern int NormalFrameTime;
47 extern int GlobalAmbience;
48 /* JH 29/5/97 - to control how D3D does the lighting */
49 struct D3DLightColourControl d3d_light_ctrl;
50 /*KJL****************************************************************************************
51 *                                     F U N C T I O N S	                                    *
52 ****************************************************************************************KJL*/
53 void SetupVision(void);
54 
55 extern void DrawNoiseOverlay(int t);
56 
SetupVision(void)57 void SetupVision(void)
58 {
59 	/* KJL 16:33:47 01/10/97 - change view for alien;
60 	this must be called after ProcessSystemObjects() */
61 	if(AvP.PlayerType == I_Alien)
62    	{
63 		/* setup wide-angle lens */
64 		extern VIEWDESCRIPTORBLOCK *ActiveVDBList[];
65 		extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
66 		VIEWDESCRIPTORBLOCK *VDBPtr = ActiveVDBList[0];
67 
68 		LOCALASSERT(VDBPtr);
69 
70 		/* change clipping planes for new field of view */
71 		/* KJL 12:00:54 07/04/97 - new projection angles */
72 		VDBPtr->VDB_ProjX = ScreenDescriptorBlock.SDB_Width/4;
73 		VDBPtr->VDB_ProjY = (ScreenDescriptorBlock.SDB_Height)/4;
74 
75 		/* KJL 17:37:51 7/17/97 - frustrum setup */
76 		SetFrustrumType(FRUSTRUM_TYPE_WIDE);
77 	}
78 	else if (AvP.PlayerType == I_Predator)
79 	{
80 		/* setup normal-angle lens */
81 		extern VIEWDESCRIPTORBLOCK *ActiveVDBList[];
82 		extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
83 		VIEWDESCRIPTORBLOCK *VDBPtr = ActiveVDBList[0];
84 
85 		LOCALASSERT(VDBPtr);
86 
87 		/* change clipping planes for new field of view */
88 		VDBPtr->VDB_ProjX = ScreenDescriptorBlock.SDB_Width/2;
89 		VDBPtr->VDB_ProjY = (ScreenDescriptorBlock.SDB_Height)/2;
90 
91 		SetupPredOVision();
92 		/* KJL 17:37:51 7/17/97 - frustrum setup */
93 		SetFrustrumType(FRUSTRUM_TYPE_NORMAL);
94 	}
95 	else
96 	{
97 		/* setup normal-angle lens */
98 		extern VIEWDESCRIPTORBLOCK *ActiveVDBList[];
99 		extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
100 		VIEWDESCRIPTORBLOCK *VDBPtr = ActiveVDBList[0];
101 
102 		LOCALASSERT(VDBPtr);
103 
104 		/* change clipping planes for new field of view */
105 		VDBPtr->VDB_ProjX = ScreenDescriptorBlock.SDB_Width/2;
106 		VDBPtr->VDB_ProjY = (ScreenDescriptorBlock.SDB_Height)/2;
107 
108 		SetupMarineOVision();
109 		/* KJL 17:37:51 7/17/97 - frustrum setup */
110 		SetFrustrumType(FRUSTRUM_TYPE_NORMAL);
111 	}
112 
113 	InitCameraValues();
114 
115 	/* KJL 12:01:09 16/02/98 - init visionmode */
116 	CurrentVisionMode = VISION_MODE_NORMAL;
117 
118 	predOVision_SoundHandle=SOUND_NOACTIVEINDEX;
119 	PredatorVisionChangeCounter=0;
120 
121 	FMVParticleColour = RGBA_MAKE(255,255,255,128);
122 	LogosAlphaLevel = 3*ONE_FIXED;
123 }
124 
125 /*
126 IMPORTANT NOTE OF KNOWN BUG NOT YET FIXED
127 Note that there is a potential problem in that
128 if the game exits with *-o-vision on or in transition,
129 the next instance of playing the game with the
130 alien character will still have the same vision settings.
131 - JH
132 */
133 
134 /* Pred-O-Vision */
SetupPredOVision(void)135 void SetupPredOVision(void)
136 {
137 
138 	/* setup in-game data */
139 	PredOVision.VisionMode = PREDOVISION_NORMAL;
140 	PredOVision.VisionIsChanging=0;
141 	/* JH - 29/5/97 for d3d */
142 	d3d_light_ctrl.ctrl = LCCM_NORMAL;
143 }
144 
145 
HandlePredOVision(void)146 void HandlePredOVision(void)
147 {
148 	PLAYER_STATUS *playerStatusPtr= (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
149 
150 	if (playerStatusPtr->IsAlive) {
151 		CurrentGameStats_VisionMode(CurrentVisionMode);
152 	}
153 
154 	if (playerStatusPtr->cloakOn)
155 	{
156 		DrawNoiseOverlay(16);
157 	}
158 	if (CurrentVisionMode==VISION_MODE_PRED_SEEPREDTECH)
159 	{
160 		D3D_PredatorScreenInversionOverlay();
161 	}
162 
163 	if (CurrentVisionMode==VISION_MODE_NORMAL)
164 	{
165 		if (predOVision_SoundHandle!=SOUND_NOACTIVEINDEX)
166 		{
167 			Sound_Stop(predOVision_SoundHandle);
168 		}
169 	}
170 	else
171 	{
172 		if (predOVision_SoundHandle!=SOUND_NOACTIVEINDEX)
173 		{
174 			if (ActiveSounds[predOVision_SoundHandle].soundIndex!=SID_PREDATOR_CLOAKING_ACTIVE)
175 			{
176 				Sound_Stop(predOVision_SoundHandle);
177 			}
178 		}
179 		if (predOVision_SoundHandle==SOUND_NOACTIVEINDEX)
180 		{
181 			Sound_Play(SID_PREDATOR_CLOAKING_ACTIVE,"elh",&predOVision_SoundHandle);
182 		}
183 	}
184 
185 	if (PredatorVisionChangeCounter)
186 	{
187 		D3D_FadeDownScreen(ONE_FIXED-PredatorVisionChangeCounter,0xffffffff);
188 		PredatorVisionChangeCounter -= NormalFrameTime*4;
189 
190 		if (PredatorVisionChangeCounter<0)
191 		{
192 			PredatorVisionChangeCounter=0;
193 		}
194 	}
195 
196 }
197 
ChangePredatorVisionMode(void)198 extern void ChangePredatorVisionMode(void)
199 {
200 	switch (CurrentVisionMode)
201 	{
202 		case VISION_MODE_NORMAL:
203 		{
204 			CurrentVisionMode=VISION_MODE_PRED_THERMAL;
205 			break;
206 		}
207 		case VISION_MODE_PRED_THERMAL:
208 		{
209 			CurrentVisionMode=VISION_MODE_PRED_SEEALIENS;
210 			break;
211 		}
212 		case VISION_MODE_PRED_SEEALIENS:
213 		{
214 			CurrentVisionMode=VISION_MODE_PRED_SEEPREDTECH;
215 			break;
216 		}
217 		case VISION_MODE_PRED_SEEPREDTECH:
218 		{
219 			CurrentVisionMode=VISION_MODE_NORMAL;
220 			break;
221 		}
222 		default:
223 			break;
224 	}
225 	Sound_Play(SID_VISION_ON,"h");
226 	PredatorVisionChangeCounter=ONE_FIXED;
227 }
228 
229 
230 /* Marine-O-Vision */
231 
SetupMarineOVision(void)232 void SetupMarineOVision(void)
233 {
234 	/* setup in-game data */
235 	MarineOVision.VisionMode = MARINEOVISION_NORMAL;
236 	MarineOVision.VisionIsChanging=0;
237 	/* JH - 29/5/97 for d3d */
238 	d3d_light_ctrl.ctrl = LCCM_NORMAL;
239 }
240 
241 
HandleMarineOVision(void)242 void HandleMarineOVision(void)
243 {
244 	PLAYER_STATUS *playerStatusPtr= (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
245 
246 	if (playerStatusPtr->IsAlive) {
247 		CurrentGameStats_VisionMode(CurrentVisionMode);
248 	}
249 
250 	if (CurrentVisionMode == VISION_MODE_IMAGEINTENSIFIER)
251 	{
252 		DrawNoiseOverlay(64);
253 	}
254 
255 	/* We might have just morphed. */
256 	if (predOVision_SoundHandle!=SOUND_NOACTIVEINDEX) {
257 		Sound_Stop(predOVision_SoundHandle);
258 	}
259 
260 	if (playerStatusPtr->Mvt_InputRequests.Flags.Rqst_ChangeVision)
261 	{
262 		if (visionModeDebounced)
263 		{
264 			visionModeDebounced = 0;
265 			if (CurrentVisionMode == VISION_MODE_IMAGEINTENSIFIER)
266 			{
267 				/* then we'll be changing to normal vision */
268 				NewOnScreenMessage(GetTextString(TEXTSTRING_INGAME_INTENSIFIEROFF));
269 				CurrentVisionMode = VISION_MODE_NORMAL;
270 				FMVParticleColour = RGBA_MAKE(255,255,255,128);
271 				Sound_Play(SID_IMAGE_OFF,"h");
272 			}
273 			else
274 			{
275 				/* then we'll be changing to intensified vision */
276 				NewOnScreenMessage(GetTextString(TEXTSTRING_INGAME_INTENSIFIERON));
277 				CurrentVisionMode = VISION_MODE_IMAGEINTENSIFIER;
278 				FMVParticleColour = RGBA_MAKE(0,255,0,128);
279 				Sound_Play(SID_IMAGE,"h");
280 			}
281 		}
282 	}
283 	else
284 	{
285 		visionModeDebounced = 1;
286 	}
287 
288 
289 }
290 
291 
HandleAlienOVision(void)292 void HandleAlienOVision(void)
293 {
294 	PLAYER_STATUS *playerStatusPtr= (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
295 
296 	if (playerStatusPtr->IsAlive) {
297 		CurrentGameStats_VisionMode(CurrentVisionMode);
298 	}
299 
300 	if (CurrentVisionMode == VISION_MODE_ALIEN_SENSE)
301 	{
302 		D3D_ScreenInversionOverlay();
303 	}
304 
305 	/* We might have just morphed. */
306 	if (predOVision_SoundHandle!=SOUND_NOACTIVEINDEX) {
307 		Sound_Stop(predOVision_SoundHandle);
308 	}
309 
310 	if (playerStatusPtr->Mvt_InputRequests.Flags.Rqst_ChangeVision)
311 	{
312 		if (visionModeDebounced)
313 		{
314 			visionModeDebounced = 0;
315 			if (CurrentVisionMode == VISION_MODE_ALIEN_SENSE)
316 			{
317 				/* then we'll be changing to normal vision */
318 				CurrentVisionMode = VISION_MODE_NORMAL;
319 				FMVParticleColour = RGBA_MAKE(255,255,255,128);
320 			}
321 			else
322 			{
323 				/* then we'll be changing to alien sense */
324 				CurrentVisionMode = VISION_MODE_ALIEN_SENSE;
325 				FMVParticleColour = RGBA_MAKE(255,255,255,128);
326 			}
327 		}
328 	}
329 	else
330 	{
331 		visionModeDebounced = 1;
332 	}
333 
334 }
335 /* used when the palette has been changed, eg. by database screens */
336 
337 
IsVisionChanging(void)338 int IsVisionChanging(void)
339 {
340 	switch (AvP.PlayerType)
341 	{
342 		case I_Marine:
343 			return (MarineOVision.VisionIsChanging);
344 			break;
345 		case I_Predator:
346 			return (PredOVision.VisionIsChanging);
347 			break;
348 		case I_Alien:
349 			return(0);
350 			break;
351 		default:
352 			return(0);
353 			break;
354 	}
355 }
356