System Zwiebelchen's Casting Bar System

Zwiebelchen

You can change this now in User CP.
Reaction score
60
wc3scrnshot022609035648.jpg



This System creates a floating text style Casting bar below (or above) your unit via using a simple function call.


Features:
- Automaticly cancels the bar progression when the unit gets a different order (you can deactivate this feature if you wish)
- 3 visibility options (Player only, all friendlys, all players)
- easy to use and adjust
- 100% leak free
- ordinary and channeled cast (inverted) settings


Requires:
- Newgen (http://www.thehelper.net/forums/showthread.php?t=73936)
- TTbars (Modular version)
- ARGB (Modular version)
- TimerUtils (Modular version)

Pros:
- Easy to implement and adjust
- MUI and GUI-accessable

Cons:
- May slow down your map on heavy use due to masses of string calls (mostly unavoidable)

Implementation:
- Create a new trigger called "CastingBar"
- Convert it to custom text
- Replace everything in the trigger with the Jass Code below


Use
Custom Script: call Castingbar(Castingtime, orderstring, unit, visibilityInt, ChanneledBool)
when you want to attach a casting bar to a unit.
For example:
Custom Script: call Castingbar(2.50, "heal", GetTriggerUnit(), 2, false)

Note: This Casting Bar system only works properly, if the unit maintains the order during the execution. This means it works only during the "casting" time or the "channeling" time of the ability. If you wish to apply the Casting bar without having the unit ordered a spell, you can disable the orderstring checking.

Thanks to Deaod for the modular version:
JASS:

library CastingBar uses TTBARS, ARGB


// Zwiebelchen's Casting Bar System
// redone.

// Requires NewGen, such as Warcraft III Patch 1.24b

    globals
        private constant integer NUMBER_OF_BAR_BITS = 40       // The number of the commas/apostrophes/whatever you use to fill an entire bar
                                        // It's not recommended to set this higher than 100, since it will cause lag due to the bad string handling of Warcraft III
                                        // Use a bigger Size instead.
                                        // Never set this to 0, since it will create a divide by 0 error.
        private constant string BAR_BIT = "'"             // The letter used for the Bar
        private constant integer COLOR = 0xFF33CCFF // The hex color code for the bar - Leave out the "|r" at the end!
        private constant integer COLOR_CHANNEL = 0xFF00FF00   // The hex color code for the Channeling bar - Leave out the "|r" at the end!
        private constant integer BACKGROUND_COLOR = 0xFF000033 // The hex color codes for the Background of the Bar
        private constant integer BACKGROUND_COLOR_CHANNEL = 0xFF003300 // The hex color codes for the Background of the Channeling Bar
        private constant real CASTING_BAR_X_OFFSET = 0   // The X Offset of the bar position to the unit. + being east
        private constant real CASTING_BAR_Y_OFFSET = 0   // The Y Offset of the bar position to the unit. + being north
                                        // Set these values to 0 if you want to use a third person camera or do the math
                                        // and get an equation depending on the camera angle if you want to use a 3D camera.
                                        // It may need a little bit of trying to find good values for these
        private constant real CASTING_BAR_Z_OFFSET = 0      // The Z Offset of the bar position to the unit.
        private constant real CASTING_BAR_SIZE = 8         // The size of the bar font
        private constant real CASTING_BAR_FADE_OUT = 0.5
        private constant real TICK = 0.02   // The frequency the bars get updated - recommended value: 0.02
    endglobals
    
//----------------------------------------------------------------------------------------

//Use call Castingbar(Castingtime, Orderstring, Casterunit, VisiblyModifier, ChannelingBool) to attach a casting bar to a unit.

//  variables:  real Castingtime -->    Only use casting times above 0.3 seconds, otherwise it will look strange
//              string Orderstring -->  The Orderstring of the ability. Used to determine wether the unit moves
//                                      during the casting. Set this to "_" to disable the orderstring check.
//              unit Casterunit -->     Obviously the caster
//              integer Visibly Modifier -->     Changes Visibility of the Casting bar
//                                                 0: Only the owner of the casting unit sees the bar
//                                                 1: All Allies of the Player can see the bar
//                                                 2: All Players can see the bar
//              boolean Channeled -->   false: ordinary cast; true: channeled cast

    private struct Data
        TTBar bar
        unit c
        real t
        real tt
        string order
        
        private integer i
        
        private static thistype array Structs
        private static timer T=CreateTimer()
        private static integer Count=0
        
        method onDestroy takes nothing returns nothing
            call .bar.FadeOut(CASTING_BAR_FADE_OUT, true, 0,0)
            // clean your struct here
            set .Count=.Count-1
            set .Structs[.i]=.Structs[.Count]
            set .Structs[.i].i=.i
            if .Count==0 then
                call PauseTimer(.T)
            endif
        endmethod
        
        private static method Callback takes nothing returns nothing
        local integer i=.Count-1
        local thistype s
            loop
                exitwhen i<0
                set s=.Structs<i>
                //
                if GetUnitCurrentOrder(s.c)==OrderId(s.order) or s.order==&quot;_&quot; then
                    set s.t=s.t+TICK
                    set s.bar.Value=100*s.t/s.tt
                    if s.t&gt;=s.tt then
                        call s.destroy()
                    endif
                else
                    call s.destroy()
                endif
                // do your things here, dont forget to call s.destroy() somewhen
                //
                set i=i-1
            endloop
        endmethod
        
        static method create takes unit caster, real time, string order, force disp, boolean channel returns thistype
        local thistype s=.allocate()
            set s.bar=TTBar.create(BAR_BIT, NUMBER_OF_BAR_BITS, CASTING_BAR_SIZE, GetUnitX(caster)+CASTING_BAR_X_OFFSET,GetUnitY(caster)+CASTING_BAR_Y_OFFSET,CASTING_BAR_Z_OFFSET)
            call s.bar.ChangeVisibility(disp)
            call s.bar.LockToUnit(caster, CASTING_BAR_X_OFFSET, CASTING_BAR_Y_OFFSET, CASTING_BAR_Z_OFFSET)
            if channel then
                call s.bar.SetBackground(ARGB(BACKGROUND_COLOR_CHANNEL))
                call s.bar.SetForeground(ARGB(COLOR_CHANNEL))
            else
                call s.bar.SetBackground(ARGB(BACKGROUND_COLOR))
                call s.bar.SetForeground(ARGB(COLOR))
            endif
            set s.c=caster
            set s.t=0
            set s.tt=time
            set s.order=order
            // initialize the struct here
            set .Structs[.Count]=s
            set s.i=.Count
            if .Count==0 then
                call TimerStart(.T, TICK, true, function thistype.Callback)
            endif
            set .Count=.Count+1
            return s
        endmethod
    endstruct
    
    function Castingbar takes real Casttime, string Order, unit Caster, integer ShowCastingBar, boolean Channeled returns nothing
    local force TextTagForce=null
    local player LocalPlayer = GetOwningPlayer(Caster)
        if ShowCastingBar == 0 then
            set TextTagForce = CreateForce()
            call ForceAddPlayer(TextTagForce, LocalPlayer)
        elseif ShowCastingBar == 1 then
            set TextTagForce = CreateForce()
            call ForceEnumAllies(TextTagForce, LocalPlayer, null)
        endif
        call Data.create(Caster, Casttime, Order, TextTagForce, Channeled)
        if TextTagForce!=null then
            call DestroyForce(TextTagForce)
            set TextTagForce = null
        endif
    endfunction

endlibrary
</i>


If you don't like modularity and prefer a stand-alone version, use this code:
JASS:

library CastingBar initializer InitCastingBar


// Zwiebelchen&#039;s Casting Bar System

// Requires NewGen, such as Warcraft III Patch 1.24b

globals
    private constant integer NumberOfBarBits = 40       // The number of the commas/apostrophes/whatever you use to fill an entire bar
                                    // It&#039;s not recommended to set this higher than 100, since it will cause lag due to the bad string handling of Warcraft III
                                    // Use a bigger Size instead.
                                    // Never set this to 0, since it will create a divide by 0 error.
    private constant string BarBit = &quot;&#039;&quot;             // The letter used for the Bar
    private constant string Colorcode = &quot;|cff33ccff&quot; // The hex color code for the bar - Leave out the &quot;|r&quot; at the end!
    private constant string ColorcodeCh = &quot;|cff00ff00&quot;   // The hex color code for the Channeling bar - Leave out the &quot;|r&quot; at the end!
    private constant string ColorcodeBG = &quot;|cff000033&quot; // The hex color codes for the Background of the Bar
    private constant string ColorcodeBGCh = &quot;|cff003300&quot; // The hex color codes for the Background of the Channeling Bar
    private constant real CastingBarXOffset = 0   // The X Offset of the bar position to the unit. + being east
    private constant real CastingBarYOffset = 0   // The Y Offset of the bar position to the unit. + being north
                                    // Set these values to 0 if you want to use a third person camera or do the math
                                    // and get an equation depending on the camera angle if you want to use a 3D camera.
                                    // It may need a little bit of trying to find good values for these
    private constant real CastingBarZOffset = 0      // The Z Offset of the bar position to the unit.
    private constant real CastingBarSize = 8         // The size of the bar font
    private constant real ZCBTimerIntervall = 0.02   // The frequency the bars get updated - recommended value: 0.02
    
    
    //Do not edit the following variables!
    private boolexpr b = null
    private texttag array ZCBarray
    private integer NumberOfBars = 0
    private hashtable ZCBHash = InitHashtable()
    private timer ZCBTimer = CreateTimer()
endglobals
    
//----------------------------------------------------------------------------------------

//Use call Castingbar(Castingtime, Orderstring, Casterunit, VisiblyModifier, ChannelingBool) to attach a casting bar to a unit.

//  variables:  real Castingtime --&gt;    Only use casting times above 0.3 seconds, otherwise it will look strange
//              string Orderstring --&gt;  The Orderstring of the ability. Used to determine wether the unit moves
//                                      during the casting. Set this to &quot;_&quot; to disable the orderstring check.
//              unit Casterunit --&gt;     Obviously the caster
//              integer Visibly Modifier --&gt;     Changes Visibility of the Casting bar
//                                                 0: Only the owner of the casting unit sees the bar
//                                                 1: All Allies of the Player can see the bar
//                                                 2: All Players can see the bar
//              boolean Channeled --&gt;   false: ordinary cast; true: channeled cast


private function CommaMultiplier takes integer Number returns string // This function seems poorly triggered, but it&#039;s like this for a reason
    local string CommaString = &quot;&quot;
    // 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&#039;t recommend that), feel free to add more ifs here.
    // It&#039;s highly recommended to hardcode the Barbits here (replace them with &quot;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&quot; for example) - it will greatly improve performance
//example:
//    if Number &gt;= 25 then
//        set CommaString = CommaString+&quot;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&quot;
//        set Number = Number - 25
//    endif
//    if Number &gt;= 15 then
//        set CommaString = CommaString+&quot;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&quot;
//        set Number = Number - 15
//    endif
//    if Number &gt;= 5 then
//        set CommaString = CommaString+&quot;&#039;&#039;&#039;&#039;&#039;&quot;
//        set Number = Number - 5
//    endif

    loop
        exitwhen Number &lt;= 0
        set CommaString = CommaString+BarBit
        set Number = Number - 1
    endloop
    return CommaString
endfunction


private function BarTimerLoop takes nothing returns nothing
    local integer i = 0
    local texttag Tag
    local real Casttime
    local real CurrentTime
    local string Order
    local unit Caster
    local boolean Channeled
    local integer a = 0
    if NumberOfBars &gt; 0 then
        loop
            if ZCBarray<i> == null then //Fill up empty array positions
                if ZCBarray[NumberOfBars-1] != null then
                    set ZCBarray<i> = ZCBarray[NumberOfBars-1]
                    set ZCBarray[NumberOfBars-1] = null // Cleanup: Take the last entry of the list and move it to the empty slot
                    set NumberOfBars = NumberOfBars - 1
                else
                    set NumberOfBars = NumberOfBars - 1
                endif
            else //The bar tag exists
                if HaveSavedReal(ZCBHash, GetHandleId(ZCBarray<i>), 0) then
                    set Tag = ZCBarray<i>
                    set Casttime = LoadReal(ZCBHash, GetHandleId(Tag), 0)
                    set CurrentTime = LoadReal(ZCBHash, GetHandleId(Tag), 1)
                    set Order = LoadStr(ZCBHash, GetHandleId(Tag), 2)
                    set Caster = LoadUnitHandle(ZCBHash, GetHandleId(Tag), 3)
                    set Channeled = LoadBoolean(ZCBHash, GetHandleId(Tag), 4)
                    set CurrentTime = CurrentTime + ZCBTimerIntervall
                    call SaveReal(ZCBHash, GetHandleId(Tag), 1, CurrentTime) //Store the Bar progress time
                    set a = R2I((CurrentTime/Casttime) * I2R(NumberOfBarBits)) //Calculate the number of &quot;filled&quot; bar bits
                    if CurrentTime &lt; Casttime then
                        if (GetUnitCurrentOrder(Caster) == OrderId(Order)) then
                            if Channeled == false then
                                call SetTextTagText(Tag, Colorcode+CommaMultiplier(a)+&quot;|r&quot;+ColorcodeBG+CommaMultiplier(NumberOfBarBits-a)+&quot;|r&quot;, (CastingBarSize * 0.023 / 10))
                            else
                                call SetTextTagText(Tag, ColorcodeCh+CommaMultiplier(NumberOfBarBits-a)+&quot;|r&quot;+ColorcodeBGCh+CommaMultiplier(a)+&quot;|r&quot;, (CastingBarSize * 0.023 / 10))
                            endif
                        else
                            if Order == &quot;_&quot; then
                                if Channeled == false then
                                    call SetTextTagText(Tag, Colorcode+CommaMultiplier(a)+&quot;|r&quot;+ColorcodeBG+CommaMultiplier(NumberOfBarBits-a)+&quot;|r&quot;, (CastingBarSize * 0.023 / 10))
                                else
                                    call SetTextTagText(Tag, ColorcodeCh+CommaMultiplier(NumberOfBarBits-a)+&quot;|r&quot;+ColorcodeBGCh+CommaMultiplier(a)+&quot;|r&quot;, (CastingBarSize * 0.023 / 10))
                                endif
                            else
                                call SetTextTagFadepoint(Tag, CurrentTime) //casting bar cancelled - fade out instantly
                                call SetTextTagLifespan(Tag, CurrentTime+0.5 )
                                call FlushChildHashtable(ZCBHash, GetHandleId(Tag)) //clear the hashtable entry
                                set ZCBarray<i> = null
                            endif
                        endif
                    else
                        call FlushChildHashtable(ZCBHash, GetHandleId(Tag)) //casting bar expired - clear the hashtable entry
                        set ZCBarray<i> = null
                    endif
                endif
            endif
            set i = i + 1
            set a = 0
            exitwhen i &gt;= NumberOfBars
        endloop
    set Caster = null
    set Tag = null
    endif
endfunction

function Castingbar takes real Casttime, string Order, unit Caster, integer ShowCastingBar, boolean Channeled returns nothing
    local force TextTagForce
    local texttag FloatingText
    local real X = (GetUnitX(Caster) + CastingBarXOffset)
    local real Y = (GetUnitY(Caster) + CastingBarYOffset)
    local player LocalPlayer = GetOwningPlayer(Caster)
    set FloatingText = CreateTextTag()
    if FloatingText == null then
        call BJDebugMsg(&quot;|cffff0000ERROR: Maximum number of Texttags reached. Bar not created.|r&quot;)
        return
    endif
    if ShowCastingBar == 0 then
        set TextTagForce = CreateForce()
        call ForceAddPlayer(TextTagForce, LocalPlayer)
    endif
    if ShowCastingBar == 1 then
        set TextTagForce = CreateForce()
        call ForceEnumAllies(TextTagForce, LocalPlayer, b)
    endif
    set LocalPlayer = null
    call SetTextTagPos(FloatingText, X, Y, CastingBarZOffset)
    if Channeled == false then
        call SetTextTagText(FloatingText, Colorcode+CommaMultiplier(NumberOfBarBits)+&quot;|r&quot;, (CastingBarSize * 0.023 / 10))
    else
        call SetTextTagText(FloatingText, ColorcodeCh+CommaMultiplier(NumberOfBarBits)+&quot;|r&quot;, (CastingBarSize * 0.023 / 10))
    endif
    call SetTextTagPermanent( FloatingText, false )
    call SetTextTagFadepoint( FloatingText, Casttime )
    call SetTextTagLifespan( FloatingText, (Casttime + 0.5) )
    if IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS) then
        call SetTextTagVisibility(FloatingText, false)
    endif
    if ShowCastingBar == 2 then
        if IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS) then
            call SetTextTagVisibility(FloatingText, true)
        endif
    else
        if IsPlayerInForce(GetLocalPlayer(), TextTagForce) then
            call SetTextTagVisibility(FloatingText, true)
        endif
    endif
    call SaveReal(ZCBHash, GetHandleId(FloatingText), 0, Casttime)     //
    call SaveReal(ZCBHash, GetHandleId(FloatingText), 1, 0.0)          //
    call SaveStr(ZCBHash, GetHandleId(FloatingText), 2, Order)         //Save all required variables to the Floating Text
    call SaveUnitHandle(ZCBHash, GetHandleId(FloatingText), 3, Caster) //
    call SaveBoolean(ZCBHash, GetHandleId(FloatingText), 4, Channeled) //
    set ZCBarray[NumberOfBars] = FloatingText //Add The created casting-bar to the list of active bars
    set NumberOfBars = NumberOfBars + 1       //Update the number of bars
    set FloatingText = null
    if ShowCastingBar &lt; 2 then
        call DestroyForce(TextTagForce)
    endif
    set TextTagForce = null
