• 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.

[JASS] Floating Text stops working

Status
Not open for further replies.
Level 4
Joined
Nov 27, 2012
Messages
85
Hello, I have this trigger that a player can set a message, and when he dies/kills a unit that message will display in floating text above the dead/killing unit. It works for a little bit when I test, but then it just stops displaying.
I assume this is because I hit the 99 text limit but aren't these all destroyed?

I've also tried NOT using native functions as this guy did, but result was the same thing
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/problem-multiplayer-floating-texts-227135/

JASS:
function Trig_Messages_Actions takes nothing returns nothing
    local unit k=GetKillingUnit()
    local unit d=GetDyingUnit()  
    local real H=16.00 // Height - Default = 16
    local real h=0.023 // Size - Default = 0.023
    local real T=0 // Transparency
    local real L=6.00 // Lifespan
    local real F=3.00 // Fade Point
    local real v=0.0355 //Velocity - Default = 0.0355
    local real xv=(v)*Cos(90*bj_DEGTORAD)
    local real xy=(v)*Sin(90*bj_DEGTORAD)
    local real w=8.0
    local real s=32.0
    local real sk=RMinBJ(StringLength(udg_kmsg[GetPlayerId(GetOwningPlayer(k))+1])*(w),(s))
    local real sd=RMinBJ(StringLength(udg_dmsg[GetPlayerId(GetOwningPlayer(d))+1])*(w),(s))
    local texttag t=CreateTextTag()
    local texttag Tt=CreateTextTag()
      
    if udg_kmsg[GetPlayerId(GetOwningPlayer(k))+1]!="" then
        call SetTextTagText((t),udg_kmsg[GetPlayerId(GetOwningPlayer(k))+1],(h))
        call SetTextTagPos((t),GetUnitX(k)-(sk),GetUnitY(k),(H))
        call SetTextTagColor((t),PercentToInt(100,255),PercentToInt(100,255),PercentToInt(100,255),PercentToInt(100.0-(T),255))   
        call SetTextTagPermanent((t),false)
        call SetTextTagVisibility((t),true)
        call SetTextTagLifespan((t),(L))
        call SetTextTagFadepoint((t),(F))
        call SetTextTagVelocity((t),(xv),(xy))
        set udg_kmsg[GetPlayerId(GetOwningPlayer(k))+1]=""
    endif
    if udg_dmsg[GetPlayerId(GetOwningPlayer(d))+1]!="" then
        call SetTextTagText((Tt),udg_dmsg[GetPlayerId(GetOwningPlayer(d))+1],(h))
        call SetTextTagPos((Tt),GetUnitX(d)-(sd),GetUnitY(d),(H))
        call SetTextTagColor((Tt),PercentToInt(100,255),PercentToInt(100,255),PercentToInt(100,255),PercentToInt(100.0-(T),255))   
        call SetTextTagPermanent((Tt),false) 
        call SetTextTagVisibility((Tt),true)
        call SetTextTagLifespan((Tt),(L))
        call SetTextTagFadepoint((Tt),(F))
        call SetTextTagVelocity((Tt),(xv),(xy))
        set udg_dmsg[GetPlayerId(GetOwningPlayer(d))+1]=""
    endif
    
    set k=null
    set d=null
    set t=null
    set Tt=null
endfunction
//===========================================================================
function InitTrig_Messages takes nothing returns nothing
    local integer i=0
    
    set gg_trg_Messages=CreateTrigger()
    loop
        exitwhen i==bj_MAX_PLAYER_SLOTS
        call TriggerRegisterPlayerUnitEvent(gg_trg_Messages,Player(i),EVENT_PLAYER_UNIT_DEATH,null)
        set i=i+1
    endloop
    
    call TriggerAddAction(gg_trg_Messages,function Trig_Messages_Actions)
endfunction
 
Last edited:
Level 7
Joined
Nov 15, 2009
Messages
225
you don't null any locals but I am not sure if every single local is needed to be nulled

You don't need to null reals, they don't leak.

I assume this is because I hit the 99 text limit but aren't these all destroyed?

They are destroyed over time, since you made them non-permanent and set the lifetime.
What happens to all the other floating texts ingame? Do they all fade out? Or do some still remain?

You should try to add
call BJDebugMsg("Test")
Inside every if then else and at the top of your function.

Check if it sometimes not writing test ingame. If yes, you know where you have to look at.

But at the moment I don't see the mistake.

JASS:
local integer i=0
    loop
        exitwhen i==bj_MAX_PLAYER_SLOTS
        call TriggerRegisterPlayerUnitEvent(gg_trg_Messages,Player(i),EVENT_PLAYER_UNIT_DEATH,null)
        set i=i+1
    endloop

The TriggerRegisterPlayerUnitEventBJ is doing fine, give it a try.
Makes your trigger much more readable.


And dude seriously, there is no need for so many local variables.. :p
Makes it very hard to read!
 
Level 4
Joined
Nov 27, 2012
Messages
85
They are destroyed over time, since you made them non-permanent and set the lifetime.
What happens to all the other floating texts ingame? Do they all fade out? Or do some still remain?

You should try to add
call BJDebugMsg("Test")
Inside every if then else and at the top of your function.

Check if it sometimes not writing test ingame. If yes, you know where you have to look at.

But at the moment I don't see the mistake.

And dude seriously, there is no need for so many local variables.. :p
Makes it very hard to read!
I'll try a debugging

there are already 783 globals so I try to limit those :D
 
Level 7
Joined
Nov 15, 2009
Messages
225
there are already 783 globals so I try to limit those :D

:vw_wtf:
However this is possible.. xD



I ment you don't need a variable for any value.
For example:
JASS:
local real L = 6.00 // Lifespan
Why don't you just type in 6, instead of L?
Doesn't make a difference for you, but for warcraft!

The only reason why alot variables for anything might be good are systems, to make sure almost anyone can change it very very easy.
 
Level 4
Joined
Nov 27, 2012
Messages
85
I ment you don't need a variable for any value.
For example:
JASS:
local real L = 6.00 // Lifespan
Why don't you just type in 6, instead of L?
Doesn't make a difference for you, but for warcraft!

The only reason why alot variables for anything might be good are systems, to make sure almost anyone can change it very very easy.

oh yea, same thing here, except it's just for me to change easily :grin:

----------

I THINK I figured it out,

These 2 strings weren't set to "" so they fired each time if I didn't set it, technically creating an invisible text?
Also setting a condition for the dying unit to be a hero has improved it

JASS:
if udg_kmsg[GetPlayerId(GetOwningPlayer(k))+1]!="" then
 
Last edited by a moderator:
Level 4
Joined
Nov 27, 2012
Messages
85
That's the same as this I think, never tried nulling a string

JASS:
if udg_kmsg[GetPlayerId(GetOwningPlayer(k))+1]!="" then

Anyways, yea previous post cleared it up I guess, thanks though
 
Status
Not open for further replies.
Top