/*This function is run when a new game i started */
void OnInit()
{
//----SOUND INIT---------------------
	//FOTSTEPS
	/*
	PreloadSound("player_step_run_concrete.snt"); PreloadSound("player_step_walk_concrete.snt"); PreloadSound("player_step_sneak_concrete.snt");
	PreloadSound("player_step_run_dirt.snt"); PreloadSound("player_step_walk_dirt.snt"); PreloadSound("player_step_sneak_dirt.snt");
	PreloadSound("player_step_run_fabric.snt"); PreloadSound("player_step_walk_fabric.snt"); PreloadSound("player_step_sneak_fabric.snt");
	PreloadSound("player_step_run_generic_hard.snt"); PreloadSound("player_step_walk_generic_hard.snt"); PreloadSound("player_step_sneak_generic_hard.snt");
	PreloadSound("player_step_run_metal.snt"); PreloadSound("player_step_walk_metal.snt"); PreloadSound("player_step_sneak_metal.snt");
	PreloadSound("player_step_run_metal_loose.snt"); PreloadSound("player_step_walk_metal_loose.snt"); PreloadSound("player_step_sneak_metal_loose.snt");
	PreloadSound("player_step_run_ventilation.snt"); PreloadSound("player_step_walk_ventilation.snt"); PreloadSound("player_step_sneak_ventilation.snt");
	PreloadSound("player_step_run_wood.snt"); PreloadSound("player_step_walk_wood.snt"); PreloadSound("player_step_sneak_wood.snt");
	PreloadSound("player_step_run_wood_squeak.snt"); PreloadSound("player_step_walk_wood_squeak.snt"); PreloadSound("player_step_sneak_wood_squeak.snt");
	*/
	//PHYSICS IMPACTS
	/*
	PreloadSound("imp_book_high.snt"); PreloadSound("imp_book_med.snt"); PreloadSound("imp_book_low.snt");
	PreloadSound("imp_chair_wheel_high.snt"); PreloadSound("imp_chair_wheel_med.snt"); PreloadSound("imp_chair_wheel_low.snt");
	PreloadSound("imp_concrete_high.snt"); PreloadSound("imp_concrete_med.snt"); PreloadSound("imp_concrete_low.snt");
	PreloadSound("imp_fabric_high.snt"); PreloadSound("imp_fabric_med.snt"); PreloadSound("imp_fabric_low.snt");
	PreloadSound("imp_generic_hard_high.snt"); PreloadSound("imp_generic_hard_med.snt"); PreloadSound("imp_generic_hard_low.snt");
	PreloadSound("imp_glass_high.snt"); PreloadSound("imp_glass_low.snt"); PreloadSound("imp_glass_low.snt");
	PreloadSound("imp_metal_can_high.snt"); PreloadSound("imp_metal_can_med.snt"); PreloadSound("imp_metal_can_low.snt");
	PreloadSound("imp_metal_case_high.snt"); PreloadSound("imp_metal_case_med.snt"); PreloadSound("imp_metal_case_low.snt");
	PreloadSound("imp_metal_chair_high.snt"); PreloadSound("imp_metal_chair_med.snt"); PreloadSound("imp_metal_chair_low.snt");
	PreloadSound("imp_metal_high.snt"); PreloadSound("imp_metal_med.snt"); PreloadSound("imp_metal_low.snt");
	PreloadSound("imp_metal_pipe_high.snt"); PreloadSound("imp_metal_pipe_med.snt"); PreloadSound("imp_metal_pipe_low.snt");
	PreloadSound("imp_paper_box_h_high.snt"); PreloadSound("imp_paper_box_h_med.snt"); PreloadSound("imp_paper_box_h_low.snt");
	PreloadSound("imp_paper_box_high.snt"); PreloadSound("imp_paper_box_med.snt"); PreloadSound("imp_paper_box_low.snt");
	PreloadSound("imp_paper_high.snt"); PreloadSound("imp_paper_med.snt"); PreloadSound("imp_paper_low.snt");
	PreloadSound("imp_plastic_elec_high.snt"); PreloadSound("imp_plastic_elec_med.snt"); PreloadSound("imp_plastic_elec_low.snt");
	PreloadSound("imp_wood_high.snt"); PreloadSound("imp_wood_med.snt"); PreloadSound("imp_wood_low.snt");
	PreloadSound("imp_wood_box_high.snt"); PreloadSound("imp_wood_box_med.snt"); PreloadSound("imp_wood_box_low.snt");
	PreloadSound("imp_wood_chair_high.snt"); PreloadSound("imp_wood_chair_med.snt"); PreloadSound("imp_wood_chair_low.snt");
	PreloadSound("imp_wood_shelf_s_high.snt"); PreloadSound("imp_wood_shelf_s_med.snt"); PreloadSound("imp_wood_shelf_s_low.snt");
	*/
	//PHYSICS SCRAPES & ROLL
	/*
	PreloadSound("scrape_book.snt"); 
	PreloadSound("scrape_chair_wheel.snt");
	PreloadSound("scrape_concrete.snt");
	PreloadSound("scrape_fabric.snt"); 
	PreloadSound("scrape_generic_hard.snt"); 
	PreloadSound("scrape_glass.snt"); 
	PreloadSound("scrape_metal.snt"); 
	PreloadSound("scrape_metal_can.snt"); 
	PreloadSound("scrape_metal_case.snt");
	PreloadSound("scrape_metal_chair.snt");  
	PreloadSound("scrape_metal_pipe.snt"); 
	PreloadSound("scrape_paper.snt"); 
	PreloadSound("scrape_paper_box.snt"); 
	PreloadSound("scrape_paper_box_h.snt");
	PreloadSound("scrape_plastic_elec.snt"); 
	PreloadSound("scrape_wood.snt");
	PreloadSound("scrape_wood_box.snt");
	PreloadSound("scrape_wood_chair.snt");
	PreloadSound("scrape_wood_shelf_s.snt");
	*/	
	
	
//----ITEMS-------------------------------------
	
	for(int i=0; i< 5; ++i)
		GiveItem("battery","item_battery.ent", -1);
	
	
//---- GLOBAL VARIABLES ------------
	//To check if player has seen the cotton string, if true will be told about it when picking explosion book.
	CreateGlobalVar("SeenCottonString", 0);
	//To check if player has explosives book and trigger different events based on that.
	CreateGlobalVar("HasExplosivesBook", 0);
	//To check if player picked zippo and in that case trigger dog event
	CreateGlobalVar("HasPickedZippo", 0);
	//Check if generator is running or not
	CreateGlobalVar("generator", 0);
	//If beam sawed and door opened
	CreateGlobalVar("sawdoor", 0);
	//Is the gasoline brute force opened?
	CreateGlobalVar("gasolinebrute", 0);
	//If the storage room is opened.
	CreateGlobalVar("new_storage_room_door_open",0);
	//If the storage room door checked
	CreateGlobalVar("new_storage_room_door_checked",0);
	/*//Check if wood broken 1.13 C while entering 1.13 B
	CreateGlobalVar("1_13_planks",0);*/
	//Check if cart is removed in 1.18 to enable 1.13 B entrance
	CreateGlobalVar("1_18_cart", 0);
	//Saves in 1.13 when UV note received in 1.18
	CreateGlobalVar("1_18_UVNoteSave", 0);
	//Save in 1.13B if player has found blanknote
	CreateGlobalVar("GotBlankNote", 0);
	//Code panel in 1.13B will only work if player red note.
	CreateGlobalVar("ReadUVNote", 0);
	
	// START ROOM VISTIED VARIABLES
	CreateGlobalVar("mine_entrance_visited",0);
	CreateGlobalVar("old_mine_shafts_visited",0);
	
	CreateGlobalVar("lead_mine_shafts_visited",0);
	CreateGlobalVar("new_storage_room_visited",0);
	
	CreateGlobalVar("iron_mine_shafts_visited",0);	
	// END ROOM VISTIED VARIABLES
	
//TESTING
	return;
	for(int i=0; i< 2; ++i)
		GiveItem("flare01","items_flare.ent", -1);
	for(int i=0; i< 10; ++i)
		GiveItem("dynamite01","item_dynamite.ent", -1);
	for(int i=0; i< 10; ++i)
		GiveItem("meat01","item_meat.ent", -1);
	GiveItem("notebook","item_notebook.ent", -1);
	GiveItem("flashlight","item_flashlight.ent", -1);
	GiveItem("glowstick","item_glowstick.ent",-1);

	//GiveItem("chemicalA","item_chemical_A.ent",-1);
	//GiveItem("chemicalB","item_chemical_B.ent",-1);
	//GiveItem("chemicalC","item_chemical_C.ent",-1);
	//GiveItem("chemicalD","item_chemical_D.ent",-1);
	//GiveItem("chemicalE","item_chemical_E.ent",-1);
	//GiveItem("chemicalF","item_chemical_F.ent",-1);
	
	//GiveItem("shaftfuse","item_shaft_fuse.ent",-1);
	GiveItem("redskey","item_reds_key.ent",-1);
	GiveItem("crowbar","item_crowbar.ent",-1);
	GiveItem("boltcutter","item_boltcutter.ent", -1);
	GiveItem("screwdriver","item_screwdriver.ent", -1);
	GiveItem("uvnote","item_blank_note.ent", -1);
	GiveItem("machinekey","item_mining_machine_key.ent", -1);
	GiveItem("gasoline","item_gasoline.ent", -1);
	GiveItem("zippofire","item_lighter_working.ent", -1);
	GiveItem("steelrod","items_steelrod.ent",-1);
	GiveItem("axe","items_pickaxe.ent",-1);
	GiveItem("saw01","item_saw.ent",-1);
	GiveItem("hammer","item_hammer.ent",-1);
	GiveItem("oldminekey","item_oldkey.ent",-1);
	GiveItem("fuse01","item_replacement_fuse.ent",-1);
	GiveItem("wcrate_broken_batterygen","item_generator_battery.ent",-1);
	GiveItem("fuse","item_fuse.ent", -1);
	GiveItem("explosivebook","items_bookexplosives.ent",-1);
	GiveItem("cottonstring","item_cottonstring.ent",-1);
	GiveItem("dextrin","items_dextrin.ent",-1);	
	
}	

