• 🏆 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!

[Solved] progress bar/cast bar

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
hey,

I am trying to make a progress bar for the target of a channeling spell. I know this subject has been raised tons of times before, and there are loads of great models and spellpacks for this exact purpose... but I wasn't able to get any of them working (I suffer from noobism and acute jassaphobia), and as this spell only needs to use it in a really simple way I doubt it'll require more than a few lines of basic GUI to sort it out....

I'm using @HappyTauren 's Genericbar model which has a 100 different animations for the progress of the bar. he explains how to use it there using jass and other terms I don't yet get how to imply. my main question is this - how do I get the bar to scroll through its animations over the course of a a set time?

thanks!!!
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,455
So basically you use a Dummy unit to represent the channel bar. Then do something like this when you begin channeling the spell:
  • Events:
  • Every 0.05 seconds
  • Actions:
  • Set ChannelTime = ChannelTime + 1
  • call SetUnitAnimationByIndex(udg_ChannelBar, udg_ChannelTime)
You can use the Unit Indexer to make these variables MUI and link the ChannelBar to the Channeling Hero. You'd also use a Periodic Interval to increase ChannelTime/SetAnimation every X seconds.

To determine how much you should increase ChannelTime by and how often is pretty simple math.

Example: If the spell channels for 5.00 seconds total, you'd want to increase ChannelTime by 1 every 0.05 seconds. This way it runs through all 100 animations smoothly over the course of 5.00 seconds.
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
so I must have done (at least) something here wrong Bc the loop trigger keeps getting canceled when I try to test the game. first I had set channelTime as a Real and it showed me this message - Invalid argument type (real). So I changed it to a integer and now I get: Expected 'call'.

this is the loop trigger which kept spazzing out:
  • progbar loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set NM_ChannelTime = (NM_ChannelTime + 1.00)
      • Custom script: SetUnitAnimationByIndex(udg_NM_Progbar[1], udg_NM_ChannelTime)
and this is what I added to my spell to try to link this to it (I'm not sure I linked it right since I couldn't directly refer to the triggering unit in the periodic loop[btw - same bulding steal spell you helped me with earlier]):
  • steal buildings
    • actions
      • Unit - Create 1 Progress Bar for (Triggering player) at (Position of NM_Target[ID]) facing Default building facing degrees
      • Set NM_Progbar[ID] = (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (NM_Group is empty) Equal to True
        • Then - Actions
          • Trigger - Turn on progbar loop <gen>
        • Else - Actions
      • Unit Group - Add NM_Progbar[ID] to NM_Group
this is what i added to the part that ends the loop:
  • stop steal building
    • ...
    • Actions
      • Unit - Remove NM_Progbar[ID] from the game
      • Trigger - Turn off progbar loop <gen>

  • steal buildings
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • ((Ability being cast) Equal to New Management ) or ((Ability being cast) Equal to New Management(townhall) )
    • Actions
      • Set ID = (Custom value of (Triggering unit))
      • Set NM_Target[ID] = (Target unit of ability being cast)
      • Game - Display to (All players) for 5.00 seconds the text: start casting
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Orc\AncestralSpirit\AncestralSpiritCaster.mdl
      • Set NM_SFX[ID] = (Last created special effect)
      • Unit - Create 1 Progress Bar for (Triggering player) at (Position of NM_Target[ID]) facing Default building facing degrees
      • Set NM_Progbar[ID] = (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (NM_Group is empty) Equal to True
        • Then - Actions
          • Trigger - Turn on progbar loop <gen>
        • Else - Actions
      • Unit Group - Add NM_Progbar[ID] to NM_Group
  • finish steal buiding
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • ((Ability being cast) Equal to New Management ) or ((Ability being cast) Equal to New Management(townhall) )
    • Actions
      • Set ID = (Custom value of (Triggering unit))
      • Unit - Change ownership of NM_Target[ID] to (Triggering player) and Change color
      • Game - Display to (All players) for 5.00 seconds the text: finish casting
      • Special Effect - Destroy NM_SFX[ID]
  • stop steal building
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • ((Ability being cast) Equal to New Management ) or ((Ability being cast) Equal to New Management(townhall) )
    • Actions
      • Set ID = (Custom value of (Triggering unit))
      • Game - Display to (All players) for 5.00 seconds the text: stop casting
      • Special Effect - Destroy NM_SFX[ID]
      • Unit - Remove NM_Progbar[ID] from the game
      • Trigger - Turn off progbar loop <gen>
  • switch spell
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Level of New Management for (Triggering unit)) Greater than 0
      • (Issued order) Equal to (Order(devour))
      • ((Target unit of issued order) is A town-hall-type unit) Equal to True
    • Actions
      • Unit - Order (Triggering unit) to Neutral Dark Ranger - Charm (Target unit of issued order)
+ progbar loop above


thanks!!
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,455
ChannelTime has to be an Integer. SetUnitAnimationByIndex uses Integers.

Animation Index 1 = The progress bar at 1% full
Animation Index 2 = The progress bar at 2% full
etc...

You're setting the Bar's animation to one of these Indexed Animations.

You also forgot to write "call" in the custom script. See how my example says "call SetUnitAnimationByIndex(udg_ChannelBar, udg_ChannelTime)".

And you should add the caster to the Unit Group not the Progress Bar. Then in your loop, pick every unit in this Unit Group, set ID = picked unit's custom value, and set ChannelTime[ID] = ChannelTime[ID] + 1.

  • Bar Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Bar_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet ID = (Custom value of (Picked unit))
          • Set VariableSet ChannelTime[ID] = (ChannelTime[ID] + 1)
          • Custom script: call SetUnitAnimationByIndex(udg_Bar[udg_ID], udg_ChannelTime[udg_ID])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ChannelTime[ID] Equal to 100
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Bar_Group.
            • Else - Actions
      • -------- --------
      • -------- Turn off this timer if all of the Progress Bars are finished --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Bar_Group) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
You also forgot to write "call" in the custom script
oh the shame... :peasant-blushing:

so I tried this, and it's still erroring: expected a name

what did I do wrong?
  • progbar loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in NM_BarGroup and do (Actions)
        • Loop - Actions
          • Set ID = (Custom value of (Picked unit))
          • Set NM_ChannelTime[ID] = (NM_ChannelTime[ID] + 1)
          • Custom script: call SetUnitAnimationByIndex(udg_ProgBar[udg_ID], udg_NM_ChannelTime[udg_ID])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • NM_ChannelTime[ID] Equal to 100
            • Then - Actions
              • Unit Group - Remove (Picked unit) from NM_BarGroup
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (NM_BarGroup is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,455
It should show some more information in the error screen like which line of code is causing the problem.

Anyway, you probably misspelled something or haven't created one of those variables. It's case sensitive in the Custom Script.
 
Status
Not open for further replies.
Top