/****************************************************************************
*
* EFFECT2.H
*
* PROGRAMMER : Chris
*    VERSION : 00.00
*    CREATED : 02/06/98
*   MODIFIED : 02/06/98
*       TABS : 5
*
* DESCRIPTION
*	Header file for EFFECT2.C
*
*****************************************************************************/

#ifndef _EFFECT2_H
#define _EFFECT2_H

#ifdef __cplusplus
extern "C" {
#endif

/*---------------------------------------------------------------------------
 *	Import Headers
\*--------------------------------------------------------------------------*/

#ifdef PSX_VERSION
#include "../spec_psx/typedefs.h"
#else
#include "..\specific\stypes.h"
#endif

#include "anim.h"

/*---------------------------------------------------------------------------
 *	Constants
\*--------------------------------------------------------------------------*/

#define	MAX_DYNAMIC2	32

#define	MAX_SPARKS	192
#define	MAX_SPLASHES	4
#define	MAX_RIPPLES	16
#define	MAX_BATS		32

#define	SP_FLAT		1
#define	SP_SCALE		2
#define	SP_BLOOD		4
#define	SP_DEF		8
#define	SP_ROTATE		16
#define	SP_EXPLOSION	32
#define	SP_FX		64
#define	SP_ITEM		128
#define	SP_WIND		256
#define	SP_EXPDEF		512
#define	SP_USEFXOBJPOS	1024
#define	SP_UNDERWEXP	2048
#define	SP_NODEATTATCH	4096
#define	SP_PLASMAEXP	8192

enum		{	SPN_PILOTFLAME,
			SPN_WINGMUTEPARTICLES,
			SPN_PUNKFLAME,
			SPN_PENDULUMFLAME,
			SPN_TONYHANDLFLAME,
			SPN_TONYHANDRFLAME,
			SPN_CLAWMUTEPLASMA,
			SPN_WILLBOSSLPLASMA,
			SPN_WILLBOSSRPLASMA,
			SPN_CLEANER5,
			SPN_CLEANER9,
			SPN_CLEANER13,
};

#define	SD_EXPLOSION	1
#define	SD_UWEXPLOSION	2

#define	SEMITRANS		1
#define	COLADD		2
#define	COLSUB		3
#define	WEIRD		4

#define	LEFT_HAND		0
#define	RIGHT_HAND	1
#define	LARA_HIPS		2
#define	LARA_TORSO	3
#define	LARA_HEAD		4
#define	LEFT_FOOT		5
#define	RIGHT_FOOT	6

#define	ROCKET_YOFF	180
#define	ROCKET_ZOFF	72	// 20
#define	GRENADE_YOFF	180
#define	GRENADE_ZOFF	80
#define	SHOTGUN_YOFF	228
#define	SHOTGUN_ZOFF	32
#define	M16_YOFF		228
#define	M16_ZOFF		96
#define	PISTOLS_YOFF	128
#define	PISTOLS_ZOFF	40
#define	MAGNUMS_YOFF	160
#define	MAGNUMS_ZOFF	56
#define	UZIS_YOFF		140
#define	UZIS_ZOFF		48

#define	SPL_ON			1
#define	SPL_TRANS			2
#define	SPL_RIPPLEINNER	4
#define	SPL_RIPPLEMIDDLE	8
#define	SPL_MORETRANS		16
#define	SPL_BLOOD			32
#define 	SPL_KAYAK_SPLASH	64

#define	B_ON				1

/*---------------------------------------------------------------------------
 *	Type Definitions
\*--------------------------------------------------------------------------*/

typedef struct
{
	long		x;
	long		y;
	long		z;

	unsigned	short	falloff;	// 0 - 31. (1/8 block per value).
	unsigned	char	used;
	unsigned	char	pad1[1];

	unsigned	char	on;
	unsigned	char r;
	unsigned	char g;
	unsigned	char b;

} DYNAMIC;

typedef struct
{
	long		x,y,z;

	short	Xvel;
	short	Yvel;
	short	Zvel;
	short	Gravity;		// Y vel.

	short	RotAng;
	short	Flags;	// See SP_... defs above.

	unsigned char	sWidth;
	unsigned char	dWidth;
	unsigned char	sHeight;
	unsigned char	dHeight;

	unsigned char	Friction; 	// X & Z vels - (vels -= vels>>Friction)	// Top nibble = Yvel friction.
	unsigned char	Width;
	unsigned char	Height;
	unsigned char	Scalar;

	unsigned char	Def;
	signed char	RotAdd;
	signed char	MaxYvel;
	unsigned char	On;		// Used ?

	unsigned char	sR;		//
	unsigned char	sG;  	// Start RGB.
	unsigned char	sB;  	//
	unsigned char	dR;		//

	unsigned char	dG;  	// End RGB.
	unsigned char	dB;  	//
	unsigned char	R;		//
	unsigned char	G;  	// Current RGB.

	unsigned char	B;  	//
	unsigned char	ColFadeSpeed;	// Speed at which to fade to endcol in frames.
	unsigned char	FadeToBlack;	// When to start fading to black (life left). (0 = never).
	unsigned char	sLife;

	unsigned char 	Life;	// Start life, current life.
	unsigned char	TransType;	// 0 = Semi, 1 = Col add, 2 = Colsub, 3 = weird!
	unsigned char	extras;
	signed char	Dynamic;	// Which dynamic-light-controller to use. -1 = no dynamic.

	unsigned char	FxObj;	// Attached to Fx or Object number.
	unsigned char	RoomNumber; // For those which have the stupid fucking waste of time shit piss fuck.
	unsigned char	NodeNumber;	// Index into a table of bite_infos for attatching particles to nodes. (Defined in DRAWSPKS.C).
	unsigned char	pad;

} SPARKS;

typedef struct
{
	unsigned char	On;
	unsigned char	Falloff;	// 0 - 31. (1/4 block per value).
	unsigned char 	R;
	unsigned char 	G;
	unsigned char 	B;
	unsigned char	Flags;
	unsigned char	Pad[2];
} SP_DYNAMIC;

typedef struct
{
	short	wx;	//
	short	wy;  // XYZ offsets from origin.
	short	wz;  //

	short	xv;	//
	long		yv;  // XYZ velocities (8 bit fraction).
	short	zv;  //

	short	oxv;  //
	short	ozv;  //

	unsigned char	friction; //	XZ friction (bit shift).
	unsigned char	gravity;  //   Y gravity.
} SPLASH_VERTS;

typedef struct
{
	long		x;
	long		y;
	long		z;
	char		flags; 	// bit 0 = on/off;
	unsigned	char		life;	// dictates transparency level.
	char		pad[2];
	SPLASH_VERTS	sv[48];

} SPLASH_STRUCT;

typedef struct
{
	long		x;
	long		y;
	long		z;
	char		flags; 	// bit 0 = on/off;
	unsigned	char		life;	// dictates transparency level.
	unsigned	char		size;	// << 2
	unsigned	char		init;

} RIPPLE_STRUCT;

typedef struct
{
	long		x;	//
	long		y;	// XYZ origin.
	long		z;	//
	short	InnerXZoff;
	short	InnerXZsize;
	short	InnerYsize;
	short	InnerXZvel;
	short 	InnerYvel;
	short	InnerGravity;
	short	InnerFriction;
	short	MiddleXZoff;
	short	MiddleXZsize;
	short	MiddleYsize;
	short	MiddleXZvel;
	short 	MiddleYvel;
	short	MiddleGravity;
	short	MiddleFriction;
	short	OuterXZoff;
	short	OuterXZsize;
	short	OuterXZvel;
	short	OuterFriction;

} SPLASH_SETUP;

typedef	struct
{
	long		x,y,z;
	short	angle;
	short	speed;
	unsigned	char	WingYoff;	// Make the wings flap;
	unsigned	char	flags;  	// bit 0 = on/off.
	unsigned	char	life;
	unsigned	char	pad;
} BAT_STRUCT;

/*---------------------------------------------------------------------------
 *	Prototypes
\*--------------------------------------------------------------------------*/

extern DYNAMIC	dynamics[];
extern RIPPLE_STRUCT ripples[];
extern SPLASH_STRUCT splashes[];
extern SPLASH_SETUP	splash_setup;
extern BAT_STRUCT bats[];

extern SP_DYNAMIC spark_dynamics[32];
extern SPARKS spark[MAX_SPARKS];
//extern	ushort 	sincos_tbl[];

extern long wibble;
extern long SplashCount;
extern long SmokeWind;
extern long SmokeCountL;
extern long SmokeCountR;
extern long SmokeWeapon;

extern long KillEverythingFlag;

#ifdef PSX_VERSION
extern void S_DrawSparks();
#endif

extern void InitialiseSparks();
extern void InterpolateItemLights(ITEM_LIGHT *itemlight);
extern void InitItemLights(ITEM_LIGHT *itemlight);

extern void TriggerSideFlame(long x, long y, long z, long angle, long speed, long pilot);

extern long GetFreeSpark();
extern void UpdateSparks();
extern void TriggerRicochetSpark(GAME_VECTOR *pos,long angle,long size);
extern void TriggerFlareSparks(long x, long y, long z,long xv,long yv,long zv, long smoke, long FromLara);
extern void TriggerExplosionSparks(long x, long y, long z,long extra_trigs, long dyn, long uw, short roomnum);
extern void TriggerExplosionSmokeEnd(long x, long y, long z, long uw);
extern void TriggerExplosionSmoke(long x, long y, long z, long uw);
extern void TriggerFireSmoke(long x, long y, long z, long body_part, long type);
extern void TriggerFireFlame(long x, long y, long z, long body_part, long type);
extern void TriggerStaticFlame(long x, long y, long z, long size);
extern void TriggerAlertLight(long x, long y, long z, long r, long g, long b, long angle, short room_no);
extern void DetatchSpark(long num, long type);
extern void ControlGunShell(short fx_number);
extern void TriggerGunShell(short leftright, long type, long weapon);
extern void TriggerGunSmoke(long x, long y, long z, long xv, long yv, long zv, long initial, long weapon, long count);
extern void TriggerExplosionBubble(long x, long y, long z, short roomnum);
extern void TriggerWaterfallMist(long x, long y, long z, long angle);
extern void ControlSmokeEmitter(sint16 item_number);
extern void ControlColouredLights(sint16 item_number);


extern void UpdateBats();
extern void BatEmitterControl(short item_number);
extern void TriggerBats(long x, long y, long z, long angle);


extern void SetupSplash(SPLASH_SETUP *spl);
extern void UpdateSplashes();
extern void S_DrawSplashes();
extern RIPPLE_STRUCT *SetupRipple(long x, long y, long z, long size, long moretrans);

extern void TriggerShotgunSparks(long x, long y, long z,long xv,long yv,long zv);
extern void TriggerRocketFlame(long x, long y, long z, long xv, long yv, long zv, long item_no);
extern void TriggerRocketSmoke(long x, long y, long z, long body_part);

extern void TriggerStaticFlame(long x, long y, long z, long size);
extern void TriggerDartSmoke(long x, long y, long z, long xv, long zv, long hit);

extern void TriggerBlood(long x, long y, long z,long angle, long num);
extern void TriggerBloodD(long x, long y, long z,long angle, long num);
extern void TriggerUnderwaterBlood(long x, long y, long z, long size);
extern void TriggerUnderwaterBloodD(long x, long y, long z, long size);

extern void KillEverything();
extern void TriggerBubble(long x,long y, long z, long size, long sizerange, short itemnum);

extern void ClearDynamics();
extern void TriggerDynamic(long x, long y, long z,long falloff, long r, long g, long b);

extern void TriggerBreath(long x, long y, long z, long xv, long yv, long zv);

#ifdef __cplusplus
}
#endif

#endif
