Frictional Games Forum (read-only)
Setting an Entity Active - 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: Setting an Entity Active (/thread-15772.html)

Pages: 1 2 3


Setting an Entity Active - TheIcyPickle - 06-02-2012

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.


RE: Setting an Entity Active - FlyingFruitcake - 06-02-2012

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


RE: Setting an Entity Active - Xanthos - 06-02-2012

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.


RE: Setting an Entity Active - FlawlessHappiness - 06-02-2012

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");

}


RE: Setting an Entity Active - TheIcyPickle - 06-02-2012

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.


RE: Setting an Entity Active - FlawlessHappiness - 06-02-2012

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


RE: Setting an Entity Active - Putmalk - 06-02-2012

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".

Code:
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
}



RE: Setting an Entity Active - TheIcyPickle - 06-02-2012

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.


RE: Setting an Entity Active - FlawlessHappiness - 06-02-2012

have you tried typing asType instead of just Type?

(string &in asEntity, string &in asType)


RE: Setting an Entity Active - Putmalk - 06-02-2012

(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).