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


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting an Entity Active
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#1
Setting an Entity Active

SetEntityCallbackFunc("lantern", "SetEntityActive"); (so when player picks up lantern, entity is set active (pretty sure this is right)


void SetEntityActive(string &in asEntity, string &in type)
{
SetEntityActive("monster1", "OnPickup");
SetEntityActive("monster2", "OnPickup");
}

that is what the script page seemed like it was saying.. here it is for reference:


void SetEntityCallbackFunc(string& asName, string& asCallback);
Calls a function when the player interacts with a certain entity.
Callback syntax: void MyFunc(string &in asEntity, string &in type)
Type depends on entity type and includes: “OnPickup”, “Break”, “OnIgnite”, etc


I think my callback syntax is messed up, but I don't know!

SetEntityCallbackFunc("lantern", "OnPickup");


void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster1", true);
ShowEnemyPlayerPosition("monster1");
SetEntityActive("monster2", true);
ShowEnemyPlayerPosition("monster2");
}

this should be a bit better, but it still won't work.
(This post was last modified: 06-02-2012, 07:27 AM by TheIcyPickle.)
06-02-2012, 06:31 AM
Find
FlyingFruitcake Offline
Junior Member

Posts: 18
Threads: 4
Joined: May 2012
Reputation: 0
#2
RE: Setting an Entity Active

Are you sure all of your ingame objects have the same name as in the code?

Always watch your back...
06-02-2012, 01:12 PM
Find
Xanthos Offline
Senior Member

Posts: 318
Threads: 9
Joined: Mar 2012
Reputation: 8
#3
RE: Setting an Entity Active

Removed
Spoiler below!


void OnStart()
{
SetEntityCallbackFunc("lantern", "SetEntityActive");
}
void SetEntityActive(string &in asEntity, string &in type)
{
SetEntityActive("monster1", true);
ShowEnemyPlayerPosition("monster1");
SetEntityActive("monster2", true);
ShowEnemyPlayerPosition("monster2");
}

----------EDIT-----------------
Make sure the name of the "lantern" Corresponds with the one in the level editor.

(This post was last modified: 06-02-2012, 01:26 PM by Xanthos.)
06-02-2012, 01:21 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Setting an Entity Active

I'm not sure how you use the OnPickup or OnIgnite, but i believe they are used in an If script. Like

void SetEntityActive(string &in asEntity, string &in type)
if(OnPickup == true)


Anyway i would use the SetEntityPlayerInteractCallback function. This is directly triggered when you interact with an object. Here you don't have to define when it should happen Wink

void OnStart()
{
SetEntityPlayerInteractCallback("lantern", "SetEntityActive", true);
}

void SetEntityActive(string &in asEntity)
{
SetEntityActive("monster1", true);
ShowEnemyPlayerPosition("monster1");
SetEntityActive("monster2", true);
ShowEnemyPlayerPosition("monster2");

}

Trying is the first step to success.
(This post was last modified: 06-02-2012, 01:24 PM by FlawlessHappiness.)
06-02-2012, 01:24 PM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#5
RE: Setting an Entity Active

hmmm, I've tried everything, I've checked the names tried various scripts, even tried the "MonsterFunction" callback and still either an error or nothing happens.

I did find my lantern in game is capitalized so I did that in the editor so its not "Lantern"

otherwise. No luck.

Any Ideas?

The lantern does have alot of things to fill in in the entity tab if that means anything. Like it has things like "CallbackFunc", and a spot for "PlayerInteractCallback" (in the level editor)

but yeah. I don't know.
06-02-2012, 03:24 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Setting an Entity Active

The things you can fill in is instead of making a line inside the void OnStart().

You can try put SetEntityActive in one of them.

I would put it in the PlayerInteractCallback

Trying is the first step to success.
06-02-2012, 06:46 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#7
RE: Setting an Entity Active

Quote:The things you can fill in is instead of making a line inside the void OnStart().

You can try put SetEntityActive in one of them.

I would put it in the PlayerInteractCallback

Idk what this means exactly, but I do not recommend doing any of this.



You're trying to make monsters spawn when you pick up a lantern? (-.-)

Make the lantern named "lantern_1". Make two monsters named "servant_grunt_1", "servant_grunt_2".

void OnStart()
{
SetEntityCallbackFunc("lantern_1", "PickLantern");

//you can also add patrol nodes here, I would recommend this; makes spawning codes cleaner
}

void OnEnter()
{
}

void OnLeave()
{
}

void PickLantern(string &in asEntity, string &in type)
{
SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);

//add your patrol nodes here
}

(This post was last modified: 06-02-2012, 07:11 PM by Putmalk.)
06-02-2012, 07:09 PM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#8
RE: Setting an Entity Active

ok, cool, I tried what you said Putmalk, the script is not invalid, but it just doesn't work, I don't quite know why.

http://www.youtube.com/watch?v=dSKp4yBdFDE this is the video of my custom map and at around 1:36 is the part where two monster next the piano will kill you (they have to) where then you will spawn into a prison type area. (I know soooo original Wink


So I don't think a path node is needed per say. (but what do I know, you are the experts, I'm not lol)

anywho....

SetEntityCallbackFunc("lantern_1", "PickLantern");


then



void PickLantern(string &in asEntity, string &in type)
{
SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);
}

correct? If this is then its not working.
06-02-2012, 07:37 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: Setting an Entity Active

have you tried typing asType instead of just Type?

(string &in asEntity, string &in asType)

Trying is the first step to success.
(This post was last modified: 06-02-2012, 07:42 PM by FlawlessHappiness.)
06-02-2012, 07:42 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#10
RE: Setting an Entity Active

(06-02-2012, 07:42 PM)beecake Wrote: have you tried typing asType instead of just Type?

(string &in asEntity, string &in asType)
Crazily enough, I've used this in my script as well as string &in entity, string &in type...and both worked...

What the hell? (I didn't even realize that they were different).

06-02-2012, 07:46 PM
Find




Users browsing this thread: 1 Guest(s)