Page 1 of 1

Attributes

Posted: Wed Nov 07, 2007 1:19 pm
by Masta_J
Hi guys, got two possibly stupid questions for yous:

1) How do I get a health metre going for a player pawn. I read the tutorials, but I can't really determine the exact process.

2) I would like to add an experience attribute to my player pawn, but so far I've had no luck. I've tried to use the AddAttribute command, but it seems to have no effect what so ever.

Thanks

Posted: Wed Nov 07, 2007 1:52 pm
by Juutis
You can use the built-in player's attributes for a scripted player too.

1.) Give your scripted player a health attribute and add an attribute to the built-in player's attributes. Then just synchronize the two attributes within your script with SetAttribute(ATTRIBUTENAME, VALUE, "Player"). Then you can use the HUD normally to display a health meter.

2.) I think you should make the experience attribute a built-in player attribute only. That way you can modify it from any script with ModifyAttribute(ATTRIBUTENAME, VALUE, "Player") and read it with GetAttribute(ATTRIBUTENAME,"Player").

Posted: Wed Nov 07, 2007 1:59 pm
by Masta_J
Thanks alot man! Such a simple solution to such a simple problem.

Posted: Sun Nov 11, 2007 10:16 pm
by Masta_J
Got both to work, but when I synchronise the health attribute of my player pawn and the built in player's, the health bar decreases to 0 on my first hit. My pawn is still alive though. Here's my script:

Code: Select all

HEALTHATTRIB [healthgood]
PAWNHEALTH [self.health]

if(self.in_pain)
{
  self.think="Pain";
 }
}]

Pain[()
{
   SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");
   self.think="Fight";
  }
}]