//Global Variables
bool GruntScareDone = false;
bool chairScare = false;
////////////////////////////
// Run first time starting map
void OnStart()
{
//Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}
SetEntityPlayerInteractCallback("Key_1", "HammerScare", true);
AddUseItemCallback("", "Key_1", "mansion_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player","script_chairscare","ChairScare", false, 1);
AddEntityCollideCallback("Player","script_GruntScare","GruntScare",false,1);
SetEntityConnectionStateChangeCallback("lever_nice01_1", "func_shelf");
AddEntityCollideCallback("Player","script_dollscare","DollScare",false,1);
for (int x = 1; x < 23; x++) {
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+x, 0, "");
}
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_1", "Reverse", false, 1);
for (int x = 24; x < 188; x++) {
AddEnemyPatrolNode("servant_brute_deadiler_1", "PathNodeArea_"+x, 0, "");
}
for (int x = 24; x > 0; x--) {
AddEnemyPatrolNode("servant_brute_deadiler_1", "PathNodeArea_"+x, 0, "");
}
}
void Reverse() {
for (int x = 23; x > 1; x--) {
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+x, 0, "");
}
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity,false,true);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
void DollScare(string &in entity, string &in type) {
SetEntityActive("ceiling_doll_1",true);
AddPlayerBodyForce(0,0,100000,false);
}
void HammerScare(string &in entity, string &in type)
{
AddPropImpulse("sledge_1", 30, 5, 20, "world");
PlaySoundAtEntity("FistPump", "FistPump.snt","Player", 0, false);
}
void ChairScare(string &in asParent, string &in asChild, int alState)
{
//SetEntityActive("chairscare",false);
if(chairScare == false) {
PlaySoundAtEntity("StephanoScream", "StephanoScream.snt","Player", 0, false);
AddPropImpulse("chairscare", 0, 0, -25, "world");
chairScare = true;
AddTimer("1",2.0f,"StephanoDisappear");
}
}
void GruntScare(string &in asParent, string &in asChild, int alState)
{
if(GruntScareDone == false) {
SetEntityActive("servant_grunt_ragdoll_1",true);
PlaySoundAtEntity("","react_scare","Player",0,false);
AddPropImpulse("servant_grunt_ragdoll_1", 30, 0, 0, "world");
SetEntityActive("Stephano",true);
PlaySoundAtEntity("HelloStephano", "HelloStephano.snt","Player", 0, false);
AddTimer("1",3.0f,"CloseDoor");
AddTimer("2",4.0f,"CloseDoor");
GruntScareDone = true;
}
}
void CloseDoor(string &in asTimer) {
if (asTimer == "1") {
SetSwingDoorClosed("mansion_3", true, true);
SetEntityActive("SpotLight_2",false);
}
if (asTimer == "2") {
SetSwingDoorLocked("mansion_3", true, true);
}
}
void StephanoDisappear(string &in asTimer) {
if(asTimer == "1") {
SetEntityActive("chairscare",false);
}
}
void func_shelf(string &in asEntity, int alState)
{
if (alState == 1)
{
SetMoveObjectState("shelf_secret_door_rot_1",1.0f);
PlaySoundAtEntity("", "quest_completed.snt", "shelf_move_1", 0, false);
return;
}
/* if (alState == 0)
{
SetMoveObjectState("shelf_secret_door_rot_1",0.0f);
return;
}*/
}
void InsaneMoment(string &inEntity) {
SetMoveObjectState("shelf_secret_door_rot_1",0.0f);
StartPlayerLookAt("shelf_secret_door_rot_1",10,100,"");
StartScreenShake(0.3f,10.0f,3.0f,1.0f);
AddTimer("1", 2.0f,"Stare");
AddTimer("2", 4.0f, "Stare");
AddTimer("3", 6.0f, "Stare");
AddTimer("4", 8.0f, "Stare");
AddTimer("5", 10.0f, "Stare");
AddTimer("6", 12.0f, "Stare");
AddTimer("7", 14.0f, "Stare");
}
void Introduce(string &inEntity) {
PlaySoundAtEntity("IntroduceMartin", "IntroduceMartin.snt","Player", 0, false);
}
void Stare(string &in asTimer) {
if(asTimer == "1") {
SetEntityActive("painting_portrait_insane_1", true);
CreateParticleSystemAtEntity("PSDustPainting", "ps_ghost_release.ps", "painting_portrait_insane_1", false);
StartPlayerLookAt("painting_portrait_insane_1", 10, 100, "");
PlaySoundAtEntity("snd_scare", "react_scare.snt", "Player", 0.0, false);
GiveSanityDamage(3, true);
CreateParticleSystemAtEntity("PSRoses", "rose_petals_loop.ps", "chandelier_nice_1", false);
}
if(asTimer == "2") {
SetEntityActive("spider_2",true);
StartPlayerLookAt("spider_2", 10, 100, "");
GiveSanityDamage(3, true);
}
if(asTimer == "3") {
StopPlayerLookAt();
SetLampLit("chandelier_nice_1", false, false);
SetLampLit("bonfire_1", true, true);
}
if(asTimer == "4") {
SetEntityActive("chandelier_nice_1", false);
SetEntityActive("hanging_prisoner_1", true);
StartPlayerLookAt("hanging_prisoner_1", 10, 100, "");
GiveSanityDamage(3, true);
}
if(asTimer == "5") {
StopPlayerLookAt();
SetEntityActive("corpse_male_1", true);
StartPlayerLookAt("corpse_male_1", 10, 100, "");
AddPropImpulse("corpse_male_1",0,0,-200, "world");
GiveSanityDamage(10,true);
}
if(asTimer == "6") {
StopPlayerLookAt();
SetEntityActive("painting_portrait_insane_1", false);
SetEntityActive("spider_2",false);
SetEntityActive("chandelier_nice_1", false);
SetEntityActive("hanging_prisoner_1", false);
SetEntityActive("corpse_male_1", false);
SetEntityActive("chandelier_nice_1", true);
SetMoveObjectState("shelf_secret_door_rot_1",1.0f);
if(asTimer == "7") {
SetEntityActive("CustomPainting_1",true);
}
}
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}