| 12-30-2003, 07:07 AM | #1 |
Has anyone figured out a way to solve for the fact that all wait functions wipe out the Event Response functions? Or figured out a solution that is remotely feasible for multiple waits in a event chain? I noticed that it doesn't clear it out immediately... that the time before the Event Response function is lost differs in single or multiplayer. The time before the Event Response is lost is much shorter in multiplayer... less than 4 seconds usually.. where it can be up to 15 seconds in single player... |
| 12-30-2003, 07:21 AM | #2 |
local variables are THE way. You can actually use a form of local variables almost entirely with GUI triggers, first make a global variable say TempUnit Actions for a trigger: Code:
custom script: local unit udg_TempUnit //Now in this trigger TempUnit is a local variable Set TempUnit = (Target unit of ability being cast) .. do stuff.... waits ... more stuff ... The major cavet of this method, other than being a bit of a hack (even if one reccomended by a blizzard employee) is it gets very, very screwy as soon as you start using for loops, if/then/else etc, so it's only good for simple triggers, but if the trigger is something simple like "Wait 4 seconds, kill targetted unit" then it's perfect. Otherwise you need full JASS to use local variables properly, which is outside the scope of my post :) |
| 12-30-2003, 07:32 AM | #3 |
Ok, I have trouble understanding what a global and local variable is with respect to wc3 maps. This is what I am assuming, please confirm. A global variable is something that shared by all players and triggers and is created by modifying the variable list. A local variable is something that is uniquely created by the trigger that creates it, only modifiable by the trigger that creates it, and is destroyed when the trigger stops using it. Like Integer A and Integer B are local variables. I'm terrible with JASS, and don't know the advanced mapmaking stuff... but let me interpret your code thing. So at map initialization I make a variable called, TempUnit, and turn it into a local variable by running a custom JASS trigger with the line: local unit udg_TempUnit. And then after that, TempUnit is treated like a local variable when i manipulate it with triggers? Yeah currently the way I'm using it is pretty simple.. but if I can get it to work stabily for loops.. ooh the things i could do.. Thanks alot for the help! edit: Nevermind, I just stumbled upon's Vex's holy tutorial on local variables and figured it out. |
| 12-30-2003, 10:30 AM | #4 |
OK. Apparently it works for one spell but not the other. What is wrong with this? Global Variable: LocalUnitCasting Trigger: Event: Unit - A unit starts the effect of an ability. Conditions: (ability being cast) Equal to DUMMYABILITY Actions: Custom script: local unit udg_LocalUnitCasting Set LocalUnitCasting = (TriggeringUnit) Sound - Play LightningBolt at 100% volume attached to LocalUnitCasting Game - Display text for all players : test If current order of Local Unit Casting is Equal to ordertextstring of DUMMYABILITY then do specialeffect - create special effect attached to the weapon of LocalUnitCasting using lightning bolt, else do skip remaining actions Ok, the sound appears and text appears, but the bolt doesn't appear. Any ideas? I have the whole if thing there because the ability is channeled. |
| 12-30-2003, 10:57 AM | #5 |
The problem is that you are using IF. In the actions of that IF, the local variable does not exist, and the global variable will be used instead. Since there has been no waits at the time of that if statement, you can simply use (Casting unit) in there instead of LocalUnitCasting. |
| 12-30-2003, 11:23 AM | #6 |
Yeah the problem is the rest of the trigger has waits, and IFs. It's weird, I thought only IFs with multiple action messes up the local variables, turns out all ifs screw it up. |
| 12-30-2003, 12:18 PM | #7 |
lol.. WHAT is the problem here.... dont use a local! i never have, and i have worked around this forever.... just set a global variable 2 the desired event responce unit... first thing, or whenever, just before its gonna get reset/stop working. i know for a fact this works... because i have been doing it forever... |
| 12-30-2003, 12:42 PM | #8 |
stinky you sure it works? what if there are three instances at a time? do you need a global variable 3? heh heh .. and so on... anyways. i figured out a solution to this fix. Yes I am still technically fooling the world editor and not creating a local variable through JASS so I think it's interesting enough to post here. Anyways, what I did was I converted the trigger to JASS, then went through and removed all the extra functions that were generated by the IFs. Then, being frightfully unfamiliar with JASS, I pasted the condition from the functions i deleted and replaced it in the IF statements in the main trigger function. Evidently, even with single events, the editor still generates extra function calls for each of them instead of just plopping in the condition. I know I am still fooling the worldeditor because the variable I'm using still has a udg_ before it, and it works great. Just an interesting tidbit. edit: ok i think i know why this works. it's because local variable names are unique to local variables... independent of global variable names.. i just removed the udg_ extension from my jass and it still works. this brings up yet another interesting point. for those who read vex's tutorial about making local variables.. if you want to optimize your map, and don't really use the "dummy global variable".. you can simply convert your trig to jass when you are done with it.. and delete the global variable from which your local was based upon. |
