f2k sel 164 Posted September 22, 2011 (edited) just a quick look at that script and it has no chance of working. foreach _nearTargets would need to be at the end of the script deletewaypoint (waypoints _groupsHunter select 0) is't valid it's deletewaypoint [_groupHunter,xx] xx would be the value of the waypoint you want to delete. and _groupsHunter should be _groupHunter you would also need to change the value of xx until it removes all the waypoints. Edited September 22, 2011 by F2k Sel Share this post Link to post Share on other sites
wiggum2 31 Posted September 22, 2011 I thought the waypoint part was correct: When you want to remove all waypoints, do NOT iterate over waypoints _group while trying to delete them (an array is by reference!). Instead use an approach like this: while {(count (waypoints _group)) > 0} do { deleteWaypoint ((waypoints _group) select 0); }; http://community.bistudio.com/wiki/deleteWaypoint Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2011 (edited) It didn't work in my tests, maybe because I hadn't removed the s from_groupsHunter. I see what he's trying to do but I can't find any other reference to a deletewaypoint being used that way. while {(count (waypoints _huntergroup)) > 0} do { deleteWaypoint [_huntergroup, 1]; }; Maybe that would work as it keeps deleting waypoint 1 until there are no more left. I've not tested it though. update I have tested it now and that works. Edited September 22, 2011 by F2k Sel Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2011 Minor update, it does seem to work setting the first <= 1.3 value to !=0. I also changed the way the delay worked I found it a bit unreadable. //nul=[this,this,1500,group this,mygroup,5] execVM "patrolhunt.sqf"; _unit = _this select 0; _areaname = _this select 1; _areasize = _this select 2; _grphunter = _this select 3; _grptarget = _this select 4; _delay = _this select 5; _eastmen = nearestobjects [_areaname,["SoldierEB"],_areasize]; _westmen = nearestobjects [_areaname,["SoldierWB"],_areasize]; _patrol = [_unit, position _unit, 300, 7, "MOVE", "SAFE", "RED", "LIMITED", "STAG COLUMN", "", [2,5,10]] call CBA_fnc_taskPatrol; hint "Patroling"; hint format ["%1",count units _grphunter]; while { ({alive _x} count units _grphunter > 0) && ({_x knowsAbout ({_x} forEach _westmen) != 0} count _eastmen > 0) } do { sleep 1; hint "test"; { _temp = _x; {_temp reveal _x} foreach _westmen; } foreach _eastmen; sleep 1; if (({_x knowsAbout ({_x} forEach _westmen) > 1.3} count _eastmen > 0) && ({alive _x} count units _grptarget > 0)) then { hint format ["west %1 east %2",count _westmen,count _eastmen]; sleep 2; terminate _patrol; hint "Stop patrol"; {_x setBehaviour "AWARE"; _x setCombatMode "RED"; _x setSpeedMode "FULL"} foreach units _grphunter; if (count units _grphunter > 2) then {_delay = 10}; _grphunter move getpos leader _grptarget; hint format ["%1",_delay]; sleep _delay; hint "hunting"; sleep 1; }; }; hint "done"; Share this post Link to post Share on other sites
wiggum2 31 Posted September 22, 2011 I worked a bit more on the script and this is the result: //hunting_patrol.sqf _patrolpos = _this select 0; _areaname = _this select 1; _areasize = _this select 2; _grphunter = _this select 3; _eastmen = nearestobjects [_areaname,["SoldierEB"],_areasize]; _westmen = nearestobjects [_areaname,["SoldierWB"],_areasize]; _formation = ["WEDGE", "ECH LEFT", "ECH RIGHT", "VEE", "DIAMOND"] call BIS_fnc_selectRandom; _speed = ["NORMAL", "FULL"] call BIS_fnc_selectRandom; _behaviour = ["AWARE", "COMBAT"] call BIS_fnc_selectRandom; _mode = ["YELLOW", "RED"] call BIS_fnc_selectRandom; private ["_myVariable", "_myVariable2"]; _myVariable = 0; _myVariable2 = 0; _patrol = [_grphunter, position _patrolpos, 300, 7, "MOVE", "SAFE", "YELLOW", "LIMITED", "STAG COLUMN", "", [2,5,10]] call CBA_fnc_taskPatrol; hint "Patroling"; while {({alive _x} count units _grphunter > 0)} do { if ({_x knowsAbout ({_x} forEach _westmen) <= 1.3} count _eastmen > 0) then { { _temp = _x; {_temp reveal _x} foreach _westmen; } foreach _eastmen; sleep 5; }; if (({_x knowsAbout ({_x} forEach _westmen) > 1.3} count _eastmen > 0) && ({alive _x} count units mygroup > 0) && (_myVariable == 0)) then { terminate _patrol; sleep 1; _myVariable = 1; {_x setBehaviour _behaviour; _x setCombatMode _mode; _x setSpeedMode _speed; _x setFormation _formation} foreach units _grphunter; }; if (_myVariable == 1) then { _grphunter move getpos leader mygroup; hint "Hunting"; sleep 20; }; if (({alive _x} count units mygroup == 0) && (_myVariable2 == 0)) then { _myVariable = 0; terminate _hunt; sleep 1; _patrol = [_grphunter, position _patrolpos, 300, 7, "MOVE", "SAFE", "RED", "LIMITED", "STAG COLUMN", "", [2,5,10]] call CBA_fnc_taskPatrol; _myVariable2 = 1; hint "Patroling"; }; }; The problem is, if two groups access the script simultaneously there will (or maybe "can") be problems with the local variables ! Only solution i found was to copy the script and give it another name so the second group access not the same script. Does someone know a better solution then having the same script twice ? I mean, there are many patrol scripts for example who dont have such a problem if many groups access them at the same time... Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2011 (edited) How are you calling the scripts and how are the groups set up and what side hunts what side. Using it the way you have it they go hunting but even when close to the enemy they don't follow them and oddly I had a second group with no script who follow the hunters. I have this in Blufor group null=[this,this,1500,mygroup] execvm "hunting_patrol.sqf" and mygroup=group this in Opfor group is that right or wrong. I worked out I was calling it wrong. I just passed mygroup and renamed mygroup to _mygroup and now it works with multiple groups. // null=[this,this,1500,this,mygroup] execvm "hunting_patrol.sqf" //hunting_patrol.sqf _patrolpos = _this select 0; _areaname = _this select 1; _areasize = _this select 2; _grphunter = _this select 3; _mygroup =_this select 4; _eastmen = nearestobjects [_areaname,["SoldierEB"],_areasize]; _westmen = nearestobjects [_areaname,["SoldierWB"],_areasize]; _formation = ["WEDGE", "ECH LEFT", "ECH RIGHT", "VEE", "DIAMOND"] call BIS_fnc_selectRandom; _speed = ["NORMAL", "FULL"] call BIS_fnc_selectRandom; _behaviour = ["AWARE", "COMBAT"] call BIS_fnc_selectRandom; _mode = ["YELLOW", "RED"] call BIS_fnc_selectRandom; private ["_myVariable", "_myVariable2"]; _myVariable = 0; _myVariable2 = 0; _patrol = [_grphunter, position _patrolpos, 300, 7, "MOVE", "SAFE", "YELLOW", "LIMITED", "STAG COLUMN", "", [2,5,10]] call CBA_fnc_taskPatrol; hint "Patroling"; while {({alive _x} count units _grphunter > 0)} do { if ({_x knowsAbout ({_x} forEach _westmen) <= 1.3} count _eastmen > 0) then { { _temp = _x; {_temp reveal _x} foreach _westmen; } foreach _eastmen; sleep 5; }; if (({_x knowsAbout ({_x} forEach _westmen) > 1.3} count _eastmen > 0) && ({alive _x} count units _mygroup > 0) && (_myVariable == 0)) then { terminate _patrol; sleep 1; _myVariable = 1; {_x setBehaviour _behaviour; _x setCombatMode _mode; _x setSpeedMode _speed; _x setFormation _formation} foreach units _grphunter; }; if (_myVariable == 1) then { _grphunter move getpos leader _mygroup; hint "Hunting"; sleep 20; }; if (({alive _x} count units _mygroup == 0) && (_myVariable2 == 0)) then { _myVariable = 0; terminate _hunt; sleep 1; _patrol = [_grphunter, position _patrolpos, 300, 7, "MOVE", "SAFE", "RED", "LIMITED", "STAG COLUMN", "", [2,5,10]] call CBA_fnc_taskPatrol; _myVariable2 = 1; hint "Patroling"; }; }; Edited September 22, 2011 by F2k Sel Share this post Link to post Share on other sites
.kju 3245 Posted September 23, 2011 @F2k Sel waypoints _unit/_group returns a list of wayspoints: [[b 1-1-B,0],[b 1-1-B,1],[b 1-1-B,2],[b 1-1-B,3],[b 1-1-B,4],[b 1-1-B,5],[b 1-1-B,6]] a waypoint is an array that consists of group name and waypoint index [b 1-1-B,0] now that is the basics you are well aware of. the first waypoint (select 0) is normally the initial position of the unit. now with using the index 1 like you do, you do not remove this one. if you really want to remove alll waypoints of an unit, you also need to remove this one. hence index 0/select 0 is used. when is this needed: for example when you reuse a (dead/empty) group or think of respawn for AI. hope this helps Share this post Link to post Share on other sites
twirly 11 Posted September 23, 2011 The problem is, if two groups access the script simultaneously there will (or maybe "can") be problems with the local variables !Only solution i found was to copy the script and give it another name so the second group access not the same script. Does someone know a better solution then having the same script twice ? I mean, there are many patrol scripts for example who dont have such a problem if many groups access them at the same time... There could be problems if you used global variables! Local variables shouldn't cause problems. Local variables are local to the script they are used in....global variables can be used across all scripts. No reason why 20 groups couldn't use it if it's written properly. Share this post Link to post Share on other sites