changing image for health state
by Richard Preziosi · in Torque Game Engine · 08/09/2010 (1:16 am) · 2 replies
I was attempting to make a bitmap ctrl that i can change the image of depending on the client's current health. I understand the how in a sense, just cannot seem to set it up properly. Here is how i was going about it:
server/commands.cs
I was attempting to set this by calling updateHealthImage, any time that the player was damaged or healed, however I know that the above code is wrong, plus i can't get getDamageLevel() to do anything. Any advice on this would be great.
server/commands.cs
function updateHealthImage(%client)
{
%healthdamagelevel = %client.getDamageLevel();
if (%healthdamagelevel = 50);{
healthbarhud.setbitmap("./starter.fps/client/ui/healthimages/healthbar50");
}
if (%healthdamagelevel = 25);
{
healthbarhud.setbitmap("./starter.fps/client/ui/healthimages/healthbar25");
}
if (%healthdamagelevel = 75);
{
healthbarhud.setbitmap("./starter.fps/client/ui/healthimages/healthbar75");
}
}I was attempting to set this by calling updateHealthImage, any time that the player was damaged or healed, however I know that the above code is wrong, plus i can't get getDamageLevel() to do anything. Any advice on this would be great.
#2
And actually i do want it to only show at exactly at certain intervals due to damage being restricted to a specific amount, I just used those in the above to save space/time while typing it out.
Thanks a ton, hopefully I can get it going.
08/09/2010 (10:15 pm)
Ah ok, i will try this out momentarily and let you know how it goes.And actually i do want it to only show at exactly at certain intervals due to damage being restricted to a specific amount, I just used those in the above to save space/time while typing it out.
Thanks a ton, hopefully I can get it going.
Torque Owner Daniel Buckmaster
T3D Steering Committee
Also, I think getDamageLevel will return a float in the range 0...1. So you'd want to be comparing against 0.25, 0.5, and 0.75. Also, inequalities. You don't want to only change the bitmap when the client's health is exactly a certain value.
I assume you want the healthbar75 to display when the health is greater than .75 as well? So your function could look something like this: