1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. 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
  3. 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
  4. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  5. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  8. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  9. 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.

Arcing Floating Text 1.0.0.3

Submitted by Maker
This bundle is marked as approved. It works and satisfies the submission rules.
This system creates floating texts on units. The text tags change their height throughout their lifespan and they travel in a nice arc.
The system offers a bit nicer method than the standard that is used. Very suitable for damage detection systems.
Creates the texts only for players that have visibility over the target unit, thus the limit of 100 floating texts is less likely to be reached.

Code (vJASS):

// Arcing Text Tag v1.0.0.3 by Maker

library FloatingTextArc
    globals
        private constant    real    SIZE_MIN        = 0.018         // Minimum size of text
        private constant    real    SIZE_BONUS      = 0.012         // Text size increase
        private constant    real    TIME_LIFE       = 1.0           // How long the text lasts
        private constant    real    TIME_FADE       = 0.8           // When does the text start to fade
        private constant    real    Z_OFFSET        = 50            // Height above unit
        private constant    real    Z_OFFSET_BON    = 50            // How much extra height the text gains
        private constant    real    VELOCITY        = 2             // How fast the text move in x/y plane
        private constant    real    ANGLE           = bj_PI/2       // Movement angle of the text. Does not apply if
                                                                    // ANGLE_RND is true
        private constant    boolean ANGLE_RND       = true          // Is the angle random or fixed
        private             timer   TMR             = CreateTimer()
    endglobals
   
    struct ArcingTextTag extends array
        private texttag tt
        private real as         // angle, sin component
        private real ac         // angle, cos component
        private real ah         // arc height
        private real t          // time
        private real x          // origin x
        private real y          // origin y
        private string s        // text
        private static integer array next
        private static integer array prev
        private static integer array rn
        private static integer ic           = 0       // Instance count  
       
        private static method update takes nothing returns nothing
            local thistype this=next[0]
            local real p
            loop
                set p = Sin(bj_PI*.t)
                set .t = .t - 0.03125
                set .x = .x + .ac
                set .y = .y + .as
                call SetTextTagPos(.tt, .x, .y, Z_OFFSET + Z_OFFSET_BON * p)
                call SetTextTagText(.tt, .s, SIZE_MIN + SIZE_BONUS * p)
                if .t <= 0 then
                    set .tt = null
                    set next[prev[this]] = next[this]
                    set prev[next[this]] = prev[this]
                    set rn[this] = rn[0]
                    set rn[0] = this
                    if next[0]==0 then
                        call PauseTimer(TMR)
                    endif
                endif
                set this = next[this]
                exitwhen this == 0
            endloop
        endmethod
       
        public static method create takes string s, unit u returns thistype
            local thistype this = rn[0]
            static if ANGLE_RND then
                local real a = GetRandomReal(0, 2*bj_PI)
            else
                local real a = ANGLE
            endif
            if this == 0 then
                set ic = ic + 1
                set this = ic
            else
                set rn[0] = rn[this]
            endif
           
            set next[this] = 0
            set prev[this] = prev[0]
            set next[prev[0]] = this
            set prev[0] = this
           
            set .s = s
            set .x = GetUnitX(u)
            set .y = GetUnitY(u)
            set .t = TIME_LIFE
            set .as = Sin(a)*VELOCITY
            set .ac = Cos(a)*VELOCITY
            set .ah = 0.
           
            if IsUnitVisible(u, GetLocalPlayer()) then
                set .tt = CreateTextTag()
                call SetTextTagPermanent(.tt, false)
                call SetTextTagLifespan(.tt, TIME_LIFE)
                call SetTextTagFadepoint(.tt, TIME_FADE)
                call SetTextTagText(.tt, s, SIZE_MIN)
                call SetTextTagPos(.tt, .x, .y, Z_OFFSET)
            endif
           
            if prev[this] == 0 then
                call TimerStart(TMR, 0.03125, true, function thistype.update)
            endif
           
            return this
        endmethod
    endstruct
endlibrary
 


Trigger

  • Create Floating Text
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: if GetOwningPlayer(udg_DamageEventSource) == GetLocalPlayer() then
      • Set str = (|c00FFFF00 + ((String((Integer(DamageEventAmount)))) + |r))
      • Custom script: else
      • Set str = (|c00FF0000 + ((String((Integer(DamageEventAmount)))) + |r))
      • Custom script: endif
      • Custom script: call ArcingTextTag.create( udg_str, udg_DamageEventTarget)



Change log

v1.0.0.0 Uploaded 14th Jan 2013
v1.0.0.1 Uploaded 14th Jan 2013
-Remove a static struct member that counted the amount of active instances, used to turn the timer off and on. Using another method for that now
v1.0.0.2 Uploaded 14th Jan 2013
-Struct member s is no longer nulled
-Inlined destroy method
v1.0.0.3 Uploaded 14th Jan 2013
-Rearranged some code
-Added an option to give the text fixed angle


Credits

Thanks for Magtheridon96 for suggestions on arranging code


Keywords:
floating, text, tag, maker, damage
Contents

Just another Warcraft III map (Map)

Reviews
Moderator
17:02, 14th Jan 2013 Magtheridon96: Approved. This thing is awesome.
  1. 17:02, 14th Jan 2013
    Magtheridon96: Approved.
    This thing is awesome.
     
  2. meowie

    meowie

    Joined:
    Jun 13, 2010
    Messages:
    43
    Resources:
    0
    Resources:
    0
    Add configuration for angle/degrees rather then setting it random
     
  3. zv27

    zv27

    Joined:
    Aug 21, 2010
    Messages:
    296
    Resources:
    0
    Resources:
    0
    Very good system. Nothing overly complex, but very useful 4.8/5.0
     
  4. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Now you can set it to a fixed angle or to random angle.

    Thanks.
     
  5. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,861
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Ralle should fix the JASS script now.I cant read the whole script :((

    but,the idea is cool.
     
  6. mateuspv

    mateuspv

    Joined:
    Apr 16, 2011
    Messages:
    140
    Resources:
    0
    Resources:
    0
    My suggestion (not sure if it's possible) is:
    - Use different colors for different types of injury:
    Damage spells
    Damage heroes
    Damage units
    ...
    - Perhaps support for healing too?
    Anyway, I loved your code.
    5/5
     
  7. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    The colours are upto the user to define. When you detect damage or healing, colour the string you pass to the create method.

    Thanks for the comment.
     
    Last edited: Feb 8, 2013
  8. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,861
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    It is in you to configure it.It isnt a damage detection,its an arcing texttag
     
  9. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    TQ this is what I searching for ;) ;)
     
  10. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,035
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Thanks Maker - I will be using this to spice up my demo map when I release Damage Engine 5.1.
     
  11. Kusanagi Kuro

    Kusanagi Kuro

    Joined:
    Mar 11, 2012
    Messages:
    699
    Resources:
    0
    Resources:
    0
    The motion of the arc changed when you change the TIME_LIFE variable.

    If you want to keep the arc going up then down, then this line:

    set p = Sin(bj_PI*.t)

    in the update trigger, should become this:

    set p = Sin(bj_PI*(.t / TIME_LIFE))

    Also, the attribute "ah" seems meaningless? I don't see you using it in the update trigger at all.