• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

GenericBar

This is an animated bar model that can be manually colored depending on the user's needs.

How it works is - you create a bar unit and force it to move to the bar owner's position with a timer, and then update its values. The way you can make a hp bar with a color run from green to red, or to make sure that enemies and allies have a different colored bar, create a spell channel bar, and so on.

In order to animate this, you need to use this approach:

JASS:
call SetUnitAnimationByIndex(barUnit, VALUE_BETWEEN_0_AND_100)

The bar is filled when the value is 100 and it's empty when it's 0, so trigger the system in such a way that it display it correctly.

I will probably be uploading a system that does this, however, and that's configurable enough. There are many issues to think of with custom HP/MP bars and I'd want to solve them for majority of users. This bar can also be used for spell channel animation which I think is primarily what people would use it for, after all.

IMPORTANT!!! TO MAKE IT RENDER ON TOP OF EVERYTHING YOU HAVE TO USE SetUnitVertexColor on it at least once! This makes it render in front of everything.

Updated: Now works from left to right (0 to 100)
Updated: Now doesn't clip with anything I think

Also, special thanks to Emm-A- who debugged this to hell and back.

Keywords:
bar, interface, channel
Contents

GenericBar (Model)

Reviews
17:35, 24th Apr 2016 Fingolfin: A useful alternative to JesusHipster's bars.
Level 14
Joined
Jul 1, 2008
Messages
1,314
There is a lot of bars, but what I like about this one is its ambivalence. This can also be used as a general progress bar for any type of timed event, so I think this is actually very useful!
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
This is exactly the same kind of model Invasion in Duskwood uses. The great thing about it is that it is animated naturally by the WC3 engine, so you don't need to do any fancy movement for the bars - you will get smooth transitions with literally no effort, which is great.
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
No, I just use SetUnitAnimationByIndex - it does a smooth transition. Isn't it the case for you too?

What I meant was that I simply put my model as a unit model seeing how it would look in game, and it was doing smooth transitions right from the start, without having to do any other configuration whatsoever.
 
Ah, I thought you only use one animation. Because such a solution exists too. It doesn't do that in my case because I set blend time to 0. But if I set it higher it will be smoothed out. I practically generated this animation data using a python script so it'd work well, but I realize now I should probably reverse it and make it start from 0 towards 100 instead of the other way around.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
For example, look at this screen shot: disappearing bar

The bar is flying at Z = 150.00 at the very same position of this cow (which is a normal, ground, non-hero unit), but it seems to be semi-transparent.
Might be a problem with my WE though, and it does not dissappear behind any type of objects. (It does so quite often though, but I am not able to see any logic behind it ...)
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I looked more closely, and it actually happens to every object you can see on that screen: the harvester, walls, hay stacks and the cow.
But only the white part of the bar disappears, not the black part - the latter is just fine.
So it is not the cow itself, and the hay stack is a blizzard doodad. Maybe you cant use any unit as a base for the bar? (I used a human falkon rider by blizzard)

I can upload the cow tomorrow anyway if that helps you finding out whats wrong. Might be a unique thing with my We as well ...
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I tried it, and unfortunately, it still disappears. (BTW: The animation indices are mirrowed now ...)

Check this screen. There u see the hero "standing" on the bar, which is actually still flying at 150 over the cow's position. If you look at it from 180° different angle, the bar appears to fly over the cow correctly, but as soon as it "hits" another object, it disappears behind it.

I dont know, if that is only my Wc3 doing that. It is not a big deal though, the bar is still useful.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I restarted my WE, opened a complete new map and loaded both bars. Jesus Hipsters bar does not clip, but yours does, see here: example. It does not change anything to use different base units.

Would be really interesting, if someone else could try the bar and see if it works?
 
Level 34
Joined
Sep 19, 2011
Messages
2,119
I restarted my WE, opened a complete new map and loaded both bars. Jesus Hipsters bar does not clip, but yours does, see here: example. It does not change anything to use different base units.

Would be really interesting, if someone else could try the bar and see if it works?

Hmmm, wait, which of of bars of mine (1 or 100 animations) was not clipping.

i haven't encountered problems with HT's bar, this is realy weird.

mind sharing a testmap?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Hmmm, wait, which of of bars of mine (1 or 100 animations) was not clipping.

i haven't encountered problems with HT's bar, this is realy weird.

mind sharing a testmap?

sry, I thought that clipping is the word for that behaviour that Happy Taurens bars show in my WC3. So no need to be worried, because your bar is fine.

@Happy Tauren: The black part is fine now for most models (yay! :)), especially blizzard ones. The white part still disappears though.

@both: You can check out this test map, where I observe this dissappearing effect in my WC3. bar test
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Try this one then.

I think you got it right with this one. It worked for blizzard models as well as the already shown custom ones from my previous posts. :thumbs_up:

Now, you got a great model there! :) thank you for sharing!

(sidenote: I do not want to be fussy, but just wanted to state, that selection circles might show up in fornt of the black part, but I am not sure...)
 
Yes, but I used a python script to generate sequence/translation data, so it was no biggie.

That's pretty clever actually. Work smart, not hard.

I see you guys have tested it back and forth, can you confirm that it works as intended? Because if it does, i can approve it on good faith seeing as you are a senior modeler.
 
That's pretty clever actually. Work smart, not hard.

I see you guys have tested it back and forth, can you confirm that it works as intended? Because if it does, i can approve it on good faith seeing as you are a senior modeler.

Yeah, this is tested to hell and back, but will only work properly if you make sure its transparency is reduced to at least 254 or something, because if it is set to 255 via SetUnitVertexColor it will clip with other objects. Naturally, you're going to apply that function so it will work as intended.
 
Top