endfunction

function InitCastingBar takes nothing returns nothing
    call TimerStart(ZCBTimer,ZCBTimerIntervall,true, function BarTimerLoop)
endfunction

endlibrary
</i></i></i></i></i></i>



Special Thanks to N-a-z-g-u-l for his HandleCount System.
 

Attachments

  • Castingbarv124.w3x
    32 KB · Views: 551
  • Castingbarv124modular.w3x
    50.2 KB · Views: 515

Azlier

Old World Ghost
Reaction score
461
Could we have a Channeling Bar that does the same thing but runs backwards?

What's with the BJ's? Why won't you let us adjust the background color in a constant? Why is there no 'requires ABC' at the top of the library? Why is there no demo map?

>Call Castingbar(...)
call, not Call.

>ElectricSheepRocks...
Why can't we just leave it blank?
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Could we have a Channeling Bar that does the same thing but runs backwards?
Done.

What's with the BJ's?
Errr, I tried to remove as much BJs as I could. If you see more of them, feel free to use natives if you want. ^^
This system isn't made for heavy use, since it requires attaching and stores 6 variables to a struct, which limits the number of parallel uses anyway.

Why won't you let us adjust the background color in a constant?
Done that.

Why is there no 'requires ABC' at the top of the library? Why is there no demo map?
Done.

