/****************************************************************************
*
* ITEMS.H
*
* PROGRAMMER : Chris
*    VERSION : 00.00
*    CREATED : 27/05/98
*   MODIFIED : 27/05/98
*       TABS : 5
*
* DESCRIPTION
*	Header file for ITEMS.C
*
*****************************************************************************/

#ifndef _ITEMS_H
#define _ITEMS_H

#ifdef __cplusplus
extern "C" {
#endif

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

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

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

#define NUMBER_ITEMS 256

#define NO_ITEM -1

/* -------- item states */

#define NOT_ACTIVE  0
#define ACTIVE      1
#define DEACTIVATED 2
#define INVISIBLE	3

/*\
 *
 * DrawItem() allows 'extra_rotation' specified by setting object bone
 * structure poppush bits. The actual rotation amount is read from item->data,
 * which points to object specific struct such as WOLF_INFO - therefore
 * WOLF_INFO must have 'sint16 extra_rotation[N]' as first part of its
 * structure
 *
\*/

#define ROT_X 4
#define ROT_Y 8
#define ROT_Z 16

#define GUARD	1			//AI bits
#define AMBUSH	2
#define PATROL1	4
#define MODIFY	8
#define FOLLOW	16

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

/* -------- this shouldn't really be in here */

typedef struct {
	PHD_VECTOR sun;
	PHD_VECTOR bulb;
	PHD_VECTOR dynamic;
	unsigned char sunr, sung, sunb;
	char init;
	unsigned char bulbr, bulbg, bulbb;
	unsigned char ambient;
	unsigned char dynamicr, dynamicg, dynamicb, pad2;
} ITEM_LIGHT;

/* -------- ITEM_INFO structure */

typedef struct {
	sint32 floor;
	uint32 touch_bits;
	uint32 mesh_bits;
	sint16 object_number;
	sint16 current_anim_state;
	sint16 goal_anim_state;
	sint16 required_anim_state; 		// May need to pass through several goals
	sint16 anim_number;
	sint16 frame_number;
	sint16 room_number;
	sint16 next_item;       			// For linked list within rooms
	sint16 next_active;
	sint16 speed;
	sint16 fallspeed;
	sint16 hit_points;
	uint16 box_number;
	sint16 timer;						// For timer switches
	sint16 flags;						// For oneshot and code switches (i.e. NOT flags)
	sint16 shade, shadeB;				// -1 for dynamic lighting
	sint16 carried_item;				// 6/8/97: bad guys hold whatever pickup
	sint16 after_death;
	uint16 fired_weapon;				// Has item fired a weapon (counter) ?
	sint16 item_flags[4];				// Had to be added 'cos it was getting fucking stupid.
	void *data;
	PHD_3DPOS pos;
	ITEM_LIGHT il;
	uint16 active:1;			// Is Item Active or Not??
	uint16 status:2;			// Bit packing fun
	uint16 gravity_status:1;
	uint16 hit_status:1;		// Has item been hit by a bullet
	uint16 collidable:1;		// Can Lara Collide with It??
	uint16 looked_at:1;			// has item ever been a camera target
	uint16 dynamic_light:1;		// Used in cutscenes to attach light to first pivot point
	uint16 clear_body:1;		// do we want corpse to be cleared away?
	uint16 ai_bits:5;			// store AI instruction pickups
	uint16 really_active:1;		// Special for Claxons and Sentry guns to say whether or not to do their stuff.
}ITEM_INFO;

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

extern ITEM_INFO *items;
extern sint16 body_bag;
extern int level_items;

/* Items.c */
extern	sint16		next_item_free;
extern	sint16		next_item_active;
//extern	FX_INFO		*effects;
extern	sint16		next_fx_free;
extern	sint16		next_fx_active;

extern void InitialiseItemArray(int numitems);
extern void KillItem(sint16 item_number);
extern sint16 CreateItem();
extern void InitialiseItem(sint16 item_num);
extern void RemoveActiveItem(sint16 item_num);
extern void RemoveDrawnItem(sint16 item_num);
extern void AddActiveItem(sint16 item_num);
extern void ItemNewRoom(sint16 item_number, sint16 room_number);
extern sint16 SpawnItem(ITEM_INFO *item, int object_number);
extern int GlobalItemReplace(int in_objnum, int out_objnum);

extern void InitialiseFXArray();
extern void KillEffect(sint16 fx_num);
extern sint16 CreateEffect(sint16 room_num);
extern void InitialiseEffect(sint16 fx_num);
extern void EffectNewRoom(sint16 fx_num, sint16 room_number);

extern void ClearBodyBag();

#ifdef PSX_VERSION
extern uint32 *VehiclePtr;
extern uint32 *WeatherPtr;
extern uint32 *Effect1Ptr;
extern uint32 *Effect2Ptr;
extern uint32 *Effect3Ptr;
extern uint32 *Baddie1Ptr;
extern uint32 *Baddie2Ptr;
extern uint32 *Baddie3Ptr;
extern uint32 *Baddie4Ptr;
extern uint32 *Baddie5Ptr;
extern uint32 *Baddie6Ptr;
extern uint32 *Baddie7Ptr;
extern uint32 *Baddie8Ptr;
#endif

#ifdef __cplusplus
}
#endif


#endif
