FANDOM


Originally posted by Checkpointng Ok, so was board today at work, decided to donate more code 

This basically creates an HP Bar over the targets head rather than the current bland way with the interact window, note lots of neat things can be done, however i figured id keep it simple and allow *you* folks to expand on it.

In Actors.bb inside the ActorInstance Type add the following field HPBarEN <<< i've added it next to the NametagEN field like so:

   Field EN, CollisionEN, HatEN, ChestEN, WeaponEN, ShieldEN, ShadowEN, NametagEN, HPBarEN, GubbinEN[5] ;; <<< Added HPBarEN

In Actors3D.bb find a function called CreateActorNametag() inside add the follow code BEFORE Delete(MMV) at the bottom

 A\HPBarEN = CreateMesh()
   Local S = CreateSurface(A\HPBarEN)
   v1 = AddVertex(S, 0.0, -1.0, 0.0, 0.0, 1.0)
   v2 = AddVertex(S, 1.0, -1.0, 0.0, 1.0, 1.0)
   v3 = AddVertex(S, 1.0,  0.0, 0.0, 1.0, 0.0)
   v4 = AddVertex(S, 0.0,  0.0, 0.0, 0.0, 0.0)
   AddTriangle S, v3, v2, v1
   AddTriangle S, v4, v3, v1
   
   PositionMesh(A\HPBarEN, MeshWidth#(A\HPBarEN) / -2.0, 1.0, 0.0)
   EntityParent(A\HPBarEN, A\NametagEN)
   PositionEntity(A\HPBarEN, 0, 0, 0)
   TranslateEntity(A\HPBarEN, 0.0, -0.3, 0.0, True)
   TranslateEntity(A\NametagEN, 0.0, 0.3, 0.0, True)
   EntityAutoFade(A\HPBarEN, 40.0, 45.0)
   EntityColor(A\HPBarEN, 240, 0, 0)
   EntityFX(A\HPBarEN, 1 + 8)      
   TranslateEntity(A\NametagEN, 0, 0.5, 0, True)

and finally in Client.bb find the function UpdateActorInstances() and inside replace this section:

         ; Show/hide nametags in HideNametags mode 2 (selected only)
         If HideNametags = 2 And AI\NametagEN <> 0
            If Handle(AI) = PlayerTarget
               ShowEntity(AI\NametagEN)
            Else
               HideEntity(AI\NametagEN)
            EndIf
         EndIf

With this one:

         ; Show/hide nametags in HideNametags mode 2 (selected only)
         If HideNametags = 2 And AI\NametagEN <> 0
            If Handle(AI) = PlayerTarget
               ShowEntity(AI\NametagEN)
               MyT.ActorInstance = Object.ActorInstance(PlayerTarget)
               If MyT <> Null
                  Local HP# = (Float#(MyT\Attributes\Value[HealthStat]) / Float#(MyT\Attributes\Maximum[HealthStat])) * 2.0
                  ScaleEntity(MyT\HPBarEN, HP#, 0.3, 1)
               EndIf
            Else
               HideEntity(AI\NametagEN)
            EndIf
         EndIf

**Optional** if you would like to NOT display the interact window for targets with HP Bar then do the following:

Inside Interface3D.bb find the function CreateCharInteractionWindow() and add the following line at the top:

If AI\HPBarEN > 0 Then Return

and also find the function UpdateCharInteractionWindow() and add the same as above right below Local AI.ActorInstance = CharInteract, like this;

   Local AI.ActorInstance = CharInteract
   If AI\HPBarEN > 0 Then Return

And that should do it, next time you get on your targets will have a red bar over their heads displaying their HP, below is a quick YouTube vid to show what it looks like: Please excuse my crappy art as i dont do art and yes the actionbar is an old one that siredblood gave me, thanks again sired.

http://www.youtube.com/watch?v=c84q7tzNleE

Have fun! -C