Frictional Games Forum (read-only)
[SCRIPT] LocalVariables acting up. [CASE CLOSED] - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] LocalVariables acting up. [CASE CLOSED] (/thread-13984.html)



LocalVariables acting up. [CASE CLOSED] - araphon1 - 03-14-2012

Im trying to create an event where you pick up a note, and a grunt spawn behind you, you turn and look at him and he walks out the door into a hallway. When you move out into the hallway, youll hear a noise to the left and youll catch a glimpse of the grunt just as he rounds the corner of the hallway further down.

What I did is this(Note, I wont post my entire .hps in here, just the things that matters, and in an orderly manner:

Code:
void OnStart()
{
SetEntityPlayerInteractCallback("notetwo","scare1",true);
AddEntityCollideCallback("Bro_1", "monsterStand_1", "monsterDelete1", true, 0);
AddEntityCollideCallback("Bro_2", "monsterStand_2", "monsterDelete2", true, 0);
AddEntityCollideCallback("Player", "EventArea_1", "Event1", false, -1));
}

Here I set up the groundwork, when you pick up notetwo, activate scare1, and then delete the event.
I also set up despawn areas where the grunts will despawn upon entry. These look like this:

Code:
void monsterDelete1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Bro_1", false);
}
void monsterDelete2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Bro_2", false);
}

Nothing fancy. This is how the main "grunt control" scripts look like:

Code:
void scare1(string &in asItem)
{
PlaySoundAtEntity("","enabled.snt", "Player", 0, false);
SetEntityActive("Bro_1",true);
GiveSanityDamage(50.0f,true);
AddEnemyPatrolNode("Bro_1","PathNodeArea_1",3,"idle");
AddEnemyPatrolNode("Bro_1","PathNodeArea_2",0,"idle");
AddEnemyPatrolNode("Bro_1","PathNodeArea_3",0,"idle");
StartPlayerLookAt("Bro_1", 8, 8, "");
SetPlayerCrouching(true);
SetPlayerActive(false);
SetLanternDisabled(true);
AddTimer("", 8, "stoplookingatme");
}

void stoplookingatme(string &in asTimer)
{
SetPlayerCrouching(false);
SetPlayerActive(true);
SetLanternDisabled(false);
StopPlayerLookAt();
SetMessage("Messages", "EventReaction1", 0);
AddLocalVarInt("MonsterSeen_1",1);
}

void Event1(string &in asChild, string &in asParent, int alState)
{
    if(GetLocalVarInt("MonsterSeen_1")==1)
    {
        PlaySoundAtEntity("","amb_hunt.snt", "Bro_2", 0, false);
        SetEntityActive("Bro_2",true);
        AddEnemyPatrolNode("Bro_2","PathNodeArea_4",1,"idle");
        AddEnemyPatrolNode("Bro_2","PathNodeArea_5",0,"idle");
        SetLocalVarInt("MonsterSeen_1",0);
    }
}

So basically (I know this is wall of code) what im trying to achieve is this: Since you have to enter the room, and the "EventArea_1" area is in the doorway, I dont want anything to happen the before you pick up the note, so it will check the variable MonsterSeen_1, and if it's not 1, nothing should happen, right? But I dont want the area to go away either, so I set delete to false. When I pick up the note, the main scare with the camera control sets up. This part is working nicely btw. The grunt looks at you, then leaves the room (through the EventArea_1, which should still be inactive). As the timer reaches 8, you regain control of character and you get a message, and the local variable integer should be 1. The next time I enter EventArea_1 it should check the variable again, and this time, it should come up with 1, and the script should run, the second grunt should spawn, move ofscreen into the despawn area and poof.

However, it does no such thing. The script just refuses to fire off. I have checked, double checked and tripple checked all the names in the editor, as well as everything in the script, but to no avail.

Anyone manage to wrap his head around this and that'd be grand. Cheers.

EDIT: Case closed- Found the problem, I had put a space where it didn't belong -.- Wow, that's just a half day worth of work to find an empty space...