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

[General] Floating text just for players with vision on tower.

Level 13
Joined
Sep 11, 2013
Messages
467
Greetings!

I've made this trigger and I wish to know if there is a solution for my problem. :peasant-confused:
  • Incinerated Arrow
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Unit-type of (Damage source)) Equal to Tower
      • (Damage From Normal Attack) Equal to True
    • Actions
      • Set VariableSet IncinerateTowerForUnit1 = (Damage source)
      • Set VariableSet IncinerateTowerForUnit2 = (Damage Target)
      • Game - Display to (All players) the text: X
      • Set VariableSet IncinerateTowerReal1 = ((Max life of (Damage Target)) x 0.01)
      • Set VariableSet IntegerFloatingTextArrow = ((Base Damage of (Damage source) for weapon index 0) + (Integer(IncinerateTowerReal1)))
      • Unit - Cause IncinerateTowerForUnit1 to damage IncinerateTowerForUnit2, dealing IncinerateTowerReal1 damage of attack type Chaos and damage type Universal
      • Floating Text - Create floating text that reads (String(IntegerFloatingTextArrow)) above (Damage source) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
That floating text will appear for everyone, even if an ally or an enemy has no vision on the tower. They can see the floating text through fog of war.
How can I make that floating text to appear just for players (allies/enemy) with vision on tower?
I don't know if that matter but this tower can be created only be team 2 players.

The help will be appreciated!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Use the Hide floating text Action, hiding it for anyone that doesn't have vision of the damaged unit:
  • Floating Text - Create floating text that reads (String(IntegerFloatingTextArrow)) above IncinerateTowerForUnit1 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
  • Set VariableSet IncinerateText = (Last created floating text)
  • Floating Text - Set the velocity of IncinerateText to 64.00 towards 90.00 degrees
  • Floating Text - Change IncinerateText: Disable permanence
  • Floating Text - Change the lifespan of IncinerateText to 1.50 seconds
  • Floating Text - Change the fading age of IncinerateText to 0.75 seconds
  • Set VariableSet IncinerateTextGroup = (All players matching ((IncinerateTowerForUnit1 is fogged to (Matching player).) Equal to True).)
  • Floating Text - Hide IncinerateText for IncinerateTextGroup
  • Custom script: call DestroyForce( udg_IncinerateTextGroup )
Also, you're setting variables but never using them. That defeats their purpose.
 
Last edited:
Level 10
Joined
Jan 26, 2019
Messages
90
Just create tag text only for player who sees the tower.
1.png
Unit (unit) is visible to the player (local player)

Comparison with local player allows you to perform actions only for a specific player, but you should not use this function in other cases if you do not know how to use it, because this can lead to desynchronization.

Apparently you are using the reforged editor and not YDWE PK, so most likely this is the only crutch option left for you:
4.png
3.png
5.png
 
Level 13
Joined
Sep 11, 2013
Messages
467
Use the Hide floating text Action, hiding it for anyone that doesn't have vision of the damaged unit:
  • Floating Text - Create floating text that reads (String(IntegerFloatingTextArrow)) above IncinerateTowerForUnit1 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
  • Set VariableSet IncinerateText = (Last created floating text)
  • Floating Text - Set the velocity of IncinerateText to 64.00 towards 90.00 degrees
  • Floating Text - Change IncinerateText: Disable permanence
  • Floating Text - Change the lifespan of IncinerateText to 1.50 seconds
  • Floating Text - Change the fading age of IncinerateText to 0.75 seconds
  • Set VariableSet IncinerateTextGroup = (All players matching ((IncinerateTowerForUnit1 is fogged to (Matching player).) Equal to True).)
  • Floating Text - Hide IncinerateText for IncinerateTextGroup
  • Custom script: call DestroyForce( udg_IncinerateTextGroup )
