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

Need some help with spell charges

Status
Not open for further replies.
Level 4
Joined
May 12, 2022
Messages
22
Hi, I have made a trigger for a reveal that has 3 charges. After I have used the spell for the first time, the cooldown is supposed to start and load the charge back.

For each charge used, the icon of the spell is supposed to change to an icon that has 1 less charge (as shown in the picture bellow).

1663188543347.png

Now .. the trigger seemed to be working after some tests..

But after I implemented the trigger in a map and played with some people, I then came across a problem.
It looks like after any of the players uses a charge at any given time, the trigger then interferes with every other player that has the same spell. It either resets the cooldown for all other players or it doesn't let you cast it after you use the first charge. I don't know if it's simply because other players also have the same spell or if it's because they use it before the charge finishes charging and it somehow messes it up.

From my understanding, you can fix this by using hashtables but I'm not very knowledgeable with these kind of triggers..

I'll attach a simple map with the trigger so you can see what i'm talking about.
If someone could take a look at the triggers I used for this spell and help me out if possible, that would be awesome.

Thanks in advance!
 

Attachments

  • Charges_Spell.w3x
    90.5 KB · Views: 10

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,576
It's not MUI because you're sharing the same variables/timer with everyone. That's the very nature of Global variables, as opposed to Local variables which would be unique to each trigger instance. Unfortunately, local variables aren't really the solution here either nor are they readily available in GUI (the standard trigger editor).

Luckily, there are other ways of going about this (and yes, a Hashtable could be one solution). I updated your map using a method which takes advantage of a Unit Indexer, a very powerful and easy to use system for storing Data to units. This in combination with a Periodic trigger and a Unit Group allows us to track each hero's Sight Charges and manages their Abilities.

Also, I noticed that the True Sight ability had strange behavior like causing the Hero to ignore Move orders. I went ahead and fixed this by creating separate versions of the ability. So the Hero casts a "fake" ability which then tells a Dummy unit to cast the real True Sight ability.

Warning! The Unit Indexer has 2 important rules:
1) You cannot have multiple Unit Indexers in the same map. One is all you'll ever need.
2) You cannot Set Custom Value yourself - The system relies on setting Custom Value in order to work. The fix to this is simple, replace those Custom Value actions with an Integer Array. A tutorial can be found here. The whole point of a Unit Indexer is to mimic the behavior as well as remove the limitation of Custom Value.
 

Attachments

  • Charges_Spell.w3x
    98 KB · Views: 8
Last edited:
Status
Not open for further replies.
Top