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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GivePlayerDamage help and some explanation please!
Theforgot3n1 Offline
Member

Posts: 192
Threads: 20
Joined: Apr 2012
Reputation: 6
#11
RE: GivePlayerDamage help and some explanation please!

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

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
(This post was last modified: 08-22-2012, 06:40 PM by Theforgot3n1.)
08-22-2012, 06:39 PM
Website Find




Users browsing this thread: 2 Guest(s)