Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
Quest - Create a Required quest titled Hp and Mana Bars with the description To turn bars off an..., using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
-------- ---------------To make bars custom color simply change the RGB using the variables HP_Red, HPGreen, and HP_Blue to whatever you like---------------- --------
-------- ---------------------------------Remember wc3 uses hexidecimal/HTML color codes - |CFF (red = ff0000), (green = 00ff00), and (blue = 0000ff)----------|r---------------------------------- --------
-------- -----------------------End Mana Bar Color-------------------------------- --------
HP Units init
Events
Time - Elapsed game time is 0.01 seconds
Conditions
Actions
-------- Selects all units already in the map to get HP bars --------
Set Mana_Group = (Units in (Playable map area))
Unit Group - Pick every unit in Mana_Group and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Life of (Picked unit)) Greater than or equal to 100.00
(Owner of (Picked unit)) Not equal to Neutral Passive
(Unit-type of (Picked unit)) Not equal to Gold Mine
(Unit-type of (Picked unit)) Not equal to Entangled Gold Mine
(Unit-type of (Picked unit)) Not equal to Haunted Gold Mine
Then - Actions
-------- Sets the length of the Bar --------
Set StateString = llllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_int = (HP_int + 1)
-------- sets an index number for each of the units --------
Set HP_Unit[HP_int] = (Picked unit)
Set HPstatus = (((Life of (Picked unit)) / (Max life of (Picked unit))) x (Real((Length of StateString))))
Set tempp1 = (Position of HP_Unit[HP_int])
Set tempp2 = (tempp1 offset by 40.00 towards 180.00 degrees)
Floating Text - Create floating text that reads StateString at tempp2 with Z offset 0.00, using font size 4.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
Set HP_Text[HP_int] = (Last created floating text)
Floating Text - Show (Last created floating text) for (All players)
Custom script: call RemoveLocation(udg_tempp1)
Custom script: call RemoveLocation(udg_tempp2)
-------- ---------------- --------
-------- sets the size and position of the bar for different types of units --------
-------- ---------------- --------
-------- ---You may alter the size of the bar by adding lower-case Ls to StateString, and----- --------
-------- you can adjust the height with the values of HP_RealZ and the offset with HP_Real --------
-------- ---------------- --------
-------- Normal Unit - Default --------
Set HP_Bar_String[HP_int] = llllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 45.00
Set HP_Real_Z[HP_int] = 150.00
-------- ---------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A flying unit) Equal to True
Then - Actions
-------- Flying unit --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 45.00
Set tempp1 = (Position of HP_Unit[(Integer A)])
Custom script: set udg_Real_Z = GetLocationZ(udg_tempp1)
Set HP_Real_Z[HP_int] = ((Current flying height of HP_Unit[(Integer A)]) + (300.00 + (Real_Z / 2.00)))
Custom script: call RemoveLocation(udg_tempp1)
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A town-hall-type unit) Equal to True
Then - Actions
-------- Main Base / Hall --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 150.00
Set HP_Real_Z[HP_int] = 350.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A structure) Equal to True
Then - Actions
-------- Buildings --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 130.00
Set HP_Real_Z[HP_int] = 300.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(HP_Unit[HP_int] is A Hero) Equal to True
(HP_Unit[HP_int] is an illusion) Equal to True
Then - Actions
-------- Hero --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 52.00
Set HP_Real_Z[HP_int] = 250.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is Mechanical) Equal to True
Then - Actions
-------- Mechanical --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 70.00
Set HP_Real_Z[HP_int] = 150.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A peon-type unit) Equal to True
Then - Actions
-------- Workers --------
Set HP_Bar_String[HP_int] = llllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 47.00
Set HP_Real_Z[HP_int] = 100.00
-------- ---------------- --------
Else - Actions
Trigger - Turn on Visibility Loop <gen>
Trigger - Turn on Bars Loop <gen>
Else - Actions
Custom script: call DestroyGroup(udg_Mana_Group)
Add HP Units
Events
Unit - A unit enters (Entire map)
Unit - A unit Finishes reviving
Conditions
Actions
-------- Sets the default length of the Bar - Note: will be changed below --------
Set StateString = llllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_int = (HP_int + 1)
-------- sets an index number for each of the units --------
Set HPstatus = (((Life of (Triggering unit)) / (Max life of (Triggering unit))) x (Real((Length of StateString))))
Set HP_Unit[HP_int] = (Triggering unit)
Set tempp1 = (Position of HP_Unit[HP_int])
Set tempp2 = (tempp1 offset by 40.00 towards 180.00 degrees)
Floating Text - Create floating text that reads StateString at tempp2 with Z offset 0.00, using font size 4.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
Set HP_Text[HP_int] = (Last created floating text)
Floating Text - Show (Last created floating text) for (All players)
Custom script: call RemoveLocation(udg_tempp1)
Custom script: call RemoveLocation(udg_tempp2)
-------- ---------------- --------
-------- sets the size and position of the bar for different types of units --------
-------- ---------------- --------
-------- ---You may alter the size of the bar by adding lower-case Ls to StateString, and----- --------
-------- you can adjust the height with the values of HP_RealZ and the offset with HP_Real --------
-------- ---------------- --------
-------- Normal Unit - Default --------
Set HP_Bar_String[HP_int] = llllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 45.00
Set HP_Real_Z[HP_int] = 150.00
-------- ---------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A flying unit) Equal to True
Then - Actions
-------- Flying unit --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 45.00
Set tempp1 = (Position of HP_Unit[(Integer A)])
Custom script: set udg_Real_Z = GetLocationZ(udg_tempp1)
Set HP_Real_Z[HP_int] = ((Current flying height of HP_Unit[(Integer A)]) + (300.00 + (Real_Z / 2.00)))
Custom script: call RemoveLocation(udg_tempp1)
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A town-hall-type unit) Equal to True
Then - Actions
-------- Main Base / Hall --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 150.00
Set HP_Real_Z[HP_int] = 350.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A structure) Equal to True
Then - Actions
-------- Buildings --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 130.00
Set HP_Real_Z[HP_int] = 300.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(HP_Unit[HP_int] is A Hero) Equal to True
(HP_Unit[HP_int] is an illusion) Equal to True
Then - Actions
-------- Hero --------
Set HP_Bar_String[HP_int] = llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 52.00
Set HP_Real_Z[HP_int] = 250.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is Mechanical) Equal to True
Then - Actions
-------- Mechanical --------
Set HP_Bar_String[HP_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 70.00
Set HP_Real_Z[HP_int] = 150.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[HP_int] is A peon-type unit) Equal to True
Then - Actions
-------- Workers --------
Set HP_Bar_String[HP_int] = llllllllllllllllllllllllllllllllllllllll
Set HP_Real_BarLength[HP_int] = (Length of HP_Bar_String[HP_int])
Set HP_Real_Offset[HP_int] = 47.00
Set HP_Real_Z[HP_int] = 100.00
-------- ---------------- --------
Else - Actions
Mana Units init
Events
Time - Elapsed game time is 0.02 seconds
Conditions
Actions
Set Mana_Group = (Units in (Playable map area))
Unit Group - Pick every unit in Mana_Group and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Max mana of (Picked unit)) Greater than or equal to 1.00
((Picked unit) is A structure) Equal to False
Then - Actions
Set Mana_int = (Mana_int + 1)
Set Mana_Unit[Mana_int] = (Picked unit)
Set StateString = llllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set tempp1 = (Position of (Picked unit))
Set tempp2 = (tempp1 offset by 40.00 towards 180.00 degrees)
Set ManaStatus = (((Mana of (Picked unit)) / (Max mana of (Picked unit))) x (Real((Length of StateString))))
Floating Text - Create floating text that reads StateString at tempp2 with Z offset 0.00, using font size 4.00, color (0.00%, 0.00%, 100.00%), and 0.00% transparency
Set Mana_Txt[Mana_int] = (Last created floating text)
Floating Text - Show (Last created floating text) for (All players)
Custom script: call RemoveLocation(udg_tempp1)
Custom script: call RemoveLocation(udg_tempp2)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana_Unit[Mana_int] is Mechanical) Equal to True
Then - Actions
-------- Mechanical --------
Set Mana_Bar_String[Mana_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set Mana_Real_BarLength[Mana_int] = (Length of Mana_Bar_String[Mana_int])
Set Mana_Real_Offset[Mana_int] = 70.00
Set Mana_Real_Z[Mana_int] = 142.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Mana_Unit[Mana_int] is A Hero) Equal to True
(Mana_Unit[Mana_int] is an illusion) Equal to True
Then - Actions
-------- Heroes --------
Set Mana_Bar_String[Mana_int] = llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set Mana_Real_BarLength[Mana_int] = (Length of Mana_Bar_String[Mana_int])
Set Mana_Real_Offset[Mana_int] = 52.00
Set Mana_Real_Z[Mana_int] = 237.00
-------- ---------------- --------
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana_Unit[Mana_int] is A flying unit) Equal to True
Then - Actions
-------- Flying unit --------
Set Mana_Bar_String[Mana_int] = lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Set Mana_Real_BarLength[Mana_int] = (Length of Mana_Bar_String[Mana_int])
Set Mana_Real_Offset[Mana_int] = 45.00
Set tempp1 = (Position of Mana_Unit[(Integer A)])
Custom script: set udg_Real_Z = GetLocationZ(udg_tempp1)
Set Mana_Real_Z[Mana_int] = ((Current flying height of Mana_Unit[(Integer A)]) + (290.00 + (Real_Z / 2.00)))
Custom script: call RemoveLocation(udg_tempp1)
-------- ---------------- --------
Else - Actions
-------- Default Units --------
Set Mana_Bar_String[Mana_int] = llllllllllllllllllllllllllllllllllllllllllllllllllll
Set Mana_Real_BarLength[Mana_int] = (Length of Mana_Bar_String[Mana_int])
Set Mana_Real_Offset[Mana_int] = 45.00
Set Mana_Real_Z[Mana_int] = 137.00
-------- ---------------- --------
Else - Actions
Custom script: call DestroyGroup(udg_Mana_Group)
Bars Loop
Events
Time - Every 0.05 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to HP_int, do (Actions)
Loop - Actions
-------- Checks for signs of Life --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(HP_Unit[(Integer A)] is alive) Equal to True
HP_Unit[(Integer A)] Not equal to No unit
Then - Actions
-------- Implements the position of the bar for different types of units selected in the set-up triggers --------
Set tempp1 = (Position of HP_Unit[(Integer A)])
Set tempp2 = (tempp1 offset by HP_Real_Offset[(Integer A)] towards 180.00 degrees)
Floating Text - Change the position of HP_Text[(Integer A)] to tempp2 with Z offset HP_Real_Z[(Integer A)]
Custom script: call RemoveLocation(udg_tempp1)
Custom script: call RemoveLocation(udg_tempp2)
-------- Sets portion of health --------
Set HPstatus = (((Percentage life of HP_Unit[(Integer A)]) / 100.00) x (Real(HP_Real_BarLength[(Integer A)])))
-------- Re-Sets color for fading effect and amount/length of Hp. --------
Floating Text - Change text of HP_Text[(Integer A)] to (((HP_Bar_Color[(Integer((Percentage life of HP_Unit[(Integer A)])))] + (Substring(HP_Bar_String[(Integer A)], 1, (Integer(HPstatus))))) + |r) + ((|cff000000 + (Substring(HP_Bar_String[(Integer A)], (Integer((HPstatus + 1.00))), HP_Real_BarLength[(Integer A)] using font size 4.00
-------- Hides bars for units that are not visible to a player --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HP_Unit[(Integer A)] Not equal to No unit
Then - Actions
Floating Text - Destroy HP_Text[(Integer A)]
Set HP_Unit[(Integer A)] = No unit
Else - Actions
-------- ----------------------------Mana Bar Loop----------------------------------- --------
-------- This section works the same as above but just for the mana bars --------
For each (Integer A) from 1 to Mana_int, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana_Unit[(Integer A)] is alive) Equal to True
Mana_Unit[(Integer A)] Not equal to No unit
Then - Actions
Set tempp1 = (Position of Mana_Unit[(Integer A)])
Set tempp2 = (tempp1 offset by Mana_Real_Offset[(Integer A)] towards 180.00 degrees)
Floating Text - Change the position of Mana_Txt[(Integer A)] to tempp2 with Z offset Mana_Real_Z[(Integer A)]
Custom script: call RemoveLocation(udg_tempp1)
Custom script: call RemoveLocation(udg_tempp2)
Set ManaStatus = (((Percentage mana of Mana_Unit[(Integer A)]) / 100.00) x (Real(Mana_Real_BarLength[(Integer A)])))
-------- Sets color for fading effect --------
Floating Text - Change text of Mana_Txt[(Integer A)] to (((Mana_Bar_Color[(Integer((Percentage mana of Mana_Unit[(Integer A)])))] + (Substring(Mana_Bar_String[(Integer A)], 1, (Integer(ManaStatus))))) + |r) + ((|cff000000 + (Substring(Mana_Bar_String[(Integer A)], (Integer((ManaStatus + 1.00))), Mana_Real_BarLengt using font size 4.00
Player - Player 1 (Red) types a chat message containing -Bars as An exact match
Player - Player 2 (Blue) types a chat message containing -Bars as An exact match
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ManaBars_On[(Player number of (Triggering player))] Equal to True
Then - Actions
Set ManaBars_On[(Player number of (Triggering player))] = False
Else - Actions
Set ManaBars_On[(Player number of (Triggering player))] = True
As with all floating text there is a limit of 100 at any time during a game. So if your map will require more than 100 bars this system will stop at 100. Also, if you use dummy units in triggered spells they must be neutral passive or they will get a HpBar. You can add exceptions to the system in the "Add Bars" trigger. Also, some units are very tall and the system does not adjust for this. KotG and Morphed Illidan are two units I know about. All other unit classes are accounted for. Besides the limitations I just mentioned this system provides classic HpBars and ManaBars with a simple cut and paste, it is leakless and clean. Enjoy!
By: Legal_Ease.
Needs update for GetLocalPlayer()
This will reduce the number of floating text dramatically and in effect increase the usefulness of this system by getting more use out of the 100 limit, making it a 100 limit for visible floating text bars per player rather than 100 total per map.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.