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

About MUI , game cache , handle vars

Status
Not open for further replies.
Level 3
Joined
Oct 8, 2007
Messages
41
I heard of MUI, game cache, and handle vars but i dont really know what they are.

I know MUI is Multi User Instancible and i think it means the spell/trigger can be used at the same time by many people. Am i correct about the meaning?

I heard game cache is one of the only ways to make spells MUI, but what is game cache? how do i used game cache? why not use global variables?

And i also heard of handle vars , what are they?
 
Level 14
Joined
Nov 25, 2004
Messages
1,185
if you have any ideas about programming, the concepts should be simple for you :/

to make a spell mui you need to make sure that no 2 instances of trigger can share the same variable. You have to make unique variables per hero casting spells.

gamecache is a simple hashtable (something like std::map in c++ and dictionaries in Python). it allows you to store variables of any type (H2I function converts pointers to integer format easy to store in gamecache) and reference the value using an unique key.

Handle vars are closely connected to gamecache, they are just a system to make unique variables per-timer or per-unit. They just convert the handle to integer, and set it into gamecache with key for example "Footman_01_variable1", if you do it to another unit it would set it with a key "Footman_02_variable1", this way you can have unique variables for every unit and they never overlap. (the naming is a bit different, that was just an example).
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
CSCache does that but pros suggest using structs in Jass NewGen Pack
anyway I dont know how to
cya later xD

you can use variables with handles
what is handle ?
its something that carries variables
this may be a unit or timer or anything AS I know
like "custom value" but we have more and different types of values
anyway you got what I mean
 
Level 14
Joined
Nov 25, 2004
Messages
1,185
you can read about handles here:

http://jass.sourceforge.net/doc/types.shtml

they are just types of pointers to game entities and players

there are few systems, like KaTTaNa's Local Handle Vars, Vexorian's CSCache, structs and few other systems. it doesn't really matter which one you choose, just pick one and stick to it.

also on wc3campaigns there are GUI triggers made by MindWorX which allow you to use handle vars in GUI
 
Level 3
Joined
Oct 8, 2007
Messages
41
So game cache is a way to make a spell MUI? How does that work? How do i do that? Why not use global variables instead?

I heard of structs, can it make spells MUI? So far i have been searching but i found no tutorials, if there are any can you please post a link?
 
Level 14
Joined
Nov 25, 2004
Messages
1,185
ok an example of global variables versus local ones

you have a spell that deals damage per second as long as the buff is placed on target unit.

global variables:
Unit 1 casts the spell, global variable target is set to target of the ability being cast

every second, damage is dealt to "target" global variable

suddenly, unit 2 casts the same spell on another target. Global variable target is set to the target of unit 2.

every second, unit1 deals damage to the new target forgetting about it's target, because it's overlapped by new one, and unit2 deals damage to the new target.

as you see the spell is bugged now, buff is on the first target, but damage is dealt to another unit instead

local variables:

Unit 1 casts the spell, local variable target is set to target of the ability being cast

every second, damage is dealt to "target" global variable

suddenly, unit 2 casts the same spell on another target. Local variable is created only for that unit and that new variable is set to the target of unit 2.

every second, unit1 deals damage to the target in its own local variable and unit2 deals damage its own target.

as you see the spell works now, because every unit has its own targets and they never overlap
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
Unit 1 casts the spell, local variable target is set to target of the ability being cast

every second, damage is dealt to "target" global variable

suddenly, unit 2 casts the same spell on another target. Local variable is created only for that unit and that new variable is set to the target of unit 2.

every second, unit1 deals damage to the target in its own local variable and unit2 deals damage its own target.

as you see the spell works now, because every unit has its own targets and they never overlap
Well, the variable isn't really "set" its created as the value(usually).
Also, be sure to null locals that require it.
 
Level 11
Joined
Aug 25, 2006
Messages
971
Two lines of code is less efficient then one. Though the difference is almost immeasurably small even in large numbers of instances.

The gamecache is another way of storing information. Its incredibly slow. A handle is a number which stands for a value. When you set a variable to a specific lightning, your actually setting that variable to a handle which can be used to find the lightning. This handle is just an integer. The game disguises it as a completely different type of variable. Using a glitch in the game we can get this integer. Finally we can use this integer to glue values to other values.

Now your probably saying wtf?
Will look at the gamecache. It needs 2 strings and a value. Then you give it the same two strings and you get the value back. The first string is the handle of whatever you want to 'attach' to. The second string is a string you decide . Sort of like a variable name. The value is what you want to attach. To get something you attached, you give it the handle of the object its attached to, and the unique string you decided. Poof. You get back your value. This is used so that unrelated triggers can communicate data through a single object. (Like the spellcasting unit)
This would be used if say you wanted two triggers. A trigger when the spell starts, and another when it stops. You could pass important data (like effects & such) through values attached to the spellcaster.
 
Level 3
Joined
Oct 8, 2007
Messages
41
Two lines of code is less efficient then one. Though the difference is almost immeasurably small even in large numbers of instances.

The gamecache is another way of storing information. Its incredibly slow. A handle is a number which stands for a value. When you set a variable to a specific lightning, your actually setting that variable to a handle which can be used to find the lightning. This handle is just an integer. The game disguises it as a completely different type of variable. Using a glitch in the game we can get this integer. Finally we can use this integer to glue values to other values.

Now your probably saying wtf?
Will look at the gamecache. It needs 2 strings and a value. Then you give it the same two strings and you get the value back. The first string is the handle of whatever you want to 'attach' to. The second string is a string you decide . Sort of like a variable name. The value is what you want to attach. To get something you attached, you give it the handle of the object its attached to, and the unique string you decided. Poof. You get back your value. This is used so that unrelated triggers can communicate data through a single object. (Like the spellcasting unit)
This would be used if say you wanted two triggers. A trigger when the spell starts, and another when it stops. You could pass important data (like effects & such) through values attached to the spellcaster.

What do you mean by gamecache is incredibly slow? Are other ways faster?

What does it mean by 'attach' why does it have to 'attach' what does 'attaching' do?
 
Level 11
Joined
Aug 25, 2006
Messages
971
Gamecache is a necessary evil, and also a wonderful friend. It is slow, but without it there would be no method of attaching things to other things.
I mean what I say. I can take a unit and 'Attach' another unit to it. Then another completely independent trigger can take that unit and get the unit 'attached' to it. By attach I mean you relate one variable to another.
Like if I had two triggers. The first happened on the beginning of a cast. The second happens at the end. They both need to happen, share data, and by MUI. But how do i do that? Locals can't go across triggers. The trick is you attach all the data the second one needs in the first one, to the spell caster. Then when the second one starts it gets all the attached data and uses it for w/e.
The gamecache is slow so people have invented methods of using it only once to attach dozens of variables at the same time. This method is called structs For further information about structs please goto: http://www.wc3campaigns.net/showthread.php?t=91491
 
Status
Not open for further replies.
Top