Announcement

Collapse
No announcement yet.

Random Route script help

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:06 PM. Reason: it was supposed to be router.sqf in the first file :(
    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member
    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

  • #2
    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, 01:42 PM.
    Yink | Vanilla Pilot | Killer of Stirling | CS GOD | Projects Team

    Comment


    • #3
      Re: Random Route script help

      Ahhh indeed. Ty
      |TG-189th| Unkl
      ArmA 3 Game Officer
      Dean of Tactical Gamer University
      189th Infantry Brigade Member
      SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
      "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

      Comment


      • #4
        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 | CS GOD | Projects Team

        Comment


        • #5
          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;
          |TG-189th| Unkl
          ArmA 3 Game Officer
          Dean of Tactical Gamer University
          189th Infantry Brigade Member
          SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
          "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

          Comment


          • #6
            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, 07:35 PM.
            Yink | Vanilla Pilot | Killer of Stirling | CS GOD | Projects Team

            Comment


            • #7
              Re: Random Route script help

              your banned lol
              |TG-189th| Unkl
              ArmA 3 Game Officer
              Dean of Tactical Gamer University
              189th Infantry Brigade Member
              SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
              "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

              Comment


              • #8
                Re: Random Route script help

                "you're"

                Current ARMA Development Project: No Current Project

                "An infantryman needs a leader to be the standard against which he can judge all soldiers."

                Friend of |TG| Chief

                Comment


                • #9
                  Re: Random Route script help

                  Originally posted by Dimitrius View Post
                  "you're"
                  lol

                  i thought it suited you well
                  Yink | Vanilla Pilot | Killer of Stirling | CS GOD | Projects Team

                  Comment


                  • #10
                    Re: Random Route script help

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

                    Comment

                    Connect

                    Collapse

                    TeamSpeak 3 Server

                    Collapse

                    Advertisement

                    Collapse

                    Twitter Feed

                    Collapse

                    Working...
                    X