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

Easiest Way to MUI?

Status
Not open for further replies.

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
I think it is using Unit Indexer or local variables (I'm not guarantee the 2nd one because I have only heard about it but never tested it before).
U can also using Hashtable of course. But sometimes, the information in the Hashtable is overwritten so I suggest u should use the Unit Indexer for making MUI spell.
 
Well, doing instant spells is the easiest way to make an MUI spell...

Hashtables are really good though you can only have 256 hashtables in a map, and they are slower than arrays... But you can have only one hashtable for all your spells, by using an integer specific for each spell for the parent key, and maybe handleId of the target unit for child key (or any other child key you wanna use)

If you already have unit indexer on your map, then using unit indexer + arrays will be better for you I guess... Arrays are easier to write than hashes too...

The first thing to do will always be to know why your spell won't be MUI...
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Hashtables are really good though you can only have 256 hashtables in a map
Awww why do you have to exploit only the weakness of Hashtable ? :(
Indexing has a max of 8192 instances :(

Wanna know which to choose ? (Either Hashtable or Indexing)
Click here:
http://www.hiveworkshop.com/forums/triggers-scripts-269/arrays-hashtables-223616/#post2225726
http://www.hiveworkshop.com/forums/triggers-scripts-269/arrays-hashtables-223616/#post2225735

Long Story Short: It really depends on the situation you want, Hashtable will give you overwriting power while Indexing gives you stacking power, your choice.

Well, how do you differ Hashtable from Unit Indexer ?

Unit Indexer
More efficient than Hashtable in terms of speed but cannot save values to non-existent object in the map

Hashtable
Less efficient than Unit Indexer in terms of speed but able to save values to non-existent object in the map

What is non-existent objects ?
Unit-type, Item-type, etc.

Let's say you want to save value of 500 to a Paladin.
You cannot use Unit Indexer since it has nothing to refer to.
But you can use Hashtable to refer to its Unit-type (Paladin), later when a Paladin is created in the map, simply load it from the Unit-type of the Unit and get the value (500).

Once again, it really depends on your situation, all has advantages and disadvantages.
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
Local variables, hashtables, unit indexer - they all have their uses. Using local variables is the easiest way to make a spell MUI, though they're incompatible with timers. That's when a unit indexer comes in handy.

Hashtables are much more slower than using local variables or unit indexers, in most of the cases you can avoid them as well, though sometimes it's necessary to use them - I still managed to write 98% of my map's spells without them, and everything is perfectly MUI.
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
Yeah I don't use Hashtables too often.

Locals are alright.

So by Unit Indexer you mean a trigg that queries every unit in the map, and associates them with a number from an array, in a variable, ex. X[CustomValueofEnumUnit]

Etc.

If so, how does an already existing indexer help me?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
It assigns each a special index to each unit, which means each unit can hold each data, separately, simultaneously, that will make it MUI by default.

Say Unit A holds data of Integer value 300, Unit B holds data of Integer value of 500.
When loaded from each unit (Custom Value = Unit), it will give each respective Integer value loaded from the unit.
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
It assigns each a special index to each unit, which means each unit can hold each data, separately, simultaneously, that will make it MUI by default.

Say Unit A holds data of Integer value 300, Unit B holds data of Integer value of 500.
When loaded from each unit (Custom Value = Unit), it will give each respective Integer value loaded from the unit.

Yes, I know that. That's not the question. The question is how do I query the unit in a different trigger ex.

Unit A kills Unit B, unit A gains an ability.

30 seconds later, the ability has to be removed from Unit A because it's designed to be temporary.

That's the question of MUI here.
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Well, u can do it like this:
  • Unit Gains Ability
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to <the type of the unit u want to be killed to get the ability>
    • Actions
      • Set CV = (Custom value of (Killing unit))
      • Set Duration[CV] = 30.00
      • Set Ability[CV] = <Your ability>
      • Unit - Add Ability[CV] to (Killing unit)
      • Unit Group - Add (Killing unit) to CasterGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit Lose Ability <gen> is on) Equal to True
        • Then - Actions
        • Else - Actions
          • Trigger - Turn on Unit Lose Ability <gen>
  • Unit Lose Ability
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (CasterGroup is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in CasterGroup and do (Actions)
            • Loop - Actions
              • Set CV = (Custom value of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Duration[CV] Greater than 0.00
                • Then - Actions
                  • Set Duration[CV] = (Duration[CV] - 0.50)
                • Else - Actions
                  • Unit - Remove Ability[CV] from (Picked unit)
                  • Unit Group - Remove (Picked unit) from CasterGroup
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Well, there is a problem with it: If ur unit dies, the duration will still be calculated.
But I think u fix it with just a basic If/Then/Else.
 
Status
Not open for further replies.
Top