Frictional Games Forum (read-only)
GivePlayerDamage help and some explanation please! - 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: GivePlayerDamage help and some explanation please! (/thread-17889.html)

Pages: 1 2


RE: GivePlayerDamage help and some explanation please! - Theforgot3n1 - 08-22-2012

Code:
AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);
Calls a function when two entites collide.
Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)
alState: 1 = enter, -1 = leave
asParentName - internal name of main object
asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)
asFunction - function to call
abDeleteOnCollide - determines whether the callback after it was called
alStates - 1 = only enter, -1 = only leave, 0 = both
This part above
void MyFunc(string &in asParent, string &in asChild, int alState)
is what exactly you need to specify for the script to find your specific function.
One simple example that Beecake wrote was
void Function_1(string &in asParent, string &in asChild, int alState)
which can only be callbacked(triggered) by an

AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

As you see
, there are five different specifications inside the AECC that you can change in purpose of your desired script. Whatever string you write inside "string& asParentName" and "string& asChildName", will be accessible inside the { }, for example at


void OnStart()
{
AddEntityCollideCallback("elevator_1", "AreaElevatorDown, Function_1, false, 1);

}
void Function_1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Elevator_Stuck_Sound", "elevator_stop.snt",asParent, 0.0f, false);
}


In the script above, you can write "elevator_1" at "PlaySoundAtEntity" instead of asParent, without any actual difference. But that isn't always the case. When having multiple AECC referring to the same function it's a very useful tool for the script to know which one collided. For example:


void OnStart()
{
AddEntityCollideCallback("elevator_1", "AreaElevatorDown, Function_1, false, 1);
AddEntityCollideCallback("elevator_2", "AreaElevatorDown, Function_1, false, 1);
}
void Function_1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Elevator_Arrive_Sound", "elevator_stop.snt",asParent, 0.0f, false);
}


This script will play the elevator stop sound at whichever elevator touches the area, because of asParent defining exactly which one collided into it. It's incredibly useful to save space and sanity.

I'm still very new to alState, the "enter/leave" integer, so I won't be commenting that. But it doesn't collide with the rest anyway, so don't worry.
You can also create your own function-defining, but you must understand this before you can move onto it.

Hope that helped. Smile

PS: Oh, I saw you already understood. Wasn't too bad writing it anyway. xD