• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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