/*This function is run everytime a map is loaded for the first time*/
void OnMapStart()
{
	//---- GLOBAL COMBOS-------------------
	//Creating the fuse
	AddCombineCallback("cottonstring","dextrin", "@StringDextrinCombine");
	AddCombineCallback("lightergas1","zippo", "@LighterGasZippoCombine");
	AddCombineCallback("gasoline","hammer", "@GasolineHammerCombine");
}


/*This function is run everytime a map is loaded */
void OnMapLoad()
{	

}


/*This function is run 60 times a sec*/
void OnUpdate()
{

}


//////////////////////
/*CALLBACK FUNCTIONS*/

///////////////////////
//START FUSE CREATION//
void StringDextrinCombine(string asItem1, string asItem2, int alSlot)
{
	RemoveItem("dextrin");
	RemoveItem("cottonstring");
	
	PlayGuiSound("item_string_dextrin_comb",1);
	
	CreateTimer("cottondelay1", 0.5f, "@CottonDelay1",true);
	
	SetInventoryMessageTrans("Global", "CombineStringDextrin");
	
}
void CottonDelay1(string asTimer)
{
	GiveItem("cottonstringsoaked","item_cottonstringsoaked.ent", -1);
	
	DestroyTimer("cottondelay1");
}
void LighterGasZippoCombine(string asItem1, string asItem2, int alSlot)
{
	RemoveItem("lightergas1");
	RemoveItem("zippo");		//Removed to make scripting easier
	
	PlayGuiSound("item_string_dextrin_comb",1);
	
	CreateTimer("zippodelay1", 0.5f, "@ZippoDelay1",true);
		
	SetInventoryMessageTrans("Global", "CombineLighterGasZippo");
}
void ZippoDelay1(string asTimer)
{
	GiveItem("zippofire","item_lighter_working.ent", -1);	//Added same item but different name
	
	DestroyTimer("zippodelay1");
}
//STOP FUSE CREATION//
//////////////////////


