• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

local var is behaving like global...

Status
Not open for further replies.
Level 9
Joined
Aug 21, 2008
Messages
533
i have a prob with my texttags: at first, they behaving normally. Everytime a unit is damaged by this trigger, there is created a new texttag. But after soem time, suddenly instead of creating a new textag, a old one is changed.

This actually means, that a existing one is removed, and a new one, with the life span and visibly , is created.
So... just like i used a global instead of a local :ugly:


JASS:
function PhysicalDamage takes unit attacker, unit target , real dmg,boolean crit returns nothing

    local real armor    =   LoadReal(udg_HashTable, GetHandleId(target), StringHash("armor"))
    local real armor2   =   armor*0.7
    local texttag text  =   CreateTextTag()
    local texttag text2 =   CreateTextTag()
    
    //armor
    if armor>dmg then
        set dmg=dmg*0.3
    else
        set dmg=dmg-armor2
    endif
    
    //dmg
    call UnitDamageTarget(attacker,target,dmg,true,false,ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
    

    //text
    if crit==true then
        call SetTextTagText(text, I2S(R2I(dmg))+"!", 12* 0.023 / 10)
        call SetTextTagColor(text, 255, 0, 0, 0)
    else
        call SetTextTagText(text, I2S(R2I(dmg)), 8* 0.023 / 10)
        call SetTextTagColor(text, 255, 255, 255, 0)
    endif
    call SetTextTagPos(text, GetUnitX(target)+GetRandomReal(-25,25), GetUnitY(target)+GetRandomReal(-25,25), 50)
    call SetTextTagPermanent(text, false)
    call SetTextTagVelocity(text, 0, 0.04)
    call SetTextTagVisibility(text, true)
    call SetTextTagLifespan(text, 3)
    call SetTextTagFadepoint(text, 0.01)
    set text=null
endfucntion
 
Level 9
Joined
Aug 21, 2008
Messages
533
i need text 2 for something different =/ I just delede everything trigger which may cause Problem and tested it again, i just forget to delete the var.

any way to extend the limit? or how im able to kill textags? I thought the lifespann kill it =/

no endfunction? well a c&p mistake =) its there, i just forget to copy it...
 
Level 9
Joined
Aug 21, 2008
Messages
533
ok-it need exactly 100 hits

i found other function which was always creating atexttag too. But it only set a lifespan, when the attack failed.
So i thought it may be the bug

i created 20 textags in the function instead of 1 and, what a surprise, now i only need 6 attacks to create the bug.

changed the fucntion to only create the texttag, when its also destroying it. Hopefully it works now =/

edit: WORKS! WORKS!
now after this stupid bug is gone, i am able to continue =)
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
The typical handle (widgets, timers, rects) allocate a special handle ID that is unique to that handle.

Text-tags implement a different (perhaps better, except for the limit) method of creating IDs using an integer from either 1 to 100 or 0 to 99 (I forget which).
 
Text-tags implement a different (perhaps better, except for the limit) method of creating IDs using an integer from either 1 to 100 or 0 to 99 (I forget which).

Yep, they start off at 99 and go down to 0. ;) I believe ubersplats share the same quality, and maybe one more handle (weather, or something) I'm forgetting.
 
Status
Not open for further replies.
Top