| 09-17-2007, 08:31 AM | #1 |
I've been meaning to learn the usage of these for awhile now, but no matter how many times I read this script, it makes no sense to me. Its so bad I have read 100s of people's input on them and I still don't understand what they even do. I included the functions used in the example I found. I'm wondering if I should even bother learning because I can't figure it out, and I'm frustrated! JASS:function LocalVars takes nothing returns gamecache return InitGameCache("jasslocalvars.w3v") endfunction function GetHandleGroup takes handle subject, string name returns group return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function SetHandleHandle takes handle subject, string name, handle value returns nothing if value==null then call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name) else call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value)) endif endfunction // Add spawn to a group stored on master local unit master = GetSummoningUnit() local unit spawn = GetSummonedUnit() local group spawns = GetHandleGroup(master, "spawns") // Initialize group if needed if (spawns == null) then set spawns = CreateGroup() call SetHandleHandle(master, "spawns", spawns) endif // Add spawn to group call GroupAddUnit(spawns, spawn) // Store pointer to master on spawn call SetHandleHandle(spawn, "master", master) This came from JASS vault, and I just can't see what is actually going on here. An example of my confusion is the function "GetHandleGroup" is used when declaring a local group variable, how can something be retrieved that was never stored? What exactly is it "Getting"? And it says "Add spawn to a group stored on master". So I'm assuming you use a unit to point to a group or something...The unit master is local, how is it used in another function? What if master or spawn dies? I'm so confused on these... From what I've read it seems like you store a local and retrieve it like a global. Why not just use globals? Is there anywhere I can read some thorough tutorials or some explanation of how these actually work? Like step by step this does this, that does that? The ones I have found have not helped at all, and were very limited in explaining how exactly this system works. I have read every possible forum containing these, some example scripts, and are still 100% obscure to me... This is the most thorough tutorial I could find and it still makes no sense to me.... Using the Handle Vars |
| 09-17-2007, 10:52 AM | #2 |
Handle vars is used to pass variables from one function to another. If you use globals, your spells won't be MUI. I think you would need a tutorial more focused on how to apply the Handle vars on spells for instance. Check this one, it helped me a lot to understand that system: http://www.wc3campaigns.net/showthread.php?t=83337 |
| 09-17-2007, 11:44 AM | #3 |
Basically its a complex array that can be used to store mostly anything. It is like a global but globals are limited to there respective types. It more or less maks things MUI and simplifies variables Im not that good at JASS and in fact Ive never had more then one or 2 cases that ive ever used it :/ |
| 09-17-2007, 03:35 PM | #4 |
Local Handle Variables have largely been replaced. They are still used for attaching stuff occasionally, but normally just to attach structs. That is, unless you're on a silly MAC and can't use JassHelper. |
| 09-17-2007, 05:08 PM | #5 |
If jasshelper doesn't work in darwine red is not a color. Not even Mac players got an excuse to use handle vars, there are good alternatives for them over handle vars... |
| 09-17-2007, 06:52 PM | #6 | |
Quote:
|
| 09-17-2007, 09:52 PM | #7 | |
Quote:
This could be good news so I don't have to learn how these work. Where can I find the alternative and any info on it? |
| 09-17-2007, 10:41 PM | #8 |
Structs. Read some tutorials about how to use them from either here or hiveworkshop. |
| 09-17-2007, 10:43 PM | #9 |
You still need some way to attach structs to things. I still use gamecache for that in the cases when it's necessary, it's not as if using gamecache once or twice per spell is going to slow it up. So, I would recommend still learning it, it might be a bit confusing at first but it's really pretty easy once you figure it out. http://www.wc3campaigns.net/showthread.php?t=90999 is what you want - Jass NewGen Pack. Has a bunch of nice features, but mainly a preprocessor for vJass, which allows you to use structs and other useful things. Edit: Those two tutorials at wc3jass.com are very good. Simple and to the point, but they do a good job of explaining how to use it. Is there a specific part of the tutorial you don't understand? Try this one too, it shows how they are actually used and might help you understand. http://www.wc3jass.com/viewtopic.php?t=1999 |
| 09-18-2007, 02:27 AM | #10 |
does it at least work correctly in bnet without desyncing players that haven't opened the map first? |
| 09-18-2007, 06:36 AM | #11 | |
Quote:
Congratulations you just made red not a color!!! Oh my long lost red... |
| 09-18-2007, 07:48 AM | #12 |
Wow thanks TaintedReality, after reading that post for some reason it all came clear to me. I finally understand how they work. And yeah I'm using the NewGen pack right now, so far I think it's awesome. I was reading a little about libraries and structs and private members and such from the JassHelper readme but at the time it blew my mind. I figured I'd learn a few more of the basics before digging too deep into that. Edit: Yay, here is a trigger I revised that originally used triggersleepaction. No more waits for me . JASS:function BeamSatteliteCond takes nothing returns boolean return GetSpellAbilityId() == 'A03M' endfunction function RemoveLight takes nothing returns nothing local timer t = GetExpiredTimer() local weathereffect w = GetHandleWeather(t, "weather") call EnableWeatherEffect(w, false) call RemoveWeatherEffect(w) call SetHandleHandle(t, "weather", null) call FlushHandleLocals(t) call DestroyTimer(t) set t = null set w = null endfunction function BeamSattelite takes nothing returns nothing local unit u = GetSpellAbilityUnit() local player p = GetOwningPlayer(u) local timer t = CreateTimer() local real x local rect r local weathereffect w if (IsPlayerInForce(p, udg_Force1)) then set r = gg_rct_SatteliteTop else set r = gg_rct_SatteliteBottom endif set w = AddWeatherEffect(r, 'LRaa') call EnableWeatherEffect(w, true) call SetHandleHandle(t, "weather", w) call TimerStart(t, 40, false, function RemoveLight) set u = null set p = null set t = null set w = null endfunction function InitTrig_BeamSatteliteCast takes nothing returns nothing set gg_trg_BeamSatteliteCast = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_BeamSatteliteCast, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(gg_trg_BeamSatteliteCast, Condition(function BeamSatteliteCond)) call TriggerAddAction(gg_trg_BeamSatteliteCast, function BeamSattelite) endfunction I have few more questions now... 1.) Did I do the cleanup part right in the function "RemoveLight"? 2.) After looking at many examples, I noticed that every one I looked at uses a timer to attach and retrieve vars in another function. Is this the preferred way, the only way, or simply a way with many others? 3.) My last concern is not with the trigger, but the spell Unholy Aura using negative values. Anyway, when the above spell is casted it creates a "Sattelite" with an Unholy Aura that subtracts 2% hit points a second and the trigger only makes the light beam weather effect. When a unit hits 1 HP, sometimes it doesn't die from the aura and bugs out, leaving it with 1 HP and impervious to death. Is this a commonly known bug and is it avoidable? Sorry if I ask too many questions >.< |
| 09-18-2007, 06:07 PM | #13 | |
Quote:
I've seen screenshots of darwine running MSOffice. Darwine not running jasshelper which was specially tweaked by me to run correctly on Wine is something I find very hard to believe. |
| 09-18-2007, 06:39 PM | #14 |
The only problem is the libraries for Darwine don't work quite right all the time and well this is one of those :/ im sure it will work SOMEDAY just not today... oh and congrats on removing red as a color :P PS: and the main diferance between ms office and jasshelper is this, you want to run jass helper so it wont, you dont want to run office so it will :) |
| 09-18-2007, 07:32 PM | #15 | |||
Quote:
You don't need to SetHandleHandle(t, "weather", null), FlushHandleLocals does that for you. Also, you should always pause a timer before destroy it when using gamecache, otherwise some wierd problems can occur that are very hard to find and get rid of. Other than that looks good though. Quote:
Timers are just usually the only thing that can be passed as a local variable from one function to another (using GetExpiredTimer()). There are cases where you'll want to attach things to other handles, but in many cases timers are the best. So no, it's not preferred or anything, just use whatever works (it just happens to usually be timers). Quote:
You could check periodically for units with 1 hp and the unholy aura buff, or you could use the event Unit - Unit's life becomes less than X. It's a specific unit event, so you would have to add it for each unit that might be affected by unholy aura, but that would probably be the better solution. Then you can check when their hp is 1 and they have the unholy aura buff, and kill them. |