Errrr, demo map? I guess anyone can imagine how it looks ... it's not that innovative after all.

>Call Castingbar(...)
call, not Call.
Fixed.

>ElectricSheepRocks...
Why can't we just leave it blank?
Because this would mess up the functionality when you have no order issued to a unit --> empty orderstring
However, I could adjust this to a spacebar or underline or something.
EDIT: Changed it to "_".
 

Azlier

Old World Ghost
Reaction score
461
>I wrote in the requirements that it needs ABC, however, I alsoadded it to the code now.

No, require it at library declaration.

JASS:
library Castingbar requires ABC


>However, I could adjust this to a spacebar or underline or something.

Why not check what the order is before using it? You do the same thing with 'electricsheeprocks'.

>Errr, I tried to remove as much BJs as I could. If you see more of them, feel free to use natives if you want.

Aren't systems supposed to do the hard work for us?
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
>I wrote in the requirements that it needs ABC, however, I alsoadded it to the code now.

No, require it at library declaration.
Done.
>However, I could adjust this to a spacebar or underline or something.

Why not check what the order is before using it? You do the same thing with 'electricsheeprocks'.
This would need another if then else ...
Also, if the issued order of the unit is blank and my stored orderstring is also blank, the condition is true, which is not what it should be.
Underline should be alright.

