|
|
#1 |
|
User
Join Date: Sep 2006
Posts: 687
![]()
|
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 Last edited by Joker : 04-08-2009 at 03:42 AM. |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#2 |
|
extends net.wc3c.Jasser
|
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. Last edited by ToukoAozaki : 04-08-2009 at 03:59 AM. |
|
|
|
|
|
#3 |
|
User
Join Date: Sep 2006
Posts: 687
![]()
|
@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. |
|
|
|
|
|
#4 |
|
User
Join Date: Jun 2008
Posts: 116
|
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. |
|
|
|
|
|
#5 |
|
User
Join Date: Sep 2006
Posts: 687
![]()
|
@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? |
|
|
|
|
|
#6 |
|
User
Join Date: Feb 2009
Posts: 109
|
You create temporary globals and use those globals in the filter function.
__________________ |
|
|
|
|
|
#7 |
|
User
Join Date: Sep 2006
Posts: 687
![]()
|
@You create temporary globals and use those globals in the filter function.
Then I lose MUI support. |
|
|
|
|
|
#8 | |
|
User
Join Date: Feb 2009
Posts: 109
|
Quote:
That's fully MUI. |
|
|
|
|
|
|
#9 | |
|
Free Software Terrorist
Technical Director
|
Quote:
|
|
|
|
|
|
|
#10 |
|
User
Join Date: Sep 2006
Posts: 687
![]()
|
Any alternatives?
|
|
|
|
|
|
#11 | ||
|
extends net.wc3c.Jasser
|
Quote:
Quote:
Last edited by ToukoAozaki : 04-10-2009 at 04:02 PM. |
||
|
|
|
|
|
#12 |
|
Procrastination Incarnate
Development Director
|
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 Last edited by Anitarf : 04-10-2009 at 08:16 PM. |
|
|
|
|
|
#13 |
|
User
Join Date: Sep 2006
Posts: 687
![]()
|
Thx Anit, that's what I needed. I can't seem to rep anyone since it logs me off when I try.
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |