RTSUnit Health Bar Color Damage
by BillF · in RTS Starter Kit · 03/16/2008 (10:32 am) · 3 replies
This is a simple modification to the existing RTSUnit health bar rendering that makes the bar show green for healthy, yellow for medium damage, and red for heavy damage.
In guiRTSTSCtrl.h
replace
with
In guiRTSTSCtrl.cc
replace
with
replace
with
That's it, you should now have RTSUnit health bars that show green, yellow, or red based on the unit's damage level.
In guiRTSTSCtrl.h
replace
ColorF mDamageFillColor;
with
ColorF mDamageFillColorHealthy; ColorF mDamageFillColorMedium; ColorF mDamageFillColorHeavy;
In guiRTSTSCtrl.cc
replace
mDamageFillColor.set( 0, 1, 0, 1 );
with
mDamageFillColorHealthy.set( 0, 1, 0, 1 ); mDamageFillColorMedium.set( 1, 1, 0, 1 ); mDamageFillColorHeavy.set( 1, 0, 0, 1 );
replace
dglDrawRectFill(rect, mDamageFillColor);
with
dglDrawRectFill(rect, damage<0.33f?mDamageFillColorHeavy:damage<0.66f?mDamageFillColorMedium:mDamageFillColorHealthy);
That's it, you should now have RTSUnit health bars that show green, yellow, or red based on the unit's damage level.
Torque 3D Owner Novack
CyberianSoftware