wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-08-2009, 03:41 AM   #1
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default Filters in Timers

I can't seem to figure out how to create a ally detection in a filter in a timer.

Collapse 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.
Joker is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-08-2009, 03:58 AM   #2
ToukoAozaki
extends net.wc3c.Jasser
 
Join Date: Jun 2008
Posts: 336

Submissions (5)

ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)

Send a message via MSN to ToukoAozaki
Default

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.
ToukoAozaki is offline   Reply With Quote
Old 04-08-2009, 04:10 AM   #3
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

@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.
Joker is offline   Reply With Quote
Old 04-08-2009, 04:22 AM   #4
azlier
User
 
Join Date: Jun 2008
Posts: 116

azlier is on a distinguished road (10)

Default

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.
__________________
You hate me, don't you?
azlier is offline   Reply With Quote
Old 04-08-2009, 04:23 AM   #5
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

@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?
Joker is offline   Reply With Quote
Old 04-08-2009, 04:38 AM   #6
FriendlyPsycho
User
 
FriendlyPsycho's Avatar
 
Join Date: Feb 2009
Posts: 109

Submissions (1)

FriendlyPsycho is on a distinguished road (12)

Default

You create temporary globals and use those globals in the filter function.
__________________
" YOU RAGE, YOU LOSE! "
FriendlyPsycho is offline   Reply With Quote
Old 04-08-2009, 04:52 AM   #7
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

@You create temporary globals and use those globals in the filter function.
Then I lose MUI support.
Joker is offline   Reply With Quote
Old 04-08-2009, 05:00 AM   #8
FriendlyPsycho
User
 
FriendlyPsycho's Avatar
 
Join Date: Feb 2009
Posts: 109

Submissions (1)

FriendlyPsycho is on a distinguished road (12)

Default

Quote:
Originally Posted by FriendlyPsycho
You create temporary globals and use those globals in the filter function.

That's fully MUI.
__________________
" YOU RAGE, YOU LOSE! "
FriendlyPsycho is offline   Reply With Quote
Old 04-08-2009, 01:52 PM   #9
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,901

Submissions (37)

Vexorian has a reputation beyond repute (1054)Vexorian has a reputation beyond repute (1054)Vexorian has a reputation beyond repute (1054)Vexorian has a reputation beyond repute (1054)Vexorian has a reputation beyond repute (1054)Vexorian has a reputation beyond repute (1054)

Hero Contest #3 - 2nd Place

Default

Quote:
Originally Posted by FriendlyPsycho
That's fully MUI.
It depends on circumstances, so it is half MUI.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 04-10-2009, 03:51 PM   #10
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

Any alternatives?
Joker is offline   Reply With Quote
Old 04-10-2009, 03:56 PM   #11
ToukoAozaki
extends net.wc3c.Jasser
 
Join Date: Jun 2008
Posts: 336

Submissions (5)

ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)ToukoAozaki will become famous soon enough (60)

Send a message via MSN to ToukoAozaki
Default

Quote:
Originally Posted by Joker
Can I see an example?
It's basically the same to what FriendlyPsycho said. Static variable is actually equivalent to a global.

Quote:
Originally Posted by Vexorian
It depends on circumstances, so it is half MUI.
In this particular GroupEnum case, I'm 100% sure that temp globals are no issue. Warcraft III seem to behave like single-threaded parser. In one execution context (and its childs), continuous exclusive execution is guaranteed unless halted by TriggerSleepAction or hitting op limit. This also explains why op limit exists; letting unlimited number of ops to run would definitely freeze the game.

Last edited by ToukoAozaki : 04-10-2009 at 04:02 PM.
ToukoAozaki is offline   Reply With Quote
Old 04-10-2009, 08:15 PM   #12
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,084

Submissions (19)

Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

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:

Collapse 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.
Anitarf is offline   Reply With Quote
Old 04-10-2009, 09:24 PM   #13
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

Thx Anit, that's what I needed. I can't seem to rep anyone since it logs me off when I try.
Joker is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 09:49 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2013, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services