How to give a player "Health
by Henry Garle · in Torque X Platformer Kit · 10/15/2007 (4:26 pm) · 1 replies
Ok, i only got this today and i think im overlooking a health system that is already implemented with armour mitigation but ive changed the "pepper" system into a kind of health system. So here is the code to only remove 1 pepper at a time when you get hit and to reverse the bar so it goes from left to right rather than right to left. Bare with me, its been a long day!
First off ... to make sure that we only remove 1 pepper at a time:
In PlayerActorDragonComponent.cs change:
_inventory.Item("Pepper").Count = 0;
to:
_inventory.Item("Pepper").Count = _inventory.Item("Pepper").Count - 1;
Next, in GUI.cs around line 100 change:
// place grey empty peppers
// (visible)
for ( int i = 9; i <= 0; i--)
to:
for ( int i = 0; i <= 9; i++)
And also the same for the "red peppers" just a few lines below it.
There you have it, the GUI (Excluding the fact it still has pictures of a vegetable) Is now your health hud and each pepper represents 10% of your life. This ofcourse does not disable the counter being reset when you hit 10 peppers. If i have actualy overlooked a far better health system, please let me know :)
Henry.
First off ... to make sure that we only remove 1 pepper at a time:
In PlayerActorDragonComponent.cs change:
_inventory.Item("Pepper").Count = 0;
to:
_inventory.Item("Pepper").Count = _inventory.Item("Pepper").Count - 1;
Next, in GUI.cs around line 100 change:
// place grey empty peppers
// (visible)
for ( int i = 9; i <= 0; i--)
to:
for ( int i = 0; i <= 9; i++)
And also the same for the "red peppers" just a few lines below it.
There you have it, the GUI (Excluding the fact it still has pictures of a vegetable) Is now your health hud and each pepper represents 10% of your life. This ofcourse does not disable the counter being reset when you hit 10 peppers. If i have actualy overlooked a far better health system, please let me know :)
Henry.
About the author
Torque Owner Anachronistic
so i figured out the same solution and am using the peppers to manage my health.
everything works correctly, for example, the player will respawn with a set health amount, except i can't figure out how to alter the initial health points (number of held peppers at start) without having it affect other functionality
any suggestions?