void OnStart()
{
PreloadSound("insanity_baby_cry.snt");
PreloadSound("door_sewer_close.snt");
PreloadSound("24_rock_move.snt");
PreloadSound("guardian_distant1.snt");





//LOCKED HALL DOOR
SetEntityPlayerInteractCallback("sewer_arched_4", "door_locked", true);
AddUseItemCallback("hallwaydoorunlocked", "HallwayKey", "sewer_arched_4", "hallwaydoorunlocked", true);

//HALL SCARE
AddEntityCollideCallback("Player", "hitthelights", "hittingthelights", true, 1);

//LOOPING HALL
SetEntityPlayerInteractCallback("Hallway Key", "passout", true);




//LOOPING HALLS
SetEntityPlayerInteractCallback("HallwayKey", "loophalls", false);
//CANDELS
SetEntityPlayerInteractCallback("light_1a", "light_1", false);
SetEntityPlayerInteractCallback("light_2a", "light_2", false);
SetEntityPlayerInteractCallback("light_3a", "light_3", false);
SetEntityPlayerInteractCallback("light_4a", "light_4", false);

SetEntityPlayerInteractCallback("light_1b", "light_1b", false);
SetEntityPlayerInteractCallback("light_2b", "light_2b", false);
SetEntityPlayerInteractCallback("light_3b", "light_3b", false);
SetEntityPlayerInteractCallback("light_4b", "light_4b", false);

}








void OnEnter()
{
//MUSIC CHANGE
StopMusic(2, 0);
PlayMusic("23_amb.ogg", true, 2, 2, 0, true);
}



//LOCKED HALL DOOR
void door_locked(string &in asEntity)
{
SetMessage("Locked", "HallDoor", 5);
AddQuest("hallquest", "HallQuest");
}

void hallwaydoorunlocked(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("sewer_arched_4", false, false);
RemoveItem("HallwayKey");
CompleteQuest("hallquest", "HallQuest");
PlaySoundAtEntity("unlocking", "unlock_door.snt", "Player", 0, false);
}




