| 08-29-2007, 12:39 PM | #1 |
Can a function which returns a boolean, used for a boolexpr take an argument? Like this: JASS:function Heat_Stroke_Check_2 takes unit u returns boolean JASS:call GroupEnumUnitsInRange(g2, x2, y2, 300, Condition(function Heat_Stroke_Check_2(f))) Something along those lines. |
| 08-29-2007, 01:09 PM | #2 |
No this can't be done. But if you need to pass arguments to the test function, you could use bj vars to do that. In your case, you could use the unit var bj_meleeNearestMine. One example: JASS:function Heat_Stroke_Check_2 takes nothing returns boolean //use "bj_meleeNearestMine" var and use it in your evaluation return <your boolean var> endfunction function bla takes nothing returns nothing // your locals local boolexpr b = Condition(function Heat_Stroke_Check_2) // your stuff set bj_meleeNearestMine = f call GroupEnumUnitsInRange(g2, x2, y2, 300, b) call DestroyBoolExpr(b) // more stuff set b = null //return endfunction |
| 08-29-2007, 01:10 PM | #3 |
No, not in this way. But you can use a gamecache or for units the "bj_ghoul" variable (or any other global var). Of course you have to declare the var befor usin' the function (then "u" is for example "bj_ghoul[99]"). |
| 08-29-2007, 01:14 PM | #4 |
Darn, that's annoying. I normally wouldn't have to do this, but since the second unit (the one who needs the second check) damages his allies, I can't use getDyingUnit, since that variable is the unit who set the trigger off in the first place. A bj variable or my own global will suffice in this situation then, and the global will be MUI since only one player per game will be possessing this hero. Thanks anyways guys. EDIT: I just realized I could do it a different way and achieve the same results, so no bj_globals or udg globals will be needed. |
| 08-29-2007, 04:58 PM | #5 |
Event responses should all be thread specific (except for the buggy cast event responses that were added in a later patch) so you could just as well use GetDyingUnit(). |
| 08-29-2007, 05:18 PM | #6 |
I couldn't, because technically the DyingUnit is was the one who set the trigger off. At a point, a loop kicks in, and if a unit dies there, then it grabs another group from it. GetDyingUnit() would return the unit that set the main trigger in motion, would it not? |
| 08-29-2007, 05:28 PM | #7 |
If a unit died there and you detected that with another trigger that ran on a unit dies event, then that unit would be the dying unit for that trigger. If, instead, you detected that by checking the unit's life in this trigger, then that unit is nothing here. I can't know what you're doing because you didn't post any code. |
| 08-29-2007, 05:57 PM | #8 |
Ah, sorry. The unit dies by checking life, not from a seperate trigger. So GetDyingUnit() would still return the one who set the trigger off. |
| 08-29-2007, 10:02 PM | #9 |
Using a global in a filter does not make the spell non-MUI, what gave you that idea? |
| 08-30-2007, 12:26 AM | #10 |
If the spell ran twice or more at the same time, the global would be confused, thus non MUI. |
| 08-30-2007, 01:02 AM | #11 |
It's not possible that there are two functions running at exactly the same time, so it's just important to set the global var just befor the function call (at least no waits, or ExecuteFunc are allowed between) and nothing can happen. |
| 08-30-2007, 02:58 AM | #12 |
It matters not, my problem was solved ages ago. I simply had to use a different function call. |
| 08-30-2007, 06:47 AM | #13 |
Using a global var could be a problem if the actions within the group enum block could cause the same trigger (or any other trigger using the same global variable) to run again. Then again, I thought of a way to avoid that too. Before setting your global before the loop, store it's current value to a local, then after the loop, set the global back to what it was, so in case this trigger is interrupting another instance of itself mid-loop, by the time that loop resumes the global will have been set back to what it was. |
| 08-30-2007, 08:36 AM | #14 |
Or use a private global... makes more sense that way. |
| 08-30-2007, 11:28 AM | #15 | |
Quote:
Point to point, my issue's solved. |
