• 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] Force question

Status
Not open for further replies.
Level 5
Joined
Sep 19, 2006
Messages
152
In the following set of commands, how does the Force aspect relate to the Texttag aspect? They seem almost independent of one another, yet always are written together. (I'm just wondering because I have a global "udg_HumanPlayers" that could be used in lieu of the always-created "f" force, but I don't know how/where I would insert it.)

JASS:
//  ** Death Penalty **
    set trig_unitE = GetHeroLevel (trig_unit)
    set t_1000 = bj_randDistID [trig_unitQ + 1000]
    set t_1500 = bj_randDistID [trig_unitQ + 1500]
    set t_1860 = bj_randDistID [trig_unitQ + 1860]
    if t_1500 == 0 and t_1860 == 0 then
        set y = GetPlayerState (Player (trig_unitQ), PLAYER_STATE_RESOURCE_GOLD)
        set n = ((100 - trig_unitE) * y) / 100
        call SetPlayerState (Player (trig_unitQ), PLAYER_STATE_RESOURCE_GOLD, n)
        set f = CreateForce ()
        call ForceAddPlayer (f, Player (trig_unitQ))   
        set tt = CreateTextTag ()
        call SetTextTagText (tt, "|CffFFFF00-" + I2S (y - n) + " Gold|r", 0.025)
        call SetTextTagPos (tt, trig_unitX - 100.00, trig_unitY, 50.00)
        call SetTextTagColor (tt, 255, 255, 255, 0)    
        call SetTextTagPermanent (tt, false)
        call SetTextTagLifespan (tt, 3.00)
        call SetTextTagFadepoint (tt, 0.00)    
        call SetTextTagVelocity (tt, 0.03 * Cos (1.57079), 0.03 * Sin (1.57079))
        call SetTextTagVisibility (tt, true)
        call DestroyForce (f)
        set f = null
        set tt = null
    endif
 
Level 5
Joined
Sep 19, 2006
Messages
152
Thank you for your response.

My question is, is it necessary to create a force in order for the texttag to be visible? If it is, I would prefer to use my pre-created udg_HumanPlayers force in lieu of creating/destroying a new force every time this trigger trips. Is that possible (if applicable)?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Sometimes one does not want to create a text tag for players who have no vision over the location where the text tag is created. And it is possible to make the text tag visible for some players and not visible for others.

call SetTextTagVisibilitytt, IsUnitVisible(trig_unit, GetLocalPlayer()))
^This would make it visible for players who have vision over the unit, and invisible for those who do not see the unit.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Indeed, that would be the opposite to be desycn free :

JASS:
local string s="string"
if not IsPlayerInForce(GetLocalPlayer(),FORCE) then
    set s=""
endif

The reason for this is the fear of a desycn due to the internal string table, but i don't believe in that theory, some strings are already localized, depending the language of wc3 (english, french, whatever).
All i can say for sure : at least it doesn't desync instantly (i've already tried it)

In fact you can even create texttag in a local block, instead of display it locally.
This way you will reach later or never the hardcoded limit of 100 texttags simultaneously.
And no it doesn't desync at all.
 
Status
Not open for further replies.
Top