Also, you're setting variables but never using them. That defeats their purpose.
I tried to test it with a player that was in enemy team and i saw the floating text through fog of war.. so this solution not work..

  • Incinerated Arrow
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Unit-type of (Damage source)) Equal to Tower
      • (Damage From Normal Attack) Equal to True
    • Actions
      • Set VariableSet IncinerateTowerForUnit1 = (Damage source)
      • Set VariableSet IncinerateTowerForUnit2 = (Damage Target)
      • Game - Display to (All players) the text: X
      • Set VariableSet IncinerateTowerReal1 = ((Max life of (Damage Target)) x 0.01)
      • Set VariableSet IntegerFloatingTextArrow = ((Base Damage of (Damage source) for weapon index 0) + (Integer(IncinerateTowerReal1)))
      • Unit - Cause IncinerateTowerForUnit1 to damage IncinerateTowerForUnit2, dealing IncinerateTowerReal1 damage of attack type Chaos and damage type Universal
      • Floating Text - Create floating text that reads (String(IntegerFloatingTextArrow)) above IncinerateTowerForUnit1 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
      • Set VariableSet FloatingTextVar = (Last created floating text)
      • Floating Text - Set the velocity of FloatingTextVar to 64.00 towards 90.00 degrees
      • Floating Text - Change FloatingTextVar: Disable permanence
      • Floating Text - Change the lifespan of FloatingTextVar to 1.50 seconds
      • Floating Text - Change the fading age of FloatingTextVar to 0.75 seconds
      • Set VariableSet PlayerGroupFloatingText = (All players matching ((IncinerateTowerForUnit1 is fogged to (Matching player).) Equal to True).)
      • Floating Text - Hide FloatingTextVar for PlayerGroupFloatingText
      • Custom script: call DestroyForce(udg_PlayerGroupFloatingText)

Just create tag text only for player who sees the tower.
Unit (unit) is visible to the player (local player)

Comparison with local player allows you to perform actions only for a specific player, but you should not use this function in other cases if you do not know how to use it, because this can lead to desynchronization.

Apparently you are using the reforged editor and not YDWE PK, so most likely this is the only crutch option left for you:
I have no idea what is a tag text or how to find it in world editor..

Thanks for the help guys, but the problem is still strong :peasant-work-work:
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Edit: Hold on, testing it myself.

Edit 2:
Okay, got it to work by checking if it's fogged OR masked:
  • Hide Floating Text
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Floating Text - Create floating text that reads TEXT! above Scout Tower 0000 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Scout Tower 0000 <gen> is fogged to (Picked player).) Equal to True
                  • (Scout Tower 0000 <gen> is masked to (Picked player).) Equal to True
            • Then - Actions
              • Player Group - Add (Picked player) to FogGroup
            • Else - Actions
      • Floating Text - Hide (Last created floating text) for FogGroup
      • Player Group - Remove all players from FogGroup.
You can get it working by modifying your Player Group to this:
  • Set VariableSet PlayerGroupFloatingText = (All players matching (((IncinerateTowerForUnit1 is fogged to (Matching player).) Equal to True) or ((IncinerateTowerForUnit1 is masked to (Matching player).) Equal to True)).)
  • Floating Text - Hide FloatingTextVar for PlayerGroupFloatingText
  • Custom script: call DestroyForce(udg_PlayerGroupFloatingText)
Oh and a TextTag is Floating Text. When working with Jass code there's often a different term for something that exists in GUI.
TextTag = Floating Text, Location = Point, and Force = Player Group.
(This is why your Custom Script will say things like RemoveLocation and DestroyForce)

Enemy'1s solution could be more efficient than mine but GetLocalPlayer() scares me since when used improperly it can lead to desyncs. But maybe this is a proven solution. Note that my solution is far from performant, especially if the tower or towers deal damage often.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,928
Just create tag text only for player who sees the tower.
Unit (unit) is visible to the player (local player)

Comparison with local player allows you to perform actions only for a specific player, but you should not use this function in other cases if you do not know how to use it, because this can lead to desynchronization.

Apparently you are using the reforged editor and not YDWE PK, so most likely this is the only crutch option left for you:
Sorry if I'm missing something, but can you create texttags for a local player? I thought that creating a handle just some players causes a desync.
 
Level 13
Joined
Sep 11, 2013
Messages
467
  • set.gif
    Set VariableSet PlayerGroupFloatingText = (All players matching (((IncinerateTowerForUnit1 is fogged to (Matching player).) Equal to True) or ((IncinerateTowerForUnit1 is masked to (Matching player).) Equal to True)).)
  • page.gif
    Floating Text - Hide FloatingTextVar for PlayerGroupFloatingText
  • page.gif
    Custom script: call DestroyForce(udg_PlayerGroupFloatingText)
