• 🏆 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!

[vJASS] Strange floating text bug

Status
Not open for further replies.

EdgeOfChaos

E

EdgeOfChaos

So I'm making a battle system, and displaying a floating text message after each user attacks. This is my function:
JASS:
    private function text takes string s, unit u, integer r, integer g, integer b, integer z returns nothing
        local texttag display = CreateTextTag()
        local real textHeight = 9 * 0.023 / 10
        local real vel = 64 * 0.071 / 128
        local real xvel = vel * Cos(90 * bj_DEGTORAD)
        local real yvel = vel * Sin(90 * bj_DEGTORAD)
        call SetTextTagText(display, s , textHeight)
        call SetTextTagPosUnit(display, u, z)
        call SetTextTagColor(display, r, g, b, 255)
        call SetTextTagVelocity(display, xvel, yvel)
        call SetTextTagPermanent( display, false )
        call SetTextTagLifespan( display, 1.50 )
    endfunction

When I play the game, it displays and remains there for 1.5 seconds. No problem there. But eventually (and it seems there is no real pattern to it), but text starts to glitch. It still displays, but when it does, it overwrites/deletes the last created floating text, so that there can only be one present anymore. I'm using a local text tag, so I don't understand what could possibly be causing this.. Once this happens, it remains for the rest of the game like this.

If it makes any difference, I don't call that function directly, but call these ones instead:
JASS:
    function redText takes string s, unit u, integer z returns nothing
        call text(s,u,255,85,85,z)
    endfunction
    
    function blueText takes string s, unit u, integer z returns nothing
        call text(s,u,85,85,255,z)
    endfunction
    
    function greenText takes string s, unit u, integer z returns nothing
        call text(s,u,85,255,85,z)
    endfunction
    
    function plainText takes string s, unit u, integer z returns nothing
        call text(s,u,255,255,255,z)
    endfunction
    
    function darkText takes string s, unit u, integer z returns nothing
        call text(s,u,127,127,127,z)
    endfunction

Anyone know what's going on?
 

EdgeOfChaos

E

EdgeOfChaos

I did not, but I am not hitting 100 text tags, unless this still counts removed text tags (in which case I do have a problem)
 

EdgeOfChaos

E

EdgeOfChaos

I tried adding a null into it:
JASS:
set display = null
But that did nothing

I added in a handle check, and this was the result (it starts at 99, just cut off).
http://imgur.com/DJkAixL
When it starts to repeat the zeroes, that is when it starts failing. So it seems that it is the of limit of text tags.. Do you have any idea of how to fix this? I'm already deleting the text tags automatically with the lifespan thing, so I'm not sure if deleting them does anything, and I need to display these messages or the battles will be impossible to follow, and displaying to player on the screen is a lot more messy.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You are not setting the fade point so maybe the auto destruction setup is incomplete so never occurs.
JASS:
native SetTextTagFadepoint takes texttag t,real fadepoint returns nothing
Fade point of 0 means they will start to fade immediately. Fade point of lifespan will mean it does not fade and disappears as soon as it expires.

Try also using...
JASS:
set display = null
After the texttag setup and before the function returns.
 

EdgeOfChaos

E

EdgeOfChaos

I revised the trigger to this, but it still has the same problem:
JASS:
    private function text takes string s, unit u, integer r, integer g, integer b, integer z returns nothing
        local texttag display = CreateTextTag()
        local real textHeight = 9 * 0.023 / 10
        local real vel = 64 * 0.071 / 128
        local real xvel = vel * Cos(90 * bj_DEGTORAD)
        local real yvel = vel * Sin(90 * bj_DEGTORAD)
        call SetTextTagText(display, s , textHeight)
        call SetTextTagPosUnit(display, u, z)
        call SetTextTagColor(display, r, g, b, 255)
        call SetTextTagVelocity(display, xvel, yvel)
        call SetTextTagPermanent( display, false )
        call SetTextTagLifespan( display, 1.50 )
        call SetTextTagFadepoint(display,1.50)
        call DisplayTextToForce(GetPlayersAll(),I2S(GetHandleId(display)))
        set display = null
    endfunction
 
