• 🏆 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!

[vJASS] Regions and Rects :/

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hi guys,

I am starting to develop a tower defense and I'm having trouble registering when creeps enter a region (pre-placed in the World Editor). How can I do this in vJASS? For example, when a creep enters region A, order it to move to region B...

Thanks.
 
Level 2
Joined
Jul 23, 2010
Messages
11
It's quite simple, really.. Here:
JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    local unit u
    local location l

    set u = GetEnteringUnit()
    set l = GetRectCenter(gg_rct_Region_001)
    call IssuePointOrderLoc(u, "Move", l)
    call RemoveLocation(l)
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Untitled_Trigger_001, gg_rct_Region_000 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
There may be better ways, though.
 
You could use it's native counterpart.
Just hold Ctrl and click the function in the code.
A window will pop-up containing what the BJ function actually is.

edit
JASS:
local region rectRegion = CreateRegion()
call RegionAddRect(rectRegion, r)
return TriggerRegisterEnterRegion(trig, rectRegion, null)

That's what TriggerRegisterEnterRectSimple does.
What you could do is declare 1 local region, set it to CreateRegion(), and add your rect to it using RegionAddRect, register the enter region event, then set the local region to CreateRegion(), add your other rect, and register another event, etc...
You would keep repeating this for as many rect-region enter events as you need.

JASS:
local region r = CreateRegion()
local trigger t = CreateTrigger()

call RegionAddRect(r, gg_rct_myRect1)
call TriggerRegisterEnterRegion(t, r, null)
call TriggerAddCondition(t, Condition(function myCondition))
call TriggerAddAction(t, function myAction)

set r = CreateRegion()
set t = CreateTrigger()

call RegionAddRect(r, gg_rct_myRect2)
call TriggerRegisterEnterRegion(t, r, null)
call TriggerAddCondition(t, Condition(function myCondition2))
call TriggerAddAction(t, function myAction2)

// etc...

set t = null
set r = null
 
Level 13
Joined
Jan 21, 2012
Messages
1,982
Do this:
1.Open trigger editor
2.Make a new list
3.Make an event and do this:
Press unit then if unit enters region select your region and press ok
4.create a new condition and do this:Unit equal to player and select your creep player and press ok.
5.New trigger and do this:
press unit then issue order targeting a poin then on the first thing press it and press entering unit the press ok on that and on the second one make it where you want the unit to go!
 
Status
Not open for further replies.
Top