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. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  5. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  6. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  7. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  8. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. 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.

Casting-Channeling Bar v1.6.0

Submitted by maddeem
This bundle is marked as approved. It works and satisfies the submission rules.
Casting-Channeling Bar v1.6.0

The casting bar is made out of floating text, and is displayed when a unit casts a spell.
The Casting Bar is hidden to players who don't have vision of the casting unit.
The casting bar's color variates depending on which player casted it.
NEW!
Reworked and removed a lot of useless GUI

This uses Bribe's Indexer
Indexer Used
http://www.hiveworkshop.com/forums/spells-569/gui-unit-indexer-1-2-0-2-a-197329/?prev=search%3Dindexer%26d%3Dlist%26r%3D20

But this casting bar system can be used with any unit indexing system.


Change Log

v1.0.0 - First release to hive.
v1.0.1 - Got rid of many hideous loops, removed the sight of bar (going to make it based off of player vision soon) and made size changeable. I also think I have made it easier to add/edit spells.
v1.0.2 - Added levels to casting time, also made it easier to add abilities.
v1.0.3 - Added offset and visibility of the bar to those who can see the casting unit.
v1.0.4 - Improved the code a TON, also fixed things due to request.
v1.5.0 - Added channeling bar and fixed a little bug at the beginning of the bar.
v1.5.1 - Quickly redid some logic to prevent spells that weren't set to have no casting bar
v1.5.2 - Changed how the bar is offset, made the bar follow the caster.
v1.6.0 - Removed as many BJs as possible whilst still keeping it GUI friendly

