Announcement

Collapse
No announcement yet.

Vehicle health bars

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Vehicle health bars

    Does anyone know how the game spawns the vehicle health bars over the top of a vehicle. I can only get one to spawn when i hope in the vehicle which is nice.. however i would really like to be able to see some other values on a vehicle in a bar form when it is unmanned.
    If you dont know what im talking about... whenever you look at a vehicle in Onslaught a health bar is displayed above the top of it that updates itself when you heal it.

    What i found:
    The closest thing i found so far was a something in HudOnslaught or something like that (At work right now) and it was drawhealthbar but the only place it was called was when linking the powercores and nodes. That isnt exactly what im looking for. Does anyone know where I could find this stuff. Thanks.

    #2
    http://www.ataricommunity.com/forums...hreadid=369225

    Comment


      #3
      thanks alot... my search didnt pull that up for some reason.

      Comment


        #4
        Okay ive searched for HOURS... I think ive found the team beacon stuff but still no luck. I have NO IDEA where they draw the health bars. All i can find is the drawing of the text and some DrawCustomerBeacon function that is never called and doesnt look like it draws the vehicles health as it never even uses those variables. Can someone please post the code that draws the vehicle health bars or something like that. PLEASE :bulb:

        Comment


          #5
          I would also like to know how to do this... :weird:

          Comment


            #6
            if you want to add new hud stuff without making a new hud, use HudOverlay's, make your own subclass and when one is spawned do:
            Code:
            local Controller C;
            for(C=Level.ControllerList;C!=None;C=C.nextController)
            {
                if( PlayerController(C) != None )
                    PlayerController(C).myHUD.AddHudOverlay(MyHudOverlay);
            }

            Comment


              #7
              Hey Mr Slate, long time no see. Anyways, I think this is what you are looking for:

              Code:
              simulated function DrawHealthBar(Canvas C, Actor A, int Health, int MaxHealth, float Height)
              {
              	local vector		CameraLocation, CamDir, TargetLocation, HBScreenPos;
              	local rotator		CameraRotation;
              	local float			Dist, HealthPct;
              	local color         OldDrawColor;
              
              	// rjp --  don't draw the health bar if menus are open
              	if ( PlayerOwner.Player.GUIController.bActive )
              		return;
              
              	OldDrawColor = C.DrawColor;
              
              	C.GetCameraLocation( CameraLocation, CameraRotation );
              	TargetLocation = A.Location + vect(0,0,1) * Height;
              	Dist = VSize(TargetLocation - CameraLocation);
              
              	// Check Distance Threshold
              	if (Dist > HealthBarViewDist)
              		return;
              
              	CamDir	= vector(CameraRotation);
              
              	// Target is located behind camera
              	HBScreenPos = C.WorldToScreen(TargetLocation);
              	if ((TargetLocation - CameraLocation) dot CamDir < 0 || HBScreenPos.X <= 0 || HBScreenPos.X >= C.SizeX || HBScreenPos.Y <= 0
                         || HBScreenPos.Y >= C.SizeY)
              	{
              		TargetLocation = A.Location + vect(0,0,1) * A.CollisionHeight;
              		if ((TargetLocation - CameraLocation) dot CamDir < 0)
              			return;
              		HBScreenPos = C.WorldToScreen(TargetLocation);
              		if (HBScreenPos.X <= 0 || HBScreenPos.X >= C.ClipX || HBScreenPos.Y <= 0 || HBScreenPos.Y >= C.ClipY)
              			return;
              	}
              
              	if (FastTrace(TargetLocation, CameraLocation))
              	{
              	    	C.DrawColor = WhiteColor;
              
              	    	C.SetPos(HBScreenPos.X - HealthBarWidth * 0.5, HBScreenPos.Y);
              	    	C.DrawTileStretched(HealthBarBackMat, HealthBarWidth, HealthBarHeight);
              
              	    	HealthPct = 1.0f * Health / MaxHealth;
              
              	    	if (HealthPct < 0.35)
              	    	   C.DrawColor = RedColor;
              	    	else if (HealthPct < 0.70)
              	    	   C.DrawColor = GoldColor;
              	    	else
              	    	   C.DrawColor = GreenColor;
              
              	    	C.SetPos(HBScreenPos.X - HealthBarWidth * 0.5, HBScreenPos.Y);
              	    	C.DrawTileStretched(HealthBarMat, HealthBarWidth * HealthPct, HealthBarHeight);
              	}
              
              	C.DrawColor = OldDrawColor;
              }
              It only shows up in ONS_Hud and AS_Hud. The above is from ONS and has more in in cause the cores/nodes. The assault one is alot cleaner. I also can see no place vehicles are worked into the equation, but I also dont see the DrawHealthBar singling them out.

              Code:
              simulated function DrawHealthBar(Canvas C, vector HBScreenPos, float Health, float MaxHealth, Color ObjColor)
              {
              	local float		HealthPct;
              
                  C.DrawColor		= ObjColor;
                  C.Style			= ERenderStyle.STY_Alpha;
              	HealthBarWidth	= default.HealthBarWidth * ResScaleX * HUDScale;
              	HealthBarHeight = default.HealthBarHeight * ResScaleY * HUDScale;
              
                  C.SetPos(HBScreenPos.X - HealthBarWidth*0.5, HBScreenPos.Y - HealthBarHeight*0.5);
                  C.DrawTileStretched(HealthBarBackMat, HealthBarWidth, HealthBarHeight);
              
                  HealthPct		= Health / MaxHealth;
              	C.DrawColor		= GetGYRColorRamp( HealthPct );
              	C.DrawColor.A	= 200;
              
              	C.SetPos(HBScreenPos.X - HealthBarWidth*0.49, HBScreenPos.Y - HealthBarHeight*0.3 );
                  C.DrawTileStretched(HealthBarMat, HealthBarWidth*HealthPct*0.98, HealthBarHeight*0.6);
              }
              Also within AS_hud, there was a Customhealth function, you might be able to get what you need out of it. The space fighters and the turrets call this.

              Code:
              static function DrawCustomHealthInfo( Canvas C, PlayerController PC, bool bSkaarj )
              {
              	local float		XL, YL;
              	local float		XO, YO;
              	local float		HealthPct;
              	local float		ScaleX, ScaleY;
              	local float		myfPulse;
              
              	if ( PC.Pawn != None )
              		HealthPct = FClamp( float(PC.Pawn.Health) / PC.Pawn.HealthMax, 0.f, 1.f );
              	else
              		HealthPct = 0.f;
              
              	ScaleX		= PC.myHUD.ResScaleX * PC.myHUD.HUDScale;
              	ScaleY		= PC.myHUD.ResScaleY * PC.myHUD.HUDScale;
              
              	// Ugly hack FIXME
              	if ( HUD_Assault(PC.myHUD) != None )
              		myfPulse = HUD_Assault(PC.myHUD).fPulse;
              	else
              		myfPulse = 1.f;
              
              	C.Style	= ERenderStyle.STY_Alpha;
              	XL = 256 * 0.5 * ScaleX;
              	YL = 128 * 0.5 * ScaleY;
              
              	// Team color overlay
              	C.DrawColor = GetTeamColor( PC.GetTeamNum() );
              	C.SetPos( 0, C.ClipY - YL );
              	C.DrawTile(Texture'AS_FX_TX.HUD.SpaceHUD_Health_Grey', XL, YL, 0, 0, 256, 128);
              
              	// Solid Background
              	C.DrawColor = C.MakeColor(255, 255, 255);
              	C.SetPos( 0, C.ClipY - YL );
              	if ( bSkaarj )
              		C.DrawTile(Texture'AS_FX_TX.HUD.SpaceHUD_Health_Solid_Skaarj', XL, YL, 0, 0, 256, 128);
              	else
              		C.DrawTile(Texture'AS_FX_TX.HUD.SpaceHUD_Health_Solid', XL, YL, 0, 0, 256, 128);
              
              	// Health Bar
              	XL	=			80 * 0.5 * ScaleX;
              	YL	=			10 * 0.5 * ScaleY;
              	XO	=		   147 * 0.5 * ScaleX;
              	YO	= C.ClipY - 20 * 0.5 * ScaleY;
              
              	C.DrawColor		= GetGYRColorRamp( HealthPct );
              	C.DrawColor.A	= 96;
              
              	C.SetPos( XO - XL*0.5, YO - YL*0.5 );
              	C.DrawTile(Texture'InterfaceContent.WhileSquare', XL*HealthPct, YL, 0, 0, 8, 8);
              
              	// Health Icon
              	XL	=			64 * 0.5 * ScaleX;
              	YL	=			64 * 0.5 * ScaleY;
              	XO	=		   114 * 0.5 * ScaleX;
              	YO	= C.ClipY - 62 * 0.5 * ScaleY;
              
              	if ( HealthPct < 0.34 )
              	{
              		C.DrawColor = C.DrawColor * myfPulse + C.MakeColor(255, 255, 255) * (1.f-myfPulse);
              		C.DrawColor.A = 96;
              	}
              
              	C.SetPos( XO - XL*0.5, YO - YL*0.5 );
              	C.DrawTile(Texture'AS_FX_TX.HUD.SpaceHUD_HealthIcon', XL, YL, 0, 0, 64, 64);
              }

              Comment

              Working...
              X