>Errr, I tried to remove as much BJs as I could. If you see more of them, feel free to use natives if you want.

Aren't systems supposed to do the hard work for us?
I checked again and couldn't find any BJ in the code that could be removed without the need of adding new lines. Tell me which BJ calls you want to replace and how and I will do it.
 

Azlier

Old World Ghost
Reaction score
461
>...without the need of adding new lines...
So? Why should that stop you? Add new lines.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
And whats the purpose of this? The BJs just call natives and mess around a little with the parameters - you get the same effect on the runtime as if you manually replace the BJs.
I already replaced all of the BJs that are just inverting the parameters. The remaining ones either have no matching native (like SetTextTagBJ()) or require equations (Like SetTextTagVelocityBJ()) or CreateTextTagLocationBJ().
 

Azlier

Old World Ghost
Reaction score
461
It takes more processing power to call the BJ itself, which then call either eachother or natives. It's insignificant, but I'm a speed freak.
 

Azlier

Old World Ghost
Reaction score
461
And your functions that aren't meant to be called from outside. Oh, and make your globals constant. Private-ize your struct, as well.
 

Flare

Stops copies me!
Reaction score
662
- MUI and GUI
Ahm... what?
1) How would GUI be a pro?
2) If it is a pro, how can it be a pro for this system?

