/*********************************************************************************************/
/*                                                                                           */
/* New Game Setup Code                                                                       */
/*                                                                                           */
/*********************************************************************************************/

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

#ifdef PSX_VERSION
#include <sys\types.h>
#include <stdio.h>
#include "../spec_psx/typedefs.h"
#include "../spec_psx/malloc.h"
#include "../spec_psx/memory.h"
#include "../spec_psx/file.h"
#include "../spec_psx/specific.h"
#include "../spec_psx/cd.h"
#else
#include "../specific/standard.h"
#include "../specific/global.h"
#endif

#include "objects.h"
#include "lara.h"
#include "laraanim.h"
#include "camera.h"
#include "control.h"
#include "sound.h"
#include "invfunc.h"
#include "savegame.h"
#include "laramisc.h"
#include "lara1gun.h"
#include "laraflar.h"
#include "hair.h"
#include "title.h"
#include "demo.h"
#include "cinema.h"
#include "setup.h"
#include "lot.h"
#include "health.h"

#include "bird.h"
#include "boat.h"
//#include "dino.h"
#include "dog.h"
#include "effects.h"
#include "effect2.h"
#include "moveblok.h"
#include "people.h"
#include "pickup.h"
#include "rat.h"
//#include "shark.h"
#include "orca.h"
#include "traps.h"
#include "trex.h"
#include "objlight.h"
#include "quadbike.h"
#include "minecart.h"
#include "tiger.h"
#include "diver.h"
#include "orca.h"
#include "kayak.h"
#include "sub.h"
#include "triboss.h"
#include "tonyboss.h"
#include "londboss.h"
#include "willboss.h"
#include "flamer.h"
#include "lizman.h"
#include "lasers.h"
#include "tribeaxe.h"
#include "blowpipe.h"
#include "raptor.h"
#include "compy.h"
#include "51rocket.h"
#include "shiva.h"
#include "51laser.h"
#include "firehead.h"
#include "wingmute.h"
#include "monkey.h"
#include "cobra.h"
#include "cleaner.h"
#include "oilred.h"
#include "oilsmg.h"
#include "punk.h"
#include "londsec.h"
#include "clawmute.h"
#include "hybrid.h"
#include "sealmute.h"
#include "armysmg.h"
#include "51baton.h"
#include "51civvy.h"
#include "mpgun.h"
#include "prisoner.h"
#include "autogun.h"
#include "swat.h"
#include "dragfire.h"
#include "biggun.h"
#include "rapmaker.h"
#include "flymaker.h"
#include "train.h"
#include "winston.h"
#include "boomute.h"
#include "croc.h"
#include "target.h"
#include "fusebox.h"

extern void	save_game_malloc_totals( char *fname );
extern void	build_ext( char *fname, char *ext );
extern	void S_DrawFish(ITEM_INFO *item);
extern	void	S_DrawDarts( ITEM_INFO *item );
extern	void ControlAnimating_1_4(sint16 item_number);

extern char exit_message[];

extern int level_complete;
extern void ControlFish(short item_number);
extern void KillAllCurrentItems(short item_number);
extern 	sint16	CarcassItem;
extern int compy_scared_timer;
extern int compys_attack_lara;

extern uchar CurrentAtmosphere;
extern uchar IsAtmospherePlaying;
extern int QuadbikeLapTime, QuadbikeLapTimeDisplayTimer;

/********************************************
* Globals for Tribe Boss.
********************************************/

BOSS_STRUCT	bossdata;

char TribeBossShieldOn;
ITEM_INFO *TribeBossItem;
char lizard_man_active = 0;

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

#define UNIT_SHADOW 256

#define DEFAULT_RADIUS	10

#define DOG_HIT_POINTS	16
#define DOG_RADIUS		(WALL_L/3)

#define MOUSE_HIT_POINTS 4
#define MOUSE_RADIUS	(WALL_L/10)

#define COMPY_HIT_POINTS 10
#define COMPY_RADIUS	(WALL_L/10)

#define COBRA_HIT_POINTS	8
#define COBRA_RADIUS	(WALL_L/10)

#define MONKEY_HIT_POINTS	8
#define MONKEY_RADIUS		(WALL_L/10)

#define CULT1_HIT_POINTS 25
#define CULT1_RADIUS	(WALL_L/10)

#define TONYBOSS_HIT_POINTS 200
#define TONYBOSS_RADIUS	(WALL_L/10)

#define TRIBEBOSS_HIT_POINTS 200
#define TRIBEBOSS_RADIUS	(WALL_L/10)

#define LONDONBOSS_HIT_POINTS 300
#define LONDONBOSS_RADIUS	(WALL_L/10)

#define WILLARDBOSS_HIT_POINTS 200
#define WILLARDBOSS_RADIUS	(WALL_L/10)

#define SHARK_HIT_POINTS 30
#define SHARK_RADIUS	(WALL_L/3)

#define TIGER_HIT_POINTS 24
#define TIGER_RADIUS	(WALL_L/3)

#define DIVER_HIT_POINTS		20
#define DIVER_RADIUS		(WALL_L/3)

#define ORCA_HIT_POINTS		5000
#define ORCA_RADIUS		(WALL_L/3)

#define WORK1_HIT_POINTS		25
#define WORK1_RADIUS		(WALL_L/10)

#define WORK2_HIT_POINTS		20
#define WORK2_RADIUS		(WALL_L/10)

#define WORK3_HIT_POINTS		27
#define WORK3_RADIUS		(WALL_L/10)

#define LIZMAN_HIT_POINTS	36
#define LIZMAN_RADIUS		(WALL_L/5)

#define BATON_HIT_POINTS		25
#define BATON_RADIUS		(WALL_L/10)

#define CIVVY_HIT_POINTS		15
#define CIVVY_RADIUS		(WALL_L/10)

#define PUNK_HIT_POINTS		20
#define PUNK_RADIUS			(WALL_L/10)

#define CROC_HIT_POINTS		42
#define CROC_RADIUS			(WALL_L/3)

#define OILSMG_HIT_POINTS	30
#define OILSMG_RADIUS		(WALL_L/10)

#define SWAT_HIT_POINTS		45
#define SWAT_RADIUS			(WALL_L/10)

#define ARMYSMG_HIT_POINTS	30
#define ARMYSMG_RADIUS		(WALL_L/10)

#define PRISONER_HIT_POINTS	20
#define PRISONER_RADIUS		(WALL_L/10)

#define AUTOGUN_HIT_POINTS	100
#define AUTOGUN_RADIUS		(WALL_L/10)

#define FLAMER_HIT_POINTS	36
#define FLAMER_RADIUS		(WALL_L/10)

#define CULT3_HIT_POINTS		150
#define CULT3_RADIUS		(WALL_L/10)

#define TRIBEAXE_HIT_POINTS  	28
#define TRIBEAXE_RADIUS	    	(WALL_L/10)

#define BLOWPIPE_HIT_POINTS  	28
#define BLOWPIPE_RADIUS	    	(WALL_L/10)

#define SHIVA_HIT_POINTS  	100
#define SHIVA_RADIUS	    	(WALL_L/3)

#define MONK_HIT_POINTS		30
#define MONK_RADIUS			(WALL_L/10)

#define WINGMUTE_HIT_POINTS	24
#define WINGMUTE_RADIUS		(WALL_L/5)

#define VULTURE_HIT_POINTS	18
#define VULTURE_RADIUS		(WALL_L/5)

#define CROW_HIT_POINTS		8
#define CROW_RADIUS			(WALL_L/5)

#define BANDIT1_HIT_POINTS	34
#define BANDIT1_RADIUS		(WALL_L/10)

#define BANDIT2_HIT_POINTS	28
#define BANDIT2_RADIUS		(WALL_L/10)

#define CULT2_HIT_POINTS		60
#define CULT2_RADIUS		(WALL_L/10)

#define RAPTOR_HIT_POINTS	90
#define RAPTOR_RADIUS		(WALL_L/3)

#define DINO_HIT_POINTS		800
#define DINO_RADIUS			(WALL_L/2)

#define CLAWMUTE_HIT_POINTS		130
#define CLAWMUTE_RADIUS			(WALL_L/4)

#define HYBRID_HIT_POINTS		90
#define HYBRID_RADIUS			(WALL_L/8)

#define SEALMUTE_HIT_POINTS		50
#define SEALMUTE_RADIUS			(WALL_L/5)

#define AI_PICKUP_HIT_POINTS 0
#define WASP_FACTORY_HIT_POINTS 150

enum	{
	OILRED_BITE = 0,
	WHITE_SOLDIER_BITE,
	SWAT_GUN_BITE,
	SWAT_GUN_LASER_BITE,
	AUTOGUN_LEFT_BITE,
	AUTOGUN_RIGHT_BITE,
	ARMYSMG_GUN_BITE,
};

/*---------------------------------------------------------------------------
 *	Globals
\*--------------------------------------------------------------------------*/

int monks_attack_lara = 0;

/*---------------------------------------------------------------------------
 *	Macros
\*--------------------------------------------------------------------------*/

