SHARE
TWEET

AegisGFxHUD

a guest Mar 19th, 2013 554 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class AegisGFxHUD extends GFxMoviePlayer;
  2.  
  3. //Create a Health Cache variable
  4. var float LastHealthpc;
  5.  
  6. //Create variables to hold references to the Flash MovieClips and Text Fields that will be modified
  7. var GFxObject MainHUDMC, HealthBarMC;
  8. var GFxObject HealthText;
  9.  
  10. //reference our player controller
  11. var AegisPlayerController PlayerOwner;
  12.  
  13. //  Function to round a float value to an int
  14. function int roundNum(float NumIn)
  15. {
  16.         local int iNum;
  17.         local float fNum;
  18.  
  19.         fNum = NumIn;
  20.         iNum = int(fNum);
  21.         fNum -= iNum;
  22.         if (fNum >= 0.5f)
  23.         {
  24.                 return (iNum + 1);
  25.         }
  26.         else
  27.         {
  28.                 return iNum;
  29.         }
  30. }
  31.  
  32. //  Function to return a percentage by dividing the actual value from the maximum value
  33. function int getpc2(int val, int max)
  34. {
  35.         return roundNum((float(val) / float(max)) * 100.0f);
  36. }
  37.  
  38. //Called from AegisHUD'd PostBeginPlay() to begin playing the HUD movie
  39. function Init2(PlayerController PC)
  40. {
  41.         //Start and load the SWF Movie
  42.         Start();
  43.         Advance(0.f);
  44.  
  45.         //Set the cache value to something rediculous to know it gets updated on the first tick
  46.         LastHealthpc = -1337;
  47.  
  48.         //Load the references using the instance names from our HUD movie flash file
  49.         MainHUDMC = GetVariableObject("_root.Base_mc");
  50.         HealthBarMC = GetVariableObject("_root.Base_mc.HPbar_mc");
  51.         HealthText = GetVariableObject("_root.Base_mc.health_txt");
  52. }
  53.  
  54. //Updates the HUD
  55. function TickHUD()
  56. {
  57.         //If the cached value for Health percentage isn't equal to the current...
  58.         if (LastHealthpc != getpc2(GetPC().Pawn.Health, GetPC().Pawn.HealthMax))
  59.         {
  60.                 //...Make it so...
  61.                 LastHealthpc = getpc2(GetPC().Pawn.Health, GetPC().Pawn.HealthMax);
  62.                 //...Update the bar's xscale (but don't let it go over 100)...
  63.                 HealthBarMC.SetFloat("_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc);
  64.                 //...and update the text field
  65.                 HealthText.SetString("text", round(LastHealthpc)$"%");
  66.         }
  67. }
  68.  
  69. DefaultProperties
  70. {
  71.         //hide the flash movie if the HUD is hidden
  72.         bDisplayWithHudOff=false
  73.         //The path to the swf asset we will create later
  74.         MovieInfo=SwfMovie'soldier.Aegis_MainHUD'
  75. }
RAW Paste Data
Top