This system isn't made for heavy use, since it requires attaching and stores 6 variables to a struct, which limits the number of parallel uses anyway.
How do either of those imply that heavy use isn't very-well supported? Numerous things use attaching, and are capable of being used heavily. The fact that you are storing 6 variables in a struct means nothing - that's not limiting you in anyway. The number of separate struct members has no influence on instanceability, it's the largest specified size of an arrayed member, you have specified no arrayed members.

And whats the purpose of this? The BJs just call natives and mess around a little with the parameters - you get the same effect on the runtime as if you manually replace the BJs.
I already replaced all of the BJs that are just inverting the parameters. The remaining ones either have no matching native (like SetTextTagBJ()) or require equations (Like SetTextTagVelocityBJ()) or CreateTextTagLocationBJ().
Well, alot of BJ's are just additional, unnecessary, function calls - why call 3 functions, when you can just call 2, and get the same end result? Also, the TextTag BJ's call alot more functions than most other BJ's. If you look at CreateTextTagUnitBJ...
JASS:
//The function itself
function CreateTextTagUnitBJ takes string s, unit whichUnit, real zOffset, real size, real red, real green, real blue, real transparency returns texttag
    set bj_lastCreatedTextTag = CreateTextTag()
    call SetTextTagTextBJ(bj_lastCreatedTextTag, s, size)
    call SetTextTagPosUnitBJ(bj_lastCreatedTextTag, whichUnit, zOffset)
    call SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency)

    return bj_lastCreatedTextTag