This seems to work very well! Thank you so much!
Note that my solution is far from performant, especially if the tower or towers deal damage often.
What that means? More bugs or more lag?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Performant means performance which in the case of video games refers to the framerate or FPS.

You're creating a Player Group every single time one of those towers deals damage. The game has to fill it with matching players, then loop over it to hide the text for them, before finally destroying the player group. It's not a super complicated task but it's definitely something to keep an eye on if the trigger runs too often.

Anyway, it's the sort of thing that you might not even notice. I just wanted to note that there could be a better solution (Enemy1 suggested one but needs to confirm if it desyncs or not).
 
Level 13
Joined
Sep 11, 2013
Messages
467
Performant means performance which in the case of video games refers to the framerate or FPS.

You're creating a Player Group every single time one of those towers deals damage. The game has to fill it with matching players, then loop over it to hide the text for them, before finally destroying the player group. It's not a super complicated task but it's definitely something to keep an eye on if the trigger runs too often.

Anyway, it's the sort of thing that you might not even notice. I just wanted to note that there could be a better solution (Enemy1 suggested one but needs to confirm if it desyncs or not).
Thank you for explanation! I'll not risk a desync, so I'll go with your trigger.

Enemy1PK - Thank your anyway for your help!​

 
Level 10
Joined
Jan 26, 2019
Messages
90
Sorry if I'm missing something, but can you create texttags for a local player? I thought that creating a handle just some players causes a desync.
For some reason, the text tags are local, I’m not a programmer but a simple jass user and I don’t know the details, but it really works like that, in any case, nothing stops you from testing it in 2 windows in literally 5 minutes.

As you may know, the game has a limit on displaying 100 tag texts to a player at a time, so the best option is to create tag text only for the player who needs to see it.
If you create it for everyone, but only show it to a specific player, you can hit the limit when, for example, 10 players fight a boss, which happened before in my map - Twilights Eve Resurrection.

As for the author of the question, I proposed the only correct and even simplest option, but if the author did not see the similarity of parameters in his and my
omg.png
(for example, seconds) and could not guess that the tag text and the floating text are the same thing, then I am powerless here.
Unfortunately, I'm not a wizard and I can't just put my knowledge into someone else's mind.
For everyone else, I want to add something about the method proposed above.
When you put objects in a group, it creates a linked list that is not completely removed even after clearing and deleting the group, which is why some authors, such as the authors of Dota, use group reuse systems
reuse.png
I certainly didn’t clarify this issue, but I assume that a group of players works the same way as a group of units.
Personally, I didn’t know this before and still haven’t felt any real problems in my map, but still I think that creating and destroying a group for EVERY damage dealt is not the best idea, especially considering everything that I said above.
I hope someone learned something new today, because personally I feel like I wasted my time. gl hf
 
Level 13
Joined
Sep 11, 2013
Messages
467
As for the author of the question, I proposed the only correct and even simplest option, but if the author did not see the similarity of parameters in his and my
(for example, seconds) and could not guess that the tag text and the floating text are the same thing, then I am powerless here.
I clearly noticed the similarity, although I still wasn't sure, but the main reason I avoided trying that solution is the apparent risk of desynchronization.
in any case, nothing stops you from testing it in 2 windows in literally 5 minutes.
As you may know, the game has a limit on displaying 100 tag texts to a player at a time, so the best option is to create tag text only for the player who needs to see it.
When you put objects in a group, it creates a linked list that is not completely removed even after clearing and deleting the group, which is why some authors, such as the authors of Dota, use group reuse systems
Personally, I didn’t know this before and still haven’t felt any real problems in my map, but still I think that creating and destroying a group for EVERY damage dealt is not the best idea, especially considering everything that I said above.
I hope someone learned something new today, because personally I feel like I wasted my time. gl hf
No need to worry, now I understand better what are you trying to say and I will strongly take your suggestion in consideration for next tests.
Thank you! :peasant-thumbs-up:
 
Top