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

[General] Restart the counter of an index ability

Status
Not open for further replies.
Level 2
Joined
Jun 8, 2015
Messages
5
Hi, I’m a bit new to the MUI(Index), and I’d like to know how to restart the counter when launching the skill on the same unit more than 1 time.

The problem is that my spell adds another spell to the chosen drive and when the counter reaches its limit it is removed (normal). But releasing it on the same drive does not restart the counter, so the added ability does not restart its time before being deleted.

I leave the map with skill, I hope you can help me.
 

Attachments

  • Empower Index.w3x
    17.9 KB · Views: 16

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Have you ever used a Unit Indexer? Here's an example of your ability using one.

It's very similar to what you were doing already but I personally find it easier to work with.
 

Attachments

  • Empower Index Uncle.w3x
    23.5 KB · Views: 19

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
The big difference is that Unit Indexer uses unit's custom value for spells, meaning that if you have a spell over time or something that isn't instant, it will reset its characteristics and start over.
Dynamic Indexing, which it's what you're using, enables you to have multiple instances of the same skill on the same unit.
Although Uncle is right, Unit Indexer is trully more appropriate for this spell.
 
Level 2
Joined
Jun 8, 2015
Messages
5
Have you ever used a Unit Indexer? Here's an example of your ability using one.

It's very similar to what you were doing already but I personally find it easier to work with.

If I used the system (By the way, I don’t open your map maybe my version of the Editor is old), but the problem is that I use spells that involve the custom value of drives and for some strange reason, I don’t know if it will have been discussed in another post, but it causes error with the unit with custom value. I don’t know if there is another way to do this spell with MUI/Index and not with the JASS system because I’m not very expert on this system, anyway thanks for answering. :D
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
You should avoid using custom value manually for spells. If you have multiple such spells in your map already they will all conflict with each other any way. First, keep the indexer in your map. Then, to convert any existing spells that use it you will need to create an integer array variable for each spell. Then, everywhere you use CV in that spell (both setting and getting) you need to instead use SpellInteger[CV].
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Yeah, I'm using the latest version.

Anyway, it's your call, but I highly recommend doing what Pyro said. Compare these two triggers, one using your method and another using a Unit Indexer:
  • Without Unit Indexer
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Set Variable TempUnit = (Triggering unit)
      • Set Variable CV = (Custom value of TempUnit)
      • -------- - --------
      • -------- We're stuck with having to use the unit's custom value for only one thing at a time --------
      • -------- In this example I'm using it to track the unit's level --------
      • Unit - Set the custom value of TempUnit to (CV + 1)
  • With Unit Indexer
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Set Variable TempUnit = (Triggering unit)
      • Set Variable CV = (Custom value of TempUnit)
      • -------- - --------
      • -------- With a Unit Indexer we can store as much information as we want to our unit --------
      • -------- I added an extra Integer (SkillPoints) to show that you can store multiple variables to a unit --------
      • Set Variable Level[CV] = (Level[CV] + 1)
      • Set Variable SkillPoints[CV] = (SkillPoints[CV] + 1)
With the Unit Indexer we can store just about as many Integers (or any type of variable) to our Unit as we want. So now you basically have infinite Custom Values to work with per unit.

The big difference is that Unit Indexer uses unit's custom value for spells, meaning that if you have a spell over time or something that isn't instant, it will reset its characteristics and start over.
Dynamic Indexing, which it's what you're using, enables you to have multiple instances of the same skill on the same unit.
Although Uncle is right, Unit Indexer is trully more appropriate for this spell.
True, so I guess use both, no reason not to.
 
Last edited:
Level 2
Joined
Jun 8, 2015
Messages
5
You should avoid using custom value manually for spells. If you have multiple such spells in your map already they will all conflict with each other any way. First, keep the indexer in your map. Then, to convert any existing spells that use it you will need to create an integer array variable for each spell. Then, everywhere you use CV in that spell (both setting and getting) you need to instead use SpellInteger[CV].
Yeah, I'm using the latest version.

Anyway, it's your call, but I highly recommend doing what Pyro said. Compare these two triggers, one using your method and another using a Unit Indexer:
  • Without Unit Indexer
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Set Variable TempUnit = (Triggering unit)
      • Set Variable CV = (Custom value of TempUnit)
      • -------- - --------
      • -------- We're stuck with having to use the unit's custom value for only one thing at a time --------
      • -------- In this example I'm using it to track the unit's level --------
      • Unit - Set the custom value of TempUnit to (CV + 1)
  • With Unit Indexer
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Set Variable TempUnit = (Triggering unit)
      • Set Variable CV = (Custom value of TempUnit)
      • -------- - --------
      • -------- With a Unit Indexer we can store as much information as we want to our unit --------
      • -------- I added an extra Integer (SkillPoints) to show that you can store multiple variables to a unit --------
      • Set Variable Level[CV] = (Level[CV] + 1)
      • Set Variable SkillPoints[CV] = (SkillPoints[CV] + 1)
With the Unit Indexer we can store just about as many Integers (or any type of variable) to our Unit as we want. So now you basically have infinite Custom Values to work with per unit.


True, so I guess use both, no reason not to.

Thank you very much for the system with custom value. Thank you for your help :D
 
Status
Not open for further replies.
Top