• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] String Leaks?

Status
Not open for further replies.
Level 9
Joined
May 28, 2007
Messages
365
I'm trying to create a way for floating text to follow a unit and display it's percentage of health.

( It's a dungeon map )

The problem is, I'm almost positive the strings leak or something, and it's lagging my map. There must be a way to fix this, since I know Fate ORPG has similar kind of systems...

The global variable are declared once, at map init. This is probably where the leak is. The event is periodic at 0.05 seconds.

JASS:
function Trig_Floating_Text_Actions takes nothing returns nothing
    set udg_StringLeak = udg_StringLeak + 1
    call SetTextTagPos( udg_HPText[0], GetUnitX(udg_PartyUnit[1])-10, GetUnitY( udg_PartyUnit[1])+20, 0 )
    call SetTextTagText( udg_HPText[0], I2S(R2I(GetUnitState(udg_PartyUnit[1], UNIT_STATE_LIFE)/GetUnitState(udg_PartyUnit[1], UNIT_STATE_MAX_LIFE)*100))+"%", 0.023)
    call SetTextTagPos( udg_HPText[1], GetUnitX(udg_PartyUnit[2])-10, GetUnitY( udg_PartyUnit[2])+20, 0 )
    call SetTextTagText( udg_HPText[1], I2S(R2I(GetUnitState(udg_PartyUnit[2], UNIT_STATE_LIFE)/GetUnitState(udg_PartyUnit[2], UNIT_STATE_MAX_LIFE)*100))+"%", 0.023)
    call SetTextTagPos( udg_HPText[2], GetUnitX(udg_PartyUnit[3])-10, GetUnitY( udg_PartyUnit[3])+20, 0 )
    call SetTextTagText( udg_HPText[2], I2S(R2I(GetUnitState(udg_PartyUnit[3], UNIT_STATE_LIFE)/GetUnitState(udg_PartyUnit[3], UNIT_STATE_MAX_LIFE)*100))+"%", 0.023)
    call SetTextTagPos( udg_HPText[3], GetUnitX(udg_PartyUnit[4])-10, GetUnitY( udg_PartyUnit[4])+20, 0 )
    call SetTextTagText( udg_HPText[3], I2S(R2I(GetUnitState(udg_PartyUnit[4], UNIT_STATE_LIFE)/GetUnitState(udg_PartyUnit[4], UNIT_STATE_MAX_LIFE)*100))+"%", 0.023)
    call SetTextTagPos( udg_HPText[4], GetUnitX(udg_PartyUnit[5])-10, GetUnitY( udg_PartyUnit[5])+20, 0 )
    call SetTextTagText( udg_HPText[4], I2S(R2I(GetUnitState(udg_PartyUnit[5], UNIT_STATE_LIFE)/GetUnitState(udg_PartyUnit[5], UNIT_STATE_MAX_LIFE)*100))+"%", 0.023)
endfunction
 
Last edited:
This could be unrelated to your problem but you could optimize(?) your code into
JASS:
function Trig_Floating_Text_Actions takes nothing returns nothing
    local integer index = 0
    set udg_StringLeak = udg_StringLeak + 1
    loop
        call SetTextTagPos( udg_HPText[index], GetUnitX(udg_PartyUnit[index + 1])-10, GetUnitY( udg_PartyUnit[index + 1])+20, 0 )
        call SetTextTagText( udg_HPText[index], I2S(R2I(GetUnitState(udg_PartyUnit[index + 1], UNIT_STATE_LIFE)/GetUnitState(udg_PartyUnit[index + 1], UNIT_STATE_MAX_LIFE)*100))+"%", 0.023)
        exitwhen index == 4
        set index = index + 1
    endloop            
endfunction
Sorry if this wasn't any help. :\
 
Status
Not open for further replies.
Top