//HALL SCARE
void hittingthelights(string &in asParent, string &in asChild, int alState)
{
SetLampLit("breaklight_1", false, true);
SetLampLit("breaklight_2", false, true);
SetLampLit("breaklight_3", false, true);
SetLampLit("breaklight_4", false, true);
SetLampLit("breaklight_5", false, true);
SetLampLit("breaklight_6", false, true);
SetLampLit("breaklight_7", false, true);
SetLampLit("breaklight_8", false, true);
SetLampLit("breaklight_9", false, true);
SetLampLit("breaklight_11", false, true);
SetLampLit("breaklight_12", false, true);
PlaySoundAtEntity("", "guardian_distant1.snt", "sewer_arched_4", 0, false);
PlaySoundAtEntity("", "24_rock_move.snt", "Player", 0, false);
GiveSanityDamage(30, true);
StartScreenShake(0.4, 1.0, 1.0f, 1.0f);
CreateParticleSystemAtEntity("roar", "ps_cave_monster_scream.ps", "sewer_arched_4", false);
AddPropImpulse("door_1", -10.0, 0, 0, "world");
AddPropImpulse("door_2", -10.0, 0, 0, "world");
AddPropImpulse("door_3", -10.0, 0, 0, "world");
AddPropImpulse("door_4", 10.0, 0, 0, "world");
AddPropImpulse("door_5", 10.0, 0, 0, "world");
AddTimer("doors_move", 0.8, "move_doors1");
PlaySoundAtEntity("", "door_sewer_close.snt", "door_1", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_2", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_3", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_4", 0, false);
MovePlayerHeadPos(0, 0, 4.0, 10, 6);
AddTimer("", 0.2, "ScaryLooking");
}

void ScaryLooking(string &in asTimer)
{
MovePlayerHeadPos(0, 0, 0, 10, 4);
}

void move_doors1(string &in asTimer)
{
AddPropImpulse("door_1", 14.0, 0, 0, "world");
AddPropImpulse("door_2", 8.0, 0, 0, "world");
AddPropImpulse("door_3", 6.6, 0, 0, "world");
AddPropImpulse("door_4", -1.0, 0, 0, "world");
AddPropImpulse("door_5", -6.0, 0, 0, "world");
AddTimer("doors_move", 0.5, "move_doors2");
PlaySoundAtEntity("", "door_sewer_close.snt", "door_1", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_2", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_3", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_4", 0, false);
}

void move_doors2(string &in asTimer)
{
AddPropImpulse("door_1", -8.0, 0, 0, "world");
AddPropImpulse("door_2", -1.0, 0, 0, "world");
AddPropImpulse("door_3", -10.0, 0, 0, "world");
AddPropImpulse("door_4", 5.0, 0, 0, "world");
AddPropImpulse("door_5", 3.0, 0, 0, "world");
AddTimer("doors_move", 0.5, "move_doors3");
PlaySoundAtEntity("", "door_sewer_close.snt", "door_1", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_2", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_3", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_4", 0, false);
}

void move_doors3(string &in asTimer)
{
AddPropImpulse("door_1", 14.0, 0, 0, "world");
AddPropImpulse("door_2", 8.0, 0, 0, "world");
AddPropImpulse("door_3", 6.6, 0, 0, "world");
AddPropImpulse("door_4", -1.0, 0, 0, "world");
AddPropImpulse("door_5", -6.0, 0, 0, "world");
PlaySoundAtEntity("", "door_sewer_close.snt", "door_1", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_2", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_3", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_4", 0, false);
}
//HALL SCARE TWO
void hittingthelights2(string &in asParent, string &in asChild, int alState)
{
AddPropImpulse("door_1", 10.0, 0, 0, "world");
AddPropImpulse("door_2", 10.0, 0, 0, "world");
AddPropImpulse("door_3", 10.0, 0, 0, "world");
AddPropImpulse("door_4", -10.0, 0, 0, "world");
PlaySoundAtEntity("", "door_sewer_close.snt", "door_1", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_2", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_3", 0, false);
PlaySoundAtEntity("", "door_sewer_close.snt", "door_4", 0, false);
}
//HALL SCARE END


//LOOPING HALLS
void loophalls(string &in asEntity)
{
AddTimer("startlook", 0.5, "start_looking");
}

void start_looking(string &in asTimer)
{
StartPlayerLookAt("human_skull_1", 10, 10, "");
PlaySoundAtEntity("", "insanity_baby_cry.snt", "Player", 0, false);
SetPlayerActive(false);
ShowPlayerCrossHairIcons(false);
AddTimer("passout", 2, "pass_out");
FadeOut(1);
}

void pass_out(string &in asTimer)
{
SetLanternDisabled(true);
StartScreenShake(0.05, 0.5, 0.5f, 0.5f);
AddTimer("wakeup", 2, "wake_up");
AddTimer("SS", 6, "scarysound");
}



//START SCARY SOUNDS FOR LOOP
void scarysound(string &in asTimer)
{
PlaySoundAtEntity("", "scare_wall_crawl.snt", "sound_2", 0, false);
PlaySoundAtEntity("", "scare_wall_crawl.snt", "sound_3", 0, false);
AddTimer("SS", 6, "scarysound2");
}

void scarysound2(string &in asTimer)
{
PlaySoundAtEntity("", "scare_wall_crawl.snt", "sound_2", 0, false);
PlaySoundAtEntity("", "scare_wall_crawl.snt", "sound_3", 0, false);
AddTimer("SS", 6, "scarysound");
}
//END SCARY SOUNDS FOR LOOP


void wake_up(string &in asTimer)
{
FadeIn(1);
StartPlayerLookAt("human_skull_2", 10, 10, "");
TeleportPlayer("wake_up_area");
SetPlayerActive(true);
ShowPlayerCrossHairIcons(true);
AddTimer("stoplook", 0.5, "stoplooking");
AddTimer("stoploop", 40, "stop_loop");
}

void stoplooking(string &in asTimer)
{
StopPlayerLookAt();
}

void stop_loop(string &in asTimer)
{
SetLanternDisabled(false);
SetPlayerActive(false);
ShowPlayerCrossHairIcons(false);
FadeOut(1);
AddTimer("saneback", 3.0, "sanity");
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
}

void sanity(string &in asTimer)
{
PlaySoundAtEntity("", "insanity_baby_cry.snt", "Player", 0, false);
TeleportPlayer("wake_up_area_1");
FadeIn(3);
SetPlayerActive(true);
ShowPlayerCrossHairIcons(true);
StartPlayerLookAt("human_skull_1", 10, 10, "");
AddTimer("finalstop", 3.0, "stoplooking");
RemoveTimer("SS");
AddEntityCollideCallback("Player", "hitthelights", "hittingthelights2", true, 1);
}



//CANDLES IN LOOPING HALL
void light_1(string &in asEntity)
{
SetLampLit("light_1b", true, false);
}

void light_2(string &in asEntity)
{
SetLampLit("light_2b", true, false);
}

void light_3(string &in asEntity)
{
SetLampLit("light_3b", true, false);
}

void light_4(string &in asEntity)
{
SetLampLit("light_4b", true, false);
}


void light_1b(string &in asEntity)
{
SetLampLit("light_1a", true, false);
}

void light_2b(string &in asEntity)
{
SetLampLit("light_2a", true, false);
}

void light_3b(string &in asEntity)
{
SetLampLit("light_3a", true, false);
}

void light_4b(string &in asEntity)
{
SetLampLit("light_4a", true, false);
}
//END CANDELS 
//END LOOPING HALLS

void OnLeave()
{

}