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

why cant ihide this floating text tag?

Status
Not open for further replies.
Level 3
Joined
Dec 17, 2017
Messages
39
hello,
im trying to show the damage a unit deals in text tags, but only for the player that deals it (white color) and the player which owns the unit suffering it (red color).

this is the function. it is run after damage-detection once for each unit (the target and the damage-dealer at location p. r1 is the amount of damage and rgb are the color-values.):

JASS:
function score1 takes location p, unit u, real r1, real r, real g, real b returns nothing
    //defining
    local force f
    local force f2
    local real r2
    local real scale
    local string str
    //operations
    set r2 = I2R(GetHeroLevel(udg_avatar[GetConvertedPlayerId(GetOwningPlayer(u))]))
    set scale = ( Pow(( ( r1 + udg_FloatingSize1 + (r2*80) ) / udg_FloatingSize2 + (r2*4) ), udg_FloatingSizePow - (0.1*r2)) * udg_FloatingSize3 )
    set str = I2S(R2I(r1))
    if (r1 > (0.2+(4*r2))) then
        set f = GetForceOfPlayer(GetOwningPlayer(u))
        set f2 = GetPlayersAll()
            call ForceRemovePlayerSimple( GetOwningPlayer(u), f2 )
        if ( udg_ScoreDmg1[GetConvertedPlayerId(GetOwningPlayer(u))] == 1 ) then
                call CreateTextTagLocBJ( str, p, 50.00, scale, r, g, b, 0 )
                call SetTextTagVelocityBJ( GetLastCreatedTextTag(), ( scale * 10.00 ), 90 )
                call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
                call SetTextTagLifespanBJ( GetLastCreatedTextTag(), ( ( scale + 25.00 ) / 100.00 ) )
                call ShowTextTagForceBJ( true, GetLastCreatedTextTag(), f )
                call ShowTextTagForceBJ( false, GetLastCreatedTextTag(), f2 )
        else
            if (( udg_ScoreDmg1[GetConvertedPlayerId(GetOwningPlayer(u))] == 2 ) and (udg_avatar[GetConvertedPlayerId(GetOwningPlayer(u))] == u)) then   
                    call CreateTextTagLocBJ( str, p, 50.00, scale, r, g, b, 0 )
                    call SetTextTagVelocityBJ( GetLastCreatedTextTag(), ( scale * 10.00 ), 90 )
                    call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
                    call SetTextTagLifespanBJ( GetLastCreatedTextTag(), ( ( scale + 25.00 ) / 100.00 ) )
                    call ShowTextTagForceBJ( true, GetLastCreatedTextTag(), f )
                   call ShowTextTagForceBJ( false, GetLastCreatedTextTag(), f2 )
            endif
        endif
    endif
    // clearing
    call DestroyForce(f)
    call DestroyForce(f2)
    set f=null
    set f2=null
endfunction

but it doesnt work. i always see both, the white and the red texttag. i even added the
JASS:
call ShowTextTagForceBJ( false, GetLastCreatedTextTag(), f2 )
line and force f2 but it didnt help. Is there anything im missing?
greetings
 
JASS:
function score1 takes location p, unit u, real r1, real r, real g, real b returns nothing
    //defining
    //Forces f, f2 not needed
    // local force f
    // local force f2
    local real r2
    local real scale
    local string str
    local integer id = GetPlayerId(GetOwningPlayer(u)) + 1  //GetConvertedPlayerId(GetOwningPlayer(u))'s result
    //operations
    set r2 = I2R(GetHeroLevel(udg_avatar[id]))
    set scale = ( Pow(( ( r1 + udg_FloatingSize1 + (r2*80) ) / udg_FloatingSize2 + (r2*4) ), udg_FloatingSizePow - (0.1*r2)) * udg_FloatingSize3 )
    set str = I2S(R2I(r1))
    if (r1 > (0.2+(4*r2))) then
        // set f = GetForceOfPlayer(GetOwningPlayer(u))
        // set f2 = GetPlayersAll()
        // call ForceRemovePlayerSimple( GetOwningPlayer(u), f2 )
        //using new local id
        if ( udg_ScoreDmg1[id] == 1 ) then
            call CreateTextTagLocBJ( str, p, 50.00, scale, r, g, b, 0 )
            //GetLastCreatedTextTag() -> bj_lastCreatedTextTag
            //Not worth inlining {SetTextTagVelocityBJ}
            call SetTextTagVelocityBJ( bj_lastCreatedTextTag, ( scale * 10.00 ), 90 )
            call SetTextTagPermanent( bj_lastCreatedTextTag, false )
            call SetTextTagLifespan( bj_lastCreatedTextTag, ( ( scale + 25.00 ) / 100.00 ) )
            // Using GetLocalPlayer trick here
            // Machine-dependent, will hide for other players and show for the owner of that player.
            call SetTextTagVisibility( bj_lastCreatedTextTag, GetLocalPlayer() == GetOwningPlayer(u))
        else
            if (( udg_ScoreDmg1[id] == 2 ) and (udg_avatar[id] == u)) then   
                call CreateTextTagLocBJ( str, p, 50.00, scale, r, g, b, 0 )
                call SetTextTagVelocityBJ( bj_lastCreatedTextTag, ( scale * 10.00 ), 90 )
                call SetTextTagPermanent( bj_lastCreatedTextTag, false )
                call SetTextTagLifespan( bj_lastCreatedTextTag, ( ( scale + 25.00 ) / 100.00 ) )
                call SetTextTagVisibility( bj_lastCreatedTextTag, GetLocalPlayer() == GetOwningPlayer(u))
            endif
        endif
    endif
    // clearing
    // call DestroyForce(f)
    //GetPlayersAll must not be destroyed. It is a static handle.
    // call DestroyForce(f2)
    // set f=null
    // set f2=null
