HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Multiinstanceability w/o locals in GUI?

08-13-2006, 05:35 AM#1
darkwulfv
Don't flame me or nothing for this, I just thought of something that I thought may work...
~EDIT: the title should probably be "partial multiinstanceablity w/o locals in GUI"
If I am correct, multiinstanceability is having a spell able to be casted by more than one unit at the same time, right? So if the spell is only used by one unit per player (like a hero) couldn't you technically use Global Variable Arrays? From what I do know, this would only work if the spell only has once caster per player. If, for example, a player had 2 heros with the same triggered spell, and managed to cast them at the same time, this wouldn't work. But if that player only had 1 hero, and another player had that same hero, and they casted that same spell at the same time, then this should work.
I know this isn't the best way, but for people who don't already know a way, or don't know JASS, this could come in handy. Just saying.
08-13-2006, 05:39 AM#2
DioD
Array based storage system uses global array only.
You need only return H2I and use it inside.
08-13-2006, 11:22 AM#3
The)TideHunter(
Not really, Dark's theory is right, if you use a global array of 12, and store all the neccersary vars in them, then thats fine, its 70% MUI.
08-14-2006, 02:19 AM#4
darkwulfv
Yeah, what I'm saying is that this method is simply for maps in which the spell is only used by one unit per player. This wouldn't work otherwise, since the global vars would override themselves, causing problems. So only use this if you don't know how (or don't want to) JASS, and only use it how I stated.
I'm surprised at how few people have posted...
08-14-2006, 03:55 AM#5
Naakaloh
You could actually take it slightly further than that and use the trick which allows you use GUI functions with local variables, and using very little JASS in the process. That would allow you not only to make some your spells even more multi-instanceable without really using the global arrays at all.

Have a global variable array, when you start your spell add a few lines like:
Trigger:
Custom Script: local real udg_Reals[0] = 0.
Custom Script: local real udg_Reals[1] = 1.
Then you can do stuff like:
Trigger:
Unit - Create 1 unit of type footman at location facing Reals[0]

Edit: This does not appear to work. The Custom Script apparently does not parse "[]" as anything valid so it does not seem to work. I think I may have been too tired to have realized what it would imply if it worked as I assumed it would. :/

It would be nice if it functioned in this manner, however, I'm clearly too inexperienced with this method of using local variables to have realized that it would not work. Instead you need to use individual variables and not arrays as there does not appear to be any way to utilize arrays in this fashion.
08-14-2006, 05:14 AM#6
DioD
No waits inside == 100% MUI with no any arrays
08-14-2006, 05:32 AM#7
PipeDream
Wow! That parses? Very cool, Naakaloh, I wouldn't have thought [] were valid characters for symbol names.
08-14-2006, 06:05 AM#8
Daelin
Quote:
Originally Posted by DioD
No waits inside == 100% MUI with no any arrays

Agreed... I don't encourage using variables in GUI when not really necessary. There are a lot of people who make one trigger spells, need only the caster and dummy units, and they store the caster in a variable (not even the dummies, because they only cast a spell and then disappear) and complain then about the spell not being MUI. When I first saw such a spell I was like

And darkwulfy, don't get me wrong but I've been using this for quite some time, in my first GUI spells, before I started learning JASS, and so I don't think this is new stuff. Naakaloh's stuff is newer to me, yet not brand new, since I saw it used before and I find it perfectly logical. In C++ if you had a global and a local with the same name, the local would be prioritary. Apparently JASS inherited this too. :)

And even though I totally disagree with GUI, a lot of people still use it so I don't think we should forget about it. I find it good initiative to start this thread, in order to help those people! +rep granted

~Daelin
08-14-2006, 06:19 AM#9
PipeDream
Quote:
Naakaloh's stuff is newer to me, yet not brand new, since I saw it used before and I find it perfectly logical. In C++ if you had a global and a local with the same name, the local would be prioritary. Apparently JASS inherited this too. :)
I think you may have missed the point. This goes beyond the usual local / global scoping to replace a slot in an array with something entirely different, a non array local. Apparently, if it's really true, the parser checks for a local name before it checks for a match against an array pattern.
08-14-2006, 07:20 AM#10
darkwulfv
Thanks for the positive reinforcement Daelin. Yeah, I didn't think it was that new, but like I said this is targeted towards those who may need a way and don't already know one.
@Naakaloh: wow that's taking it a step further, never would have thought of that... cool.
08-14-2006, 05:42 PM#11
Naakaloh
Um, I'm not sure I can take credit for it, I don't actually know if it parses arrays, but I assumed it did. I'll have to check that now.

Edit: I just tried it and apparently you can't do it like that, sorry for the confusion, it should still work with non-array variables, unfortunately I can't see any way of demonstrating it doing what PipeDream mentioned, so apparently it checks the arrays before the locals. :/

Though unless I'm mistaken you should still be able to use
Trigger:
Custom Script: local real udg_real1 = 1.
and then use the GUI functions. Previous post edited as well.
08-14-2006, 06:01 PM#12
The)TideHunter(
You could still use arrays, just not as nice fitting.
I prefer your way Naakaloh, because it saves memory, instead of reserving 8k vars, although, arrays can be handy in loops.
So you can also do:
Trigger:
Custom Script: local real array udg_MyReal
set MyReal[0] = 50.
set MyReal[500] = -32.2
Wait - Wait MyReal[1] seconds
08-14-2006, 06:07 PM#13
Naakaloh
Does that work? Ok, so perhaps I wasn't entirely incorrect.
08-14-2006, 06:09 PM#14
The)TideHunter(
I think so lol =/.
Im not sure if arrays work with the GUI global buggy thing.
That would work fine without GUI though.
Its just can you bug the bug?
08-14-2006, 06:31 PM#15
Vexorian
Quote:
Originally Posted by DioD
No waits inside == 100% MUI with no any arrays
That's not a general true, when there are waits, also using arrays for each player is not multi instancibility either