System Zwiebelchen's Casting Bar System

Zwiebelchen

You can change this now in User CP.
Reaction score
60
I checked the code again and there should be no problem with it, since it doesn't contain elseif-return and H2I routines.
All you have to do is update your ABC and it should work fine.
 

Azlier

Old World Ghost
Reaction score
461
This doesn't even need ABC. You should probably move to an actual timer system. I would use KT2. It doesn't need 1.24 updating, lets you specify a period, and is the fastest system with such flexibility out there.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
This doesn't even need ABC. You should probably move to an actual timer system. I would use KT2. It doesn't need 1.24 updating, lets you specify a period, and is the fastest system with such flexibility out there.
I already mentioned about the optimization and stuff. It makes no sense here, since you are limited to 100 floating texts anyways. Also, the bar filling looks "smoother" with variable timer intervalls.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
!! UPDATE - System Completely remastered !!
+ Requires WCIII Patch 1.24b or higher!
+ No longer requires ABC; completely standalone now
+ Uses the new native Hashtables
+ Optimized Code, now with Single Timer



If I didn't miss something very vital, it should be worth approving now.
 

Nerzhul

New Member
Reaction score
7
I looked at it and it's very nice :thup:
For approval, I'm not sure but,i think it require a readme for those who aren't very skilled with JASS.
 

Steel

Software Engineer
Reaction score
109
JASS:

private function CommaMultiplier takes integer Number returns string // This function seems poorly triggered, but it's like this for a reason
    local string CommaString = ""
    // Ordinary Loopcalls would totally fuck off the performance on heavy duty cause of the awkward string handling of Warcraft III
    // If you want to use more than 50 Barbits (though I don't recommend that), feel free to add more ifs here.
    // It's highly recommended to hardcode the Barbits here (replace them with "''''''''''" for example) - it will greatly improve performance
    if Number >= 25 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 25
    endif
    if Number >= 15 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 15
    endif
    if Number >= 5 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 5
    endif
    loop
        exitwhen Number <= 0
        set CommaString = CommaString+BarBit
        set Number = Number - 1
    endloop
    return CommaString
endfunction


Elaborate on the awkwardness of WC3 string handling, because this function is insanely horrible for complexity sake.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
JASS:

private function CommaMultiplier takes integer Number returns string // This function seems poorly triggered, but it's like this for a reason
    local string CommaString = ""
    // Ordinary Loopcalls would totally fuck off the performance on heavy duty cause of the awkward string handling of Warcraft III
    // If you want to use more than 50 Barbits (though I don't recommend that), feel free to add more ifs here.
    // It's highly recommended to hardcode the Barbits here (replace them with "''''''''''" for example) - it will greatly improve performance
    if Number >= 25 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 25
    endif
    if Number >= 15 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 15
    endif
    if Number >= 5 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 5
    endif
    loop
        exitwhen Number <= 0
        set CommaString = CommaString+BarBit
        set Number = Number - 1
    endloop
    return CommaString
endfunction


Elaborate on the awkwardness of WC3 string handling, because this function is insanely horrible for complexity sake.
Basicly, you could just remove the ifs and it would still work fine. However, after doing stress test on the system (Create 100 Bars at once), I realized that it seriously decreases FPS. The problem is, that there is no real workaround for this, since strings in WC3 always create heavy lag on parallel creating. (Try it out ... create a trigger than shows 200 text messages per second and try to move a unit during that)
You could workaround this by hardcoding the strings to reduce the number of string modifications per function call like I did. I didn't find another solution to that.
As I said: It's something related to blizzard's coding of string handling. I don't know how anyone could fix that.

I looked at it and it's very nice :thup:
For approval, I'm not sure but,i think it require a readme for those who aren't very skilled with JASS.
A "readme" is included to the system's header (comments) and this post. I think it's pretty clear how it works - I even posted examples (yes, also for GUI users).
 

Nerzhul

New Member
Reaction score
7
Basicly, you could just remove the ifs and it would still work fine. However, after doing stress test on the system (Create 100 Bars at once), I realized that it seriously decreases FPS. The problem is, that there is no real workaround for this, since strings in WC3 always create heavy lag on parallel creating. (Try it out ... create a trigger than shows 200 text messages per second and try to move a unit during that)
You could workaround this by hardcoding the strings to reduce the number of string modifications per function call like I did. I didn't find another solution to that.
As I said: It's something related to blizzard's coding of string handling. I don't know how anyone could fix that.


A "readme" is included to the system's header (comments) and this post. I think it's pretty clear how it works - I even posted examples (yes, also for GUI users).

Didn't notice it...Probably because it was easy (for me XD).Then I think an admin din't look to this ^^ just wait...
 

