Snippet Floating Mana Bar

Sirroelivan

Gunnerkrigg Court
Reaction score
95
If you wanted to check individual units, you'd have to put an or between the different checks. A unit can't be two units at the same time. :p
 

ImmortaL_GoD

New Member
Reaction score
4
Yeah, that's what I did.

Code:
Mages
    Events
        Time - Every 0.03 seconds of game time
    Conditions
    Actions
[B]        Set temp_group = (Units in (Playable map area)(((Matching unit) Equal to |c00ff0000Mage 0021 <gen>) and (((Matching unit) Equal to |c00800080Mage 0023 <gen>) and (((Matching unit) Equal to |c00000000Mage 0020 <gen>) and (((Matching unit) Equal to |c000000ffMage 0019 <gen>) an[/B]
        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)
                    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

Still didn't work, part of the designated part got cut it off, but it simply follows the pattern, adding one more mage.
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Check my above post. Either you use or between the different mage checks or you use 1 'unit type of matching unit equal to mage'.
 

ImmortaL_GoD

New Member
Reaction score
4
OH, I misread, you said to use or, not and (I thought you just typoed "and" lol), sorry. =p

Code:
Set temp_group = (Units in (Playable map area)(((Matching unit) Equal to |c00ff0000Mage 0021 <gen>) or (((Matching unit) Equal to |c00800080Mage 0023 <gen>) or (((Matching unit) Equal to |c00000000Mage 0020 <gen>) or (((Matching unit) Equal to |c000000ffMage 0019 <gen>) or ((

Like this? Still didn't work.

EDIT: Woo, nvm, made it work. That if/and/any shit ruined it, I just added that part in with "and" into the whole aforementioned trigger. Thanks a lot for the help, man.

One question though, is there a way to make the bar stop blinking so much..?
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Experiment with the event (every ... sec) and the duration of the floating text. Make it a bit longer should work. But the duration of the floating text should always be longer than the trigger event.
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
the time of the event and of the action 'floating text - change last created floating text's duration to ...'
 

woot

New Member
Reaction score
8
I just copied the code given in the first post

I tried this in my game.. it worked alright but once I used my command to spawn 34 units the game slowed incredibly and I could see no mana bars above units heads

:(


EDIT: I also tried running the demo map and it started out ok for a few seconds but then the game slowed to a near-freeze =\ hmmmmm

EDIT: also, you are destroying the group ug in the demo map within the pick all units in group loop.. I took it out of the loop and ran your map and it seems to be running better .. it still "freezes" my game up with 34 units spawned
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Wow Sirroelivan, you are my God.
Just look at this and you'll understand why :D .
+rep and 5 stars, thank you so much!

EDIT: It doesn't show the mana bars at all for me :( ?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I build one tower and it doesn't show the mana bar.
My game spawns 9 units, and it doesn't show the mana bar at all...
 

vypur85

Hibernate
Reaction score
803
> doesn't show the mana bar at all...

Units need to have mana to be able to show the mana bar. Anyway, how did you construct the trigger? You made it yourself or copy from the map?

The trigger posted has something wrong.


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
                [del]Custom script:   call DestroyGroup(udg_ug)[/del]
                Custom script:   call DestroyForce(udg_pg)
                Custom script:   call RemoveLocation(udg_p[1])
                Custom script:   call RemoveLocation(udg_p[2])
        [B]Custom script:   call DestroyGroup(udg_ug)[/B] <-- [I]Should be outside the loop[/I]

Not sure if the map attached has the correct code or not. Didn't check.
 

D.V.D

Make a wish
Reaction score
73
I really like this system +rep, but it blinks every second or so when the unit gains mana. How can you change that?
 

Furby

Current occupation: News poster
Reaction score
144
Well, I do not have one of the best PCs in the world, but games I play are usually not lagging for me. (I can play DotA with any lag)

Though in this was lag everywhere. I could not move with screen normally and I could not see bars.

So, I cannot comment this if is it good.
 

D.V.D

Make a wish
Reaction score
73
Not really. Unless you make the mana bar last like 0.03 seconds longer after the new one is made or something like that.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top