Frictional Games Forum (read-only)
[SCRIPT] Problem with script - 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] Problem with script (/thread-18147.html)



Problem with script - amusei - 09-04-2012

Hi, forum.

Is there any way to check if an entity is active? I have tried using GetEntityExists but it doesn't work (I think it checks if an entity exists in any state - active or not). Or maybe I made a mistake with my script? Here it is.

Code:
void OnStart()
{
    SetEntityPlayerInteractCallback("bedroom_key", "ActivateMonster", true);
}

void ActivateMonster(string &in asEntity)
{
    if(GetEntityExists("grunt_1") == false && GetEntityExists("brute_1") == false
&& GetEntityExists("brute_2") == true)
    {
        SetEntityActive("grunt_1", true);
    }
  
        else if(GetEntityExists("grunt_1") == false &&
GetEntityExists("brute_1") == true &&
GetEntityExists("brute_2") == true)
    {
        SetEntityActive("brute_1", false);
        SetEntityActive("grunt_1", true);
    }



RE: Problem with script - FlawlessHappiness - 09-04-2012

Yep i've tried that too... Can't get it to work... I checked the prison in the real game, and with at least some of the monsters they just make the grunts collide with an area.


RE: Problem with script - ferryadams10 - 09-04-2012

but if you want something to happen as soon as the grunt gets active then why not putting the thing you want to happen inbetween the same brackets as the SetEntityActive("grunt_1", true); script?

I'm not very good at explaining so I'll just tell you what to use.
Try doing what you wanna do with timers and basic scripts instead of all the variables which will get you confused.


RE: Problem with script - Apjjm - 09-04-2012

One solution is to create a huge script area (make it big enough to cover the entire map) and call it "ScriptArea_WORLD". Then you can just create the following function:

Code:
bool GetEntityActive(string &in asEntity) { return GetEntitiesCollide(asEntity,"ScriptArea_WORLD"); }

Edit:
I'd also like to point out, that with boolean variables (true/false variables) you do not need to use ==.

E.g.
Code:
if( someVar == false && someOtherVar == true)

//Is Identical to writing:

if( !someVar && someOtherVar )



RE: Problem with script - GoranGaming - 09-04-2012

You can also use Variables, add a variable for every monster and then you check them.