-
11-19-2012, 12:09 PM #1
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 :(
-
11-19-2012, 01:23 PM #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
in triggerCode:this setbehaviour "aware";//or whatever you want this setspeedmode "full";//"" //nul = [this] execVM "detect.sqf" look at the bottom for this one
router.sqfCode:[badl] execVM "router.sqf";
just in case you want the vehicle to change combat modes if a blufor soldier comes within a distanceCode:_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
that was off the top of my head so there is probably some errors/bugs.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"; };
but basically i avoid waypoint via scripting. move commands are so much easier
-
11-19-2012, 01:31 PM #3
Re: Random Route script help
Ahhh indeed. Ty
-
11-19-2012, 01:38 PM #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;
-
11-19-2012, 05:37 PM #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;
-
11-19-2012, 06:36 PM #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?
-
11-19-2012, 06:43 PM #7
Re: Random Route script help
your banned lol
-
11-19-2012, 06:44 PM #8
Re: Random Route script help
"you're"

<ARMA Administrator> -- [Pathfinder] -- |TG| Irregulars
"This is for all you new people; I only have one rule.
...Everyone fights, No one quits."
-Lieutenant Jean Rasczak

Homage to LowSpeedHighDrag
-
11-19-2012, 08:13 PM #9
-
11-27-2012, 11:34 PM #10
- Join Date
- Jan 2012
- Location
- Portland, OR
- Posts
- 233
Re: Random Route script help
Rofl
"Anyone who has never made a mistake has never tried anything new."
-Einstein

















Reply With Quote






Bookmarks