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

#include "game.h"

void S_DrawFish(short item_number);
void ControlFish(short item_number);
void S_DrawDarts(short item_number);
void KillAllCurrentItems(short item_number);


void GetCarriedItems( void ); // prototype
extern int detonate_all_mines; // like I want to rebuild all for this
extern int	DemoPlay;

/* Stuff for OBJECT_INFO structure */
#define DEFAULT_RADIUS     10

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

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

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

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

#define TIGER_HIT_POINTS 5	//20
#define TIGER_RADIUS		(WALL_L/3)

#define BARACUDDA_HIT_POINTS 12
#define BARACUDDA_RADIUS (WALL_L/5)

#define SPIDER_HIT_POINTS 5
#define SPIDER_RADIUS (WALL_L/10)

#define BIGSPIDER_HIT_POINTS 40
#define BIGSPIDER_RADIUS (WALL_L/3)

#define DIVER_HIT_POINTS 20
#define DIVER_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 CULT3_HIT_POINTS 150
#define CULT3_RADIUS (WALL_L/10)

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

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

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

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

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

#define SKIDMAN_RADIUS (WALL_L/3)
#define SKIDMAN_HIT_POINTS 100

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

#define DINO_HIT_POINTS 100
#define DINO_RADIUS (WALL_L/3)

int monks_attack_lara = 0;

/*********************************** FUNCTION CODE *******************************************/

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
   /* Return 0 if initialisation fails, 1 if OK */
	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_NORMAL:
		case IL_SAVED:
		case IL_DEMO:
		default:
			if (!S_LoadLevelFile(GF_levelfilenames[level_number], level_number, type ))
				return(0);
		break;
		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;
	}
#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 ( lara.item_number!=NO_ITEM )
		InitialiseLara(type);

	if (type==IL_NORMAL || type==IL_SAVED || type==IL_DEMO)
		GetCarriedItems(); // Make baddies pickup any pickup that has been placed on their space

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

#ifdef PSX_VERSION
	show_game_malloc_totals();
#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
	InitialisePickUpDisplay();      // health.c
	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)
	{
		/* 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_NORMAL || type==IL_SAVED || type==IL_DEMO)
	{
		if (GF_CDtracks[0])
		{
			S_CDPlay(GF_CDtracks[0],1);
			printf("CDPLAY: %d\n", GF_CDtracks[0]);
		}
	}

	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);
}

/******************************************************************************
 *				Initialise Game Flags etc
 *****************************************************************************/
void	InitialiseGameFlags( void )
{
  	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;
	detonate_all_mines = 0;
	monks_attack_lara = 0;
}


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 = savegame.ammo_hit = 0;
	savegame.health_used = 0;
}

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

//							obj->draw_routine = DrawSpriteItem;
#define INIT_PICKUP(a)		obj = &objects[a];\
							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->collision = PuzzleHoleCollision; \
							obj->save_flags = 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