///////////////////////
//START OPEN GASOLINE//
void GasolineHammerCombine(string asItem1, string asItem2, int alSlot)
{
	PlayGuiSound("interact_fuel_force_open",1);
	
	CreateTimer("gasdelay11", 1.5f, "@GasDelay1",true);
	
	SetGlobalVar("gasolinebrute", 1);
}
void GasDelay1(string asTimer)
{
	SetInventoryMessageTrans("Global", "CombineGasolineHammer");
	
	DestroyTimer("gasdelay11");
}
//STOP OPEN GASOLINE//
//////////////////////


///////////////////////////
//START COMPLICATED RADIO//
void Radio02Timer01(string asTimer)
{
	PlayGuiSound("item_radio_noise", 0.9f);
	
	AddSubTitleTrans("Radio", "Start", 1.1f);
		
	CreateTimer("radio2timer2", 1.1f, "@Radio02Timer02",true);
	
	DestroyTimer("radio2timer1");
}
void Radio02Timer02(string asTimer)
{
	AddRadioMessage("Radio","Red 3.01","voice_red_03_part1.ogg");
	AddRadioMessage("Radio","Red 3.02","voice_red_03_part2.ogg");
	AddRadioMessage("Radio","Red 3.03","voice_red_03_part3.ogg");
	
	SetRadioOnEndCallback("@ComplicatedRadio");
	
	DestroyTimer("radio2timer2");
}
void ComplicatedRadio()
{
	CreateTimer("radioglobal", 8, "@RadioGlobal01",true);
}
void RadioGlobal01(string asTimer)
{
	PlayGuiSound("item_radio_noise", 0.9f);
	
	AddSubTitleTrans("Radio", "Start", 1.1f);
		
	CreateTimer("radioglobal2", 1.1f, "@RadioGlobal02",true);
	
	DestroyTimer("radioglobal");
}
void RadioGlobal02(string asTimer)
{
	AddRadioMessage("Radio","Red 4.01","voice_red_04_part1.ogg");
	AddRadioMessage("Radio","Red 4.02","voice_red_04_part2.ogg");
	
	DestroyTimer("radioglobal2");
}
//STOP COMPLICATED RADIO//
//////////////////////////