Frictional Games Forum (read-only)
Help with scripting - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Help with scripting (/thread-6753.html)



Help with scripting - Algamate - 03-01-2011

I've been working on scripting and just recently I've gotten an error at end of line crash. It said it was at line 314,2 The very end. I'm new at this so any help or criticism would be appreciated! And if anyone knows, is there a way to clean up my script to make it run faster? Like when I enter an area that activates an enemy it lags.
Heres my script, [attachment=1123]


void UseKey(string &in asItem, string &in asEntity)
{
// Set the entity(desk or door) to unlocked
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
// Remove the item used from the inventory
RemoveItem(asItem);
}


void OnStart()
{
PreloadSound("scare_baby_cry"); PreloadSound("react_breath_slow"); PreloadSound("general_wind_whirl");
PreloadSound("scare_male_terrified"); PreloadSound("react_scare"); PreloadSound("react_pant");
PreloadSound("15_slam_door.snt"); PreloadSound("amb_idle_whimp"); PreloadSound("amb_idle_scratch");
PreloadSound("enabled");
SetPlayerLampOil(20);
AddQuest("questtest","questtest");
wakeUp();
AddUseItemCallback("useexit", "Key_1", "Locked_1", "UseKey",true);
AddUseItemCallback("useexit", "Key_2", "Locked_2", "UseKey",true);
AddUseItemCallback("useexit", "Key_5", "Locked_5", "UseKey",true);
AddUseItemCallback("UseKeyOnDoor", "Key_6", "level_wood_1", "UseKeyOnDoor",true);
AddUseItemCallback("UseAcidOnWeb", "chemical_container_2", "web_1", "UseAcidOnWeb", true);
AddEntityCollideCallback("Player", "Area01", "Collide_Area01", true, 1);
AddEntityCollideCallback("Player", "Area02", "Collide_Area02", true, 1);
AddEntityCollideCallback("Player", "Area03", "Collide_Area03", true, 1);
AddEntityCollideCallback("Player", "Area04", "Collide_Area04", true, 1);
AddEntityCollideCallback("Player", "Area06", "Collide_Area06", true, 1);
AddEntityCollideCallback("Player", "Area07", "Collide_Area07", true, 1);
AddEntityCollideCallback("Player", "Area08", "Collide_Area08", true, 1);
AddEntityCollideCallback("Player", "Area09", "Collide_Area09", true, 1);
AddEntityCollideCallback("Player", "Area10", "Collide_Area10", true, 1);
AddEntityCollideCallback("Player", "Area11", "Collide_Area11", true, 1);
AddEntityCollideCallback("Player", "Area12", "Collide_Area12", true, 1);
AddEntityCollideCallback("Player", "Area_Lullaby", "Collide_Area_Lullaby", true, 1);
AddEntityCollideCallback("Player", "AreaIron", "Collide_AreaIron", true, 1);
AddEntityCollideCallback("Player", "Area_grunt3", "Collide_Area_grunt3", true, 1);
AddEntityCollideCallback("Player", "AreaWebQuest", "Collide_AreaWebQuest", true, 1);
AddEntityCollideCallback("Player", "WaterLurkerArea", "Collide_WaterLurkerArea", true, 1);
AddEntityCollideCallback("Player", "AreaDoorProblem", "Collide_AreaDoorProblem", true, 1);
AddEntityCollideCallback("Player", "AreaKeeper, "Collide_AreaKeeper", true, 1);
PlayMusic("First_Night.ogg", true, 1, 3, 0, true);
}
void Collide_Area01(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "scare_baby_cry.snt", "Area01", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
SetMessage("Message", "Text2", 0);
}
void Collide_Area02(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "scare_male_terrified.snt", "Area02", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area03(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt_1", true);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
}


void Collide_WaterLurkerArea(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("waterlurker_1", true);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
}


void Collide_Area04(string &in asParent, string &in asChild, int alState)
{ //Plays the wind sound in the area
PlaySoundAtEntity("windwhirl", "general_wind_whirl.snt", "Area05", 0.0f, false);
//Creates the wind effect in the area
CreateParticleSystemAtEntity("pswhirl", "ps_dust_whirl.ps", "Area05", false);
AddPropImpulse("WindDoor", 40.0f, 0.0f, 0.0f, "World");
StartScreenShake(0.25f, 0.1f, 0.25f, 0.1f);
PlaySoundAtEntity("doorslam", "15_slam_door.snt", "WindDoor", 0.0, false);
GiveSanityDamage(30, true);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}

void Collide_AreaIron(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("pswhirl", "ps_iron_maiden_event_smoke.ps", "iron_maiden_1", false);
AddPropImpulse("iron_maiden_1", -40.0f, 0.0f, 0.0f, "World");
StartScreenShake(0.25f, 0.1f, 0.25f, 0.1f);
GiveSanityDamage(15, true);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}


void Collide_Area06(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt_2", true);
AddEnemyPatrolNode("grunt_2", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_18", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_19", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_20", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_22", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_25", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_27", 0, "");
AddTimer("enemy1", 90, "TimerEnemy");
SetMessage("Message", "Text1", 0);
PlaySoundAtEntity("sons", "enabled.snt", "Player", 0.0, false);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
AutoSave();
}

void Collide_Area_grunt3(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Grunt_3", true);
AddEnemyPatrolNode("Grunt_3", "PathNodeArea_74", 0, "");
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
AddPropImpulse("Locked_6", 40.0f, 0.0f, 0.0f, "World");
AutoSave();
}

void Collide_Area07(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "amb_idle_whimp.snt", "Area07", 0.0, false);
PlaySoundAtEntity("sons", "04_big_feet.snt", "Area07", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area08(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "amb_idle_scratch.snt", "Area08", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area09(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "amb_alert02.snt", "Area09", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area10(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "21_girl_cry.snt", "Area10", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area_Lullaby(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "Dead Space 2 Ring Around The Rosie Trailer.snt", "agrippa_headless_1", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area12(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Brute_1", true);
SetEntityActive("waterlurker_1", false);
AddEnemyPatrolNode("Brute_1", "PathNodeArea_38", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_40", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_53", 10, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_59", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_66", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_73", 10, "");
AddTimer("enemy2", 100, "TimerEnemy2");
SetMessage("Message", "Text1", 0);
PlaySoundAtEntity("sons", "enabled.snt", "Player", 0.0, false);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
AutoSave();
}

void TimerEnemy(string &in asTimer)
{
if(asTimer == "enemy1"){
SetEntityActive("grunt_2", false);
}
}


void TimerEnemy2(string &in asTimer)
{
if(asTimer == "enemy2"){
SetEntityActive("Brute_1", false);
}
}


void Collide_AreaWebQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("Web", "Web");
SetEntityActive(asChild, false);
}
void UseAcidOnWeb(string &in asItem, string &in asEntity)
{
SetPropHealth(asEntity, 0);
RemoveItem(asItem);
GiveItemFromFile("empty_container", "chemical_container.ent");

CompleteQuest("Web", "Web");

GiveSanityBoost();

AddTimer("music", 1, "TimerMusicDelay");

FadeLightTo("PointLightAcid", -1, -1, -1, -1, 3, 1.5f);
AddTimer("PointLightAcid", 4, "TimerFadeAcidLight");
}
void TimerMusicDelay(string &in asTimer)
{
PlayMusic("02_puzzle", false, 1, 0.1f, 10, false);
}
void TimerFadeAcidLight(string &in asTimer)
{
FadeLightTo(asTimer, 0, 0, 0, 0, -1, 3);
}

void PlayerInteractDoor(string &in asEntity)
{
if(HasItem("key_6")) SetMessage("Ch01Level02", "InteractDoorHaveKey", 0);
else AddQuest("02LockedDoor", "02LockedDoor");
}
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("unlocked", "unlock_door", asEntity, 0.0f, false);

GiveSanityBoostSmall();

SetLevelDoorLocked(asEntity, false);
RemoveItem(asItem);

CompleteQuest("02LockedDoor", "02LockedDoor");
}
void Collide_AreaDoorProblem(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "noticegrunt.snt", "Locked_6", 0.0, false);
StartPlayerLookAt("Locked_6",2.0f,5.0f,"");
SetPlayerActive(false);
AddPropHealth("Locked_6",-20.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
AddTimer("DoorExplosion1",1.5f,"DoorProblemTimer");
AddTimer("DoorExplosion2",3.5f,"DoorProblemTimer");
AddTimer("DoorExplosion3",5.5f,"DoorProblemTimer");
AddTimer("DoorExplosion4",6.0f,"DoorProblemTimer");
}
void DoorProblemTimer(string &in asTimer)
{
if(asTimer == "DoorExplosion1")
{
GiveSanityDamage(30, true);
AddPropHealth("Locked_6",-30.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}
if(asTimer == "DoorExplosion2")
{
AddPropHealth("Locked_6",-30.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}
if(asTimer == "DoorExplosion3")
{
AddPropImpulse("Locked_6",100,0,0.0f,"world");
AddPropHealth("Locked_6",-50.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
SetLampLit("candle1", false, true);
}
if(asTimer == "DoorExplosion4")
{
SetPlayerActive(true);
StopPlayerLookAt();
}
if(asTimer == "DoorExplosion5")
{
SetPlayerActive(true);
StopPlayerLookAt();
}
}

void Collide_AreaKeeper(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("keeper_grunt_1", true);
GiveSanityDamage(60, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
StartPlayerLookAt("keeper_grunt_1",2.0f,5.0f,"");
SetSwingDoorLocked("castle_7",false,true);
}
void wakeUp () {
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(10); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 200, 200); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true); // Simulates being on the ground
AddTimer("trig1", 5.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer){
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}


RE: Help with scripting - Linus Ă…gren - 03-01-2011

About the error, you forgot a " at the AreaKeeper
Code:
AddEntityCollideCallback("Player", "AreaKeeper, "Collide_AreaKeeper", true, 1);
So the correct code should be:
Code:
void UseKey(string &in asItem, string &in asEntity)
{
// Set the entity(desk or door) to unlocked
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
// Remove the item used from the inventory
RemoveItem(asItem);
}


void OnStart()
{
PreloadSound("scare_baby_cry"); PreloadSound("react_breath_slow"); PreloadSound("general_wind_whirl");
PreloadSound("scare_male_terrified"); PreloadSound("react_scare"); PreloadSound("react_pant");
PreloadSound("15_slam_door.snt"); PreloadSound("amb_idle_whimp"); PreloadSound("amb_idle_scratch");
PreloadSound("enabled");
SetPlayerLampOil(20);
AddQuest("questtest","questtest");
wakeUp();
AddUseItemCallback("useexit", "Key_1", "Locked_1", "UseKey",true);
AddUseItemCallback("useexit", "Key_2", "Locked_2", "UseKey",true);
AddUseItemCallback("useexit", "Key_5", "Locked_5", "UseKey",true);
AddUseItemCallback("UseKeyOnDoor", "Key_6", "level_wood_1", "UseKeyOnDoor",true);
AddUseItemCallback("UseAcidOnWeb", "chemical_container_2", "web_1", "UseAcidOnWeb", true);
AddEntityCollideCallback("Player", "Area01", "Collide_Area01", true, 1);
AddEntityCollideCallback("Player", "Area02", "Collide_Area02", true, 1);
AddEntityCollideCallback("Player", "Area03", "Collide_Area03", true, 1);
AddEntityCollideCallback("Player", "Area04", "Collide_Area04", true, 1);
AddEntityCollideCallback("Player", "Area06", "Collide_Area06", true, 1);
AddEntityCollideCallback("Player", "Area07", "Collide_Area07", true, 1);
AddEntityCollideCallback("Player", "Area08", "Collide_Area08", true, 1);
AddEntityCollideCallback("Player", "Area09", "Collide_Area09", true, 1);
AddEntityCollideCallback("Player", "Area10", "Collide_Area10", true, 1);
AddEntityCollideCallback("Player", "Area11", "Collide_Area11", true, 1);
AddEntityCollideCallback("Player", "Area12", "Collide_Area12", true, 1);
AddEntityCollideCallback("Player", "Area_Lullaby", "Collide_Area_Lullaby", true, 1);
AddEntityCollideCallback("Player", "AreaIron", "Collide_AreaIron", true, 1);
AddEntityCollideCallback("Player", "Area_grunt3", "Collide_Area_grunt3", true, 1);
AddEntityCollideCallback("Player", "AreaWebQuest", "Collide_AreaWebQuest", true, 1);
AddEntityCollideCallback("Player", "WaterLurkerArea", "Collide_WaterLurkerArea", true, 1);
AddEntityCollideCallback("Player", "AreaDoorProblem", "Collide_AreaDoorProblem", true, 1);
AddEntityCollideCallback("Player", "AreaKeeper", "Collide_AreaKeeper", true, 1);
PlayMusic("First_Night.ogg", true, 1, 3, 0, true);
}
void Collide_Area01(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "scare_baby_cry.snt", "Area01", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
SetMessage("Message", "Text2", 0);
}
void Collide_Area02(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "scare_male_terrified.snt", "Area02", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area03(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt_1", true);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
}


void Collide_WaterLurkerArea(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("waterlurker_1", true);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
}


void Collide_Area04(string &in asParent, string &in asChild, int alState)
{ //Plays the wind sound in the area
PlaySoundAtEntity("windwhirl", "general_wind_whirl.snt", "Area05", 0.0f, false);
//Creates the wind effect in the area
CreateParticleSystemAtEntity("pswhirl", "ps_dust_whirl.ps", "Area05", false);
AddPropImpulse("WindDoor", 40.0f, 0.0f, 0.0f, "World");
StartScreenShake(0.25f, 0.1f, 0.25f, 0.1f);
PlaySoundAtEntity("doorslam", "15_slam_door.snt", "WindDoor", 0.0, false);
GiveSanityDamage(30, true);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}

void Collide_AreaIron(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("pswhirl", "ps_iron_maiden_event_smoke.ps", "iron_maiden_1", false);
AddPropImpulse("iron_maiden_1", -40.0f, 0.0f, 0.0f, "World");
StartScreenShake(0.25f, 0.1f, 0.25f, 0.1f);
GiveSanityDamage(15, true);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}


void Collide_Area06(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt_2", true);
AddEnemyPatrolNode("grunt_2", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_18", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_19", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_20", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_22", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_25", 0, "");
AddEnemyPatrolNode("grunt_2", "PathNodeArea_27", 0, "");
AddTimer("enemy1", 90, "TimerEnemy");
SetMessage("Message", "Text1", 0);
PlaySoundAtEntity("sons", "enabled.snt", "Player", 0.0, false);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
AutoSave();
}

void Collide_Area_grunt3(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Grunt_3", true);
AddEnemyPatrolNode("Grunt_3", "PathNodeArea_74", 0, "");
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
AddPropImpulse("Locked_6", 40.0f, 0.0f, 0.0f, "World");
AutoSave();
}

void Collide_Area07(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "amb_idle_whimp.snt", "Area07", 0.0, false);
PlaySoundAtEntity("sons", "04_big_feet.snt", "Area07", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area08(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "amb_idle_scratch.snt", "Area08", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area09(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "amb_alert02.snt", "Area09", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area10(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "21_girl_cry.snt", "Area10", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area_Lullaby(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "Dead Space 2 Ring Around The Rosie Trailer.snt", "agrippa_headless_1", 0.0, false);
GiveSanityDamage(5, false);
PlaySoundAtEntity("sons", "react_breath_slow.snt", "Player", 0.0, false);
}

void Collide_Area12(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Brute_1", true);
SetEntityActive("waterlurker_1", false);
AddEnemyPatrolNode("Brute_1", "PathNodeArea_38", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_40", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_53", 10, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_59", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_66", 0, "");
AddEnemyPatrolNode("Brute_1", "PathNodeArea_73", 10, "");
AddTimer("enemy2", 100, "TimerEnemy2");
SetMessage("Message", "Text1", 0);
PlaySoundAtEntity("sons", "enabled.snt", "Player", 0.0, false);
GiveSanityDamage(30, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
AutoSave();
}

void TimerEnemy(string &in asTimer)
{
if(asTimer == "enemy1"){
SetEntityActive("grunt_2", false);
}
}


void TimerEnemy2(string &in asTimer)
{
if(asTimer == "enemy2"){
SetEntityActive("Brute_1", false);
}
}


void Collide_AreaWebQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("Web", "Web");
SetEntityActive(asChild, false);
}
void UseAcidOnWeb(string &in asItem, string &in asEntity)
{
SetPropHealth(asEntity, 0);
RemoveItem(asItem);
GiveItemFromFile("empty_container", "chemical_container.ent");

CompleteQuest("Web", "Web");

GiveSanityBoost();

AddTimer("music", 1, "TimerMusicDelay");

FadeLightTo("PointLightAcid", -1, -1, -1, -1, 3, 1.5f);
AddTimer("PointLightAcid", 4, "TimerFadeAcidLight");
}
void TimerMusicDelay(string &in asTimer)
{
PlayMusic("02_puzzle", false, 1, 0.1f, 10, false);
}
void TimerFadeAcidLight(string &in asTimer)
{
FadeLightTo(asTimer, 0, 0, 0, 0, -1, 3);
}

void PlayerInteractDoor(string &in asEntity)
{
if(HasItem("key_6")) SetMessage("Ch01Level02", "InteractDoorHaveKey", 0);
else AddQuest("02LockedDoor", "02LockedDoor");
}
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("unlocked", "unlock_door", asEntity, 0.0f, false);

GiveSanityBoostSmall();

SetLevelDoorLocked(asEntity, false);
RemoveItem(asItem);

CompleteQuest("02LockedDoor", "02LockedDoor");
}
void Collide_AreaDoorProblem(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sons", "noticegrunt.snt", "Locked_6", 0.0, false);
StartPlayerLookAt("Locked_6",2.0f,5.0f,"");
SetPlayerActive(false);
AddPropHealth("Locked_6",-20.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
AddTimer("DoorExplosion1",1.5f,"DoorProblemTimer");
AddTimer("DoorExplosion2",3.5f,"DoorProblemTimer");
AddTimer("DoorExplosion3",5.5f,"DoorProblemTimer");
AddTimer("DoorExplosion4",6.0f,"DoorProblemTimer");
}
void DoorProblemTimer(string &in asTimer)
{
if(asTimer == "DoorExplosion1")
{
GiveSanityDamage(30, true);
AddPropHealth("Locked_6",-30.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}
if(asTimer == "DoorExplosion2")
{
AddPropHealth("Locked_6",-30.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
}
if(asTimer == "DoorExplosion3")
{
AddPropImpulse("Locked_6",100,0,0.0f,"world");
AddPropHealth("Locked_6",-50.0);
PlaySoundAtEntity("sons", "react_pant.snt", "Player", 0.0, false);
SetLampLit("candle1", false, true);
}
if(asTimer == "DoorExplosion4")
{
SetPlayerActive(true);
StopPlayerLookAt();
}
if(asTimer == "DoorExplosion5")
{
SetPlayerActive(true);
StopPlayerLookAt();
}
}

void Collide_AreaKeeper(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("keeper_grunt_1", true);
GiveSanityDamage(60, true); //10 = amount of damage, true = effects are used (vision distorts and such)
PlaySoundAtEntity("sons", "react_scare.snt", "Player", 0.0, false);
StartPlayerLookAt("keeper_grunt_1",2.0f,5.0f,"");
SetSwingDoorLocked("castle_7",false,true);
}
void wakeUp () {
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(10); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 200, 200); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true); // Simulates being on the ground
AddTimer("trig1", 5.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer){
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

Now I haven't checked for more errors as that one was the most clear one. If you encounter any other, reply to this Wink