1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dismiss Notice
  3. After a long wait, the results for Terraining Contest #18 are finally out! Drop by and congratulate the winners!
    Dismiss Notice
  4. The poll for Concept Art Contest #9 is up! Cast your vote for your favourite entry!
    Dismiss Notice
  5. Hero Contest #8 is up and running! This time it's a joint contest between artists and coders. Go here for team matchmaking.
    Dismiss Notice
  6. Our first StarCraft contest, The Galaxy Terraining Contest #1 - World Wonders has started. Enter to show off your Galaxy Editor skills and win a custom rank icon among other things.
    Dismiss Notice
  7. Ever wanted to get your sets ready for fast texturing while still having fun? Now it is possible with our newest Mini-Texturing Contest.
    The Skeleton Units need your dire help!
    Dismiss Notice
  8. The poll for Techtree Contest #11 is up! Cast your vote for your favorite entry.
    Dismiss Notice

[Snippet] TextTag

Discussion in 'Graveyard' started by Nestharus, Mar 21, 2012.

  1. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,144
    Not sure what you mean. You use IsPlayerInForce so that you can perform it locally for multiple players if you want to, with a low level of complexity. The direct method of GetLocalPlayer() == p is only for 1 player. The reason why I suggested IsPlayerInForce is that it has more options for what players you want to execute the actions for. ;)
     
  2. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    You don't get it.

    Code (vJASS):
    scope Sample initializer init

        globals
            private boolean Is_for_player = false
        endglobals

        private function init takes nothing returns nothing
            local player p = GetLocalPlayer()

            set Is_for_player = ( p == Player(1) or p == Player(3) )

            if Is_for_player then // local block only for Player(1) and Player(3)
     
            endif
        endfunction

    endscope


    That's why Nestharus uses a boolean argument, as it can be used for several players as well, the reason why i suggested a player argument instead, is because you rarely need a local block for X players, rather than for one player only, and it makes more sense than a boolean argument.
    He could even create a second method for that.

    Now, i suppose that only few people are aware about this, maybe that's why you are talking about complexity.
     
    Last edited: Mar 30, 2012
  3. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,144
    Oh, true I suppose you can do that as well. Although, it is all the same. I just thought inputting a force would be more convenient for the user, but I guess they have to add their own players anyway so a boolean would be more convenient.

    So yeah a boolean would be better. I didn't read the entire thread so I just offered an option. :p
     
  4. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    No problem, nothing in the post mentionned it, you had to figure it by yourself.

    Just to be clear :

    Instead of ForceAddPlayer :

    Code (vJASS):
    if GetLocalPlayer() == yourPlayer then
        set Your_boolean = true
    endif


    Instead of ForceRemovePlayer :

    Code (vJASS):
    if GetLocalPlayer() == yourPlayer then
        set Your_boolean = false
    endif


    Ofc there are room for improvements, like using a global player variable setted at map init instead of GetLocalPlayer, or you could even use a boolean array :

    Code (vJASS):
    library LocalHelp initializer init

        globals
            integer Local_id
            player Local_p
            string Local_s
            boolean array Is_local_player_id // excuse the name :p
        endglobals
       
        private function init takes nothing returns nothing
            set Local_p = GetLocalPlayer()
            set Local_id = GetPlayerId(Local_p)
            set Local_s = I2S(Local_id)
            set Is_local_player_id[Local_id] = true
        endfunction
    endlibrary
     
  5. vuongkkk

    vuongkkk
    Joined:
    Oct 13, 2010
    Messages:
    78
    Hey, Nes. You forgot something.

    When i used
    .setVelocity()
    and
    .angle=
    , i recognized that the angle you made is Radian not Degree.
    At least, add a comment about it or add
    *bj_DEGTORAD
    when calculating because "angle" makes everybody to think about degree

    Edit: btw, can you "open a hole" at method update for change texttag overtime ????
     
    Last edited: Apr 1, 2012
  6. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,106
    That feature does not belong in this resource. If you want that, code another resource that supports changing texttags over time that uses this one or start your own timers.

    I only supported what are supported by current texttags and a tiny bit more (the set texttag target position should lock to that position).

    radians are what the rest of the world uses by default.
     
  7. vuongkkk

    vuongkkk
    Joined:
    Oct 13, 2010
    Messages:
    78
    I found a weird bug:

    Example

    Error
    Code (Text):

    lifespan       = 3.0
    creating period= 0.5

    lifespan       = 3.5
    creating period= 0.5

    lifespan       = 2.4
    creating period= 0.4
     
    Non Error
    Code (Text):

    lifespan       = 2.5
    creating period= 0.5

    lifespan       = 3.1
    creating period= 0.5

    lifespan       = 2.2
    creating period= 0.4
     

    Test code

    Code (vJASS):
    function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    local TextTag tt
     set tt= TextTag.createLocal(GetLocalPlayer()== Player(0))
     call tt.setPosition(GetRectCenterX(bj_mapInitialPlayableArea), GetRectCenterY(bj_mapInitialPlayableArea),70)
     call tt.setText("ABC",12)
     call tt.setVelocity(80., 90.)
     set tt.lifespan=3.0
     set tt.fadepoint=1.1
     endfunction

    function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
        set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
        call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_001, 0.5 )
        call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
    endfunction
     
    Last edited: Apr 4, 2012
  8. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,106
    I don't understand what you mean.
     
  9. vuongkkk

    vuongkkk
    Joined:
    Oct 13, 2010
    Messages:
    78
    When creating texttags overtime like "Example - error case" with this system

    I saw:
    - First: have a texttag disappears when the time comes !!!
    - Second: some texttags disappear when they do not expire !? (i used fadepoint to confirm that)
    - Third: texttags disappear like a disease

    You should run my test code to see what is the bug.....
    I think the bug relates with timer!

    For tester 's sake: Map with The bug
     

    Attached Files:

  10. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,106
    Fixed

    Texttags were cleaned up before timers expired since they shared the same timeouts. Added .001 to the actual texttag lifespan ; P.
     
  11. vuongkkk

    vuongkkk
    Joined:
    Oct 13, 2010
    Messages:
    78
    sure allocate() method is magical but still remain a prob here!
    the code doesn't works properly if all cons are true:
    - The number of texttag breaks the limit
    - Use the standard texttag like crit, miss, bounty and GUI texttag...
     
    Last edited: Apr 12, 2012
  12. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,106
    ????

    If you reach limit, the oldest non-permanent texttag is taken.

    Not sure what you mean on point 2. I've run into 0 probs with this when running hundreds of texttags. Yes, they will end early, but that's to be expected.
     
  13. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,022
    Nes, if you're up for it, you can help users get past the 100-texttag limit by seeing if certain texttags can be merged ;)

    All texttags having the same X or Y (non-moving) can be merged.
    If two texttags have the same X or Y and and are moving, they can only be merged if they have the same velocity :p
     
  14. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,106
    uh no lol
     
  15. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    I've already tried it in the past, texttags created by triggers and the ones created by the game don't seem to share the same stack.
    The test is easy, display 100 texttags by trigger, and then display game's ones.
     
  16. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,022
    You could probably take advantage of something like that :p
    For example, if you want damage texttags, you could give units 100% critical strike and set the multiplier to 1, then modify the color data and shit in that MiscXX.txt file inside Warcraft III's MPQ files <:
     
  17. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    Overkill, here i come :p

    EDIT : Anyway, do you realize that we can't really control them, at least not in the same way that the ones created by triggers (lifespan, position, velocity, etc) ?
     
  18. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,022
    Well, it's fine if you only need a constant velocity, lifespan, fadepoint, color and such :p
     
  19. vuongkkk

    vuongkkk
    Joined:
    Oct 13, 2010
    Messages:
    78
    Creating local texttags is hard to deal.
    I think it's not a prob unless:
    have a unit learn Critical Strike and that unit have speed enough to create more than 100 - <localRemaining> texttags :vw_wtf:

    Btw, I used a part of your code in my texttag system, hope that not violate the copyright...
     
  20. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,106