Text Tag Question

MasterOfRa

New Member
Reaction score
10
Is there any reason that you cannot update text tags more than once a second?

I am trying to update them every .3 second, which includes changing their location, but it seems to only occur every 1 second.

JASS:
library PeriodicStuff initializer init uses Recycler, TowerProperties
globals
endglobals

private function Periodic takes nothing returns nothing
    local group g = NewGroup() 
    local TowerProperties data
    local EnemyProperties Data
    local unit u
    local string s
    local integer count
    local real x
    local real y
    local texttag tt
    local integer index
    local integer int
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g,u)
        if (GetWidgetLife(u) > .405)then
            set index = GetUnitUserData(u)
            if index != 0 then
                set data = TowerProperties<u>
                if (data != null) then
                    call data.Process(0.3)
                    // Health First
                endif
            else
            endif
        endif
    endloop
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g,u)
        if (GetWidgetLife(u) &gt; .405)then
            set index = GetUnitUserData(u)
            if index != 0 then
                set Data = EnemyProperties<u>
                if (Data != null) then
                    call Data.Process(0.3)
                endif
            endif
        endif
    endloop
    call ReleaseGroup(g)
    set tt = null
    set g = null

endfunction
private function init takes nothing returns nothing
    call TimerStart(NewTimer(),.3,true,function Periodic)
endfunction

endlibrary</u></u>

JASS:
library TowerProperties uses PUI
globals
    private constant string FX_SHIELD_RECHARGE  = &quot;Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl&quot;
endglobals
struct TowerProperties
    //! runtextmacro PUI()
    integer techLevel           // How high weapons you can buy
    integer currentTech         // How close you are to the next tech Level
    integer damageUpgradeLevel  // How high Damage has been upgraded
    integer energyUpgradeLevel  // How high Energy has been upgraded
    integer shieldUpgradeLevel  // How high Shields have been upgraded
    integer damageMult          // What percent of normal damage you deal
    real    currentEnergy       // How high your energy is
    integer maxEnergy           // How high your energy can go
    real    currentShield       // How high your shield energy is
    integer maxShield           // How high your shield energy can go
    real    rechargeRate        // Determins how fast effeciency goes up
    boolean isShieldOn          // Determins whether or not to use the shield
    unit    owner               // Who these stats belong to
    integer missiles            // How many missiles are lanched at a time?
    real    angleDelta          // How big the angle between the missiles are
    texttag ttHealth
    texttag ttShield
    texttag ttEnergy
    texttag ttTech
    
    method Process takes real duration returns nothing
        local string s
        local integer int
        local real x = GetUnitX(.owner)
        local real y = GetUnitY(.owner)
        local integer count
        set .currentEnergy = .currentEnergy + ((.maxEnergy / 17)*duration)
        if .currentEnergy &gt; .maxEnergy then
            set .currentEnergy = .maxEnergy
        endif
        set .currentShield = .currentShield + ((.maxShield / 17)*duration)
        if .currentShield &gt; .maxShield then
            set .currentShield = .maxShield
            if .currentEnergy == .maxEnergy then
                if not .isShieldOn then
                    set .isShieldOn = true
                    call DestroyEffect(AddSpecialEffectTarget(FX_SHIELD_RECHARGE,.owner,&quot;origin&quot;))
                    set s = GetPlayerName(GetOwningPlayer(.owner))+&quot;&#039;s &quot;+GetUnitName(.owner)+&quot;&#039;s Shield has Been Recharged&quot;
                    call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, s)
                endif
            endif
        endif
        call SetUnitState(.owner, UNIT_STATE_MANA,GetUnitState(.owner,UNIT_STATE_MANA)+(.rechargeRate * duration))
        // Health first
        set int = R2I((GetUnitState(.owner,UNIT_STATE_LIFE)/GetUnitState(.owner,UNIT_STATE_MAX_LIFE))*TAG_LENGTH)
        set s = COLOR_LIFE
        set count = 0
        loop
            exitwhen count &gt; (TAG_LENGTH - 1)
            if count == int then
                set s = s + COLOR_EMPTY
            endif
            set s = s + BAR_CHAR
            set count = count + 1
        endloop
        call SetTextTagText(.ttHealth, s, TAG_SIZE)
        call SetTextTagPos(.ttHealth, x - TEXT_SHIFT, y, 100.0)
        // Energy Next
        set int = R2I((.currentEnergy/.maxEnergy)*TAG_LENGTH)
        set s = COLOR_ENERGY
        set count = 0
        loop
            exitwhen count &gt; (TAG_LENGTH - 1)
            if count == int then
                set s = s + COLOR_EMPTY
            endif
            set s = s + BAR_CHAR
            set count = count + 1
        endloop
        call SetTextTagText(.ttEnergy, s, TAG_SIZE)
        call SetTextTagPos(.ttEnergy, x - TEXT_SHIFT, y, 125.0)
        // Now for Shields
        set int = R2I((.currentShield/.maxShield)*TAG_LENGTH)
        if .isShieldOn then
            set s = COLOR_SHIELD
        else
            set s = COLOR_SHIELD_OFF
        endif
        set count = 0
        loop
            exitwhen count &gt; (TAG_LENGTH - 1)
            if count == int then
                set s = s + COLOR_EMPTY
            endif
            set s = s + BAR_CHAR
            set count = count + 1
        endloop
        call SetTextTagText(.ttShield, s, TAG_SIZE)
        call SetTextTagPos(.ttShield, x - TEXT_SHIFT, y, 150.0)

        // And Lastly TechLevel
        set int = R2I((I2R(.currentTech)/((I2R(.techLevel) + 1)*4))*TAG_LENGTH)
        set s = COLOR_TECH_LEVEL
        set count = 0
        loop
            exitwhen count &gt; (TAG_LENGTH - 1)
            if count == int then
                set s = s + COLOR_EMPTY
            endif
            set s = s + BAR_CHAR
            set count = count + 1
        endloop
        call SetTextTagText(.ttTech, s, TAG_SIZE)
        call SetTextTagPos(.ttTech, x - TEXT_SHIFT, y, 175.0)
        
        if GetLocalPlayer() != GetOwningPlayer(.owner) then
            if DisplayAllyBars then
                call SetTextTagVisibility(.ttHealth, true)
                call SetTextTagVisibility(.ttShield, true)
                call SetTextTagVisibility(.ttEnergy, true)
                call SetTextTagVisibility(.ttTech  , true)
            else
                call SetTextTagVisibility(.ttHealth, false)
                call SetTextTagVisibility(.ttShield, false)
                call SetTextTagVisibility(.ttEnergy, false)
                call SetTextTagVisibility(.ttTech  , false)
            endif
        endif
    endmethod
    
    method ModifyMissileCount takes integer change returns nothing
        set .missiles = .missiles + change
        if .missiles &lt; 1 then
            set .missiles = 1
            call SimError(GetOwningPlayer(.owner),&quot;You cannot fire 0 missiles!&quot;)
        elseif .missiles &gt; 5 then
            set .missiles = 5
            call SimError(GetOwningPlayer(.owner),&quot;You cannot fire more than 5 missiles!&quot;)
        elseif .missiles == 1 then
            if GetLocalPlayer() == GetOwningPlayer(.owner) then
                call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,5,&quot;Now fireing &quot;+I2S(.missiles)+&quot; missile at a time.&quot;)
            endif
        else 
            if GetLocalPlayer() == GetOwningPlayer(.owner) then
                call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,5,&quot;Now fireing &quot;+I2S(.missiles)+&quot; missiles at a time.&quot;)
            endif
        endif
        
    endmethod
    
    
    method Display takes player whichPlayer returns nothing
        if GetLocalPlayer() == whichPlayer then
            call ClearTextMessages()
        endif
        call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15,GetPlayerName(GetOwningPlayer(.owner))+&quot;&#039;s Stats:&quot;)
        call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15,&quot;   - Tech      Level: &quot;+I2S(.techLevel         )+&quot; -- &quot;+I2S((.currentTech * 100)/((.techLevel + 1) * 4))+&quot;%&quot;)
        call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15,&quot;   - Damage Level: &quot;   +I2S(.damageUpgradeLevel)+&quot; -- &quot;+I2S(.damageMult)+&quot;%&quot;)
        call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15,&quot;   - Shield    Level: &quot;+I2S(.shieldUpgradeLevel)+&quot; -- &quot;+I2S(R2I(.currentShield))+&quot;/&quot;+I2S(.maxShield))
        call DisplayTimedTextToPlayer(whichPlayer, 0.52, -1.00,15,&quot;   - Energy   Level: &quot; +I2S(.energyUpgradeLevel)+&quot; -- &quot;+I2S(R2I(.currentEnergy))+&quot;/&quot;+I2S(.maxEnergy))
    endmethod

