Frictional Games Forum (read-only)
Touch an entity/item and something is triggered? - 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: Touch an entity/item and something is triggered? (/thread-17021.html)



Touch an entity/item and something is triggered? - HeadyBoy - 07-16-2012

I am a newbie at Amnesia story making and I have been only scripting for about 2 days now.
I'm trying to make, let's say, a sound happen (which I know how to do) for when I pick up maybe, a tinderbox. I'm not entirely sure on how to do this. See I've been using

AddEntityCollideCallback("Player","AREANAME","FUNCTION",true,1);


I have only been triggering sounds when a player goes into a new area but I havent wanted to experiment just in case I screw up something.

What would I do if I wanted to pick up a tinderbox and that triggered any kinda growl?


RE: Touch an entity/item and something is triggered? - drunkmonk - 07-16-2012

For the most part when you want something to happen when the player picks up an item, its basically the same concept you just need to use SetEntityPlayerInteractCallback("Name_of_Tinderbox", "Function", false);

Edit: the callback syntax is(string &in asEntity)


RE: Touch an entity/item and something is triggered? - Ongka - 07-16-2012

Code:
void OnStart()
{
SetEntityCallbackFunc("ENTER_TINDERBOX_NAME", "FUNCTION_NAME");
}

void FUNCTION_NAME(string &in asEntity, string &in type)
{
PlaySoundAtEntity("growl", "notice.snt", "Player", 0, false);
GiveSanityDamage(7.0f, true);
}
This should do the job.
Change the names how you'd like them.


RE: Touch an entity/item and something is triggered? - HeadyBoy - 07-16-2012

Thanks. It works awesomely