• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

JASS: Patrol function

Status
Not open for further replies.
Level 7
Joined
Apr 1, 2010
Messages
46
All right,
I am making a map with a lot of patroling units. My problem is, that the normal patrol command stops working, after the unit hits on an enemy. I decided to solve this problem, by creating a jass function, that would take unit and two patrol locations and endlessly loop the units move with attack order. Whenever the unit gets closer than 510 (or anything else) to the target point it shall turn arround and go to the other point 510 from that point it turns arround etc.. I have created the whole script, but my taken variables refuse to work. It simply writes expected unit / expected point. I am probably just missing something, somebody please help me. :confused:
JASS:
function Trig_FuncPatrol_Func002001 takes nothing returns boolean
    return ( IsUnitInGroup(PATROLER, GetUnitsInRangeOfLocAll(512, PointB)) == true )
endfunction

function Trig_FuncPatrol_Func004001 takes nothing returns boolean
    return ( IsUnitInGroup(PATROLER, GetUnitsInRangeOfLocAll(512, PointA)) == true )
endfunction

function Trig_FuncPatrol_Actions takes location PointA, location PointB, unit PATROLER returns nothing
   loop
    call IssuePointOrderLocBJ( PATROLER, "attack", PointB )
    loop
        exitwhen ( Trig_FuncPatrol_Func002001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 1.00))
    endloop
    call IssuePointOrderLocBJ( PATROLER, "attack", PointA )
    loop
        exitwhen ( Trig_FuncPatrol_Func004001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 1.00))
    endloop
   endloop
endfunction

//===========================================================================
function InitTrig_FuncPatrol takes nothing returns nothing
    set gg_trg_FuncPatrol = CreateTrigger(  )
    call TriggerAddAction( gg_trg_FuncPatrol, function Trig_FuncPatrol_Actions )
endfunction
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
You're trying to pass PATROLER, PointA, and PointB to another function, but they're not global variables so you can't do that.

If you can use vJass, this would be easily solved by declaring a global block with the variables in them. Else, you could just make variables with the Variable Editor and have to use udg_YourGlobalVariable to use it in your Jass script.

Also, it might be a better idea to use coordinates instead of locations and to inline the BJ's.
 
Level 7
Joined
Apr 1, 2010
Messages
46
Thanks a lot for your suggestions guys. After all you told me this seams sort of more complex than the GUI version I finally got working and looses the purpose of an easier alternative. Despite this thanks a lot for your suggestions on my JASS syntax. :-D
 
Status
Not open for further replies.
Top