Triggers
  • Init Casting
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local integer i=0
      • Hashtable - Create a hashtable
      • Set BarHash = (Last created hashtable)
      • -------- The number of the llllllllllllllllllllllll on the casting bar. . . --------
      • Set NumberofTicks = 30
      • -------- Size of the Bar --------
      • Set CastingBarSize = 6.00
      • -------- The Z offset of the casting bar. --------
      • Set BarOffset = 50.00
      • -------- Color of the casting bar for each player. . . --------
      • Set PlayerColors[1] = |cffff0303
      • Set PlayerColors[2] = |cff0042ff
      • Set PlayerColors[3] = |cff1ce6b9
      • Set PlayerColors[4] = |cff540081
      • Set PlayerColors[5] = |cfffffc01
      • Set PlayerColors[6] = |cfffe8a0e
      • Set PlayerColors[7] = |cff20c000
      • Set PlayerColors[8] = |cffe55bb0
      • Set PlayerColors[9] = |cff959697
      • Set PlayerColors[10] = |cff7ebff1
      • Set PlayerColors[11] = |cff106246
      • Set PlayerColors[12] = |cff4e2a04
      • Set PlayerColors[13] = |c002F2F2F
      • Set PlayerColors[14] = |c002F2F2F
      • -------- Spell Configuration --------
      • -------- This is the ability for the spell you want to set the casting time of --------
      • Set TempAbil = Flame Strike
      • Custom script: call SaveReal(udg_BarHash,udg_TempAbil, 1, 3.0)
      • -------- ^ --------
      • -------- That is the casting Time --------
      • Set TempAbil = Banish
      • Custom script: call SaveReal(udg_BarHash,udg_TempAbil, 1, 2.0)
      • Set TempAbil = Phoenix
      • Custom script: call SaveReal(udg_BarHash,udg_TempAbil, 1, 5.0)
      • Set TempAbil = Siphon Mana
      • Custom script: call SaveReal(udg_BarHash,udg_TempAbil, 1, 1.5)
      • -------- ^ --------
      • -------- Some Abilities require less/more casting time per level so change this --------
      • -------- 1 being the level of the ability --------
      • -------- If every level of the spell have the same casting time then only set it once. --------
      • Custom script: call SaveReal(udg_BarHash,udg_TempAbil, 2, 1.0)
      • Custom script: call SaveReal(udg_BarHash,udg_TempAbil, 3, 0.5)
      • Set TempAbil = Starfall
      • Custom script: call SaveReal(udg_BarHash,udg_TempAbil, 1, 10)
      • Custom script: call SaveBoolean(udg_BarHash,udg_TempAbil, udg_TempAbil,true)
      • -------- ^ --------
      • -------- If that is true, then the ability will be "channeled" and will go full bar to low bar instead of low bar to full bar. --------
      • -------- All you have to do is insert this boolean below ur casting times --------
      • Custom script: loop
      • Custom script: set i=i+1
      • Custom script: exitwhen i==udg_NumberofTicks
      • Custom script: set udg_LoadingBarText=udg_LoadingBarText+"l"
      • Custom script: endloop
      • Custom script: set udg_CastingBarSize=udg_CastingBarSize*.0023
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
  • BeginCast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
    • Actions
      • Custom script: local unit u=GetTriggerUnit()
      • Custom script: local integer i=GetSpellAbilityId()
      • Custom script: local integer c
      • Custom script: local string s
      • Custom script: local real r=LoadReal(udg_BarHash,i,GetUnitAbilityLevel(u,i))
      • Custom script: if r==0 then
      • Custom script: set r=LoadReal(udg_BarHash,i,1)
      • Custom script: endif
      • Custom script: if not IsUnitInGroup(u,udg_CastingGroup) and r>0 then
      • Custom script: set c=GetUnitUserData(u)
      • Custom script: set udg_BeginCastTime[c]=0
      • Custom script: set udg_EndCastTime[c]=r
      • Custom script: set udg_Channel[c]=LoadBoolean(udg_BarHash,i,i)
      • Custom script: if udg_Channel[c] then
      • Custom script: set s="["+udg_PlayerColors[GetPlayerId(GetOwningPlayer(u))+1]+udg_LoadingBarText+"|r]"
      • Custom script: else
      • Custom script: set s="["+udg_LoadingBarText+"]"
      • Custom script: endif
      • Custom script: set udg_CastingBar[c]=CreateTextTag()
      • Custom script: call SetTextTagVisibility(udg_CastingBar[c], IsUnitVisible(u,GetLocalPlayer()))
      • Custom script: call SetTextTagText(udg_CastingBar[c],s,udg_CastingBarSize)
      • Custom script: call SetTextTagPos(udg_CastingBar[c],GetUnitX(u),GetUnitY(u),udg_BarOffset)
      • Custom script: call GroupAddUnit(udg_CastingGroup,u)
      • Trigger - Turn on CastingPeiodic <gen>
      • Custom script: endif
      • Custom script: set u=null
  • EndCast
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
    • Actions
      • Custom script: local unit u=GetTriggerUnit()
      • Custom script: local integer c
      • Custom script: if IsUnitInGroup(u,udg_CastingGroup) then
      • Custom script: set c=GetUnitUserData(u)
      • Custom script: call GroupRemoveUnit(udg_CastingGroup,u)
      • Custom script: call DestroyTextTag(udg_CastingBar[c])
      • Custom script: if IsUnitGroupEmptyBJ(udg_CastingGroup) then
      • Trigger - Turn off CastingPeiodic <gen>
      • Custom script: endif
      • Custom script: endif
      • Custom script: set u=null
  • CastingPeiodic
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CastingGroup and do (Actions)
        • Loop - Actions
          • Custom script: local unit u=GetEnumUnit()
          • Custom script: local integer c=GetUnitUserData(u)
          • Custom script: local real r
          • Custom script: if udg_BeginCastTime[c]>=udg_EndCastTime[c] then
          • Custom script: call GroupRemoveUnit(udg_CastingGroup,u)
          • Custom script: call DestroyTextTag(udg_CastingBar[c])
          • Custom script: if IsUnitGroupEmptyBJ(udg_CastingGroup) then
          • Trigger - Turn off CastingPeiodic <gen>
          • Custom script: endif
          • Custom script: else
          • Custom script: set udg_BeginCastTime[c]=udg_BeginCastTime[c]+.1
          • Custom script: set r=udg_BeginCastTime[c]/udg_EndCastTime[c]
          • Custom script: if udg_Channel[c] then
          • Custom script: set r=1-r
          • Custom script: endif
          • Custom script: set r=r*udg_NumberofTicks
          • Custom script: if r>=1 then
          • Custom script: call SetTextTagText(udg_CastingBar[c],"["+udg_PlayerColors[GetPlayerId(GetOwningPlayer(u))+1]+SubString(udg_LoadingBarText,0,R2I(r))+"|r"+SubString(udg_LoadingBarText,R2I(r)-1,udg_NumberofTicks)+"]",udg_CastingBarSize)
          • Custom script: endif
          • Custom script: call SetTextTagVisibility(udg_CastingBar[c], IsUnitVisible(u,GetLocalPlayer()))
          • Custom script: call SetTextTagPos(udg_CastingBar[c],GetUnitX(u),GetUnitY(u),udg_BarOffset)
          • Custom script: endif
          • Custom script: set u=null

