Welcome to Tactical Gamer

User Tag List

Results 1 to 10 of 10
Discussion: ArmA - Development / ArmA - Mission Development - Random Route script help - Trying to have a target vehicle move to random waypoints but having a problem of
  1. #1


    Unkl's Avatar

    Join Date
    Jan 2010
    Location
    Great White North
    Age
    45
    Posts
    4,053
    Blog Entries
    4
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Random Route script help

    Trying to have a target vehicle move to random waypoints but having a problem of them stopping at the first one. Anyone suggest a way to loop this thingy?

    Code:
    //router.sqf
    //to randomize a route accross predetermined waypoints placed as invisible objects in editor named w1 w2 and so forth
    
    
    //on act of a trigger
    //nul=[this]execVM "router.sqf";
    //bad1 is the name of the enemy target vehicle
    _unit = bad1;
    _wp = [w1,w2,w3,w4,w5,w6];
    _namep = "T1";
    
    //waituntil {(alive player)}; 
    _grp = group _unit;
    
    //randomly choose waypoints
    _numb = round (random 6);
    _nextplace = (_wp select _numb);
    deleteWaypoint [_grp, 1];
    
    //make new waypoint
    _x = _grp addWaypoint [_nextplace, 1];
    [_grp, 1] setWaypointSpeed "FULL";
    [_grp,1] setWaypointCompletionRadius 20;
    [_grp, 1] setWaypointCombatMode "RED";
    
    //the following line does not work to loop this
    _x setWaypointStatements ["true", "[] execVM "recall.sqf";"];
    
    end;

    Code:
    //recall.sqf
    //to recall router.sqf to set a new waypoint for target vehicle
    
    sleep 5;
    
    [] execVM "router.sqf";
    
    end;
    Last edited by Unkl; 11-19-2012 at 03:06 PM. Reason: it was supposed to be router.sqf in the first file :(

  2.  
  3. #2


    Yink's Avatar

    Join Date
    Feb 2012
    Location
    Santa Barbara, CA
    Age
    19
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    personally i wouldn't use waypoints for a single vehicle. i would use movecommands and setbehaviour/setspeed.

    in vehicle init
    Code:
    this setbehaviour "aware";//or whatever you want
    this setspeedmode "full";//""
    //nul = [this] execVM "detect.sqf" look at the bottom for this one
    in trigger
    Code:
    [badl] execVM "router.sqf";
    router.sqf
    Code:
    _unit = this select 0;
    //w# being markers
    _wp = ["w1","w2","w3","w4","w5","w6"];
    //random 6 has 7 outputs, although you had 6 waypoints. so change it to random 5
    _numb = round (random 5);
    _loc = (_wp select _numb);
    
    _unit domove (getmarkerpos _loc);
    
    _wpchange = (15);
    waituntil {(_unit distance _loc) < _wpchange};//change _wpchange for larger radius on changing waypoints
    
    nul = [_unit] execVM "router.sqf";
    
    //note
    just in case you want the vehicle to change combat modes if a blufor soldier comes within a distance
    Code:
    _unit = badl
    while {1>0} do {
    _blufor = _unit findNearestEnemy (getpos _unit)
    };
    _var1 = 150;
    
    waituntil {(_blufor distance _unit) < _var1}; //change var1 for detect distance 
    _unit setbehaviour "combat";
    waituntil {(_blufor distance _unit) > _var1};
    _unit setbehaviour "safe"; //or w/e you want
    if (behaviour _unit == "safe") exitwith {
    execVM "detect.sqf";
    };
    that was off the top of my head so there is probably some errors/bugs.
    but basically i avoid waypoint via scripting. move commands are so much easier
    Last edited by Yink; 11-19-2012 at 01:42 PM.
    Yink | Vanilla Pilot | Killer of Stirling | TG-355ᵀᴴ | Kerbalnaut | Projects Team


  4.  
  5. #3


    Unkl's Avatar

    Join Date
    Jan 2010
    Location
    Great White North
    Age
    45
    Posts
    4,053
    Blog Entries
    4
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    Ahhh indeed. Ty

  6.  

     
  7. #4


    Yink's Avatar

    Join Date
    Feb 2012
    Location
    Santa Barbara, CA
    Age
    19
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    and besides, recall .sqf called router.sqf, when it is really router.sqs.
    and you would have to do:
    Code:
    sleep 5;
    
    nul = [badl] exec "router.sqs";// and set _unit = this select 0 in the start of router.sqf or stay with what you have
    
    end;
    Yink | Vanilla Pilot | Killer of Stirling | TG-355ᵀᴴ | Kerbalnaut | Projects Team


  8.  
  9. #5


    Unkl's Avatar

    Join Date
    Jan 2010
    Location
    Great White North
    Age
    45
    Posts
    4,053
    Blog Entries
    4
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    He he he

    Code:
    //routemaker.sqf
    //to randomize a route accross predetermined waypoints placed as invisible objects in editor named w1 w2 and so forth
    
    
    //on act of a trigger
    //nul=[this]execVM "routemaker.sqf";
    //bad1 is the name of the enemy target vehicle
    _unit = bad1;
    _wp = [w1,w2,w3,w4,w5,w6];
    _namep = "T1";
    _r = 1;
    _grp = group _unit;
    
    
    while {_r < 4} do
    {
      hint "Target is on the move.";
      //randomly choose waypoints
      _numb = round (random 5);
      _numb = _numb + 1;
      _nextplace = (_wp select _numb);
      _nowplace = (getPos _unit);
      _nowdist = (_nextplace distance _nowplace);
      
      //check the random new location isnt the current location
      if (_nowdist < 20) then {_numb = _numb - 1};
      
      //order to move
      _unit doMove (getPos _nextplace);
    
      //set radius from waypoint
      _wpchange = (20);
      waituntil {(_unit distance _nextplace) < _wpchange}; //change _wpchange for larger radius on changing waypoints
      sleep 5;
      hint "The target has made another contact.";
    };
    
    hint "Mission failed. The target has completed the route.";
    
    end;

  10.  
  11. #6


    Yink's Avatar

    Join Date
    Feb 2012
    Location
    Santa Barbara, CA
    Age
    19
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    with this one, just make sure that the w#s are objects like invisible helopads.
    tell me if it works btw!

    but other than that:


    and should you have something change _r?
    Last edited by Yink; 11-19-2012 at 07:35 PM.
    Yink | Vanilla Pilot | Killer of Stirling | TG-355ᵀᴴ | Kerbalnaut | Projects Team


  12.  

     
  13. #7


    Unkl's Avatar

    Join Date
    Jan 2010
    Location
    Great White North
    Age
    45
    Posts
    4,053
    Blog Entries
    4
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    your banned lol

  14.  
  15. #8

    Dimitrius's Avatar

    Join Date
    Apr 2007
    Location
    The Windy City of Chicago, Illinois. USA.
    Age
    33
    Posts
    1,299
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    "you're"


    ----
    --------

  16.  
  17. #9


    Yink's Avatar

    Join Date
    Feb 2012
    Location
    Santa Barbara, CA
    Age
    19
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    Quote Originally Posted by Dimitrius View Post
    "you're"
    lol

    i thought it suited you well
    Yink | Vanilla Pilot | Killer of Stirling | TG-355ᵀᴴ | Kerbalnaut | Projects Team


  18.  

     
  19. #10


    Join Date
    Jan 2012
    Location
    Portland, OR
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Route script help

    Rofl
    "Anyone who has never made a mistake has never tried anything new."
    -Einstein

  20.  

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


  
 

Back to top