#ifdef PSX_VERSION
#ifdef LOG
#define Log(format,args...) DebugOut(format "\n" , ## args)
#else
#define Log(args...)
#endif
#endif

#define INIT_PICKUP(a)	obj = &objects[a];	\
					obj->collision = PickUpCollision;	\
					obj->save_flags = obj->save_position = 1

#define INIT_PICKUP_ANIM(a)	obj = &objects[a];	\
					obj->control = AnimatingPickUp;	\
					obj->collision = PickUpCollision;	\
					obj->save_flags = obj->save_position = 1

#define INIT_KEYHOLE(a)	obj = &objects[a];	\
					obj->collision = KeyHoleCollision;	\
					obj->save_flags = 1

#define INIT_PUZZLEHOLE(a)	obj = &objects[a];	\
						obj->control = ControlAnimating_1_4;	\
						obj->collision = PuzzleHoleCollision;	\
						obj->save_flags = obj->save_anim = 1

#define INIT_DOOR(a)	obj = &objects[a]; \
					obj->initialise = InitialiseDoor; \
					obj->draw_routine = DrawUnclippedItem; \
					obj->control = DoorControl; \
					obj->collision = DoorCollision; \
					obj->save_flags = obj->save_anim = 1

#define INIT_MOVBLOCK(a)	obj = &objects[a]; \
					obj->initialise = InitialiseMovingBlock; \
					obj->control = MovableBlock; \
					obj->collision = MovableBlockCollision; \
   					obj->draw_routine = DrawMovableBlock; \
					obj->save_position = obj->save_anim = obj->save_flags = 1

/*---------------------------------------------------------------------------
 *	Local Functions
\*--------------------------------------------------------------------------*/

/******************************************************************************
 *				Initialise Game Flags etc
 *****************************************************************************/
static void InitialiseGameFlags()
{
  	int i;

   /* Clear map flips */
   flip_status = 0;
   for (i=0; i<MAX_FLIPMAPS; i++)
     	flipmap[i] = 0;

	for (i=0; i<MAX_CD_TRACKS; i++)
		cd_flags[i] = 0;

	/* Clear Object Loaded flags */
	for ( i=0;i<NUMBER_OBJECTS;i++ )
		objects[i].loaded = 0;

	/* Clear lighting flags */
	sunset = 0;

	ammotext = NULL;			// No Ammo info being printed at the moment
	level_complete = 0;			// Level isnt complete Yet
	flipeffect = -1;
	monks_attack_lara = 0;
	CarcassItem = -1;
	compys_attack_lara = 0;
}

/******************************************************************************
 *			Initialise Every Type of Object Possible In Game
 *				This is Called after Objects are Loaded!!
 *****************************************************************************/