endfunction


Try copy and pasting this snippet.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
I suspect that by destroying the f2 force handle, the result is that the text tag is effectively hidden from no one and shown only to one. Try to remove DestroyForce(f2) and see if the issue persists.

Not only that, but also first you're showing for the player you want (f1) and then hidding for all players (f2), which doesn't make sense. You need to switch the order.
 
Level 3
Joined
Dec 17, 2017
Messages
39
@MyPad thank you, it worked! :)

now, is it possible to create the whole texttag only for the local player? because that wouldbe pretty cool, since its a multiplayer map and ive read that you can only have about 90 texttags at the same time. i also read about creating them locally only on one pc, so my try:

JASS:
function score1 takes location p, unit u, real r1, real r, real g, real b returns nothing
    //defining
    local real r2
    local real scale
    local string str
    local integer id = GetPlayerId(GetOwningPlayer(u)) + 1  //GetConvertedPlayerId(GetOwningPlayer(u))'s result
    //operations
    if (GetLocalPlayer() == GetOwningPlayer(u)) then
        set r2 = I2R(GetHeroLevel(udg_avatar[id]))/28
        set scale = ( Pow(( ( r1 + udg_FloatingSize1 + (r2*80) ) / udg_FloatingSize2 + (r2*4) ), udg_FloatingSizePow - (0.1*r2)) * udg_FloatingSize3 )
        set str = I2S(R2I(r1))
        if (r1 > (0.2+(4*r2))) then
            //using new local id
            if ( udg_ScoreDmg1[id] == 1 ) then
                call CreateTextTagLocBJ( str, p, 50.00, scale, r, g, b, 0 )
                //GetLastCreatedTextTag() -> bj_lastCreatedTextTag
                //Not worth inlining {SetTextTagVelocityBJ}
                call SetTextTagVelocityBJ( bj_lastCreatedTextTag, ( scale * 10.00 ), 90 )
                call SetTextTagPermanent( bj_lastCreatedTextTag, false )
                call SetTextTagLifespan( bj_lastCreatedTextTag, ( ( scale + 25.00 ) / 100.00 ) )
                // Using GetLocalPlayer trick here
                // Machine-dependent, will hide for other players and show for the owner of that player.
                call SetTextTagVisibility( bj_lastCreatedTextTag, GetLocalPlayer() == GetOwningPlayer(u))
            else
                if (( udg_ScoreDmg1[id] == 2 ) and (udg_avatar[id] == u)) then 
                    call CreateTextTagLocBJ( str, p, 50.00, scale, r, g, b, 0 )
                    call SetTextTagVelocityBJ( bj_lastCreatedTextTag, ( scale * 10.00 ), 90 )
                    call SetTextTagPermanent( bj_lastCreatedTextTag, false )
                    call SetTextTagLifespan( bj_lastCreatedTextTag, ( ( scale + 25.00 ) / 100.00 ) )
                    call SetTextTagVisibility( bj_lastCreatedTextTag, GetLocalPlayer() == GetOwningPlayer(u))
                    endif
            endif
        endif
    endif
endfunction

does that work in multiplayergames, so that the tag is only created on the machine of the player owning the unit u?

and does
JASS:
GetConvertedPlayerId(player)
the same thing as
JASS:
GetPlayerId(player)+1
?

thanks man^^
 
Status
Not open for further replies.
Top