HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Progress Bar

03-14-2006, 04:58 PM#1
paidan_fain
Alright, I don't want to create a whole new thread so I'll post it here. The code I've posted creates a semi-smooth but nearly 100% accurate progress bar with a nice, rounded image. I've tried to do it with timers, but considering I've never really dealt with them too much, I didn't have too much success. Anyways, the new problem is that a progress bar will show up for up to two simeltanously(sp?) cast spells but if more than that is cast at the same time, each bar passed the second either fails to show or appears horribly disfigured. First I figured the problem must be that the GetSpellAbilityUnit() must have changed but then why would it work for the first two casting units? I can post a ss if its necessary.
Code:
function progressBar takes real time returns nothing
    local integer loopX = 0 //The loop variable for initially spawning 50 floatingText
    local integer loopA = 0 //The loop variable for changing the color of the 50 floatingText
    local integer loopC = 0 //The loop variable for destroying the 50 floatingText
    local string display = "0" //What I am using for the progressbar
    local texttag array textTag //The actual floatingText array
    local location unitPosOffSet //The position at which I spawn the floatingText
    local boolean exit = false //When I exit changing the color of floatingText
    local unit whichUnit = GetSpellAbilityUnit() //The unit being progressed
    local integer castID = GetUnitCurrentOrder(whichUnit) //The castID because I am too stupid to now what it is
    if (whichUnit != GetSpellAbilityUnit()) then
        set exit = true
    endif
    loop
        exitwhen loopX >= 50
        set unitPosOffSet = OffsetLocation(GetUnitLoc(whichUnit),loopX - 25,0)
        set textTag[loopX] = CreateTextTagLocBJ(display, unitPosOffSet,0,5,100,100,100,0)
        call SetTextTagVisibility(textTag[loopX],true)
        set loopX = loopX + 1
    endloop
    loop
        exitwhen exit == true
        if ( GetUnitCurrentOrder(whichUnit) != castID ) then
            set exit = true
        else
            call SetTextTagColorBJ(textTag[loopA],0,0,100,0)
            call SetTextTagColorBJ(textTag[loopA + 1],0,0,100,0)
            call SetTextTagColorBJ(textTag[loopA + 2],0,0,100,0)
            call PolledWait( time / 23.33)
            set loopA = loopA + 3
        endif
    endloop
    loop
        exitwhen loopC >= 50
        call DestroyTextTagBJ(textTag[loopC])
        set loopC = loopC + 1
    endloop
endfunction 
03-14-2006, 05:02 PM#2
Captain Griffen
Waits cannot go below 0.27. You'd have to use timers to do so.

EDIT: Beyond that, I can't really say, since you haven't given any information about what it is supposed to do beyond saying a map.
03-14-2006, 06:42 PM#3
Jacek
Interesting, I thought waits <0.10 aren't possible... well... Captain Griffen he wants progress bar like ||||||||||
03-14-2006, 07:03 PM#4
Captain Griffen
Waits might be possible of going down to 0.1, but below ~0.25, they aren't really accurate.
03-14-2006, 07:21 PM#5
paidan_fain
Quote:
Originally Posted by Captain Griffen
Waits cannot go below 0.27. You'd have to use timers to do so.

I always though polled waits used timers to calculate the remaining time? Guess not...
03-14-2006, 07:23 PM#6
Captain Griffen
No, polled waits just wait for all players to reach that point, or something along those lines (accounts for lag, basically). You need timers to do it accurately (which can be annoying).
03-14-2006, 08:05 PM#7
Chuckle_Brother
Polled wait is called it because it works as I am about to explain:

It starts a timer to expire in the time given, then it 'polls' or checks the remaining time on the timer every 0.1 seconds, but if the wait is larger it executes larger waits, divisible by 10 always I think.

Now to the matter at hand. What is the bar for exactly?
03-14-2006, 08:23 PM#8
paidan_fain
It is to show the progress of any spell as it is being casted (Eg. if the spell takes 5 seconds to cast, a bar lasting 5 seconds appears next to the unit. I can post a screen shot if you want because the graphics work fine)
03-14-2006, 08:36 PM#9
Thunder_Eye
You can find a Progressbar system at wc3sear.ch, unless you want to do it by yourself you should check that one out.
03-14-2006, 08:52 PM#10
paidan_fain
Quote:
Originally Posted by Thunder_Eye
You can find a Progressbar system at wc3sear.ch, unless you want to do it by yourself you should check that one out.

You sure? The closest thing I found was a smithing system and the problem with that is that only the player of the smithing unit can see the progress while I want everyone to be able to see it.
03-14-2006, 09:22 PM#11
Thunder_Eye
I'm 100% sure, I even have it on my comp, I can upload it If you cant find it.
The map is wow related.
03-14-2006, 09:43 PM#12
paidan_fain
Alright. Despite the inaccurate sleep in Wc3, I completed the progress bar that takes a time and a unit. I ended up having to sacrifice smoothness for accuraccy by increasing the intervals, thus making it choppy but more accepting of the PolledWait.
Close this Thread.
03-15-2006, 03:45 AM#13
Chuckle_Brother
Sorry to revive, but instead of using waits it may be better to use timers since they are wicked accurate
03-15-2006, 10:18 AM#14
Thunder_Eye
I thought you might want too see it anyway, so here it is:
(now that I look at it again it isnt as smooth as I remember it ;P)
Attached Files
File type: w3xFrostbolto_O.w3x (32.5 KB)
03-15-2006, 01:48 PM#15
Blade.dk
That map was made by Alfred, just to state it if it has not already been done.