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

[Trigger] Help with independent magics for multiplayer

Status
Not open for further replies.
Level 1
Joined
Dec 12, 2017
Messages
4
Hello, I have been dragging a very frequent problem when passing a map to multiplayer, the problem comes in the overwriting of the variables ... My solution was to use arrays with the ID of each unit, for example a dummy or the caster unit or the objectives, etc. like in the image
Screenshot
Now I do not know how to call that ID and use the functions based on the events, in this new trigger I do not have that event so it is difficult for me to call that ID ... please help
Screenshot
 
Level 13
Joined
May 10, 2009
Messages
868
Well, you are trying to use multiple Unit Groups; one for each dummy. In fact, you need only one group in order to reference all existing dummy units. Also, the function "Key(object)" or
GetHandleId(object) might return a value that isn't supported by arrays. For example, the very first unit in game might get the number 1048672(+) as its id while arrays can only use numbers from 0 to 8191. Athur12A2 suggested what can be done to overcome the id problem, or you can also use a Hash Table, which supports large numbers such as the ones retrieved by the "Key(object)" function.
 
Level 1
Joined
Dec 12, 2017
Messages
4
Thank you very much, I was learning from the spell that others raised: D effectively use the hash tables and the ID of either the caster, dummy or target ... I made the mistake of using arrays that only support 9999 units, the IDs use more than 5 digits :eek: thanks for the help
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
I made the mistake of using arrays that only support 9999 units
Arrays only support 8192. Even less if one does not included the bugged, not saved, indices. One can chain arrays together in series, but one might as well use a hashtable in this case.

People of old (before hashtable) got around the problem by subtracting a large constant from the handle ID before mapping to an array index. Even still if there is even a single handle ID leak it can eventually break the system. Hence I would recommend using a hashtable.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The frequently suggested MPI (multi-player instantiability) or MUI (multi-unit instantiability) is but a stopgap. When you decide the spell should not be per unit anymore, you can redo all the indexing, at least the entry points. The spell should manage the indexing itself, as is conducted in object oriented paradigm. So casting the ability allocates a new instance, you store the data including the unit therein and dismantle when the spell is finished. This also requires you to correctly define/track the life cycle. If you need access from other objects such like the unit, you should construct this link explicitely, from unit to spell (index). This is a much cleaner approach but, of course, GUI is not suited for it, which does not even provide local variables.
 
Status
Not open for further replies.
Top