• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Casting Time System/Snippet

Level 3
Joined
Apr 10, 2007
Messages
23
I made a Snippet for Casting Time:

It creates the Time a Spell is casting At the heroes location.
it is leakless and MPI.

enjoy!

Code:
  • Let Unit Cast
    • Events
      • Unit - A unit Begins casting an ability
      • Unit - A unit Begins channeling an ability
    • Conditions
    • Actions
      • Set Casting[(Player number of (Owner of (Casting unit)))] = 0.00
      • Set Casting_Unit_Loc[(Player number of (Owner of (Casting unit)))] = (Position of (Casting unit))
      • Set Casting_Time[(Player number of (Owner of (Casting unit)))] = True
  • Casting Time
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Casting_Time[(Integer A)] Equal to True
            • Then - Actions
              • Set Casting[(Integer A)] = (Casting[(Integer A)] + 0.01)
              • Floating Text - Destroy Casting_Floating_Text[(Integer A)]
              • Floating Text - Create floating text that reads (Casting Time: + (String(Casting[(Integer A)]))) at Casting_Unit_Loc[(Integer A)] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Set Casting_Floating_Text[(Integer A)] = (Last created floating text)
            • Else - Actions
  • Stop Unit Cast
    • Events
      • Unit - A unit Stops casting an ability
      • Unit - A unit Finishes casting an ability
    • Conditions
    • Actions
      • Set Casting_Time[(Player number of (Owner of (Casting unit)))] = False
      • Floating Text - Destroy Casting_Floating_Text[(Player number of (Owner of (Casting unit)))]
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Casting unit)) Equal to (Player((Integer A)))
            • Then - Actions
              • Custom script: call RemoveLocation (udg_Casting_Unit_Loc[GetForLoopIndexA()])
            • Else - Actions
 

Attachments

Last edited by a moderator:
There are more efficient ways of doing this...

I'm not picking here, but there are better ways to achieve the same effect:

If you use JASS and the handle var attachment system (many different ones are out there), then you could avoid destroying the text-tag per cycle and just edit the text, then destroy it at the end.

Use a timer instead of a trigger they are faster, and they can't skip.
EG: 0.01 second trigger, with 0.04 seconds passing in between frames (in the case of lag), the trigger will only trigger once per frame, so it will skip. A timer can trigger many times per frame.
Try to avoid using 0.01 second loops, 0.03 - 0.05 is usually fast enough, and doesn't lag as much (try having 5 - 10 triggers running at 0.01 seconds and watch the game lag).

Also, using locations is a much slower way to do things... JASS allows you to use co-ordinates(x,y) instead of locations. Co-ordinates are cheaper on memory and are very easy to use once you get the hang of them.

JASS isn't very difficult to learn, it's pretty straight forward. If you want help in this area, I'd be willing to assist.

I know I may have ranted here abit, but I hope I've helped.
 
Back
Top