| 04-08-2009, 03:41 AM | #1 |
I can't seem to figure out how to create a ally detection in a filter in a timer. example:scope Base initializer Init private struct asd unit blac group gg ... .. static method a takes ... set dat.blac = ... set dat.gg = CreateGroup() call SetTimerData( ... ) //Using TU call TimerStart( ... ) endmethod private static method callback ... ... call GroupEnum...( g, ..., Condition( function asd.filter ) ) endmethod private static method filter takes nothing returns boolean return ...//Here, how do you add in a ally detection? endfunction endstruct private function Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A000' endfunction private function Actions takes nothing returns nothing call asd.a(..) endfunction private function Init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventEx( t, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( t, Condition( function Conditions ) ) call TriggerAddAction( t, function Actions ) endfunction endscope |
| 04-08-2009, 03:58 AM | #2 |
You can add a static variable to pass context information to the filter. Of course it will not collide with another instance. Alternatively, GetTimerData(GetExpiredTimer()) will work (but not recommended). This can happen because context is inherited in continuous child execution flow. BTW you'll need to put your filter above the enum call. |
| 04-08-2009, 04:10 AM | #3 |
@You can add a static variable to pass context information to the filter. Can I see an example? @BTW you'll need to put your filter above the enum call. JassHelper doesn't seem to care. |
| 04-08-2009, 04:22 AM | #4 |
Last I heard, methods below are called by either TriggerEvaluate or TriggerExecute (I forget, really). By ally check, you mean checking whether the unit is a friend or not? IsUnitAlly should do the trick. |
| 04-08-2009, 04:23 AM | #5 |
@By ally check, you mean checking whether the unit is a friend or not? IsUnitAlly should do the trick. Why do you try it yourself? What TWO units are you going to compare? |
| 04-08-2009, 04:38 AM | #6 |
You create temporary globals and use those globals in the filter function. |
| 04-08-2009, 04:52 AM | #7 |
@You create temporary globals and use those globals in the filter function. Then I lose MUI support. |
| 04-08-2009, 05:00 AM | #8 | |
Quote:
That's fully MUI. |
| 04-08-2009, 01:52 PM | #9 | |
Quote:
|
| 04-10-2009, 03:51 PM | #10 |
Any alternatives? |
| 04-10-2009, 03:56 PM | #11 | ||
Quote:
Quote:
|
| 04-10-2009, 08:15 PM | #12 |
As long as the code in the GroupEnum callback doesn't cause any other triggers to run (for example, dealing damage in the group enum would cause damage detection triggers to run, which in turn could run another GroupEnum while this one is still running) it will be MUI. Even if there is a possibility of this happening you can still work around it by storing the previous value of the global in a local variable for the duration of the GroupEnum, something like this: JASS://... private static unit callbackU=null unit caster static method callback takes nothing returns nothing local unit u=callbackU set asd.callBackU=asd(GetTimerData(GetExpiredTimer())).caster call GroupEnum...( g, ..., Condition( function asd.filter ) ) set asd.callbackU=u set u=null endmethod |
| 04-10-2009, 09:24 PM | #13 |
Thx Anit, that's what I needed. I can't seem to rep anyone since it logs me off when I try. |