Keywords:
Casting, Casting Bar, Channel, String, Text Bar, Info Bar, channel
Contents

Casting-Channeling Bar v1.6.0 (Map)

Reviews
Moderator
Approved since it works nicely. -Change the version number to 1.x.x, obviously it is not 0.0.x -Change the Temp real conditions as suggested in my reply to this thread -Rethink the way you show/hide the floating text for player, now you do too...
  1. Maker, Casting Bar v0.0.3, 17th Oct 2011

    Approved since it works nicely.

    -Change the version number to 1.x.x, obviously it is not 0.0.x
    -Change the Temp real conditions as suggested in my reply to this thread
    -Rethink the way you show/hide the floating text for player, now you do too many actions
    -Add "unit is in cast group" condition to stops casting trigger, since now it triggers for all abilities
     
  2. yurneric

    yurneric

    Joined:
    Jul 16, 2009
    Messages:
    92
    Resources:
    0
    Resources:
    0
    Suggestion for you:

    - The use dynamic indexing is better (and cleaner).
    - Unit group should be destroyed when number of units equals to 0. (It doesn't hurt to recreate it.)
    - Note that you used "Begin CHANNELING". I would say, use "Begin CASTING". (I hope you know the difference.)


    Comments:

    - Fairly good idea.
    - Troublesome casting time set-up for different spells.
    - Just don't get confused with "casting time" and "channeling time".


    Example:
    - Click Storm Bolt icon, click on a target. (Issued order)
    - Hero faces the target and getting ready to throw after 2 seconds of casting time. (Casting starts)
    - 2 seconds passed, Storm Bolt thrown, cooldown starts. (Effect of ability starts)
    - OR alternatively, Starfall starts. (Channeling starts)
     
  3. RakEnRoL

    RakEnRoL

    Joined:
    Sep 2, 2011
    Messages:
    316
    Resources:
    0
    Resources:
    0
    Wow. Great Idea :D I was like thinking of this system but unfortunately, I don't know how to code or make these kind of stuff. You made my dreams come true :3
     
  4. Palooo3

    Palooo3

    Joined:
    Nov 24, 2010
    Messages:
    544
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Nice what i see from triggers, will check at home and probablly using
     
  5. RakEnRoL

    RakEnRoL

    Joined:
    Sep 2, 2011
    Messages:
    316
    Resources:
    0
    Resources:
    0
    I think it bugs. When I cast a spell, specifically Phoenix. I tried to hold the hotkey, it casts however the floating text is not visible.
     
  6. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Player Group(picked player) leaks.
    There is IsLocationVisibleToPlayer function, but I don't think it is in GUI. You could use that to decide whether to show the text or not.
    Maybe create two strings at init, different colours for empty and full. Replace the loops that create the bars with using substring.
    I'd use hashtable to load the EndCastTime.

    Init values like this:
    • Custom script: call SaveInteger(udg_hash, 'AHfs', 0, 2)

    AHfs is the raw code of Flame Strike, 2 is the duration. Use 0 as the child key for every ability.

    Load values like this:
    • Untitled Trigger 009
      • Events
        • Unit - A unit Begins channeling an ability
      • Conditions
      • Actions
        • Custom script: if HaveSavedInteger(udg_hash, GetSpellAbilityId(), 0) then
        • Set TempUnit = (Triggering unit)
        • Set TempInteger1 = (Custom value of TempUnit)
        • Custom script: Set udg_EndCastTime[udg_TempInteger1] = LoadInteger(udg_hash, GetSpellAbilityId(), 0)
        • -------- *rest of the actions* --------
        • Custom script: endif


    This way you can get rid og the potentially very long if/then/else.

    -Bribe's unit indexer is perfect for this
    -The group shouldn't be destroyed
    -Begins Channeling is the correct event

    This system shoudn't be used for abilities that have no real channeling time, like Storm Bolt.
     
    Last edited: Sep 30, 2011
  7. RakEnRoL

    RakEnRoL

    Joined:
    Sep 2, 2011
    Messages:
    316
    Resources:
    0
    Resources:
    0
    And for the effects. I think it's rather ugly seeing a large bar while playing. Imagine 12 players with their own units spamming spells with it. That is uhm. Hell'a ugly.
     
  8. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,016
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Well the size of the text tag should be configurable, and I kind of agree
    it is a bit large but I think that's fine for a demo map so it can be shown
    in more detail.

    Things like the colors of the text tag, as well, should be configurable.
     
  9. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,260
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    Thanks for the comments guys, I'll work on this when I have the time. But I have some quick questions.

    IsLocationVisibleToPlayer, could someone post a demo or something of this? I know what the Boolean is I just don't know how to do it.

    And as for saving abilities into hashtables, I had no idea you could do that =D
    Totally great to know, and I'll definitely get rid of all those if/then/else
     
  10. Vlad727

    Vlad727

    Joined:
    Oct 8, 2010
    Messages:
    132
    Resources:
    0
    Resources:
    0
    I really like this for the following reasons:
    1. I always wanted to add something like this to my maps.
    2. Useful in boss-fights, because the players can now see if a boss is starting to cast a spell and see how much time there is left to get the heck out of there.
    3. there was a VJASS version, but I don't use VJASS.
    4. It is also useful for players, and it looks good (if made smaller)
    5. It is just AWESOME!!!

    You will get +REP From me for sure,
    and thanks for creating this.

    So instant spells won't get a casting bar?
    (which I understand since there instant)
    But what if the ability does not have to be channelled to remain in play?
    (when the caster is interupted the spell stops, like death and decay.
    More like "fire bolt" were you aim, cast and fire!)

    So is using "begins casting an ability" also right?
    or am I wrong?

    Just curious...
     
  11. Palooo3

    Palooo3

    Joined:
    Nov 24, 2010
    Messages:
    544
    Resources:
    2
    Maps:
    2
    Resources:
    2
    WOW I really like it!:)
    Also supports interrupting cast with stun!
    Anyone can tell me if there are leaks wich cause lagg? If not I am importing it:)
    And if i have 50 spells do I have to make them all in one trigger (like you have banish, fire strike etc), or i can make them in separated triggers?
     
  12. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,260
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    I'm going to update it in a sec guys =p
     
  13. Palooo3

    Palooo3

    Joined:
    Nov 24, 2010
    Messages:
    544
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Great waiting for it, maybe we are going to see more maps with nice systems as this one is :)
     
  14. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,260
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    Upgrade complete =p
     
  15. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,016
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Looking really good so far.

    I recommend letting there be a GUI variable in the configuration, which is set before each custom script hashtable save, that way you can select the variable ID from GUI if you don't want/don't know how to look up the rawcode every time.

    • Set TempAbil = Blizzard //TempAbil is of type "ability"
    • Custom script: call SaveReal(udg_BarHash, udg_TempAbil, 0, 3.0)


    Also, I recommend taking advantage of the first key to represent each individual level in case there are different channeling times. Like this:

    • Set TempAbil = Blizzard
    • Custom script: call SaveReal(udg_BarHash, udg_TempAbil, 1, 3.0)
    • Custom script: call SaveReal(udg_BarHash, udg_TempAbil, 2, 4.0)
    • Custom script: call SaveReal(udg_BarHash, udg_TempAbil, 3, 5.0)
     
  16. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,260
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    Great idea, I plan on adding it as soon as I get the time =p
     
  17. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    This looks pretty good :)
     
  18. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,260
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    v0.0.2 is out guys!
     
    Last edited: Oct 1, 2011
  19. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,260
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    v0.0.3 is out! It is now only visible to players who can see the casting unit, also added offset.

    This will probably be the final version.