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


GivePlayerDamage help and some explanation please! - Dominic0904 - 08-21-2012

I'm trying to refresh my memory with this scripting business, but I seem to forgotten a lot more than I thought I had, I'm trying to mess around with a small room I made, adding objects and scripting different events with them (Play sound, screen shake and so on).

But I can't seem to get GivePlayerDamage right, I'm tried going by what it says on here;
http://wiki.frictionalgames.com/hpl2/amnesia/script_functions


but it doesn't help me, I'm still struggling to understand it. I know I would be told to look at the wiki tutorials but they explain it in a way I don't understand.

I'm trying to "kill" the player when he picked up a tomb key. The only thing that confuses me is writing in these;

(string &in asParent, string &in asChild, int alState)
or
(string &in item)


I have no idea where or when to write them or what they are needed for, I'm trying to remind myself from my old script that I made when I used it for a uni project a long time but it's not helping.

Here is what I have so far;


void OnStart()
{
SetEntityPlayerInteractCallback("key_tomb_1", "DieWhenPickUp", true);

SetEntityPlayerInteractCallback("crowbar_1", "PickUpBar", true);
}


//Plays a sound and shakes the player's screen upon pick up
void PickUpBar(string &in item)
{
PlaySoundAtEntity("", "04_scream.snt", "Player", 0, false);
StartScreenShake(0.08f, 3.0f, 0.1f, 0.02f);
}

//Kills player when key is picked up
void DieWhenPickUp(string &in item)

{
GivePlayerDamage("200", "BloodSplat", "0", "01);
}




Can anyone explain this to me please? I would really appreciate it and make me stop having to run to the forum for every single script command that doesn't work.


RE: GivePlayerDamage help and some explanation please! - Robby - 08-21-2012

"string &in asItem" goes for "DieWhenPickUp" and "PickUpBar"

EDIT: You wrote "string &in item". That isn't correct. "string &in asItem" is the correct syntax.


RE: GivePlayerDamage help and some explanation please! - Your Computer - 08-21-2012

Integers, booleans and floats aren't strings.


RE: GivePlayerDamage help and some explanation please! - Adny - 08-21-2012

GivePlayerDamage(float afAmount, string& asType, bool abSpinHead, bool abLethal);
afAmount = the amount of damage done to the player; the player's health is 100

asType = the screen + sound effect that will accompany the damage
abSpinHead = with the player's screen suddenly jerk to one side when the damage is recieved?
abLethal = regardless of the damage, will this kill the player?


Example:

GivePlayerDamage(30.0f, "Claws", true, false);

It will inflict 30 damage to the player, display 3 diagonal red slashes across the screen, the player's head will jerk to one side, and it will not kill the player.


RE: GivePlayerDamage help and some explanation please! - Dominic0904 - 08-21-2012

Ok thanks, that helped. But when do I know when to write them? Say when do I know when to write this next to the function;
(float afAmount, string& asType, bool abSpinHead, bool abLethal)"
Over;
(string &in item)
Or;
(string &in asParent, string &in asChild, int alState)



That's the only thing that is really confusing me.


RE: GivePlayerDamage help and some explanation please! - Your Computer - 08-21-2012

(08-21-2012, 09:53 PM)Dominic0904 Wrote: But when do I know when to write them?

By reading the documentation of the corresponding function.


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

(08-21-2012, 09:53 PM)Dominic0904 Wrote: Ok thanks, that helped. But when do I know when to write them? Say when do I know when to write this next to the function;
(float afAmount, string& asType, bool abSpinHead, bool abLethal)"
Over;
(string &in item)
Or;
(string &in asParent, string &in asChild, int alState)


That's the only thing that is really confusing me.
It depends entirely on what is triggering the function.
For example, if what triggers the function is AddEntityCollideCallback (you walk into an area), then you should write (string &in asParent, string &in asChild, int alState) as strings and ints you can use later.

void COLLIDE(string &in asParent, string &in asChild, int alState)
{
GivePlayerDamage(3.0f,asParent,true,true);
}

The only usage for the long (string &in asParent, string &in asChild, int alState) is to later be able to reference to what actually went into the collide, or was gone into (asParent being the Player most often).
Sorry, a little rushed here.


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

(08-22-2012, 07:06 AM)Theforgot3n1 Wrote:
(08-21-2012, 09:53 PM)Dominic0904 Wrote: Ok thanks, that helped. But when do I know when to write them? Say when do I know when to write this next to the function;
(float afAmount, string& asType, bool abSpinHead, bool abLethal)"
Over;
(string &in item)
Or;
(string &in asParent, string &in asChild, int alState)


That's the only thing that is really confusing me.
It depends entirely on what is triggering the function.
For example, if what triggers the function is AddEntityCollideCallback (you walk into an area), then you should write (string &in asParent, string &in asChild, int alState) as strings and ints you can use later.

void COLLIDE(string &in asParent, string &in asChild, int alState)
{
GivePlayerDamage(3.0f,asParent,true,true);
}

The only usage for the long (string &in asParent, string &in asChild, int alState) is to later be able to reference to what actually went into the collide, or was gone into (asParent being the Player most often).
Sorry, a little rushed here.
Ok I think I understood most of that, why did you write "asParent" in the GivePlayerDamage function?


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

Listen

When you write "void" then you specify that you want to make a function.
The function needs a name so it will be "void Function_1".

But what kind of function is this? Is it when you collide with something or is it when you touch something. That is how the program wonders.

So if it is a function when you collide with something then it is:

(string &in asParent, string &in asChild, int alState)
asParent = The first entity (Might be player)
asChild = The second entity (Might be an area) which the first entity collides with.
int alState = if the asParent is going inside asChild or away from asChild




Is it a function when you touch something? Very well:

(string &in asEntity)
asEntity = The entity that is being touched. There is only 1 thing that can touch, and that is the player. Therefor we don't need to specify what is touching.

Do you understand?

What is inside the function { INSIDE THESE } doesn't matter at all.
Here is a clear example:

void ThisIsACollideFunction(string &in asParent, string &in asChild, int alState)
{
What goes in here has nothing to do with the above.
GivePlayerDamage(Inside here is the properties for the "GivePlayerDamage")
}


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

(08-22-2012, 05:28 PM)beecake Wrote: Listen

When you write "void" then you specify that you want to make a function.
The function needs a name so it will be "void Function_1".

But what kind of function is this? Is it when you collide with something or is it when you touch something. That is how the program wonders.

So if it is a function when you collide with something then it is:

(string &in asParent, string &in asChild, int alState)
asParent = The first entity (Might be player)
asChild = The second entity (Might be an area) which the first entity collides with.
int alState = if the asParent is going inside asChild or away from asChild




Is it a function when you touch something? Very well:

(string &in asEntity)
asEntity = The entity that is being touched. There is only 1 thing that can touch, and that is the player. Therefor we don't need to specify what is touching.

Do you understand?

What is inside the function { INSIDE THESE } doesn't matter at all.
Here is a clear example:

void ThisIsACollideFunction(string &in asParent, string &in asChild, int alState)
{
What goes in here has nothing to do with the above.
GivePlayerDamage(Inside here is the properties for the "GivePlayerDamage")
}
Oh wow yeah I think I get most of it now, just gotta put it into practice, thanks a bunch Smile