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!
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#1
Sad  GivePlayerDamage help and some explanation please!

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/amn..._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.
08-21-2012, 06:34 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#2
RE: GivePlayerDamage help and some explanation please!

"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.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 08-21-2012, 06:58 PM by Robby.)
08-21-2012, 06:42 PM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#3
RE: GivePlayerDamage help and some explanation please!

Integers, booleans and floats aren't strings.

Tutorials: From Noob to Pro
(This post was last modified: 08-21-2012, 08:15 PM by Your Computer.)
08-21-2012, 08:14 PM
Website Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#4
RE: GivePlayerDamage help and some explanation please!

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.

I rate it 3 memes.
(This post was last modified: 08-21-2012, 08:23 PM by Adny.)
08-21-2012, 08:22 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#5
RE: GivePlayerDamage help and some explanation please!

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.
(This post was last modified: 08-21-2012, 09:54 PM by Dominic0904.)
08-21-2012, 09:53 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: GivePlayerDamage help and some explanation please!

(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.

Tutorials: From Noob to Pro
08-21-2012, 10:10 PM
Website Find
Theforgot3n1 Offline
Member

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

(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.

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
08-22-2012, 07:06 AM
Website Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#8
RE: GivePlayerDamage help and some explanation please!

(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?
08-22-2012, 05:11 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: GivePlayerDamage help and some explanation please!

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")
}

Trying is the first step to success.
(This post was last modified: 08-22-2012, 05:33 PM by FlawlessHappiness.)
08-22-2012, 05:28 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#10
RE: GivePlayerDamage help and some explanation please!

(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
08-22-2012, 05:57 PM
Find




Users browsing this thread: 3 Guest(s)