Game Development Reference
In-Depth Information
The health changer
Our next function to be added will be one that will affect the player's health. Add the
following code to your script:
void ChangeHealth()
{
Player.SendMessage("ChangeHealth", Amount);
}
When we call ChangeHealth , we send a message to the player to call a function
known as ChangeHealth , and we send Amount as well. As you can see, we use
Amount often. Since changing stats is all about amounts, we use a single variable
to make it easier for us.
The armor changer
The next and final stat modifying function we'll add will allow us to adjust the armor
of our player. Add this function to your script:
void ChangeArmorAmount()
{
Player.SendMessage("ChangeArmorAmount",
ArmorAmount);
}
This function is similar to the ChangeHealth function. We send the player a mes-
sage to call a function that will change the player's armor amount. Then, we also
send it the amount we want to change it by.
The item activator
This last function that we add will be called by other classes to activate the item. Add
this last function to your script:
Search WWH ::




Custom Search