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 for the enemys, 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


JASS:
library EnemyProperties uses PUI, Globals
struct EnemyProperties
    //! runtextmacro PUI()
    real    damageMin
    real    damageMax
    integer critChance
    real    critMult
    integer bounty
    real    currentShield
    real    shieldGen
    integer maxShield
    real    splash
    boolean isShieldOn
    unit    owner
    texttag ttHealth
    texttag ttShield
    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 .currentShield = .currentShield + (.shieldGen * duration)
        if .currentShield &gt; .maxShield then
            set .currentShield = .maxShield
        endif
        // Health First
        set int = R2I((GetUnitState(.owner,UNIT_STATE_LIFE)/GetUnitState(.owner,UNIT_STATE_MAX_LIFE))*TAG_LENGTH / 2)
        set s = COLOR_LIFE
        set count = 0
        loop
            exitwhen count &gt; (TAG_LENGTH / 2 - 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 / 2, y, 50.0)
        if IsUnitVisible(.owner,Player(0)) then
            if DisplayEnemyBars then
                call SetTextTagVisibility(.ttHealth, true)
            else
                call SetTextTagVisibility(.ttHealth, false)
            endif
        else
            call SetTextTagVisibility(.ttHealth, false)
        endif
        if .isShieldOn then
            // Now for Shields
            set int = R2I((.currentShield/.maxShield)*TAG_LENGTH)
            set s = COLOR_SHIELD
            set count = 0
            loop
                exitwhen count &gt; (TAG_LENGTH / 2 - 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 / 2, y, 75.0)
            if IsUnitVisible(.owner,Player(0)) then
                call SetTextTagVisibility(.ttShield, true)
            else
                call SetTextTagVisibility(.ttShield, false)
            endif
        endif
    endmethod
    
    method crit takes nothing returns boolean
        if GetRandomInt(0,99) &lt; .critChance then
            return true
        endif
        return false
    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.
 

Rainther

I guess I should write something of value here...
Reaction score
61
What prevents you from recreating one?
 

MasterOfRa

New Member
Reaction score
10
it is much less efficient
i had it that way, but creating handles(i think text tags are handles)
and then destroying them every .1 second is going to be laggy, but reusing them continuously, will not lag. i already have some things i am useing that reduce fps from 30 to 20
so I'm not trying to reduce it any further
 

Rainther

I guess I should write something of value here...
Reaction score
61
Then use 4 text tags and replace them and hide the other 3.
 

Rainther

I guess I should write something of value here...
Reaction score
61
If you update each 0.3 second you could use 4 texttags, and make a system to change one of them, have it visible and the rest invisisble. Next 0.3 second you make the current one invisible and change one of the other 3 into visisble with changed text.

Loop between these 4 that is. Or make 10 if you mish 0.1.
 
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