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

[Trigger] Displaying TextTags to nearby players

Status
Not open for further replies.
Level 22
Joined
Dec 31, 2006
Messages
2,216
You can find out where all the players are looking and find out how far they are from the casting unit. Then use the GetLocalPlayer() function to show the texttag to all the players that are looking within a certain range from the casting unit.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
To check if a player actually sees a unit I suppose you'll need to check your camera's angle and position, and from there send a "projectile" from the camera to the unit and check for collisions.

I am not sure if it's possible to get the camera's rotations, but if it is then it should work in most cases (of course you should take the Y axis (height) in consideration when checking for a collision).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Easiest way. Check if the casting unit is visable to a player. Only make the text tag visable for players who the unit is visable to. Thus the caster and allies will always see the tags as the unit is visable. Oponents will not unless it is in LOS and is not invisable.

To do this you may need to use 2 natives, one for checking invasibility and one for checking LOS, but should not really be a problem and yield best results.
To prevent OOS occuring, I would recommend creating the text tag for all players and only hiding / revealing it to those who apply. Although it sounds tempting to not create the tag at all for people who are not meant to see it, it will probably result in an OOS as handle numbers will no longer match. Thus you will still have to atleast create the object for all players, you do not however have to perform any other actions on it the tag unless the player needs it.
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
To prevent OOS occuring, I would recommend creating the text tag for all players and only hiding / revealing it to those who apply. Although it sounds tempting to not create the tag at all for people who are not meant to see it, it will probably result in an OOS as handle numbers will no longer match. Thus you will still have to atleast create the object for all players, you do not however have to perform any other actions on it the tag unless the player needs it.

WTF is an OOS? And texttags aren't really handles, just create them locally.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
OOS is besically when some is kicked from the game or the game splits. The data in the game is no longer syncronized between people so it splits to allow play to continue.

Thinking of it now, it probably is safe to make them locally as at the time I forgot they used their own handle index range (thus the cap of 100 of them at once).

Anything that affects anything to do with gameplay and not graphics will result in an OOS, eg a unit being killed or the random number generator altered. Thus it is recommended to test your maps for OOS (splits) if you do use get local player jsut to be sure.
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
OOS is besically when some is kicked from the game or the game splits. The data in the game is no longer syncronized between people so it splits to allow play to continue.

Thinking of it now, it probably is safe to make them locally as at the time I forgot they used their own handle index range (thus the cap of 100 of them at once).

Anything that affects anything to do with gameplay and not graphics will result in an OOS, eg a unit being killed or the random number generator altered. Thus it is recommended to test your maps for OOS (splits) if you do use get local player jsut to be sure.

It's called a desync. OOS is more normally out of scope. Texttags are perfectly safe for local creation/destruction.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
OOS is what it was called back in 2000, I can not help it that they constantly change the mainings of junk like OOS or WoW.

You are probably right, however I would still be careful what code you run to generate the text tags and avoid things that generate a random number.
 
Level 7
Joined
Jul 20, 2008
Messages
377
JASS:
if (player X) == GetLocalPlayer() then
    // do local stuff here
endif

Player X being whichever player the code should run locally for. Rules of thumb about local code:

  • Try to keep handles in sync (however, some handles do not need to be in sync like floating text), or else you'll desync the game.
  • In general, use GetLocalPlayer() for doing stuff with display, but not with directly gameplay-affecting things like creating an unit.
  • There are some dirty tricks you can use with this, though, like with special effects. See JASS: GetLocalPlayer()

In short, things like DisplayMultiboard(), showing images, text, and whatsnot... if there's an on/off switch for it, chances are it's safe for GetLocalPlayer(). Oh yeah, and NEVER use sleep locally. I think I saw someone on these boards trying that... yeah, that wasn't smart.
 
Level 12
Joined
Mar 23, 2008
Messages
942
JASS:
if (player X) == GetLocalPlayer() then
    // do local stuff here
endif

Player X being whichever player the code should run locally for. Rules of thumb about local code:

  • Try to keep handles in sync (however, some handles do not need to be in sync like floating text), or else you'll desync the game.
  • In general, use GetLocalPlayer() for doing stuff with display, but not with directly gameplay-affecting things like creating an unit.
  • There are some dirty tricks you can use with this, though, like with special effects. See JASS: GetLocalPlayer()

In short, things like DisplayMultiboard(), showing images, text, and whatsnot... if there's an on/off switch for it, chances are it's safe for GetLocalPlayer(). Oh yeah, and NEVER use sleep locally. I think I saw someone on these boards trying that... yeah, that wasn't smart.

Uhm, thanks.
 
Status
Not open for further replies.
Top