void BaddyObjects(void)
{
	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;

	/* Spider */
	obj = &objects[SPIDER];
	if (obj->loaded)
	{
		obj->control = SpiderControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = SPIDER_HIT_POINTS;
		obj->radius = SPIDER_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
	}

	/* Big Spider */
	obj = &objects[BIG_SPIDER];
	if (obj->loaded)
	{
		obj->control = BigSpiderControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BIGSPIDER_HIT_POINTS;
		obj->radius = BIGSPIDER_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
	}

	/* 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;
	}

	/* Shark */
	obj = &objects[SHARK];
	if (obj->loaded)
	{
		obj->control = SharkControl;
		obj->draw_routine = DrawUnclippedItem;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = SHARK_HIT_POINTS;
		obj->pivot_length = 200;
		obj->radius = SHARK_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;
	}

	/* Baracudda */
	obj = &objects[BARACUDDA];
	if (obj->loaded)
	{
		obj->control = BaracuddaControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BARACUDDA_HIT_POINTS;
		obj->pivot_length = 200;
		obj->radius = BARACUDDA_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 + 6*4] |= ROT_Y;
	}

	/* Remember this cheery chappy? */
	obj = &objects[DINOSAUR];
	if (obj->loaded)
	{
		obj->control = DinoControl;
		obj->collision = CreatureCollision;
		obj->hit_points = DINO_HIT_POINTS;
		obj->shadow_size = UNIT_SHADOW/4;
		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 + 10*4] |= ROT_Y;
	 	bones[obj->bone_index + 11*4] |= ROT_Y;
	}


	/* Doberman */
	obj = &objects[DOG];
	if (obj->loaded)
	{
		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 + 19*4] |= ROT_Y;
	}

	/* 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;
	}

	/* Venice Goon 1 */
	obj = &objects[CULT1];
	if (obj->loaded)
	{
		obj->initialise = InitialiseCult1;
		obj->control = Cult1Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CULT1_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = CULT1_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;
	}

	obj = &objects[CULT1B];
	if (obj->loaded)
	{
		if (!objects[CULT1].loaded)
			S_ExitSystem("FATAL: CULT1B requires CULT1");

		obj->frame_base = objects[CULT1].frame_base;
		obj->anim_index = objects[CULT1].anim_index;

		obj->initialise = InitialiseCult1;
		obj->control = Cult1Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CULT1_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = CULT1_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;
	}

	obj = &objects[CULT1C];
	if (obj->loaded)
	{
		if (!objects[CULT1].loaded)
			S_ExitSystem("FATAL: CULT1B requires CULT1");

		obj->frame_base = objects[CULT1].frame_base;
		obj->anim_index = objects[CULT1].anim_index;

		obj->initialise = InitialiseCult1;
		obj->control = Cult1Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CULT1_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = CULT1_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;
	}

	/* Cult2: the knife man */
	obj = &objects[CULT2];
	if (obj->loaded)
	{
		obj->control = Cult2Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CULT2_HIT_POINTS;
		obj->pivot_length = 50;
		obj->radius = CULT2_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 + 8*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;
	}

	/* Rig Worker */
	obj = &objects[WORKER1];
	if (obj->loaded)
	{
		obj->control = Worker1Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = WORK1_HIT_POINTS;
		obj->radius = WORK1_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 + 4*4] |= ROT_Y;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Rig Worker2 */
	obj = &objects[WORKER2];
	if (obj->loaded)
	{
		obj->control = Worker2Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = WORK2_HIT_POINTS;
		obj->radius = WORK2_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 + 4*4] |= ROT_Y;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Rig Worker3 */
	obj = &objects[WORKER3];
	if (obj->loaded)
	{
		obj->control = Worker3Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = WORK3_HIT_POINTS;
		obj->radius = WORK3_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 + 4*4] |= ROT_Y;
	}

	/* Rig Worker4: flame man (same as worker 2) */
	obj = &objects[WORKER4];
	if (obj->loaded)
	{
		obj->control = Worker2Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = WORK2_HIT_POINTS;
		obj->radius = WORK2_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 + 4*4] |= ROT_Y;
		bones[obj->bone_index + 13*4] |= ROT_Y;
	}

	/* Cult Boss */
	obj = &objects[CULT3];
	if (obj->loaded)
	{
		obj->initialise = InitialiseCult3;
		obj->control = Cult3Control;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = CULT3_HIT_POINTS;
		obj->radius = CULT3_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim= obj->save_flags = 1;
		obj->pivot_length = 0;
	}

	/* Monks */
	obj = &objects[MONK1];
	if (obj->loaded)
	{
		obj->control = MonkControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = MONK_HIT_POINTS;
		obj->radius = MONK_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;
	}

	obj = &objects[MONK2];
	if (obj->loaded)
	{
		obj->control = MonkControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = MONK_HIT_POINTS;
		obj->radius = MONK_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;
	}

	/* 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;
	}

	/* Tibet Goon 1: uzi man */
	obj = &objects[BANDIT1];
	if (obj->loaded)
	{
		obj->control = BanditControl;
		obj->collision = CreatureCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = BANDIT1_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;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 8*4] |= ROT_Y;
	}

	/* Tibet Goon 2: balaclava bloke */
	obj = &objects[BANDIT2];
	if (obj->loaded)
	{
		obj->control = Bandit2Control;
		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;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 8*4] |= ROT_Y;
	}

	/* Tibet Goon 2B: goon 2's brother in law */
	obj = &objects[BANDIT2B];
	if (obj->loaded)
	{
		if (!objects[BANDIT2].loaded)
			S_ExitSystem("FATAL: BANDIT2B requires BANDIT2");

		obj->frame_base = objects[BANDIT2].frame_base;
		obj->anim_index = objects[BANDIT2].anim_index;

		obj->control = Bandit2Control;
		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;
		bones[obj->bone_index + 6*4] |= ROT_Y;
		bones[obj->bone_index + 8*4] |= ROT_Y;
	}

	/* Skidoo Baddie */
	obj = &objects[BANDIT3];
	if (obj->loaded)
	{
		obj->draw_routine = DrawSkidoo;
		obj->collision = SkidmanCollision;
		obj->shadow_size = UNIT_SHADOW/2;
		obj->hit_points = SKIDMAN_HIT_POINTS;
		obj->radius = SKIDMAN_RADIUS;
		obj->intelligent = 1;
		obj->save_position = obj->save_hitpoints = obj->save_anim = obj->save_flags = 1;
		obj->pivot_length = 0;
	}

	obj = &objects[SKIDMAN];
	if (obj->loaded)
	{
		obj->initialise = InitialiseSkidman;
		obj->control = SkidManControl;
		obj->hit_points = 1;
		obj->save_position = obj->save_anim = obj->save_flags = 1;
	}

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