Steel

Software Engineer
Reaction score
109
Basicly, you could just remove the ifs and it would still work fine. However, after doing stress test on the system (Create 100 Bars at once), I realized that it seriously decreases FPS. The problem is, that there is no real workaround for this, since strings in WC3 always create heavy lag on parallel creating. (Try it out ... create a trigger than shows 200 text messages per second and try to move a unit during that)
You could workaround this by hardcoding the strings to reduce the number of string modifications per function call like I did. I didn't find another solution to that.
As I said: It's something related to blizzard's coding of string handling. I don't know how anyone could fix that.


A "readme" is included to the system's header (comments) and this post. I think it's pretty clear how it works - I even posted examples (yes, also for GUI users).

First of all you can't create 100 of these bars, TextTags has a hardcap built into the game, but that's completely irrelevant. This is highly ineffective, especially since you're just color coding the string which is the castbar.

Here is the code I used in my Floating Bars system:
JASS:
function UpdateBar takes integer in, string barstr, texttag t, unitstate curr, unitstate max returns nothing
    local integer   i       = 0
    local integer   j       = 0
    local boolean   update  = false   

        loop
            exitwhen i==BarLength
            if (not update) and (GetUnitState(structlink[in].u, curr) < (i * ((GetUnitState(structlink[in].u, max))/BarLength))+1) then
                set update = true
                set barstr = barstr+"|r|cFF000000"
            else
                set barstr = barstr+DisplayCharacter
            endif
            set i = i + 1
        endloop
        set barstr = barstr+"|r"    
        call SetTextTagText(t, barstr, BarSize * 0.023 / 10)
        call SetTextTagVisibility(t,IsUnitVisible(structlink[in].u,GetLocalPlayer()))

endfunction


You should be able to run the same thing with a simple loop to colorize your bar. You're doing so many string concatenations it's getting out of hand. I don't like how yours works because it breaks things down, I'll look at your code a close and see if I can come up with anything, it just seems like it can be optimized and you don't need all this mess.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
You should be able to run the same thing with a simple loop to colorize your bar. You're doing so many string concatenations it's getting out of hand. I don't like how yours works because it breaks things down, I'll look at your code a close and see if I can come up with anything, it just seems like it can be optimized and you don't need all this mess.
Man, what are you talking about? I did that exactly the way you have it. I HAVE a simple loop to colorize my bar (Look it up in the code).
I think you totally missed the point. I run all these ifs not because I don't have a loop inside. There IS one. I run these ifs only to SHORTEN the amount of string modifications and thus decreasing the processing time.

And I know there is a hardcap of 100 tags. I even built in a failsave for that and a debug message.
Please look through the code and check wether your statements are correct before you post negative criticism o_O'
 

Steel

Software Engineer
Reaction score
109
Man, what are you talking about? I did that exactly the way you have it. I HAVE a simple loop to colorize my bar (Look it up in the code).
I think you totally missed the point. I run all these ifs not because I don't have a loop inside. There IS one. I run these ifs only to SHORTEN the amount of string modifications and thus decreasing the processing time.

And I know there is a hardcap of 100 tags. I even built in a failsave for that and a debug message.
Please look through the code and check wether your statements are correct before you post negative criticism o_O'

JASS:

if Number >= 25 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 25
    endif
    if Number >= 15 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 15
    endif
    if Number >= 5 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 5
    endif

This is the part I'm talking about, I'm not talking about the colorization. I'm just curious as to why you are doing this. It doesn't make any sense to have such large string concats. I'm not trying to give you negative criticism I'm trying to figure out why you did it this way because this can be simplified.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
JASS:

if Number >= 25 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 25
    endif
    if Number >= 15 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 15
    endif
    if Number >= 5 then
        set CommaString = CommaString+BarBit+BarBit+BarBit+BarBit+BarBit
        set Number = Number - 5
    endif

This is the part I'm talking about, I'm not talking about the colorization. I'm just curious as to why you are doing this. It doesn't make any sense to have such large string concats. I'm not trying to give you negative criticism I'm trying to figure out why you did it this way because this can be simplified.
Alright; I try to explain it again:
Strings in Warcraft III are by far the slowest variable you could ever imagine. Warcraft III seriously decreases in FPS once you create a String. Well ... you don't notice this if you are only creating 10-20 strings at once (like you do with Text tags most of the time); however, it will seriously fuck up the performance when chain-creating or -modifying more than 100-200 strings.

Let's say you call 50 floating bars at once. This means you have to run 50*(Bar-Lenght+2) string modifications in your case.
This equals up (for 48 Bits Bar-Lenght for example) to 2500(!) String modifications, which is HUGE for Warcraft III and usually slows down your PC heavily.
In my case (bar update every 0.02 seconds), this would mean 125.000 String modifications per second.

