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

Removing ability after a wait function seems unstable.

Status
Not open for further replies.
Level 5
Joined
Jan 6, 2010
Messages
115
Why does this behave strangely? Is it because of the wait-function?
(Divine Prayer is just an healing aura-like ability).

  • Divine Shield
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Divine Shield
    • Actions
      • Unit - Add Divine Prayer to (Casting unit)
      • Wait (5.00 + (5.00 x (Real(LVLofAbility)))) seconds
      • Unit - Remove Divine Prayer from (Casting unit)
In this case, it seems that sometimes the "Divine Prayer" effect doesnt vanish. I guess it's the wait that doesn't work, but I couldn't find another way.
Is there a more clever way of detecting when the effect of "divine shield" vanishes? I could of course make a periodic check every second through the game to see of the effect is running, but it seems a bit heavy?
 
Level 7
Joined
May 3, 2007
Messages
210
Change the event to "A unit starts the effect of an ability" and see if it persists.

Another alternative problem could be the invulnerability acquired through divine shield, but realistically, that's highly not to not it.

If it does persist after you change the event, then it is indeed the wait.

You could probably then fix it with a timer if you really want that time inbetween. If you know any JASS, you can use the native declaration of vJASS to add the .ai StartThread, then open a new thread with specifically the adding, waiting, and then removal, of the ability. (I've never experimented with the .ai StartThread, but that should work).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You should really use a timer to cover any periodic events, but you may need to learn hashtables (they're in GUI) which allows multi-instanceability (MUI). This would also solve the accuracy problem that "Wait" has, it can be unacceptably inaccurate with the duration it "waits" for.

If you're not worrying about MUI then you could make a global unit variable called "DivinePrayerCaster" and set the variable before the wait. Then, instead of using (Casting unit) you could replace it with the global unit variable. You could still use a timer to be more accurate and still use the concept of the global unit variable.
 
Status
Not open for further replies.
Top