endfunction



//All the associated function calls
//Color
function SetTextTagColorBJ takes texttag tt, real red, real green, real blue, real transparency returns nothing
    call SetTextTagColor(tt, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency))
endfunction

native SetTextTagColor              takes texttag t, integer red, integer green, integer blue, integer alpha returns nothing

function PercentTo255 takes real percentage returns integer
    return PercentToInt(percentage, 255)
endfunction

function PercentToInt takes real percentage, integer max returns integer
    local integer result = R2I(percentage * I2R(max) * 0.01)

    if (result &lt; 0) then
        set result = 0
    elseif (result &gt; max) then
        set result = max
    endif

    return result
endfunction



//Position
function SetTextTagPosUnitBJ takes texttag tt, unit whichUnit, real zOffset returns nothing
    call SetTextTagPosUnit(tt, whichUnit, zOffset)
endfunction

native SetTextTagPosUnit            takes texttag t, unit whichUnit, real heightOffset returns nothing

//Text
function SetTextTagTextBJ takes texttag tt, string s, real size returns nothing
    local real textHeight = TextTagSize2Height(size)

    call SetTextTagText(tt, s, textHeight)
endfunction

function TextTagSize2Height takes real size returns real
    return size * 0.023 / 10
endfunction

native SetTextTagText               takes texttag t, string s, real height returns nothing