You have to avoid String modifications as much as possible. However; the only way to do this is via hardcoding the Barstrings in our case - and this only works with a lot of ifs.
I hope you now understand what I mean.
With my system, I can reduce the number of String modifications to: (48+2-24-14-4)*50 = 400 Strings.
In my case (bar update every 0.02 seconds), this would mean 20.000 String modifications per second.

If you don't believe it: Try to create 100 (even 50 should be enough) of your floating bars at once every second and check the FPS. (Well ... it depends on your PC of course ... if you don't notice it on a highend PC, it's a different matter ... I only have 512 megs of ram and barely 1800 Mhz)
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Updated my first post.

Now there is also a modular version, in case you like modularity. It also comes with locked bars following the unit if it moves. (Thanks to Daeod for this one)

The Stand-Alone version is still there, if you don't like unneccesary dependencies.
 

Ignitedstar

New Member
Reaction score
1
Hey, Zwiebelchen. Currently using your casting bar system (the modular version). Works beautifully.

I have a question, though. Quite a long time ago, I acquired some SFX models from JetJangInferno (hopefully spelling his name right) that are the sort of thing that you place on a unit while they are casting a spell. I had done this for awhile, but it was very inaccurate and I didn't like it very much, thus removing it and trying to find another way of applying the SFX models.

I believe that your casting bar system could potentially allow me to add special effects to units that are casting or even channeling. I don't see the harm, but I'd rather that you do it or show me how and where I could make the necessary changes to make it happen.

I'm imagining an alternated function call like this:
[ljass]call Castingbar(Castingtime, Orderstring, Casterunit, VisiblyModifier, ChannelingBool, SpecialFX)[/ljass]
Of course, you could always leave it blank if you don't want one.

On a side note, though not particularly a major issue, if you set Castingbar's ChannelingBool to true, but have a spell that has a casting time, the string made by Castingbar will show as channeling even though the ability is in casting time. This is easily fixable on my part by just adding a wait to the trigger that does it. Still, just thought I'd let you know.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Hey, Zwiebelchen. Currently using your casting bar system (the modular version). Works beautifully.

I have a question, though. Quite a long time ago, I acquired some SFX models from JetJangInferno (hopefully spelling his name right) that are the sort of thing that you place on a unit while they are casting a spell. I had done this for awhile, but it was very inaccurate and I didn't like it very much, thus removing it and trying to find another way of applying the SFX models.

I believe that your casting bar system could potentially allow me to add special effects to units that are casting or even channeling. I don't see the harm, but I'd rather that you do it or show me how and where I could make the necessary changes to make it happen.

I'm imagining an alternated function call like this:
[ljass]call Castingbar(Castingtime, Orderstring, Casterunit, VisiblyModifier, ChannelingBool, SpecialFX)[/ljass]
Of course, you could always leave it blank if you don't want one.
You can easily do that by just applying the sfx to the unit in the CastingBar function and remove it when the struct gets destroyed.

On a side note, though not particularly a major issue, if you set Castingbar's ChannelingBool to true, but have a spell that has a casting time, the string made by Castingbar will show as channeling even though the ability is in casting time. This is easily fixable on my part by just adding a wait to the trigger that does it. Still, just thought I'd let you know.
Well ... this is something the user has to watch for. The system itself wasn't made to handle spellcasting on its own; it just does periodic orderstring checks and does the bar art and nothing more. If you do not want channeled spells to trigger the casting bar during the casting time, but when the cast effect starts, use a different event.
(use "Unit starts effect of spell" event instead of "Starts casting" events)


PS: This system is not supported anymore. I recommend using Anachrons TTBars System instead.
 

Ignitedstar

New Member
Reaction score
1
Thanks for the reply. That's perfectly fine. Argh, structs... not really my cup of tea, but I'll manage somehow...

Yeah, I've looked at Anachron's Bar system and honestly, I don't like it as much because his doesn't do everything in one function call. I could do that myself, but it's a little late for that. Even though it's just copy+pasting, I really don't want to make a page of code for one spell when I have to do this for a hundred others. Sure, it had gradient mixing and what-not, but do I really need any of that?

Simply because yours is easier to apply to hundreds of spells without needing to make a hundred pages worth of code is why I prefer this over that. With yours, I can do everything I need for this to do with only about 2-3 pages.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Hmm, if you do not like importing like 2 or 3 libraries just for the casting bar, I would recommend you using the standalone version of the system instead of the modular one. The standalone version (as the name implies), does not require any other library at all.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top