void TrapObjects(void)
{
	OBJECT_INFO *obj;

	obj = &objects[GONDOLA];
	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[MINES];
	obj->collision = ObjectCollision;
	obj->control = MineControl;
	obj->save_flags = 1;

	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->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 */
	INIT_MOVBLOCK( MOVABLE_BLOCK );
	INIT_MOVBLOCK( MOVABLE_BLOCK2 );
	INIT_MOVBLOCK( MOVABLE_BLOCK3 );
	INIT_MOVBLOCK( MOVABLE_BLOCK4 );

   /* 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;

   	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].semi_transparent = 1;

	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;
}


void ObjectObjects(void)
{
	OBJECT_INFO *obj;

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

	/* Sphere that accompanies dragon transformation */
	obj = &objects[SPHERE_OF_DOOM];
	obj->control = SphereOfDoom;
	obj->draw_routine = DrawSphereOfDoom;
	obj->collision = SphereOfDoomCollision;
	obj->save_flags = obj->save_position = 1;
	obj->semi_transparent = 1;

	obj = &objects[SPHERE_OF_DOOM2];
	obj->control = SphereOfDoom;
	obj->draw_routine = DrawSphereOfDoom;
	obj->collision = SphereOfDoomCollision;
	obj->save_flags = obj->save_position = 1;
	obj->semi_transparent = 1;

	obj = &objects[SPHERE_OF_DOOM3];
	obj->control = SphereOfDoom;
	obj->draw_routine = DrawSphereOfDoom;
	obj->collision = SphereOfDoomCollision;
	obj->save_flags = obj->save_position = 1;

	/* Rocket */
	obj = &objects[ROCKET];
	obj->control = ControlRocket;
	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;

	/* The Skidoo */
	obj = &objects[SKIDOO];
	obj->initialise = InitialiseSkidoo;
	obj->collision = SkidooCollision;
	obj->draw_routine = DrawSkidoo;
	obj->save_position = obj->save_flags = obj->save_anim = 1;

	/* The Boat */
	obj = &objects[MOTORBOAT];
	obj->initialise = InitialiseBoat;
	obj->control = BoatControl;
	obj->collision = BoatCollision;
	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->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;

	// same as SMASH_WINDOW, except explodes when triggered rather than when shot at or jumped at

	obj = &objects[SMASH_ICE];
	obj->initialise = InitialiseWindow;
	obj->control = SmashIceControl;
	obj->collision = ObjectCollision;
	obj->save_anim = obj->save_flags = 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;

	objects[TROPICAL_FISH].draw_routine = S_DrawFish;
	objects[TROPICAL_FISH].control = ControlFish;
	objects[PIRAHNAS].draw_routine = S_DrawFish;
	objects[PIRAHNAS].control = ControlFish;

	obj = &objects[BAT_EMITTER];
	obj->control = BatEmitterControl;
	obj->draw_routine = DrawDummyItem;
	obj->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 */

	INIT_DOOR( DOOR_TYPE1 );
	INIT_DOOR( DOOR_TYPE2 );
	INIT_DOOR( DOOR_TYPE3 );
	INIT_DOOR( DOOR_TYPE4 );
	INIT_DOOR( DOOR_TYPE5 );
	INIT_DOOR( DOOR_TYPE6 );
	INIT_DOOR( DOOR_TYPE7 );
	INIT_DOOR( DOOR_TYPE8 );
	obj = &objects[TRAPDOOR];
	obj->control = TrapDoorControl;
	obj->floor = TrapDoorFloor;
	obj->ceiling = TrapDoorCeiling;
	obj->save_anim = obj->save_flags = 1;
	obj = &objects[TRAPDOOR2];
	obj->control = TrapDoorControl;
	obj->floor = TrapDoorFloor;
	obj->ceiling = TrapDoorCeiling;
	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( 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( MEDI_ITEM );               // initialise Health pickups
	INIT_PICKUP( BIGMEDI_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 );
	objects[PUZZLE_DONE1].save_flags = 1;		// Puzzle dones need to
	objects[PUZZLE_DONE2].save_flags = 1;       // save same as PUZZLE_HOLE
	objects[PUZZLE_DONE3].save_flags = 1;
	objects[PUZZLE_DONE4].save_flags = 1;

	/*---------------Cutscene Players------------------- */
	obj = &objects[PLAYER_1];
	obj->initialise = InitialiseGenPlayer;
	obj->control = ControlCinematicPlayer;
	obj->hit_points = 1;
	obj = &objects[PLAYER_2];
	obj->initialise = InitialiseGenPlayer;
	obj->control = ControlCinematicPlayer;
	obj->hit_points = 1;
   obj = &objects[PLAYER_3];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;
   obj = &objects[PLAYER4];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;
   obj = &objects[PLAYER_5];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;
   obj = &objects[PLAYER_6];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;
   obj = &objects[PLAYER_7];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;
   obj = &objects[PLAYER_8];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;
   obj = &objects[PLAYER_9];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;
   obj = &objects[PLAYER_10];
   obj->initialise = InitialiseGenPlayer;
   obj->control = ControlCinematicPlayer;
   obj->hit_points = 1;

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

	objects[BUBBLES1].control = ControlBubble1;
	objects[DRAGON_FIRE].control = ControlMissile;
	objects[DRAGON_FIRE].semi_transparent = 1;

	objects[SNOW_SPRITE].control = ControlSnowSprite;
	objects[WATER_SPRITE].control = ControlWaterSprite;
	objects[WATER_SPRITE].semi_transparent = 1;
	objects[WATERFALL].control = WaterFall;
	objects[WATERFALL].draw_routine = DrawDummyItem;

	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[GUN_FLASH].control = ControlGunShot;
	objects[GLOW].control=ControlGlow;

	objects[HOT_LIQUID].control = ControlHotLiquid;
	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;

}


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);
		}
	}
}
