////////////////////////////
// Run first time starting map
void OnStart()
{
	AddUseItemCallback("", "key_tomb_rusty_1", "prison_1", "UsedKeyOnDoor", true);
	AddEntityCollideCallback("Player", "PlayerCollide_1PlayerCollide", "MonsterFunction_1", true, 1);
	AddEntityCollideCallback("Player", "PlayerCollide_2PlayerCollide", "MonsterFunction_2", true, 1);
	AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
	AddEntityCollideCallback("Player", "stein", "fall", true, 1);
	AddEntityCollideCallback("Player", "neuerweg", "ha", true, 1);
	PlayMusic("01_amb_darkness.ogg", true, 1.0f, 0.0f, 3, true);
	InteractConnectPropWithMoveObject("ValveSouthDoor","valve_iron_rusty02_1", "wooden_slide_door_1",true, false, 0);
	InteractConnectPropWithMoveObject("ValveSouthDoor","valve_iron_rusty02_2", "wooden_slide_door_1",true, false, 0);
	
}



void MonsterFunction_1(string &in asParent, string &in asChild, int alState)

{ 
SetEntityActive("servant_grunt_2", true);
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_10", 0, "");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{
	
    SetSwingDoorLocked("prison_1", false, true);
    PlaySoundAtEntity("", "unlock_door", "prison_1", 0, false);
    RemoveItem("key_tomb_rusty_1");
}

void MonsterFunction_2(string &in asParent, string &in asChild, int alState)

{
SetEntityActive("waterlurker_1", true); 
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_11", 2, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_12", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_13", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_14", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_15", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_9", 0, "");
AddEnemyPatrolNode("waterlurker_1", "PathNodeArea_16", 0, "");
}
void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("servant_grunt_2", 10.0f, 10.0f, "");
GiveSanityDamage(100.0f, true);
AddTimer("", 1.0f, "stoplook");
SetLampLit("torch_static01_8", true, false);
SetLampLit("torch_static01_9", true, false);
SetLampLit("torch_static01_10", true, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
SetEntityActive("torch_static01_8", true);
SetEntityActive("torch_static01_9", true); 
SetEntityActive("torch_static01_10", true); 
}
void stoplook(string &in asTimer)

{
StopPlayerLookAt();
}




void fall(string &in asParent, string &in asChild, int alState)
{

SetEntityActive("stone_small01_brown_5", true);
SetEntityActive("stone_med01_brown_1", true);
SetEntityActive("stone_small01_brown_6", true);
}
void ha(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("armour_rusty_complete_5", 7.0f, 10.0f, "");
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
AddTimer("", 1.5f, "weg");
SetEntityActive("armour_rusty_complete_5", true);
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
}
void weg(string &in asTimer)
{
SetEntityActive("castle_4", true);
SetEntityActive("castle_3", false);
FadeOut(2.0f);
FadePlayerRollTo(90, 150, 50);
SetPlayerActive(false);
SetPlayerCrouching(true);
AddTimer("", 2.5f, "stein");
AddTimer("", 9.0f, "hell");
AddTimer("", 12.0f, "stehen");
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0, false);
PlaySoundAtEntity("", "player_bodyfall.snt", "Player", 0, false);
SetLanternDisabled(true);
StartPlayerLookAt("rock_med01_push_1", 2.0f, 10.0f, "");
SetEntityActive("stone_small01_brown_7", true);
SetEntityActive("stone_small01_1", true);
SetEntityActive("stone_med01_brown_3", true);
SetEntityActive("stone_med01_brown_2", true);
SetEntityActive("armour_rusty_complete_5", false);


}
void stein(string &in asTimer)
{
SetEntityActive("cave_in_2", true);
SetEntityActive("cave_in_1", true);
SetEntityActive("torch_static01_1", false); 
SetEntityActive("torch_static01_2", false); 
SetEntityActive("torch_static01_3", false);
SetEntityActive("torch_static01_4", false); 
SetEntityActive("torch_static01_5", false); 
SetEntityActive("torch_static01_6", false); 
SetEntityActive("torch_static01_7", false); 
SetEntityActive("stone_small01_brown_7", false);
SetEntityActive("stone_small01_1", false);
SetEntityActive("stone_med01_brown_3", false);
SetEntityActive("stone_med01_brown_2", false);
}
void hell(string &in asTimer)
{
FadeIn(6.0f);

}
void stehen(string &in asTimer)
{
FadePlayerRollTo(0.0f, 33.0f, 33.0f); 
SetPlayerActive(true);
SetPlayerCrouching(false);
StopPlayerLookAt();
AddTimer("", 1.5f, "nachricht");
}

void nachricht(string &in asTimer)
{
SetMessage("textlol", "textlols", 8.0f);
AddQuest("lampenquestlol", "lampenquest");
}


void Close_SlideDoor(string &in asEntityName, int alState)
{
	SetMoveObjectStateExt("wooden_slide_door_1", 0.0f, 8, 10, 1.1f, true);
}



////////////////////////////
// Run when entering map
void OnEnter()
{
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}