Frictional Games Forum (read-only)
Script not running! - 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 not running! (/thread-9992.html)



Script not running! - MGermundsson - 08-26-2011

Help!

I am trying to activate an enemy (+ patrolnodes), make the player look at him for 1 second, then be able to look freely but noticing boxes in your way that wasn't there before! I get no error, it simply doesn't do anything at all, i tried the .hps file to activate the enemy as soon as it started and the .hps works fine...but not the script! Please help!

Code:
void OnEnter()
{
    AddEntityCollideCallback("Player", "AreaChaseGrunt", "ActivateChaseGrunt", true, 1);
    AddEntityCollideCallback("servant_brute_1", "ScriptArea2", "Monsterdeactive", true, 1);
    SetEntityActive("ge_box_wood01_1", false);
    SetEntityActive("ge_box_wood01_2", false);
    SetEntityActive("ge_box_wood01_3", false);
    SetEntityActive("ge_box_wood01_4", false);
    SetEntityActive("ge_box_wood01_5", false);
    SetEntityActive("ge_box_wood01_6", false);
    SetEntityActive("ge_box_wood01_7", false);
    SetEntityActive("ge_box_wood01_8", false);
}

void ActivateChaseGrunt(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_brute_1", true);
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_3", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_4", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_5", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_6", 1, "");
    StartPlayerLookAt("servant_brute_1", 10.0f, 10.0f, "");
    AddTimer("StopStare", 1, "StopPlayerLookAt");
}

void StopPlayerLookAt(string &in asTimer)
{
    StopPlayerLookAt();
    SetEntityActive("ge_box_wood01_1", true);
    SetEntityActive("ge_box_wood01_2", true);
    SetEntityActive("ge_box_wood01_3", true);
    SetEntityActive("ge_box_wood01_4", true);
    SetEntityActive("ge_box_wood01_5", true);
    SetEntityActive("ge_box_wood01_6", true);
    SetEntityActive("ge_box_wood01_7", true);
    SetEntityActive("ge_box_wood01_8", true);
}

void Monsterdeactive(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_brute_1", false);
}

void OnLeave()
{

}

I can't see any bugs in the code...so please help me, i have done everything i could think of!!![/font]


RE: Script not running! - Kyle - 08-26-2011

Right when I saw it, I've seen a major problem. Change "void OnEnter()" to "void OnStart()".


RE: Script not running! - MGermundsson - 08-26-2011

No! It doesn't work!

I see no reason for it not to work!
I have the area and script named the same. So i don't see why it don't want to work!


RE: Script not running! - Kyle - 08-26-2011

Is there an error report? :/


RE: Script not running! - Elven - 08-26-2011

Make sure you don't have double OnStart() now Smile


RE: Script not running! - MGermundsson - 08-26-2011

No there's no error report and i only have one onStart()!


RE: Script not running! - Kyle - 08-26-2011

Try this:

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "AreaChaseGrunt", "ActivateChaseGrunt", true, 1);
    AddEntityCollideCallback("servant_brute_1", "ScriptArea2", "Monsterdeactive", true, 1);
    SetEntityActive("ge_box_wood01_1", false);
    SetEntityActive("ge_box_wood01_2", false);
    SetEntityActive("ge_box_wood01_3", false);
    SetEntityActive("ge_box_wood01_4", false);
    SetEntityActive("ge_box_wood01_5", false);
    SetEntityActive("ge_box_wood01_6", false);
    SetEntityActive("ge_box_wood01_7", false);
    SetEntityActive("ge_box_wood01_8", false);
}
void ActivateChaseGrunt(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_brute_1", true);
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_3", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_4", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_5", 1, "");
    AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_6", 1, "");
    StartPlayerLookAt("servant_brute_1", 10, 10, "");
    AddTimer("StopStare", 1, "StopPlayerLookAtFunc");
}
void StopPlayerLookAtFunc(string &in asTimer)
{
    StopPlayerLookAt();
    SetEntityActive("ge_box_wood01_1", true);
    SetEntityActive("ge_box_wood01_2", true);
    SetEntityActive("ge_box_wood01_3", true);
    SetEntityActive("ge_box_wood01_4", true);
    SetEntityActive("ge_box_wood01_5", true);
    SetEntityActive("ge_box_wood01_6", true);
    SetEntityActive("ge_box_wood01_7", true);
    SetEntityActive("ge_box_wood01_8", true);
}
void Monsterdeactive(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_brute_1", false);
}

Also, are you sure the area is called "ScriptArea2" instead of "ScriptArea_2"?

The main problem is that the name of the function, "StopPlayerLookAt", matched one of the game's functions, which caused it to mess up.


RE: Script not running! - MGermundsson - 08-26-2011

Ok problem solved.
I forgot to press enter to rename the area.
A simple mistake, but fatal.