Level 7
Joined
Oct 19, 2015
Messages
286
I put your function into a test library and ran it, it works fine for me. I haven't downloaded the latest WC3 patch yet, maybe this is a patch issue? Try my code in an empty map:
JASS:
library FloatingTextTest initializer Init
    private function text takes string s, unit u, integer r, integer g, integer b, integer z returns nothing
        local texttag display = CreateTextTag()
        local real textHeight = 9 * 0.023 / 10
        local real vel = 64 * 0.071 / 128
        local real xvel = vel * Cos(90 * bj_DEGTORAD)
        local real yvel = vel * Sin(90 * bj_DEGTORAD)
        call SetTextTagText(display, s , textHeight)
        call SetTextTagPosUnit(display, u, z)
        call SetTextTagColor(display, r, g, b, 255)
        call SetTextTagVelocity(display, xvel, yvel)
        call SetTextTagPermanent( display, false )
        call SetTextTagLifespan( display, 1.50 )
        call SetTextTagFadepoint(display,1.50)
        call DisplayTextToForce(GetPlayersAll(),I2S(GetHandleId(display)))
        set display = null
    endfunction
    
    globals
        private unit u
    endglobals

    private function Callback takes nothing returns nothing
        call text("test", u, 255,255,255, 128)
    endfunction

    private function Init takes nothing returns nothing
        set u = CreateUnit(Player(0), 'hfoo', 0.0,0.0,0.0)
        call TimerStart( CreateTimer(), 0.1, true, function Callback )
    endfunction
endlibrary
 

EdgeOfChaos

E

EdgeOfChaos

I tried it in an empty map, and it did work correctly. So then, some other trigger in my map is interfering? Unfortunately I can't go trigger by trigger and disable, since in order to even test my code I need my system running. I could post the map if someone would be willing to help, but it has a quite complex turn-based battle system so I doubt anyone wants to look through this.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Create texttags in a local block if it's possible (if GetLocalPlayer() == Player(X) then ... ).
I mean, yes you can do it with no desync, but if you want to display every texttag for every player, then it won't help.
This way you will reach later the 100 limit.
 

EdgeOfChaos

E

EdgeOfChaos

That's true, but not my main concern right now (I'm testing this all single player). It shouldn't be hitting the max at all, since I remove/null it. What kind of external functions make the floating text unable to recycle?

I also might want other players to be able to observe battles, so I might not do that at all.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
If you're 100 % sure that you have never 100 or more texttags simultaneously.
Then maybe it's a bug of LifeSpan, and instead of that, use a timer and DestroyTextTag.

Also i suppose it's always good to set to null, but last time i checked, there is not an handle reference counter for them.

PS : By the way, seriously why you didn't use BJDebugMsg ?!
 

EdgeOfChaos

E

EdgeOfChaos

This exact code works in an empty map so it's definitely something external affecting it. I'm just more used to using DisplayTextToForce, and it works fine.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
For my point of view, then you're reaching the 100 limit.
Or you make texttags permanents.
You don't create/work with texttags elsewhere ?

Anyway using timers and DestroyTexttag will help your debug, since then you will be able to display exactly how many texttags you have at any time.

No comment for BJDebugMsg :p
 

EdgeOfChaos

E

EdgeOfChaos

I may have found it, actually. It was a bug in the trigger where I was calling it from, it was still making a text tag from my old system and not doing anything with it -.-. Thanks for the help guys, the debugging techniques were good.

What does DebugMsg do anyways?
 
every create should have his own debug messenger
Im using "echo", which shows messages only if it's single plaeyr and player has correct (dev) nickname. safe & clean solution for everything.
in case if you got stuck with unkown/undefined behavior use our spy:
http://www.hiveworkshop.com/forums/...-277/tool-hack-unreal-jass-spy-v4-0-a-275873/

There is also a debug feature of JassHelper which will only use certain code if debugging mode is enabled.

debug call BJDebugMsg("") // only displays in debugging mode
 
Status
Not open for further replies.
Top