static void BaddyObjects()
{
	OBJECT_INFO *obj;

	/* Lara */
	obj = &objects[LARA];
	obj->initialise = InitialiseLaraLoad;
	obj->shadow_size = (UNIT_SHADOW*10)/16;
	obj->hit_points = LARA_HITPOINTS;
	obj->draw_routine = DrawDummyItem;  // Lara is drawn seperately!!!
	obj->save_position = obj->save_hitpoints = 1;
#ifdef FULL_SAVE
	obj->save_anim = obj->save_flags = 1;
#endif

	/* Lara Extra */
	obj = &objects[LARA_EXTRA];
  	obj->control = ControlLaraExtra;

	/* Cobra */
	obj = &objects[COBRA];
	if (obj->loaded)
	{
		obj->initialise = InitialiseCobra;
		obj->control = CobraControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = COBRA_HIT_POINTS;
		obj->radius = COBRA_RADIUS;
		obj->intelligent = 1;
		obj->non_lot = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 0*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_Y;
	}

	/* Macaque Monkey */
	obj = &objects[MONKEY];
	if (obj->loaded)
	{
		if (!objects[MESHSWAP2].loaded)
			S_ExitSystem("FATAL: Monkey requires MESHSWAP2 (Monkey + Pickups)");

		obj->draw_routine = (void *)DrawMonkey;
		obj->initialise = InitialiseMonkey;
		obj->control = MonkeyControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = MONKEY_HIT_POINTS;
		obj->radius = MONKEY_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 0*4] |= ROT_Z;
		bones[obj->bone_index + 7*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	/* AUTOGUN */
	obj = &objects[ROBOT_SENTRY_GUN];
	if (obj->loaded)
	{
		obj->initialise = InitialiseAutogun;
		obj->control = AutogunControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = 0;
		obj->hit_points = AUTOGUN_HIT_POINTS;
		obj->radius = AUTOGUN_RADIUS;
		obj->intelligent = 1;
		obj->non_lot = 1;
		obj->bite_offset = 	AUTOGUN_LEFT_BITE;	// enum at top of this file.
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 0*4] |= ROT_Y;
		bones[obj->bone_index + 1*4] |= ROT_X;
	}


	/* Diver */
	obj = &objects[DIVER];
	if (obj->loaded)
	{
		obj->control = DiverControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = DIVER_HIT_POINTS;
		obj->radius = DIVER_RADIUS;
		obj->intelligent = 1;
		obj->water_creature = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 50;
//		bones[obj->bone_index + 10*4] |= ROT_Y;
//		bones[obj->bone_index + 14*4] |= ROT_Z;
	}

	/* Killer Whale - Orca*/
	obj = &objects[WHALE];
	if (obj->loaded)
	{
		obj->control = OrcaControl;
//		obj->draw_routine = DrawUnclippedItem;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = DONT_TARGET;
		obj->pivot_length = 200;
		obj->radius = ORCA_RADIUS;
		obj->intelligent = 1;
		obj->water_creature = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
	//	bones[obj->bone_index + 9*4] |= ROT_Y;
	}

	obj = &objects[TREX];
	if (obj->loaded)
	{
		obj->control = DinoControl;
		obj->collision = CreatureCollision;
		obj->hit_points = DINO_HIT_POINTS;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->pivot_length = 1800;
		obj->radius = DINO_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 9*4] |= ROT_Y;
	 	bones[obj->bone_index + 11*4] |= ROT_Y;
		bones[obj->bone_index + 20*4] |= ROT_Y;
	 	bones[obj->bone_index + 22*4] |= ROT_Y;
	}

	/* Raptor */
	obj = &objects[RAPTOR];
	if (obj->loaded)
	{
		obj->control = RaptorControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = RAPTOR_HIT_POINTS;
		obj->pivot_length = 600;
		obj->radius = RAPTOR_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 20*4] |= ROT_Y;
		bones[obj->bone_index + 21*4] |= ROT_Y;
		bones[obj->bone_index + 23*4] |= ROT_Y;
		bones[obj->bone_index + 25*4] |= ROT_Y;
	}

	/* Doberman */
	obj = &objects[DOG];
	if (obj->loaded)
	{
		obj->initialise = InitialiseDog;
		obj->control = DogControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = DOG_HIT_POINTS;
		obj->pivot_length = 300;
		obj->radius = DOG_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 2*4] |= ROT_Y;
		bones[obj->bone_index + 2*4] |= ROT_X;
	}

		/* Huskie */
	obj = &objects[HUSKIE];
	if (obj->loaded)
	{
		obj->initialise = InitialiseDog;
		obj->control = DogControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = DOG_HIT_POINTS;
		obj->pivot_length = 300;
		obj->radius = DOG_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 2*4] |= ROT_Y;
		bones[obj->bone_index + 2*4] |= ROT_X;
	}


	/* Small Rat */

	obj = &objects[SMALL_RAT];
	if (obj->loaded)
	{
		obj->control = MouseControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = MOUSE_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = MOUSE_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 3*4] |= ROT_Y;
	}

	/* Compy */

	obj = &objects[COMPY];
	if (obj->loaded)
	{
		obj->initialise = InitialiseCompy;
		obj->control = CompyControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/3;
		obj->hit_points = COMPY_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = COMPY_RADIUS;
		obj->intelligent = 1;
		obj->non_lot = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 1*4] |= ROT_Y;
		bones[obj->bone_index + 2*4] |= ROT_Y;
	}

	/* Tribe boss. */
	obj = &objects[TRIBEBOSS];
	if (obj->loaded)
	{
		obj->initialise = (void *)InitialiseTribeBoss;
		obj->control = TribeBossControl;
		obj->draw_routine = S_DrawTribeBoss;
		obj->collision = CreatureCollision;
		obj->shadow_size = 0;
		obj->hit_points = TRIBEBOSS_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = TRIBEBOSS_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 4*4] |= ROT_Y;
		bones[obj->bone_index + 7*4] |= ROT_Y|ROT_X;
	}

	/* Tony the psychic boss. */
	obj = &objects[TONY];
	if (obj->loaded)
	{
		obj->initialise = (void *)InitialiseTonyBoss;
		obj->control = TonyBossControl;
		obj->draw_routine = S_DrawTonyBoss;
		obj->collision = CreatureCollision;
		obj->shadow_size = 0;
		obj->hit_points = TONYBOSS_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = TONYBOSS_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
//		bones[obj->bone_index + 4*4] |= ROT_Y;
//		bones[obj->bone_index + 7*4] |= ROT_Y|ROT_X;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

		/* London boss - chick with stick */
	obj = &objects[LON_BOSS];
	if (obj->loaded)
	{
		obj->initialise = (void *)InitialiseLondonBoss;
		obj->control = LondonBossControl;
		obj->draw_routine = S_DrawLondonBoss;
		obj->collision = CreatureCollision;
		obj->shadow_size = 0;
		obj->hit_points = LONDONBOSS_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = LONDONBOSS_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
//		bones[obj->bone_index + 4*4] |= ROT_Y;
//		bones[obj->bone_index + 7*4] |= ROT_Y|ROT_X;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Mutant Willard Spider boss. */
	obj = &objects[WILLARD_BOSS];
	if (obj->loaded)
	{
		obj->initialise = (void *)InitialiseWillBoss;
		obj->control = WillBossControl;
		obj->draw_routine = S_DrawWillBoss;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = WILLARDBOSS_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = WILLARDBOSS_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
//		bones[obj->bone_index + 0*4] |= ROT_Y;
//		bones[obj->bone_index + 0*4] |= ROT_X;
//		bones[obj->bone_index + 7*4] |= ROT_Y;
	}


	/* Tiger */
	obj = &objects[TIGER];
	if (obj->loaded)
	{
		obj->control = TigerControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = TIGER_HIT_POINTS;
		obj->pivot_length = 200;
		obj->radius = TIGER_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 21*4] |= ROT_Y;
	}

	/* Shiva! */
	obj = &objects[SHIVA];
	if (obj->loaded)
	{
		if (!objects[MESHSWAP1].loaded)
			S_ExitSystem("FATAL: Shiva requires MESHSWAP1 (Shiva statue)");

		obj->initialise = InitialiseShiva;
		obj->draw_routine = DrawShiva;
		obj->control = ShivaControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = SHIVA_HIT_POINTS;
		obj->radius = SHIVA_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 25*4] |= ROT_Y;
		bones[obj->bone_index + 25*4] |= ROT_X;
	}

	/* Oil-SMG */
	obj = &objects[WHITE_SOLDIER];
	if (obj->loaded)
	{
		obj->initialise = InitialiseOilSMG;
		obj->control = OilSMGControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = OILSMG_HIT_POINTS;
		obj->radius = OILSMG_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		obj->bite_offset = WHITE_SOLDIER_BITE;	// enum at top of this file.
		bones[obj->bone_index + 0*4] |= ROT_Y;
		bones[obj->bone_index + 0*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	/* Claw Mutant */
	obj = &objects[MUTANT2];
	if (obj->loaded)
	{
		obj->control = ClawmuteControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CLAWMUTE_HIT_POINTS;
		obj->radius = CLAWMUTE_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
//		obj->bite_offset = WHITE_SOLDIER_BITE;	// enum at top of this file.
		bones[obj->bone_index + 0*4] |= ROT_Z;
		bones[obj->bone_index + 0*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	/* Hybrid Mutant */
	obj = &objects[MUTANT3];
	if (obj->loaded)
	{
		obj->control = HybridControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = HYBRID_HIT_POINTS;
		obj->radius = HYBRID_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
//		obj->bite_offset = WHITE_SOLDIER_BITE;	// enum at top of this file.
		bones[obj->bone_index + 0*4] |= ROT_Z;
		bones[obj->bone_index + 0*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	/* Seal Mutant */
	obj = &objects[BURNT_MUTANT];
	if (obj->loaded)
	{
		obj->control = SealmuteControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = SEALMUTE_HIT_POINTS;
		obj->radius = SEALMUTE_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
//		obj->bite_offset = WHITE_SOLDIER_BITE;	// enum at top of this file.
		bones[obj->bone_index + 8*4] |= ROT_Z;
		bones[obj->bone_index + 8*4] |= ROT_X;
		bones[obj->bone_index + 9*4] |= ROT_Y;
	}

	/* Swat Bloke */
	obj = &objects[SWAT_GUN];
	if (obj->loaded)
	{
		obj->initialise = InitialiseSwat;
		obj->control = SwatControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = SWAT_HIT_POINTS;
		obj->radius = SWAT_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		obj->bite_offset = SWAT_GUN_BITE;	// enum at top of this file.
		bones[obj->bone_index + 0*4] |= ROT_Y;
		bones[obj->bone_index + 0*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	/* South Pacific Mercenary/Army Bloke */
	obj = &objects[STHPAC_MERCENARY];
	if (obj->loaded)
	{
		obj->initialise = InitialiseArmySMG;
		obj->control = ArmySMGControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = ARMYSMG_HIT_POINTS;
		obj->radius = ARMYSMG_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		obj->bite_offset = ARMYSMG_GUN_BITE;	// TS - might have to change this
		bones[obj->bone_index + 0*4] |= ROT_Y;
		bones[obj->bone_index + 0*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	/* Lizard Man */

	obj = &objects[LIZARD_MAN];
	if (obj->loaded)
	{
		obj->control = LizManControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = LIZMAN_HIT_POINTS;
		obj->radius = LIZMAN_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 1*4] |= ROT_Z;
		bones[obj->bone_index + 9*4] |= ROT_Z;
	}

	/* Area 51 Baton Man */
	obj = &objects[MP1];
	if (obj->loaded)
	{
		obj->initialise = InitialiseBaton;
		obj->control = BatonControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BATON_HIT_POINTS;
		obj->radius = BATON_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Area 51 Civilian */
	obj = &objects[CIVVIE];
	if (obj->loaded)
	{
		obj->initialise = InitialiseCivvy;
		obj->control = CivvyControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CIVVY_HIT_POINTS;
		obj->radius = CIVVY_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Area 51 Prisoner - Bob! */
	obj = &objects[BOB];
	if (obj->loaded)
	{
		obj->initialise = InitialisePrisoner;
		obj->control = PrisonerControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = PRISONER_HIT_POINTS;
		obj->radius = PRISONER_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Oil Flamer Man */
	obj = &objects[FLAMETHROWER_BLOKE];
	if (obj->loaded)
	{
		obj->control = FlamerControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = FLAMER_HIT_POINTS;
		obj->radius = FLAMER_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 0*4] |= ROT_Y;
		bones[obj->bone_index + 0*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	obj = &objects[TRIBEAXE];
	if (obj->loaded)
	{
		obj->control = TribeAxeControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = TRIBEAXE_HIT_POINTS;
		obj->radius = TRIBEAXE_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim= obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 13*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_Y;
	}

	/* Blowpipe Man */

	obj = &objects[BLOWPIPE];
	if (obj->loaded)
	{
		obj->control = BlowpipeControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BLOWPIPE_HIT_POINTS;
		obj->radius = BLOWPIPE_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
		bones[obj->bone_index + 13*4] |= ROT_X;
	}

	/* Wingmute */
	obj = &objects[MUTANT1];
	if (obj->loaded)
	{
		obj->initialise = InitialiseWingmute;
		obj->control = WingmuteControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = WINGMUTE_HIT_POINTS;
		obj->radius = WINGMUTE_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim= obj->save_flags = 1;
		obj->pivot_length = 0;
	}

	/* Vulture */
	obj = &objects[VULTURE];
	if (obj->loaded)
	{
		obj->initialise = InitialiseVulture;
		obj->control = VultureControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = VULTURE_HIT_POINTS;
		obj->radius = VULTURE_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim= obj->save_flags = 1;
		obj->pivot_length = 0;
	}

	/* Crow */
	obj = &objects[CROW];
	if (obj->loaded)
	{
		obj->initialise = InitialiseVulture;
		obj->control = VultureControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CROW_HIT_POINTS;
		obj->radius = CROW_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
	}

	/* OIL-RED*/
	obj = &objects[OILRED];
	if (obj->loaded)
	{
		obj->control = OilRedControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BANDIT1_HIT_POINTS;
		obj->radius = BANDIT1_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		obj->bite_offset = OILRED_BITE;	// enum at top of this file.
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* London Security Guard (Blakey: "I'll get you, Butler!")*/
	obj = &objects[SECURITY_GUARD];
	if (obj->loaded)
	{
		obj->control = LondSecControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BANDIT2_HIT_POINTS;
		obj->radius = BANDIT2_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		obj->bite_offset = OILRED_BITE;	// Same as oilred.
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

		/* Cleaner */
	obj = &objects[ELECTRIC_CLEANER];
	if (obj->loaded)
	{
		obj->initialise = InitialiseCleaner;
		obj->control = CleanerControl;
		obj->collision = ObjectCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = DONT_TARGET;
		obj->radius = STEP_L*2;
		obj->intelligent = 1;
		obj->non_lot = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
	}

	/* Area 51  Pistol MP (MP2)*/
	obj = &objects[MP2];
	if (obj->loaded)
	{
		obj->control = MPGunControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BANDIT2_HIT_POINTS;
		obj->radius = BANDIT2_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		obj->bite_offset = OILRED_BITE;	// Same as oilred.
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Swat Bloke */
	obj = &objects[LON_MERCENARY1];
	if (obj->loaded)
	{
		obj->initialise = InitialiseSwat;
		obj->control = SwatControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = SWAT_HIT_POINTS;
		obj->radius = SWAT_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		obj->bite_offset = SWAT_GUN_BITE;	// enum at top of this file.
		bones[obj->bone_index + 0*4] |= ROT_Y;
		bones[obj->bone_index + 0*4] |= ROT_X;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	/* Punk on a stick */
	obj = &objects[PUNK1];
	if (obj->loaded)
	{
		obj->initialise = InitialisePunk;
		obj->control = PunkControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = PUNK_HIT_POINTS;
		obj->radius = PUNK_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 6*4] |= ROT_X;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* London Crocodile */

	obj = &objects[CROCODILE];
	if (obj->loaded)
	{
		obj->control = CrocControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CROC_HIT_POINTS;
		obj->radius = CROC_RADIUS;
		obj->intelligent = 1;
		obj->water_creature = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 200;
		bones[obj->bone_index + 7*4] |= ROT_Y;
	}

	obj = &objects[WINSTON];
	if (obj->loaded)
	{
		obj->control = OldWinstonControl;
		obj->collision = ObjectCollision;
		obj->hit_points = 20;
		obj->shadow_size = UNIT_SHADOW/4;
		obj->radius = WALL_L/10;
		obj->intelligent = 1;
	}

	// Winston in Uniform
	obj = &objects[ARMY_WINSTON];
	if (obj->loaded)
	{
		obj->control = WinstonControl;
		obj->collision = ObjectCollision;
		obj->hit_points = 20;
		obj->shadow_size = UNIT_SHADOW/4;
		obj->radius = WALL_L/10;
		obj->intelligent = 1;
	}

	// Pop-Up targets for Lara's House
	obj = &objects[TARGETS];
	if (obj->loaded)
	{
//		obj->initialise = InitialiseTarget;
		obj->control = TargetControl;
		obj->collision = ObjectCollision;
		obj->hit_points = 8;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->radius = WALL_L/10;
		obj->intelligent = 1;	//So they're always visible
//		obj->non_lot = 1;
	}

	obj = &objects[AI_GUARD];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}

	obj = &objects[AI_AMBUSH];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}

	obj = &objects[AI_PATROL1];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;

	}

	obj = &objects[AI_PATROL2];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}

	obj = &objects[AI_FOLLOW];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}

	obj = &objects[AI_X1];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}

	obj = &objects[AI_X2];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}

	obj = &objects[AI_X3];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}

	obj = &objects[AI_MODIFY];
	if (obj->loaded)
	{
		obj->draw_routine = DrawDummyItem;
		obj->collision = AIPickupCollision;
		obj->hit_points = AI_PICKUP_HIT_POINTS;
	}
}

static void TrapObjects(void)
{
	OBJECT_INFO *obj;
	long	lp;

	obj = &objects[KILL_ALL_TRIGGERS];
	obj->hit_points = 0;
	obj->draw_routine = DrawDummyItem;
	obj->control = KillAllCurrentItems;

	obj = &objects[MINI_COPTER];
	obj->control = MiniCopterControl;
	obj->save_flags = obj->save_position = 1;

	obj = &objects[MOVING_BAR]; // bizarrely named Submarine slot
	obj->collision = ObjectCollision;
	obj->control = GeneralControl;
	obj->save_anim = obj->save_flags = 1;
	obj->water_creature = 1; // for SFX

	obj = &objects[DEATH_SLIDE];
	obj->initialise = InitialiseRollingBall; // saves start position like we need
	obj->collision = DeathSlideCollision;
	obj->control = ControlDeathSlide;
	obj->save_position = obj->save_anim = obj->save_flags = 1;

	obj = &objects[SPIKE_WALL];
	obj->control = ControlSpikeWall;
	obj->collision = ObjectCollision;
	obj->save_position = obj->save_flags = 1;

	obj = &objects[CEILING_SPIKES];
	obj->control = ControlCeilingSpikes;
	obj->collision = TrapCollision;
	obj->save_position = obj->save_flags = 1;

	obj = &objects[HOOK];
	obj->control = HookControl;
	obj->collision = CreatureCollision;
	obj->save_flags = obj->save_anim = 1;

	obj = &objects[SAW];
	obj->control = PropellerControl;
	obj->collision = ObjectCollision;
	obj->save_flags = obj->save_anim = 1;

	obj = &objects[FAN];
	obj->water_creature = 1; // for SFX
	obj->control = PropellerControl;
	obj->collision = TrapCollision;
	obj->save_flags = obj->save_anim = 1;

	obj = &objects[SMALL_FAN];
	obj->control = PropellerControl;
	obj->collision = TrapCollision;
	obj->save_flags = obj->save_anim = 1;

	obj = &objects[SPINNING_BLADE];
	obj->initialise = InitialiseKillerStatue; // just conveniently needs same start state and anim type
	obj->control = SpinningBlade;
	obj->collision = ObjectCollision;
	obj->save_position = obj->save_anim = obj->save_flags = 1;

	obj = &objects[ICICLES];
	obj->control = IcicleControl;
	obj->collision = TrapCollision;
	obj->save_position = obj->save_anim = obj->save_flags = 1;

	obj = &objects[BLADE];
	obj->initialise = InitialiseBlade;
	obj->control = BladeControl;
	obj->collision = TrapCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[SPRING_BOARD];
	obj->control = SpringBoardControl;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[FALLING_BLOCK];
	obj->control = FallingBlock;
	obj->floor = FallingBlockFloor;
	obj->ceiling = FallingBlockCeiling;
	obj->save_position = obj->save_anim = 1;
#ifdef FULL_SAVE
	obj->save_flags = 1;
#endif

	obj = &objects[FALLING_BLOCK2];
	obj->control = FallingBlock;
	obj->floor = FallingBlockFloor;
	obj->ceiling = FallingBlockCeiling;
	obj->save_position = obj->save_anim = 1;
#ifdef FULL_SAVE
	obj->save_flags = 1;
#endif

	obj = &objects[FALLING_PLANK];
	obj->control = FallingBlock;
	obj->floor = FallingBlockFloor;
	obj->ceiling = FallingBlockCeiling;
	obj->save_position = obj->save_anim = 1;
#ifdef FULL_SAVE
	obj->save_flags = 1;
#endif

	obj = &objects[PENDULUM];
	obj->shadow_size = UNIT_SHADOW/2;
	obj->control = Pendulum;
	obj->collision = ObjectCollision;
	obj->save_flags = 1;
#ifdef FULL_SAVE
	obj->save_anim = 1;
#endif

	obj = &objects[SWING_BOX];
	obj->shadow_size = UNIT_SHADOW/2;
	obj->control = Pendulum;
	obj->collision = ObjectCollision;
	obj->save_flags = 1;
#ifdef FULL_SAVE
	obj->save_anim = 1;
#endif

	obj = &objects[TEETH_TRAP];
	obj->collision = TrapCollision;
	obj->control = TeethTrap;
	obj->save_flags = 1;
#ifdef FULL_SAVE
	obj->save_anim = 1;
#endif

	obj = &objects[AVALANCHE];
	obj->collision = RollingBallCollision;
	obj->control = RollingBallControl;
	obj->initialise = InitialiseRollingBall;
	obj->save_position = obj->save_flags = 1;
#ifdef FULL_SAVE
	obj->save_anim = 1;
#endif

	obj = &objects[OILDRUMS];
	obj->collision = RollingBallCollision;
	obj->control = RollingBallControl;
	obj->initialise = InitialiseRollingBall;
	obj->save_position = obj->save_flags = 1;
#ifdef FULL_SAVE
	obj->save_anim = 1;
#endif

	obj = &objects[ROLLING_BALL];
	obj->collision = RollingBallCollision;
	obj->control = RollingBallControl;
	obj->initialise = InitialiseRollingBall;
	obj->save_position = obj->save_flags = 1;
#ifdef FULL_SAVE
	obj->save_anim = 1;
#endif

	obj = &objects[BIG_ROLLING_BALL];
	obj->collision = RollingBallCollision;
	obj->control = RollingBallControl;
	obj->initialise = InitialiseRollingBall;
	obj->save_position = obj->save_flags = 1;
#ifdef FULL_SAVE
	obj->save_anim = 1;
#endif

	obj = &objects[SPIKES];
	obj->control = SpikeControl;
	obj->collision = SpikeCollision;

	obj = &objects[FALLING_CEILING1];
	obj->control = FallingCeiling;
	obj->collision = TrapCollision;
	obj->save_position = obj->save_anim = 1;
#ifdef FULL_SAVE
	obj->save_flags = 1;
#endif

	/* Moving blocks */
	for (lp=MOVABLE_BLOCK;lp<=MOVABLE_BLOCK4;lp++)
	{
		INIT_MOVBLOCK( lp );
	}

   /* Dart Trap and Associated Objects */
   	objects[DART_EMITTER].control = DartEmitterControl;
	objects[DART_EMITTER].draw_routine = DrawDummyItem;
	objects[DART_EMITTER].save_flags = 1;
   	objects[HOMING_DART_EMITTER].control = DartEmitterControl;
	objects[HOMING_DART_EMITTER].draw_routine = DrawDummyItem;
	objects[HOMING_DART_EMITTER].save_flags = 1;

	objects[RAPTOR_EMITTER].initialise = InitialiseRaptorEmitter;
   	objects[RAPTOR_EMITTER].control = RaptorEmitterControl;
	objects[RAPTOR_EMITTER].draw_routine = DrawDummyItem;
	objects[RAPTOR_EMITTER].save_flags = 1;

	objects[FLYING_MUTANT_EMITTER].control = FlyEmitterControl;
	objects[FLYING_MUTANT_EMITTER].draw_routine = DrawDummyItem;
	objects[FLYING_MUTANT_EMITTER].hit_points = WASP_FACTORY_HIT_POINTS;
	objects[FLYING_MUTANT_EMITTER].save_flags = 1;

	// Seal Mutant goes BOO trap.
   	obj = &objects[BOO_MUTANT];
	obj->control = BoomuteControl;
	obj->save_position = obj->save_anim = obj->save_flags = 1;

	obj = &objects[SPECIAL_FX1];
	obj->control = (void *) ControlArea51Rocket;
	obj->save_position = obj->save_anim = obj->save_flags = 1;
	obj = &objects[SPECIAL_FX2];
	obj->control = (void *) ControlArea51Rocket;
	obj->draw_routine = DrawDummyItem;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[SPECIAL_FX3];
	obj->control = (void *) ControlArea51Struts;
	obj->initialise = (void *) InitialiseArea51Struts;
	obj->save_anim = 1;

   	obj = &objects[AREA51_LASER];
	obj->control = (void *) ControlArea51Laser;
	obj->initialise = (void *) InitialiseArea51Laser;
	obj->save_position = obj->save_anim = obj->save_flags = 1;

   	obj = &objects[DARTS];
   	obj->control = DartsControl;
	obj->draw_routine = S_DrawDarts;
   	obj->collision = ObjectCollision;
	obj->shadow_size = UNIT_SHADOW/2;

	obj = &objects[FLAME_EMITTER];
	obj->control = FlameEmitterControl;
	obj->draw_routine = DrawDummyItem;
	obj->save_flags = 1;

	obj = &objects[FLAME_EMITTER2];
	obj->control = FlameEmitter2Control;
	obj->draw_routine = DrawDummyItem;
	obj->save_flags = 1;
	obj = &objects[FLAME_EMITTER3];
	obj->control = FlameEmitter3Control;
	obj->draw_routine = DrawDummyItem;
	obj->save_flags = 1;
	obj = &objects[SIDE_FLAME_EMITTER];
	obj->control = SideFlameEmitterControl;
	obj->draw_routine = DrawDummyItem;
	obj->save_flags = 1;
	objects[FLAME].control = FlameControl;
	objects[FLAME].draw_routine = DrawDummyItem;	// Done with particles.

/*	objects[LAVA_EMITTER].control = LavaSpray;
	objects[LAVA_EMITTER].collision = ObjectCollision;
	objects[LAVA_EMITTER].draw_routine = DrawDummyItem;
	objects[LAVA_EMITTER].save_flags = 1;
	objects[LAVA].control = ControlLavaBlob;
	objects[LAVA].semi_transparent = 1;*/
}

static void ObjectObjects(void)
{
	OBJECT_INFO *obj;
	long	lp;

	objects[CAMERA_TARGET].draw_routine = DrawDummyItem;		// Dont draw Camera targets

	// Fire shooting head on the antarctic city level.
	obj = &objects[FIREHEAD];
	obj->control = ControlFireHead;
	obj->collision = ObjectCollision;
	obj->initialise = InitialiseFireHead;
	obj->save_flags = obj->save_anim = obj->save_hitpoints = 1;

	// Tony the psychic's fireballs.
	obj = &objects[TONYFIREBALL];
	obj->control = ControlTonyFireBall;
	obj->draw_routine = DrawDummyItem;
//	obj->save_position = 1;

	// Claw mutant's plasma ball.
	obj = &objects[EXTRAFX1];
	obj->control = ControlClawmutePlasmaBall;
	obj->draw_routine = DrawDummyItem;
//	obj->save_position = 1;

	// Willard boss' plasma ball.
	obj = &objects[EXTRAFX2];
	obj->control = ControlWillbossPlasmaBall;
	obj->draw_routine = DrawDummyItem;
//	obj->save_position = 1;

	// Rotatety thing on City of Tinnos level.
	obj = &objects[EXTRAFX3];
	obj->control = ControlRotateyThing;
	obj->save_position = obj->save_flags = 1;

	// Laser bolt from London boss.
	obj = &objects[EXTRAFX4];
	obj->control = ControlLaserBolts;
	obj->draw_routine = S_DrawLaserBolts;
//	obj->save_position = 1;

	// Plasma from laser bolts from London boss.
	obj = &objects[EXTRAFX5];
	obj->control = ControlLondBossPlasmaBall;
	obj->draw_routine = DrawDummyItem;
//	obj->save_position = 1;

	// Fusebox for Cleaner Puzzle & London Boss death.
	obj = &objects[EXTRAFX6];
	obj->control = ControlFusebox;
	obj->collision = ObjectCollision;
	obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;

	/* Rocket */
	obj = &objects[ROCKET];
	obj->control = ControlRocket;
//	obj->save_position = 1;

	/* Grenade */
	obj = &objects[GRENADE];
	obj->control = ControlGrenade;
//	obj->save_position = 1;

	/* Harpoon Bolt */
	obj = &objects[HARPOON_BOLT];
	obj->control = ControlHarpoonBolt;
//	obj->save_position = 1;

	/* Knife thrown by CULT2 */
	obj = &objects[KNIFE];
	obj->control = ControlMissile;
//	obj->save_position = 1;

	/* Diver harpoon bolt */
	obj = &objects[DIVER_HARPOON];
	obj->control = ControlMissile;
//	obj->save_position = 1;

/* -------- vehicles */
	obj = &objects[KAYAK];
	obj->initialise = KayakInitialise;
	obj->draw_routine = KayakDraw;
	obj->collision = (void *)KayakCollision;
	obj->save_position = obj->save_flags = obj->save_anim = 1;

	obj = &objects[BOAT];
	obj->initialise = (void *)InitialiseBoat;
	obj->control = (void *)BoatControl;
	obj->collision = BoatCollision;
	obj->draw_routine = DrawBoat;
	obj->save_position = obj->save_flags = obj->save_anim = 1;
	bones[obj->bone_index + (1*4)] |= ROT_Z;	// For rotatey propeller;

	obj = &objects[QUADBIKE];
	obj->initialise = InitialiseQuadBike;
	obj->collision = QuadBikeCollision;
	obj->draw_routine = QuadBikeDraw;
	obj->save_position = obj->save_flags = obj->save_anim = 1;

	obj = &objects[MINECART];
	obj->initialise = MineCartInitialise;
//	obj->control = (void *)MineCartControl;
	obj->collision = MineCartCollision;
//##	obj->draw_routine = QuadBikeDraw;
	obj->save_position = obj->save_flags = obj->save_anim = 1;

	obj = &objects[BIGGUN];
	obj->initialise = BigGunInitialise;
	obj->collision = BigGunCollision;
	obj->draw_routine = BigGunDraw;
	obj->save_position = obj->save_flags = obj->save_anim = 1;

	obj = &objects[UPV];
	obj->initialise = SubInitialise;
	obj->control = (void *)SubEffects;
	obj->collision = SubCollision;
	obj->draw_routine = SubDraw;
	obj->save_position = obj->save_flags = obj->save_anim = 1;

	obj = &objects[TRAIN];
	obj->control = TrainControl;
	obj->collision = TrainCollision;
	obj->save_position = obj->save_flags = obj->save_anim = 1;

	/* Flares */
	obj = &objects[FLARE_ITEM];
	obj->control = FlareControl;
	obj->collision = PickUpCollision;
	obj->draw_routine = DrawFlareInAir;
	obj->pivot_length = 256;
	obj->hit_points = 256;
	obj->save_position = obj->save_flags = 1;

	// need some save flags for position and what have you
	obj = &objects[SMASH_WINDOW];
	obj->initialise = InitialiseWindow;
	obj->control = WindowControl;
	obj->collision = ObjectCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[SMASH_OBJECT1];
	obj->initialise = InitialiseWindow;
	obj->control = WindowControl;
	obj->collision = ObjectCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[SMASH_OBJECT2];
	obj->initialise = InitialiseWindow;
	obj->control = WindowControl;
	obj->collision = ObjectCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[SMASH_OBJECT3];
	obj->initialise = InitialiseWindow;
	obj->control = WindowControl;
	obj->collision = ObjectCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[CARCASS];
	obj->control = CarcassControl;
	obj->collision = ObjectCollision;
	obj->save_anim = obj->save_flags = obj->save_position = 1;

	/* Lift */

	obj = &objects[LIFT];
	obj->initialise = InitialiseLift;
	obj->control = LiftControl;
	obj->floor = LiftFloor;
	obj->ceiling = LiftCeiling;
	obj->save_anim = obj->save_flags = obj->save_position = 1;

	obj = &objects[TROPICAL_FISH];
	obj->draw_routine = S_DrawFish;
	obj->control = ControlFish;
	obj->hit_points = -1;
	obj->save_flags = obj->save_position = obj->save_hitpoints = 1;

	obj = &objects[PIRAHNAS];
	obj->draw_routine = S_DrawFish;
	obj->control = ControlFish;
	obj->hit_points = -1;
	obj->save_flags = obj->save_position = obj->save_hitpoints = 1;

	obj = &objects[BAT_EMITTER];
	obj->control = BatEmitterControl;
	obj->draw_routine = DrawDummyItem;
	obj->save_flags = 1;

	obj = &objects[LIGHTNING_EMITTER2];
	obj->control = ControlElectricFence;
	obj->draw_routine = DrawDummyItem;
	obj->save_flags = 1;

	/* Light objects */

	objects[STROBE_LIGHT].control = ControlStrobeLight;
	objects[STROBE_LIGHT].save_flags = 1;

	objects[PULSE_LIGHT].control = ControlPulseLight;
	objects[PULSE_LIGHT].draw_routine = DrawDummyItem;
	objects[PULSE_LIGHT].save_flags = 1;

	objects[ON_OFF_LIGHT].control = ControlOnOffLight;
	objects[ON_OFF_LIGHT].draw_routine = DrawDummyItem;
	objects[ON_OFF_LIGHT].save_flags = 1;

	objects[ELECTRICAL_LIGHT].control = ControlElectricalLight;
	objects[ELECTRICAL_LIGHT].draw_routine = DrawDummyItem;
	objects[ELECTRICAL_LIGHT].save_flags = 1;

	objects[EXTRA_LIGHT1].control = ControlBeaconLight;
	objects[EXTRA_LIGHT1].draw_routine = DrawDummyItem;
	objects[EXTRA_LIGHT1].save_flags = 1;

	/* Bridges */

	obj = &objects[BRIDGE_FLAT];
	obj->floor = BridgeFlatFloor;
	obj->ceiling = BridgeFlatCeiling;
	obj = &objects[BRIDGE_TILT1];
	obj->floor = BridgeTilt1Floor;
	obj->ceiling = BridgeTilt1Ceiling;
	obj = &objects[BRIDGE_TILT2];
	obj->floor = BridgeTilt2Floor;
	obj->ceiling = BridgeTilt2Ceiling;

	obj = &objects[DRAW_BRIDGE];
	if (obj->loaded)
	{
		obj->control = GeneralControl;
		obj->collision = DrawBridgeCollision;
		obj->floor = DrawBridgeFloor;
		obj->ceiling = DrawBridgeCeiling;
		obj->save_anim = obj->save_flags = 1;
	}

	/* Switches */

	obj = &objects[SMALL_SWITCH];				// Switch Initialisation
	obj->control = SwitchControl;
	obj->collision = SwitchCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[PUSH_SWITCH];				// Switch Initialisation
	obj->control = SwitchControl;
	obj->collision = SwitchCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[AIRLOCK_SWITCH];			// Switch Initialisation
	obj->control = SwitchControl;
	obj->collision = SwitchCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[SWITCH_TYPE1];				// Switch Initialisation
	obj->control = SwitchControl;
	obj->collision = SwitchCollision;
	obj->save_anim = obj->save_flags = 1;

	obj = &objects[SWITCH_TYPE2];               // UnderWater Switch initialisation
	obj->control = SwitchControl;
	obj->collision = SwitchCollision2;
	obj->save_anim = obj->save_flags = 1;

	/* Doors */

	for (lp=DOOR_TYPE1;lp<=DOOR_TYPE8;lp++)
	{
		INIT_DOOR(lp);
	}

	obj = &objects[TRAPDOOR];
	obj->control = TrapDoorControl;
	obj->floor = TrapDoorFloor;
	obj->ceiling = TrapDoorCeiling;
//	obj->collision = TrapDoorCollision;
	obj->save_anim = obj->save_flags = 1;
	obj = &objects[TRAPDOOR2];
	obj->control = TrapDoorControl;
	obj->floor = TrapDoorFloor;
	obj->ceiling = TrapDoorCeiling;
//	obj->collision = TrapDoorCollision;
	obj->save_anim = obj->save_flags = 1;

	INIT_PICKUP( PICKUP_ITEM1 );
	INIT_PICKUP( PICKUP_ITEM2 );
	INIT_PICKUP( KEY_ITEM1 );				// initialise Key pickups
	INIT_PICKUP( KEY_ITEM2 );
	INIT_PICKUP( KEY_ITEM3 );
	INIT_PICKUP( KEY_ITEM4 );
	INIT_PICKUP( PUZZLE_ITEM1 );			// initialise Puzzle pickups
	INIT_PICKUP( PUZZLE_ITEM2 );
	INIT_PICKUP( PUZZLE_ITEM3 );
	INIT_PICKUP( PUZZLE_ITEM4 );
//	INIT_PICKUP( SECRET_ITEM1 );
//	INIT_PICKUP( SECRET_ITEM2 );
//	obj->control = SecretControl;
//	INIT_PICKUP( SECRET_ITEM3 );
	INIT_PICKUP( GUN_ITEM );				// initialise Weapon pickups
	INIT_PICKUP( SHOTGUN_ITEM );
	INIT_PICKUP( HARPOON_ITEM );
	INIT_PICKUP( ROCKET_GUN_ITEM );
	INIT_PICKUP( GRENADE_GUN_ITEM );
	INIT_PICKUP( M16_ITEM );
	INIT_PICKUP( MAGNUM_ITEM );
	INIT_PICKUP( UZI_ITEM );
	INIT_PICKUP( FLAREBOX_ITEM );
	INIT_PICKUP( GUN_AMMO_ITEM );			// initialise Ammo pickups
	INIT_PICKUP( SG_AMMO_ITEM );
	INIT_PICKUP( MAG_AMMO_ITEM );
	INIT_PICKUP( UZI_AMMO_ITEM );
	INIT_PICKUP( HARPOON_AMMO_ITEM );
	INIT_PICKUP( M16_AMMO_ITEM );
	INIT_PICKUP( ROCKET_AMMO_ITEM );
	INIT_PICKUP( GRENADE_AMMO_ITEM );
	INIT_PICKUP( MEDI_ITEM );               // initialise Health pickups
	INIT_PICKUP( BIGMEDI_ITEM );
	INIT_PICKUP_ANIM( ICON_PICKUP1_ITEM );
	INIT_PICKUP_ANIM( ICON_PICKUP2_ITEM );
	INIT_PICKUP_ANIM( ICON_PICKUP3_ITEM );
	INIT_PICKUP_ANIM( ICON_PICKUP4_ITEM );
	INIT_PICKUP_ANIM( SAVEGAME_CRYSTAL_ITEM);
	INIT_KEYHOLE( KEY_HOLE1 );
	INIT_KEYHOLE( KEY_HOLE2 );
	INIT_KEYHOLE( KEY_HOLE3 );
	INIT_KEYHOLE( KEY_HOLE4 );

	obj = &objects[DETONATOR];
	obj->collision = DetonatorCollision;
	obj->control = DetonatorControl;
	obj->save_flags = obj->save_anim = 1;

	INIT_PUZZLEHOLE( PUZZLE_HOLE1 );
	INIT_PUZZLEHOLE( PUZZLE_HOLE2 );
	INIT_PUZZLEHOLE( PUZZLE_HOLE3 );
	INIT_PUZZLEHOLE( PUZZLE_HOLE4 );

	for (lp=PUZZLE_DONE1;lp<=PUZZLE_DONE4;lp++)
	{
		obj = &objects[lp];
		obj->control = ControlAnimating_1_4;
		obj->save_flags = obj->save_anim = 1;
	}

	/*---------------Cutscene Players------------------- */

	for (lp=PLAYER_1;lp<=PLAYER_10;lp++)
	{
		obj = &objects[lp];
		obj->initialise = (void *)InitialiseGenPlayer;
		obj->control = (void *)ControlCinematicPlayer;
		obj->hit_points = 1;
	}

	/*-------------------Effects------------------------- */

	for (lp=ANIMATING1;lp<=ANIMATING6;lp++)
	{
		obj = &objects[lp];
		obj->control = ControlAnimating_1_4;
		obj->collision = ObjectCollision;
		obj->save_anim = obj->save_flags = 1;
	}

	for (lp=SMOKE_EMITTER_WHITE;lp<=STEAM_EMITTER;lp++)
	{
		obj = &objects[lp];
		obj->control = ControlSmokeEmitter;
		obj->draw_routine = DrawDummyItem;
		obj->save_flags = 1;
	}

	objects[GHOST_GAS_EMITTER].control = ControlGhostGasEmitter;
	objects[GHOST_GAS_EMITTER].draw_routine = DrawDummyItem;
	objects[GHOST_GAS_EMITTER].save_flags = 1;

	for (lp=RED_LIGHT;lp<=WHITE_LIGHT;lp++)
	{
		obj = &objects[lp];
		obj->control = ControlColouredLights;
		obj->draw_routine = DrawDummyItem;
		obj->save_flags = 1;
	}

	objects[BUBBLES1].control = ControlBubble1;
	objects[BUBBLES1].draw_routine = DrawDummyItem;
	objects[DRAGON_FIRE].control = ControlFlameThrower;
	objects[DRAGON_FIRE].draw_routine = DrawDummyItem;

	objects[WATERFALL].control = WaterFall;
	objects[WATERFALL].draw_routine = DrawDummyItem;

	for (lp=SECURITY_LASER_ALARM;lp<=SECURITY_LASER_KILLER;lp++)
	{
		obj = &objects[lp];
		obj->initialise = LaserControl;
		obj->control = LaserControl;
		obj->draw_routine = S_DrawLaser;
		obj->save_flags = obj->save_hitpoints = 1;
	}

	objects[BODY_PART].control = ControlBodyPart;
	objects[BODY_PART].nmeshes = 0; // Body part mesh number is supplied in fx->frame_number
	objects[BODY_PART].loaded = 1; // lie about this for DEBUG in DrawEffect()

//	objects[HOT_LIQUID].control = ControlHotLiquid;	// Not in anymore
//	objects[HOT_LIQUID].semi_transparent = 1;

	objects[BIRD_TWEETER].control = ControlBirdTweeter;
	objects[BIRD_TWEETER].draw_routine = DrawDummyItem;
	objects[WATER_DRIP].control = ControlBirdTweeter;
	objects[WATER_DRIP].draw_routine = DrawDummyItem;
//	objects[ALARM_SOUND].control = ControlAlarmSound;
//	objects[ALARM_SOUND].save_flags = 1;

	objects[DING_DONG].control = ControlDingDong;
	objects[DING_DONG].draw_routine = DrawDummyItem;

	objects[LARA_ALARM].control = ControlLaraAlarm;
	objects[LARA_ALARM].draw_routine = DrawDummyItem;
	objects[LARA_ALARM].save_flags = 1;

	objects[CLOCK_CHIMES].control = ControlClockChimes;
	objects[CLOCK_CHIMES].draw_routine = DrawDummyItem;
	objects[CLOCK_CHIMES].save_flags = 1;

	objects[FINAL_LEVEL].draw_routine = DrawDummyItem;
	objects[FINAL_LEVEL].control = FinalLevelCounter;
	objects[FINAL_LEVEL].save_flags = 1;

	objects[CUT_SHOTGUN].control = ControlCutShotgun;
	objects[CUT_SHOTGUN].save_flags = objects[CUT_SHOTGUN].save_anim = 1;

	objects[EARTHQUAKE].draw_routine = DrawDummyItem;
	objects[EARTHQUAKE].control = EarthQuake;
	objects[EARTHQUAKE].save_flags = 1;

	objects[GUNSHELL].control = ControlGunShell;
	objects[SHOTGUNSHELL].control = ControlGunShell;
}


/*---------------------------------------------------------------------------
 *	Public Functions
\*--------------------------------------------------------------------------*/

/* Return 0 if initialisation fails, 1 if OK */

int InitialiseLevel(int level_number, int type)
{
#ifdef JAPAN
	int i;
	static int weapon_level=0;
#endif

#ifdef GAMEDEBUG
#ifdef PSX_VERSION
	printf("Initialising Level: %d '%s' type %d\n",level_number,GF_Level_Names[level_number],type );
#else
	Log(LT_Info,"Initialising Level: %d '%s' type %d",level_number,GF_Level_Names[level_number],type );
#endif
#endif

	if ((type != IL_TITLE)
	&&  (type != IL_CUTSCENE))
		CurrentLevel = level_number;

// Global variable to tell whether we are in demo mode
// Fixes demos when savegame.bonus_flag is enabled - see also items.c
	if (type == IL_DEMO)
		DemoPlay = 1;
	else
		DemoPlay = 0;

	InitialiseGameFlags();
	lara.item_number = NO_ITEM;

	title_loaded = 0;

	switch (type)
	{
		case IL_CUTSCENE:
			if (!S_LoadLevelFile(GF_cutscenefilenames[level_number], level_number, type ))
				return(0);
			break;

		case IL_TITLE:
			if (!S_LoadLevelFile(GF_titlefilenames[GFT_TITLEFILE], level_number, type ))
				return(0);
			break;

		case IL_NORMAL:
		case IL_SAVED:
		case IL_DEMO:
		default:
			if (!S_LoadLevelFile(GF_levelfilenames[level_number], level_number, type ))
				return(0);
			break;
	}

#ifdef JAPAN
	if (type==IL_DEMO)
	{
		if (weapon_level)
		{
			// Change weapon levels back to normal
			for (i=0;i<NUM_WEAPONS;i++)
				weapons[i].damage /=2;
			weapon_level = 0;
		}
	}
	else if (!weapon_level)
	{
		// Adjust weapon levels for Japanese version
		for (i=0;i<NUM_WEAPONS;i++)
				weapons[i].damage *=2;
		weapon_level = 1;
	}
#endif

	if (savegame.AfterAdventureSave)
	{
		START_INFO *start = &savegame.start[level_number];
		printf("Copied\n");
		S_MemCpy(start, &savegame.start[MAXIMUM_LEVELS], sizeof(START_INFO));
	}

	if (lara.item_number != NO_ITEM)
		InitialiseLara(type);

	if ((type == IL_NORMAL)
	||  (type == IL_SAVED)
	||  (type == IL_DEMO))
	{
		GetCarriedItems();
		GetAIPickups();
	}

	effects = (FX_INFO *)game_malloc( NUM_EFFECTS*sizeof(FX_INFO),EFFECTS_ARRAY );		// Malloc Space for Effects....
	InitialiseFXArray();
	InitialiseLOTarray();

#ifdef PSX_VERSION

#if defined(GAMEDEBUG) || defined(EZORAY)
	show_game_malloc_totals();
#endif

#ifdef GAMEDEBUG
	switch(type)
	{
		case IL_NORMAL:
		case IL_SAVED:
		case IL_DEMO:
		default:
			sprintf(exit_message,GF_levelfilenames[level_number]);
			build_ext(exit_message,"mem");
			save_game_malloc_totals(exit_message);
			break;

		case IL_CUTSCENE:
			sprintf(exit_message,"data\\cut%d.txt",level_number);
			save_game_malloc_totals(exit_message);
			break;

		case IL_TITLE:
			sprintf(exit_message,"data\\title.txt");
			save_game_malloc_totals(exit_message);
			break;
	}
#endif
#endif

#if defined(PC_VERSION) && defined(GAMEDEBUG)
	if (type==IL_NORMAL)
	{
		Log("LEVEL START STATS:");
		Log("  Baddie Hits    %d", level.hit_points);
		Log("  Ammo           %d", level.ammo);
		Log("  Health         %d", level.health);
	}
#endif

	InitColours();					// inventry.c
	T_InitPrint();					// text.c
#ifdef PC_VERSION
	InitialisePickUpDisplay();      // health.c
#endif
	S_InitialiseScreen(type);

	health_bar_timer = 100;
	//mn_reset_sound_effects();
	SOUND_Stop();

	/* Savegame will modify CurrentLevel */
	if (type==IL_SAVED)
		ExtractSaveGameInfo();
//##	else if (type==IL_NORMAL)
	else
	{
		/* Init inventory for this level */
		GF_ModifyInventory(CurrentLevel ,0);
	}

	if (objects[FINAL_LEVEL].loaded) // should be a GF_FinalLevel style thing really
		InitialiseFinalLevel();

//#ifdef PC_VERSION
	/* Kick off this level's CD track */
#ifndef PC_VERSION
	if ((type == IL_TITLE)
	&&  (gameflow.title_track))
		S_CDPlay(gameflow.title_track, 1);
	else
#endif

	if ((type == IL_SAVED) && (savegame.mid_level_save))
	{
		S_CDPlay(CurrentAtmosphere, 1);
		IsAtmospherePlaying = 1;
	}

	else if ((type==IL_NORMAL || type==IL_SAVED || type==IL_DEMO) && CurrentLevel != LV_GYM)
	{
		if (GF_CDtracks[0])
		{
			S_CDPlay(GF_CDtracks[0], 1);

			CurrentAtmosphere = GF_CDtracks[0];
			IsAtmospherePlaying = 1;
		}
	}

	if (CurrentLevel == LV_GYM && savegame.QuadbikeKeyFlag)
	{
		long	lp;

		Inv_AddItem(KEY_ITEM1);

		for (lp=0;lp<level_items;lp++)
		{
			if (items[lp].object_number == KEY_ITEM1)
			{
				items[lp].status = INVISIBLE;
	 			RemoveDrawnItem(lp);
				break;
			}
		}
	}

	assault_timer_active = 0;
	assault_timer_display = 0;
	camera.underwater = 0;
//#endif

#ifdef GAMEDEBUG
#if CODER==JASON
	Log(LT_Info,"Level Initialised!!!");
#endif
#ifdef PSX_VERSION
	printf("Level Initialised!!!\n\n");
#endif
#endif

	return (1);
}

void InitialiseLevelFlags(void)
{
	/* This MUST NOT be called if a CUTSCENE */
	savegame.secrets = 0;
	savegame.timer = 0;
	savegame.kills = 0;
	savegame.distance_travelled = 0;
	savegame.ammo_used = 0;
	savegame.ammo_hit = 0;
	savegame.health_used = 0;

	assault_timer_active = 0;
	QuadbikeLapTime = QuadbikeLapTimeDisplayTimer = 0;
	compy_scared_timer = 0;
	compys_attack_lara = 0;
	CarcassItem = -1;

}

void InitialiseObjects(void)
{
	/* Setup information for object types */
	int 		i;
	OBJECT_INFO *obj;

	/* Set defaults */
	for (i=0, obj=objects; i<NUMBER_OBJECTS; i++, obj++)
	{
		obj->initialise = NULL;
		obj->collision = NULL;
		obj->control = NULL;
		obj->draw_routine = DrawAnimatingItem;
		obj->floor = obj->ceiling = NULL;
		obj->pivot_length = 0;
		obj->radius = DEFAULT_RADIUS;
		obj->shadow_size = 0;
		obj->hit_points = DONT_TARGET;
		obj->intelligent = obj->water_creature = 0;
		obj->save_position = obj->save_hitpoints = obj->save_flags = obj->save_anim = 0;
	}

	BaddyObjects();
	TrapObjects();
	ObjectObjects();

	InitialiseHair();
	InitialiseSparks();
}

void GetCarriedItems( void )
{
	/* make bad guys pick up any pickup that has been placed on their square (which they drop when killed) */
	int i;
	sint16 pickup_number;
	ITEM_INFO *item, *pickup;

	for (i=0, item=items; i<level_items; i++, item++)
	{
		if (objects[item->object_number].intelligent)
		{
			item->carried_item = NO_ITEM;

			/* Look for pickup items in same room that have same origin */
			pickup_number = room[item->room_number].item_number;
			do
			{
				pickup = &items[pickup_number];
				if (pickup->pos.x_pos == item->pos.x_pos && pickup->pos.y_pos == item->pos.y_pos &&
					 pickup->pos.z_pos == item->pos.z_pos && objects[pickup->object_number].collision == PickUpCollision)
				{
					pickup->carried_item = item->carried_item; // linked list for multiple pickups
					item->carried_item = pickup_number;
					RemoveDrawnItem(pickup_number);
					pickup->room_number = NO_ROOM;
				}

				pickup_number = pickup->next_item;
			}
			while (pickup_number != NO_ITEM);
		}
	}
}

void GetAIPickups( void )
{
		// make bad guys pick up AI behaviour pickup that has been placed on their square
		// This gives a way of tying a particular baddy to an AI object elsewhere on the map

	int i;
	sint16 pickup_number;
	ITEM_INFO *item, *pickup;

	for (i=0, item=items; i<level_items; i++, item++)
	{
		if (objects[item->object_number].intelligent)
		{
			item->ai_bits = 0;

			/* Look for pickup items in same room that have same origin */
			pickup_number = room[item->room_number].item_number;
			do
			{
				pickup = &items[pickup_number];
				if (pickup->pos.x_pos == item->pos.x_pos && //pickup->pos.y_pos == item->pos.y_pos &&
					 pickup->pos.z_pos == item->pos.z_pos && objects[pickup->object_number].collision == AIPickupCollision &&
					 pickup->object_number < AI_PATROL2)
				{
					item->ai_bits |= 1 << (pickup->object_number - AI_GUARD); //AI_GUARD is the first of the AI objects
					item->item_flags[3] = pickup->pos.y_rot; //Should be safe with this one
				 //	RemoveDrawnItem(pickup_number);
					if (!(pickup->object_number == AI_PATROL1 && (CurrentLevel == LV_AREA51 || CurrentLevel == LV_COMPOUND)))
					{
						KillItem(pickup_number);
						pickup->room_number = NO_ROOM;
					}
				}
				else if (pickup->object_number == FLAME_EMITTER && item->object_number == PUNK1)
				{
					item->item_flags[2] = 3; //Punk carrying a torch
					KillItem(pickup_number);
					pickup->room_number = NO_ROOM;
				}

				pickup_number = pickup->next_item;
			}
			while (pickup_number != NO_ITEM);
		}
	}
}

#ifdef PC_VERSION

/****************************************************************************
* BuildOutsideTable
*
* SYNOPSIS
*	void BuildOutsideTable()
*
* PURPOSE
*	Creates a table of outside and underwater rooms
*
* INPUTS
*	None
*
* RETURNS
*	Nothing
*/

#define OUTSIDE_Z 64	// z depth of outside table

void BuildOutsideTable()
{
	unsigned char *s;
	int x, y, i;
	long	max_slots = 0;

	OutsideRoomTable = (unsigned char *)game_malloc(27*27*OUTSIDE_Z, 0);
	S_MemSet(OutsideRoomTable, 0xff, 27*27*OUTSIDE_Z);

/* -------- determine outside rooms within a grid pos */

	printf("X %d, Y %d, Z %d, Xs %d, Ys %d\n",room[0].x,room[0].y,room[0].z,room[0].x_size,room[0].y_size);

	for ( y=0; y<108 ; y+=4 )
	{
		for ( x=0 ; x<108 ; x+=4 )
		{
			for ( i=0 ; i<number_rooms ; i++ )
			{
				unsigned char *d;
				int rx, ry, j, xl, yl;
				ROOM_INFO *r = &room[i];

				rx = (r->z >> 10) + 1;
				ry = (r->x >> 10) + 1;

 //				if ((!(r->flags & NOT_INSIDE)) && (!(r->flags & UNDERWATER)))
 //					continue;

				j = 0;
				for (yl=0;yl<4;yl++)
				{
					for (xl=0;xl<4;xl++)
					{
						if (	(x+xl) >= rx && (x+xl) < (rx + r->x_size - 2) &&
							(y+yl) >= ry && (y+yl) < (ry + r->y_size - 2))
						{
							j=1;
							break;
						}
					}
				}

				if (!j)
					continue;

#if defined(GAMEDEBUG) || defined(EZORAY)
				if (i == 255)
				{
					printf("ERROR : Room 255 fuckeroony - go tell Chris\n");
					exit(0);
				}
#endif
				d = &OutsideRoomTable[((x>>2)*OUTSIDE_Z) + ((y>>2)*(27*OUTSIDE_Z))];

				for ( j=0 ; j<OUTSIDE_Z ; j++ )
				{
					if (d[j] == 0xff)
					{
						d[j] = i;
						if (j>max_slots)
							max_slots=j;
						break;
					}
				}

#if defined(GAMEDEBUG) || defined(EZORAY)
				if (j == OUTSIDE_Z)
				{
					printf("ERROR : Buffer shittage - go tell Chris\n");
					exit(0);
				}
#endif
			}
		}
	}

/* -------- create outside room table */

	s = OutsideRoomTable;

	for ( y=0 ; y<27 ; y++ )
	{
		for ( x=0 ; x<27 ; x++ )
		{
			int z=0;
			unsigned char *d, *p;

			i = (y*27)+x;
			d = &OutsideRoomTable[(x*OUTSIDE_Z) + (y*(27*OUTSIDE_Z))];

			while (d[z] != 0xff)
				z++;

			if (z == 0)
				OutsideRoomOffsets[i] = 0xffff;
			else if (z == 1)
				OutsideRoomOffsets[i] = *d | 0x8000;
			else
			{

			/* -------- pack string */

				p = OutsideRoomTable;

				while (p < s)
				{
					if (memcmp(p, d, z) == 0)
					{
						OutsideRoomOffsets[i] = (long)p-(long)OutsideRoomTable;
						break;
					}
					else
					{
						int z2=0;

						while (p[z2] != 0xff)
							z2++;

						p+=z2+1;
					}
				}

			/* -------- add a new string */

				if (p >= s)
				{
					OutsideRoomOffsets[i] = (long)s-(long)OutsideRoomTable;

					for ( ; z ; z-- )
						*s++ = *d++;

					*s++ = 0xff;
				}
			}
		}
	}

	game_free((((27*27*OUTSIDE_Z)-((long)s-(long)OutsideRoomTable))+3)&~3, 0);

//#if defined(GAMEDEBUG) || defined(EZORAY)
	printf("Ouside room table = %d bytes, max_slots = %d\n", (long)s-(long)OutsideRoomTable,max_slots);
//#endif
}

#endif
