Kirienko 10 Posted June 16, 2014 (edited) I want to contribute with a waypoints system I have made for OFP. The absence of "AddWaypoint" and similar instructions in Cold War Assault really piss me off so I created this system to have a kind of "virtual waypoints" so I can establish them at any point and forget (I didn't want to create a custom script for baby-sitting each unit I wanted to have dynamic waypoints). Files vwaypoint_add.sqf //VWayPoint Add // Parameters................................................. // Group: target group // Type: MOVE, GETIN, GETOUT, EJECT // Speed: NOCHANGE, LIMITED, NORMAL, FULL. Default: NOCHANGE // Behaviour: NOCHANGE, CARELESS, SAFE, AWARE, COMBAT, STEALTH. Default: NOCHANGE // CombatMode: NOCHANGE, BLUE, GREEN, WHITE, YELLOW, RED. Default: NOCHANGE // GetInInfo: [targetVehicle, arrayUnitIndex, roleInVehicle]. Default: [] // --> targetVehicle: vehicle to get in // --> arrayUnitIndex: array of the unit indexes of the group to get in // --> roleInVehicle: CARGO, DRIVER, GUNNER, COMMANDER private["_group", "_position", "_type", "_speed", "_behaviour", "_combatMode", "_getInInfo", "_vwaypoint", "_groupWaypointList"]; _group = _this select 0; _position = _this select 1; if(count _this > 2) then { _type = _this select 2; } else { _type = "MOVE"; }; if(count _this > 3) then { _speed = _this select 3; } else { _speed = "NOCHANGE"; }; if(count _this > 4) then { _behaviour = _this select 4; } else { _behaviour = "NOCHANGE"; }; if(count _this > 5) then { _combatMode = _this select 5; } else { _combatMode = "NOCHANGE"; }; if(count _this > 6) then { _getInInfo = _this select 6; } else { _getInInfo = []; }; _vwaypoint = [_position, _type, _speed, _behaviour, _combatMode, _getInInfo]; //if (isNull vWayPoints) then { vWayPoints = [] }; if (format ["%1", vWayPoints] == "scalar bool array string 0xfcffffef") then { vWayPoints = []; publicVariable "vWayPoints"; }; private "_found"; _found = false; { if((_x select 0) == _group) then { _groupWaypointList = _x select 1; _found = true; };} foreach vWayPoints; if (!_found) then { vWayPoints set [count vWayPoints, [_group, [_vwaypoint]]]; } else { _groupWaypointList set [ count _groupWaypointList, _vwaypoint]; }; vwaypoint_run.sqs @(format ["%1", vWayPoints] != "scalar bool array string 0xfcffffef") private["_group", "_index", "_getIn", "_getOut", "_eject", "_waypointList", "_waypointListFound", "_waypoint", "_position", "_type", "_speed", "_behaviour", "_combatMode", "_getInInfo", "_i", "_getOutDone", "_isReady"]; private["_targetVehicle", "_arrayUnitIndex"]; _group = _this select 0; _index = 0; _getIn = false; _getOut = false; _eject = false; _waypointListFound = false; #BEGIN ~2 _getOutDone = false; _isReady = true; { _isReady = (_isReady && (unitReady _x || ! alive _x)); } foreach units _group; if(!_isReady && !_getIn) then { goto "BEGIN"; }; if(_getIn) then { _getIn = false; [_group, _getInInfo] exec "vwaypoint_getin.sqs"; } else { goto "NOWAIT_GETIN"; }; #WAIT_GETIN _targetVehicle = _getInInfo select 0; _arrayUnitIndex = _getInInfo select 1; { if(!(((units _group) select _x) in vehicle _targetVehicle) && ( alive((units _group) select _x))) then { goto "WAIT_GETIN"; } } foreach _arrayUnitIndex; #NOWAIT_GETIN if(_getOut) then { _getOut = false; {unassignVehicle _x;} forEach units _group; _getOutDone = true;}; if(_eject) then { _eject = false; { _x action ["EJECT", vehicle _x]; } forEach units _group; _getOutDone = true;}; if(!_waypointListFound) then { { if((_x select 0) == _group) then {_waypointList = (_x select 1); _waypointListFound = true;}; } foreach vWayPoints;}; if(!_waypointListFound) then { goto "BEGIN"; }; _i = count _waypointList; ;hint format["waypoints count: %1", _i]; if(count _waypointList < (_index + 1)) then {goto "BEGIN"; }; _waypoint = (_waypointList select _index); _position = _waypoint select 0; _type = _waypoint select 1; _speed = _waypoint select 2; _behaviour = _waypoint select 3; _combatMode = _waypoint select 4; _getInInfo = _waypoint select 5; _group move _position; { if(!_getOutDone && vehicle _x != _x) then { _x doMove _position; } } foreach units _group; if(_type == "GETIN") then { _getIn = true; }; if(_type == "GETOUT") then { _getOut = true; }; if(_type == "EJECT") then { _eject = true; }; if(_speed != "NOCHANGE") then { _group setSpeedMode _speed; }; if(_behaviour != "NOCHANGE") then { _group setBehaviour _behaviour; }; if(_combatMode != "NOCHANGE") then { _group setCombatMode _combatMode; }; _index = _index + 1; goto "BEGIN"; vwaypoint_getin.sqs private ["_group", "_getInInfo", "_targetVehicle", "_arrayUnitIndex", "_roleInVehicle", "_command", "_fullComand"]; _group = _this select 0; _getInInfo = _this select 1; _targetVehicle = _getInInfo select 0; _arrayUnitIndex = _getInInfo select 1; _roleInVehicle = _getInInfo select 2; _command = "assignAsCargo"; if(_roleInVehicle == "DRIVER") then { _command = "assignAsDriver"; }; if(_roleInVehicle == "GUNNER") then { _command = "assignAsGunner"; }; if(_roleInVehicle == "COMMANDER") then { _command = "assignAsCommander"; }; _fullCommand = "((units _group) select _x) " + _command + " _targetVehicle;"; { [] call _fullCommand; [(units _group) select _x] orderGetIn true; } foreach _arrayUnitIndex; Example of Use Do not forget: first you have to copy/create the files described in the previous section to your mission folder. This code is meant to be in the init of the leader of a group of soldiers: _vwaypoint_add = preprocessFile "vwaypoint_add.sqf"; [group this, getMarkerPos "BeachCharlie", "GETIN", "FULL", "NOCHANGE", "NOCHANGE", [ship, [2], "GUNNER"]] call _vwaypoint_add; [group this, getMarkerPos "BeachCharlie", "GETIN", "FULL", "NOCHANGE", "NOCHANGE", [ship, [0,3,4,5,6,7], "CARGO"]] call _vwaypoint_add; [group this, getMarkerPos "BeachCharlie", "GETIN", "FULL", "NOCHANGE", "NOCHANGE", [ship, [1], "DRIVER"]] call _vwaypoint_add; [group this, getMarkerPos "BeachDelta", "GETOUT", "FULL"] call _vwaypoint_add; [group this, getMarkerPos "IslandCenter"] call _vwaypoint_add; [group this] exec "vwaypoint_run.sqs"; In this example I have set these markers: BeachCharlie, BeachDelta, IslandCenter. I also have a boat named "ship" in "BeachCharlie". In this example the group mount the ship and goes to another island where they dismount and goes to "IslandCenter" on foot. I think this is pretty self-explicative, anyway in case of doubt just ask :) Any improvement is welcome!! Edited June 20, 2014 by Kirienko Share this post Link to post Share on other sites
kenoxite 155 Posted June 16, 2014 Excellent! Seeing that you still can't post links I've uploaded myself a demo mission, using the example you've provided: http://ge.tt/3pd7Fck1/v/0?c Feel free to reupload it yourself somewhere else once you can. Share this post Link to post Share on other sites
Kirienko 10 Posted June 16, 2014 Excellent!Seeing that you still can't post links I've uploaded myself a demo mission, using the example you've provided: http://ge.tt/3pd7Fck1/v/0?c Feel free to reupload it yourself somewhere else once you can. Thank you!! I even had to wait one day after registration to be able to post that (I think it is some anti spam measure) :) Share this post Link to post Share on other sites
Kirienko 10 Posted June 20, 2014 Update In vwaypoint_getin.sqs: This line { _isReady = (_isReady && unitReady _x); } foreach units _group; is changed for: { _isReady = (_isReady && (unitReady _x || ! alive _x)); } foreach units _group; I'm updating the first post to reflect this change. Share this post Link to post Share on other sites
krzychuzokecia 700 Posted June 20, 2014 That's very interesting, thanks! Share this post Link to post Share on other sites
Kirienko 10 Posted June 20, 2014 That's very interesting, thanks! I'm glad to hear that :D Share this post Link to post Share on other sites
damotr 49 Posted July 17, 2014 May I ask for permission to use Your script in mod? Share this post Link to post Share on other sites
Kirienko 10 Posted July 22, 2014 May I ask for permission to use Your script in mod? Yes, you can use this script in a mod. Just add me in the credits for the script :) Share this post Link to post Share on other sites
akvadakar 21 Posted July 25, 2014 Does it work in multiplayer - dedicated & LAN server? Share this post Link to post Share on other sites
Kirienko 10 Posted July 27, 2014 Does it work in multiplayer - dedicated & LAN server? I have not tested it in multiplayer, but it should work fine. Share this post Link to post Share on other sites