Snippet Floating Mana Bar

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Here's a very simple trigger to add a floating mana bar above units. It uses only 4 variables, pg(player group), ug (unit group),p (point array) and mana (integer). To change the color of the mana bar change the color code in the bold part. Hope someone finds a use for it.

Code:
Mana Trigger
    Events
        Time - Every 0.03 seconds of game time
    Conditions
    Actions
        Set ug = (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Max mana of (Matching unit)) Greater than 0.50)))
        Unit Group - Pick every unit in ug and do (Actions)
            Loop - Actions
                Set String = <Empty String>
                Set Mana = (Integer(((Percentage mana of (Picked unit)) / 2.00)))
                For each (Integer A) from 1 to 50, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Mana Greater than or equal to (Integer A)
                            Then - Actions
                                Set String = (String + |cff0000FF'|r)
                            Else - Actions
                                Set String = (String + ')
                Set p[1] = (Position of (Picked unit))
                Set p[2] = (p[1] offset by (-75.00, 0.00))
                Floating Text - Create floating text that reads String at p[2] with Z offset 210.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                Set pg = (All enemies of (Owner of (Picked unit)))
                Floating Text - Hide (Last created floating text) for pg
                Floating Text - Change (Last created floating text): Disable permanence
                Floating Text - Change the lifespan of (Last created floating text) to 0.06 seconds
                Custom script:   call DestroyGroup(udg_ug)
                Custom script:   call DestroyForce(udg_pg)
                Custom script:   call RemoveLocation(udg_p[1])
                Custom script:   call RemoveLocation(udg_p[2])


screenshot1-1.jpg
 

Attachments

  • Floating Mana Bar.w3x
    13.9 KB · Views: 378

Flare

Stops copies me!
Reaction score
662
Code tags?

And you've got a leak here
Code:
Set p = ((Position of (Picked unit)) offset by (-75.00, 0.00))
There's 2 locations involved there (Position of (Picked Unit) and the resulting offset point) so you need 2 variables (or an arrayed variable, doesn't really matter) to deal with it properly

Still leaking :\
Code:
                Set p[1] = ((Position of (Picked unit))
                Set p[2] = ([B](Position of (Picked unit))[/B] offset by (-75.00,0.00))
Change bolded to p[1]

Code:
                Custom script:   call DestroyGroup(udg_ug)
The group should be destroyed OUTSIDE the Unit Group loop (or else you're destroying it once for every unit in the group, even though it was only created once)

@Exide: It's MUI, but it's not very selective in what it allows :p
 

Exide

I am amazingly focused right now!
Reaction score
448
It's a nice idea.
You should make it MUI, though. And most importantly: Show screenshots! :p
 

Exide

I am amazingly focused right now!
Reaction score
448
Cool. Yea, it looks MUI enough to me. My bad. :p
+rep. :thup:

EDIT:
You should add a bar, above the mana bar, for the HP. =)
 
Reaction score
86
Very nice, looks smooth, MUI, what more could you want?
To change the color all you have to do is change:
Code:
Set String = (String + |cff995500'|r)
Change the color code to whatever you want :p
 

ImmortaL_GoD

New Member
Reaction score
4
Just wondering what this part of the trigger does exactly (such as the " ' "?

Code:
If - Conditions
                                Mana Greater than or equal to (Integer A)
                            Then - Actions
                                Set String = (String + |cff995500'|r)
                            Else - Actions
                                Set String = (String + ')

And also, how would I select the condition to set the variable to 6 specific units exactly (with the is alive and greater than 0.50 conditions as well)?
 

cleeezzz

The Undead Ranger.
Reaction score
268
i believe ' is the bar itself.

so the bar your looking at is really

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

except color coded.
 

Fluffball

Well-Known Member
Reaction score
35
Wow... very nice system... I believe you can change the life of the floating text and the periodic timer, although it's fine just as it is... I will use this in my map, might make it health though and add fading age (So as you walk, will fade behind you) +rep... Thanks
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Thx all for the good remarks.

@Undaddy, i'm not sure, but if it overlaps, you can adjust the height of the mana bar by changing the bolded part in this line.

Code:
                Floating Text - Create floating text that reads String at p[2] with [B]Z offset 210.00[/B], using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency

@ Immortal_God, as cleezzz said, the ' makes up the actual bar. In order to make it only visible above some units, just set "ug" to whatever you want. Put the units you want to give a mana bar in another unit group, then just check "all units in playable map area matching mana greater than 0.50 and matching unit is alive equal to true and unit is in <your unitgroup> equal to true.
 

ImmortaL_GoD

New Member
Reaction score
4
Ok, thanks a lot, I wasn't sure quite how to compress the trigger (so you didn't have to set each and every one alive/greater than .50).

Code:
Mages
    Events
        Time - Every 0.03 seconds of game time
    Conditions
    Actions
        Set temp_group = (Units in (Playable map area)((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) is alive) Equal to True) and ((Max life of (Matching unit)) Greater than 0.50))))
        Unit Group - Pick every unit in temp_group and do (Actions)
            Loop - Actions
                Set String = Empty String
                Set Life = (Integer(((Percentage life of (Picked unit)) / 2.00)))
                For each (Integer A) from 1 to 50, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Life Greater than or equal to (Integer A)
                            Then - Actions
                                Set String = (String + |cff995500'|r)
                            Else - Actions
                                Set String = (String + ')
                Set p[1] = (Position of (Picked unit))
                Set p[2] = ((Position of (Picked unit)) offset by (-75.00, 0.00))
                Floating Text - Create floating text that reads String at p[2] with Z offset 210.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                Floating Text - Change (Last created floating text): Disable permanence
                Floating Text - Change the lifespan of (Last created floating text) to 0.06 seconds
                Custom script: call RemoveLocation (udg_p[1])
                Custom script: call RemoveLocation (udg_p[2])
                Custom script: call DestroyGroup (udg_temp_group)

Lol, all it shows is "String" in white above the unit, and it also changed his color from red --> blue, o_O. Any ideas?
 

ImmortaL_GoD

New Member
Reaction score
4
Yeah, I thought I did that, second I'll recheck.

EDIT: Oh shit, I see where I messed up, haha. I useds String variable for the first two, then for reason not for the third (floating text) one. Thanks.

Which measurement would you adjust to move the bar left a little? Since I need to center it on a mage type,
smaller unit.

Code:
Mages
    Events
        Time - Every 0.03 seconds of game time
    Conditions
    Actions
        [B]Set temp_group = (Units in (Playable map area)(((Unit-type of (Matching unit)) Equal to |c00ff0000Mage) and (((Unit-type of (Matching unit)) Equal to |c00800080Mage) and (((Unit-type of (Matching unit)) Equal to |c00000000Mage) and (((Unit-type of (Matching unit)) Equal to |c
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (((Matching unit) is alive) Equal to True) and ((Max life of (Matching unit)) Greater than 0.50)
            Then - Actions
                Unit Group - Pick every unit in temp_group and do (Actions)[/B]                    Loop - Actions
                        Set String = Empty String
                        Set Life = (Integer(((Percentage life of (Picked unit)) / 2.00)))
                        For each (Integer A) from 1 to 50, do (Actions)
                            Loop - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Life Greater than or equal to (Integer A)
                                    Then - Actions
                                        Set String = (String + |c00880000'|r)
                                    Else - Actions
                                        Set String = (String + ')
                        Set p[1] = (Position of (Picked unit))
                        Set p[2] = ((Position of (Picked unit)) offset by (-75.00, 0.00))
                        Floating Text - Create floating text that reads String at p[2] with Z offset 210.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                        Floating Text - Change (Last created floating text): Disable permanence
                        Floating Text - Change the lifespan of (Last created floating text) to 0.06 seconds
                        Custom script: call RemoveLocation (udg_p[1])
                        Custom script: call RemoveLocation (udg_p[2])
                        Custom script: call DestroyGroup (udg_temp_group)
            Else - Actions
                Do nothing

Was that how you were saying to set up the first part to select specific units? Probably not, but that didn't work anyways, not sure how to select and put that condition on ALL of them. =/
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
@ immortalGodz, are those mages you want a mana bar to appear above the only mages on the map, if so, just add "unit-type of matching unit equal to mage" only once to the "set unit group" line.

To put it to the left or right, change to x value in "set p[2] is p[1] with offset (-75.00,0.00)
 

vypur85

Hibernate
Reaction score
803
Hmmm... This seems to have been done before but I can't remember :p (similar to Ace's Hatchery Havoc?). Seems interesting and nice. But provide a map so that we don't have to recreate the trigger ourself just to see the effect.

+R
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
I've added a demo map. I've also changed the code a bit, now it doens't show the mana bar to enemies of the player. In single player this doens't matter, but in multiplayer, you can use the mana bars to determine the position of your enemy under the fog of war.

Edit: I'm trying to convert it to JASS, so you only have to copy the code then.
 

ImmortaL_GoD

New Member
Reaction score
4
@ immortalGodz, are those mages you want a mana bar to appear above the only mages on the map, if so, just add "unit-type of matching unit equal to mage" only once to the "set unit group" line.

To put it to the left or right, change to x value in "set p[2] is p[1] with offset (-75.00,0.00)
Nah, there's 6 different specific mages, I changed it to simply "Unit Comparison", then I tried something else, and forgot to change it back the same way, so sec, trying again.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top