10 functions called, just to create a text tag - with natives, you can do all that, and add fadepoint, lifespan, velocity and change permanence, with about 7 or 8 function calls. There's a big difference

As regards the 'no matching native', that's not possible. Apart from the mathematical BJ's, every BJ will either call another BJ or a native, so in the end, you will always end up with a call to a native

As regards the equations, most are fairly simple once you examine what the BJ's are actually doing e.g.
JASS:
private function QuickTextTag takes string text, real x, real y, boolean dmgtext returns nothing
    local texttag tt = CreateTextTag ()
    call SetTextTagPos (tt, x, y, 0)
    call SetTextTagPermanent (tt, false)
    if dmgtext then
        call SetTextTagText (tt, DAMAGESTRING + text + &quot;|r&quot;, 0.023)
//TextTagVelocity, I believe, for the BJ is (vel * 0.071/128) - xVel will be Cos (angle) * (above formula), yVel will be Sin (angle) * (above formula)
        call SetTextTagVelocity (tt, Cos (bj_PI * 0.5) * 0.0355, Sin (bj_PI * 0.5) * 0.0355)
    else
        call SetTextTagText (tt, HEALSTRING + text + &quot;|r&quot;, 0.023)
        call SetTextTagVelocity (tt, Cos (bj_PI * 1.5) * 0.0355, Sin (bj_PI * 1.5) * 0.0355)
    endif
    call SetTextTagLifespan (tt, 3.)
    call SetTextTagFadepoint (tt, 2.)
    set tt = null
endfunction

For TextTagText, it's just (size * 0.023/10), so you can easily replace the BJ with a little bit of math
So, with natives alone, you would be calling about 3 functions (I'm not including permanence, velocity, lifespan or fadepoint in that figure, since the creation BJ doesn't include them) to get the same effect as the BJ. With the creation BJ, you are calling about 10, some of which you don't even need. Colour can be done with |c######## + yourString + |r, so an additional function to do it for you is pointless
 

Azlier

Old World Ghost
Reaction score
461
Ah, Flare. You can always count on him to type out what you're too lazy to type yourself.
 

Azlier

Old World Ghost
Reaction score
461
What about making them constant?
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Ahm... what?
1) How would GUI be a pro?
2) If it is a pro, how can it be a pro for this system?
It's a pro because not every mapmaker out here is familiar with JASS.

How do either of those imply that heavy use isn't very-well supported? Numerous things use attaching, and are capable of being used heavily. The fact that you are storing 6 variables in a struct means nothing - that's not limiting you in anyway. The number of separate struct members has no influence on instanceability, it's the largest specified size of an arrayed member, you have specified no arrayed members.
*sigh* when will you ever need thousands of castbars on the same time? It's gonna be laggy because of the loop and smallscale timers anyway then.

Well, alot of BJ's are just additional, unnecessary, function calls - why call 3 functions, when you can just call 2, and get the same end result? Also, the TextTag BJ's call alot more functions than most other BJ's. If you look at CreateTextTagUnitBJ...
I know this.
Oh well ... I just posted this system because there was no other casting bar system around. Make a better one if you want, I won't stop you. I'm not a pro with JASS. It's just that I thought someone out there who isn't a total JASS geek might find this interesting.
 

Tom Jones

N/A
Reaction score
437
Oh well ... I just posted this system because there was no other casting bar system around. Make a better one if you want, I won't stop you. I'm not a pro with JASS. It's just that I thought someone out there who isn't a total JASS geek might find this interesting.
:rolleyes:
This is your chance to learn something, to better yourself. All the comments you have gotten should be viewed as constructive criticism. Also you are never ever going to get a system approved that is not efficient, those bjs are simply not efficient enough. Also, I my mind, you should do something about the way you display the texttag, the whole force thingie. There are simpler ways of doing it, and as far as I can tell you have a leak there.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/

      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