////////////////////////////
// Run when the map starts
void OnStart()
{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("enemy_suitor_1", "MonsterEnd", "MonsterEnd", true, 1);
AddEntityCollideCallback("Player", "Baumfall", "PlaySound2", true, 1);
AddEntityCollideCallback("Player", "Monsterbrute", "PlaySound3", true, 1);
AddEntityCollideCallback("Player", "rain", "rain", true, 1);
AddUseItemCallback("", "stone_hammer_1", "padlock_1", "hammermove", true);
AddUseItemCallback("", "superkey", "hatch_metal01_1", "superkey", true);
PlayMusic("12_amb.ogg", true, 1.0f, 0.0f, 4, true);
AddEntityCollideCallback("Player", "Feuer", "trocknen", true, 1);
AddEntityCollideCallback("Player", "Hammerquest", "hammerquestf", true, 1);
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)

{	
	SetEntityActive("enemy_suitor_1", true); 
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_2", 3, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_3", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_4", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_5", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_6", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_8", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_9", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_10", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_11", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_12", 0, "");
	AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_13", 0, "");
	CheckPoint("", "PlayerStartArea_6", "", "", "");
}

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

{
	SetEntityActive("enemy_suitor_1", false);
}

void PlaySound2(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "11_forest_minor.snt", "Player", 0, false);
}
void PlaySound3(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "scare_ghost.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
StartScreenShake(1.0f, 1.5f, 0.75f, 0.75f);
FadeSepiaColorTo(1.5f, 0.0f);
AddTimer("", 1.0f, "lol");
}
void lol(string &in asTimer)
{
SetEntityActive("corpse_bloody_1", true);
SetEntityActive("slime_3way_1", true);
SetEntityActive("slime_pile_large_1", true);
SetEntityActive("slime_6way_1", true);
SetEntityActive("slime_pile_1", true);
SetEntityActive("slime_egg_1", true);
GiveSanityDamage(25.0f, true);
FadeIn(0.0f);

}
void rain(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "03_wind.snt", "rain", 0.0f, false);
PlaySoundAtEntity("", "general_rain_no3d_low.snt", "rain", 0.0f, false);
}
////////////////HAMMERACTION/////////////////////////////////////////////////////////////////////////

void hammermove(string &in asItem, string &in asEntity)
{
SetEntityActive("stone_hammer_move_1", true);

AddTimer("", 0.75f, "schlag1");
AddTimer("", 1.1f, "schlag2");
AddTimer("", 1.4f, "schlag3");
}
void schlag1(string &in asTimer)
{
SetMoveObjectState("stone_hammer_move_1", 0.3f);
PlaySoundAtEntity("", "impact_metal_high.snt", "padlock_1", 0, false);
}
void schlag2(string &in asTimer)
{
SetMoveObjectState("stone_hammer_move_1", 0.0f);
}
void schlag3(string &in asTimer)
{
SetMoveObjectState("stone_hammer_move_1", 0.30f);
PlaySoundAtEntity("", "impact_metal_high.snt", "padlock_1", 0, false);
AddTimer("", 0.1f, "UsedKeyOnDoor");
}


void UsedKeyOnDoor(string &in asTimer)
{  
    SetEntityActive("padlock_1", false);
	PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
    RemoveItem("stone_hammer_1");
	SetEntityActive("padlockbroken", true);
	AddBodyForce("padlockbroken_Body_1", 0, 0, 50000, "world");
	CreateParticleSystemAtEntity("", "ps_break_pot_plant.ps", "padlockbroken", true);
	PlaySoundAtEntity("", "break_wood_metal.snt", "Player", 0, false);
	SetEntityActive("stone_hammer_move_1", false);
	AddTimer("", 0.1f, "bam");
}
void bam(string &in asTimer)
{
AddBodyForce("padlockbroken_Body_1", 0, 0, 20000, "world");
CompleteQuest("hammeri", "hammerquesttext");
PlaySoundAtEntity("", "ui_sanity_gain.snt", "Player", 0, false);
StartEffectFlash(1.0f, 1.0f, 1.0f);
}
/////////////////////////HAMMERACTION ENDE//////////////////////////////////////////////////////////////
void superkey(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hatch_metal01_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "hatch_metal01_1", 0, false);
RemoveItem("superkey");
}

void trocknen(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("laterne", 5.0f, 5.0f, "");
SetPlayerActive(false);
AddTimer("", 3.0f, "nummereins");
AddTimer("", 6.0f, "nummerzwei");
AddTimer("", 9.0f, "nummerdrei");
AddTimer("", 10.0f, "nummervier");
AddTimer("", 1.0f, "nummernull");
}
void nummernull(string &in asTimer)
{
SetEntityActive("laterne", true);
PlaySoundAtEntity("", "ui_lantern_on.snt", "laterne", 0, false);
}
void nummereins(string &in asTimer)
{
StartPlayerLookAt("human_bone_1", 5.0f, 5.0f, "");
}
void nummerzwei(string &in asTimer)
{
StartPlayerLookAt("human_bone_2", 5.0f, 5.0f, "");
}
void nummerdrei(string &in asTimer)
{
StartPlayerLookAt("laterne", 5.0f, 5.0f, "");
}

void nummervier(string &in asTimer)
{
SetLanternDisabled(false);
SetPlayerActive(true);
SetEntityActive("laterne", false);
PlaySoundAtEntity("", "ui_lantern_off.snt", "laterne", 0, false);
StopPlayerLookAt();
SetMessage("feuer", "feuern", 8.0f);
CompleteQuest("lampenquestlol", "lampenquest");
PlaySoundAtEntity("", "ui_sanity_gain.snt", "Player", 0, false);
StartEffectFlash(1.0f, 1.0f, 1.0f);
}

void hammerquestf(string &in asParent, string &in asChild, int alState)
{
AddQuest("hammeri", "hammerquesttext");
}




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

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

