1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Displaying TextTags to nearby players

Discussion in 'Triggers & Scripts' started by Saishy, Feb 5, 2009.

  1. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    How can I display a texttag with the name of the ability being cast only to players that can see the casting unit?
     
  2. The Reborn Devil

    The Reborn Devil

    Joined:
    Dec 31, 2006
    Messages:
    1,325
    Resources:
    0
    Resources:
    0
    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.
     
  3. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    The problem is if the unit is invisible, or if its behind a tree.
     
  4. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    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).
     
  5. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,542
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  6. Captain Griffen

    Captain Griffen

    Joined:
    Nov 20, 2005
    Messages:
    1,001
    Resources:
    3
    Maps:
    3
    Resources:
    3
    WTF is an OOS? And texttags aren't really handles, just create them locally.
     
  7. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    I think its out of synch... Not sure, I wanna know too xD

    Someone could give me an example on showing the spellname locally? I never used GetLocalPlayer() in my life xD

    (Yeah, that is what happens when you try to make something big as your first map lol)
     
  8. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,542
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  9. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    Could someone help-me doing it? I never used getlocalplayer() >.<
     
  10. Captain Griffen

    Captain Griffen

    Joined:
    Nov 20, 2005
    Messages:
    1,001
    Resources:
    3
    Maps:
    3
    Resources:
    3
    It's called a desync. OOS is more normally out of scope. Texttags are perfectly safe for local creation/destruction.
     
  11. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,542
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  12. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    But... someone could give me an example so I can learn how to use it...

    please...
     
  13. Soga-

    Soga-

    Joined:
    Jul 20, 2008
    Messages:
    374
    Resources:
    0
    Resources:
    0
    Code (vJASS):
    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.
     
  14. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    Uhm, thanks.