Attributes

Topics regarding Scripting with Reality Factory
Post Reply
Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Attributes

Post 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
A good warrior knows his limits, but a great warrior finds his way around them.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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").
Pain is only psychological.
Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Post by Masta_J »

Thanks alot man! Such a simple solution to such a simple problem.
A good warrior knows his limits, but a great warrior finds his way around them.
Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Post 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";
  }
}]
A good warrior knows his limits, but a great warrior finds his way around them.
Post Reply