Frictional Games Forum (read-only)
Making a grunt appear after keypickup - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Making a grunt appear after keypickup (/thread-7253.html)



Making a grunt appear after keypickup - lordmestari - 04-08-2011

Hello, I am pretty new to scripting and all that, and I require your help.

Basically the player picks up a key, and a grunt should appear behind the door to the room. How do I do this?

I've already done this with a tinderbox, my script looks like this:


void TakeTinder(string &in asEntity)
{
SetEntityActive("servant_grunt_1", true);
}

void OnStart()
{
SetEntityPlayerInteractCallback("tinderbox_1", "TakeTinder", true);
}


void OnEnter()
{

}

void OnLeave()
{

}

Thank you


RE: Making a grunt appear after keypickup - MrBigzy - 04-08-2011

Use SetEntityCallbackFunc(string& asName, string& asCallback) for this one. It'll call the function based on what entity you use. In the case of the key, it'll call it when you pick it up.


RE: Making a grunt appear after keypickup - Simpanra - 04-08-2011

(04-08-2011, 01:45 PM)MrBigzy Wrote: Use SetEntityCallbackFunc(string& asName, string& asCallback) for this one. It'll call the function based on what entity you use. In the case of the key, it'll call it when you pick it up.

I am curious about how this would work actually, where exactly would you use the set entity callback? Would you replace it with the set player interact func?
Thanks =)


RE: Making a grunt appear after keypickup - MrBigzy - 04-08-2011

Yeah, simply put that one callback in OnStart or somewhere, and link it to the key with the entity name. Or something. That one kinda confuses me actually, cause I don't see how it can tell what entity to use. I used the level editor for this, you can put the function name for the entity right in there.


RE: Making a grunt appear after keypickup - lordmestari - 04-08-2011

Could I have an example of the script? I am a bit confused, but I'll learn.
It would help a lot, and I would appreciate it


RE: Making a grunt appear after keypickup - MrBigzy - 04-08-2011

Code:
void BackTrack(string &in asEntity, string &in asType)
{
   AddEntityCollideCallback("Player", "EnemyBack", "EnemyBack", true, 1);
   AddEntityCollideCallback("Player", "Flicker", "Flicker", true, 1);
   StartScreenShake(0.2f, 4, 1, 1);
   PlaySoundAtEntity("enemy_hallucination_disappear", "enemy_hallucination_disappear.snt", "Player", 0, false);
   PlaySoundAtEntity("guardian_distant3", "guardian_distant3.snt", "Player", 0, false);
}

And then I selected the key I had, and there should be a line for the CallbackFunc, and I put BackTrack there. You don't need to put the Callback in your script that way.