• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Casting-Channeling Bar v1.6.0

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



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
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...
Level 10
Joined
Jul 5, 2012
Messages
230
It doesnt work for me. When I (for example) set casting time for phoenix up to 5 and try to cast the spell, the bar shows up for a short moment before it dissapears again without counting the time.

What to do?

Edit: After new setup it works fine for me. Great work.
Thanks for sharing this!

Edit2: What values do I have to change to set the displayed bar above the head of the hero?
 
Last edited:
Level 10
Joined
Nov 24, 2010
Messages
546
I know that this is quite old but I found something to improve,
Maybe it is only for me but when unit begins casting an ability, it gets "paused" without playing casting animation, when bar gets full, unit starts playing animation, so it is really weird when I have ability which's casting time is 3 seconds and unit just stay paused, is there a way to fix it? or I have to use dummies?
 

sentrywiz

S

sentrywiz

Hi and well made casting bar (just copied into my map)

When copied the triggers, BeginCast had multiple errors. Read along the comments and Maker said that you should make a new variable TempInteger2. This should be in the description, because just straight copy-paste turns off BeginCast with multiple errors.

Secondly, because I am using first person camera, the casting bar is not located above the unit casting, but on the ground. Any idea how to fix this, it really looks junky to have the bar on the ground.
 

sentrywiz

S

sentrywiz

Will this work for training units instead of casting spells?
Like when training units from any building, to display
training unit progress above the building?
 
Top