endstruct

endlibrary


i am useing a periodic timer that occurs every .3 second, was at .1, i was testing it at a difforent value, which calls the function for all the towers, or enemys, it is only updating every one second.
 

Monictor

New Member
Reaction score
0
Yeah I had just made one that updated every second, but it seemed to bug out every so often, so I just made it 2 seconds. Probably doesn't answer your question :(.
 

Kuberr24

Well-Known Member
Reaction score
28
when you use "wait" or use "wait - gametime" in triggers with values below 0.27, it actually waits 0.27 seconds instead. So that could be 1 reason why it is slower.

Secondly, what exactly do you want to achieve?

Do you want the text or the color to change every 0.01 second?
Do you want to make it so the texttag moves upwards and slowly disappears, like when you get gold from killing a unit?
Do you want a certain text to "hover" above a unit and follow it when it move?


Each of those situations could require a different approach to what actions are best used.
I have seen maps where texttag fluently change color, position or text, So I cannot believe it is impossible to do. There could be some limitations with GUI (probably crappy bj functions) maybe changing it to non-bj-JASS can fix it.
 

MasterOfRa

New Member
Reaction score
10
I use vJass, and i am useing a periodic .1 second timer

I am trying to make it follow the units movement, because i am adding a mana bar to enemys.

And also, it doesnt wait .27 seconds anyway, i am pretty sure it waits for a event that occures about once every .25 seconds, and will only stop when one occures, so it will wait for anything between .01 - .25 seconds

i will attach the code to the first post in a sec
 
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