• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

TriggerRegisterEntersRegion used on multiple rects?

Status
Not open for further replies.
Level 5
Joined
Aug 15, 2007
Messages
145
How would I set up my init code with this native to register multiple regions that are entered? eg
JASS:
//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    
// I want to convert it to this native, how do I add the multiple rects to this event response?
    local region rectRegion = CreateRegion()
    call RegionAddRect(rectRegion, r)
    return TriggerRegisterEnterRegion(trig, rectRegion, null)

// current BJ
    call TriggerRegisterEnterRectSimple( t, gg_rct_Region_049  )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Region_050  )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Region_051  )

    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
    set t = null
    
endfunction

endscope
 

Cokemonkey11

Spell Reviewer
Level 29
Joined
May 9, 2006
Messages
3,534
JASS:
scope entersTripleRectRegion initializer i
    private function f takes nothing returns boolean
        if (CONDITIONS) then
            (ACTIONS)
        endif
        return false
    endfunction

    private function i takes nothing returns nothing
        local trigger t=CreateTrigger()
        local region reg=CreateRegion()
        call RegionAddRect(reg,gg_rct_Region_049)
        call RegionAddRect(reg,gg_rct_Region_050)
        call RegionAddRect(reg,gg_rct_Region_051)
        call TriggerRegisterEnterRegion(t,reg,Filter(function f))
    endfunction
endscope

You really should be defining Rects like Rect(minx,miny,maxx,maxy) instead of using gg_rct though
 
Level 5
Joined
Aug 15, 2007
Messages
145
This does not work for me, Im trying to make the TriggerRegisterEnterRectSimple BJ more efficient, I have lots of rects with units moving in and out, and its making minor lag.

Is there a way to have the 3 rects for instance in a seperate trigger so the region variable is global, so i can call it in multiple triggers?

Im trying to ensure that a unit actually enters then leaves a rect by placing other 'dummy' rects arounds the main rect and then registering if it leaves and enters those aswell, this way error is avoided. Iv had it so that units who just pass through a rect sometimes dont register as leaving. Is there another way without using so many rects to ensure leaving and entering?
 
Last edited:
Status
Not open for further replies.
Top