Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Problem with script
amusei Offline
Junior Member

Posts: 23
Threads: 8
Joined: Aug 2012
Reputation: 2
#1
Problem with script

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.

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);
    }
09-04-2012, 06:16 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Problem with script

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.

Trying is the first step to success.
09-04-2012, 07:08 AM
Find
ferryadams10 Offline
Senior Member

Posts: 288
Threads: 40
Joined: Apr 2011
Reputation: 19
#3
RE: Problem with script

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.

Got a nice sofa
Please come and have a seat for a while

(This post was last modified: 09-04-2012, 01:18 PM by ferryadams10.)
09-04-2012, 01:13 PM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: Problem with script

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:

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.
if( someVar == false && someOtherVar == true)

//Is Identical to writing:

if( !someVar && someOtherVar )
(This post was last modified: 09-04-2012, 05:01 PM by Apjjm.)
09-04-2012, 05:00 PM
Find
GoranGaming Offline
Member

Posts: 183
Threads: 30
Joined: Feb 2012
Reputation: 7
#5
RE: Problem with script

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

Current projects:

The Dark Prison 85 % (Stopped working on this one)

Unnamed Project 7 %
09-04-2012, 08:07 PM
Website Find




Users browsing this thread: 2 Guest(s)