Home   Help Search Login Register  

Author Topic: move to waypoint incrementally  (Read 1183 times)

0 Members and 1 Guest are viewing this topic.

Offline twisted

  • Members
  • *
  • I'm a llama!
move to waypoint incrementally
« on: 27 Feb 2009, 04:18:36 »
hi.

I am trying to write a script that makes a team move towards a point in thirds. then once at that point they take cover. but the only part i get right is the take cover part!

EDIT - i think i solved it.  NEW CODE below. but now they never take cover.

Code: [Select]

/*
point is to make recce move to a point. stopping every 1/3 of the way to findcover and wait 30seconds. destination is made players positon at first for conveneince


*/

if !(isserver) exitwith {};

_hideaway =
{
private ["_unit","_leader","_hidefrompos","_chosencover"];
_unit = _this select 0;
_hidefrompos = _this select 1;


_chosencover =  _unit findCover [getPos _unit, getPos _unit, 90 , 10];

_x doMove (getpos _chosencover);

// sleep 10;

};

_movetopos =
{
private ["_reccegroup","_waypoint"];
_reccegroup = _this select 0;
_waypoint = _this select 1;

{_x doMove  _waypoint; } forEach units _reccegroup;



};

private ["_reccegroup","_leader","_chosencover", "_markers","_destination" , "_tempos","_diffx","_diffz","_waypoint","_i"];

_reccegroup = _this select 0;
_markers = ["start1"];
_destination = getMarkerPos (_markers select 0);
_leader = leader _reccegroup;
_tempos = getpos _leader;

_waypoint = [0,0];

// _reccegroup setbehaviour "COMBAT";
_reccegroup setCombatMode "BLUE";
_reccegroup setSpeedMode "NORMAL";
_reccegroup setFormation "FILE";


_diffx = ((_destination select 0) - (_tempos select 0))/3;
_diffz = ((_destination select 1) - (_tempos select 1))/3;


_i = 0;
While {_i < 3} do
{


 _waypoint = [_diffx + (_tempos select 0), _diffz +( _tempos select 1)];

hint format ["\n \ndest and waypoint =  %1 %2",_destination, _waypoint];

//{_x doMove  _waypoint; } forEach units _reccegroup;
[_reccegroup, _waypoint] call _movetopos;
_enemyinfo = (units _reccegroup select 0) findNearestEnemy _leader;

if (!(isNull _enemyinfo)) exitWith
{


{[_x, _enemyinfo] call _hideaway} forEach units _reccegroup;

};

_diffx = _diffx + _diffx;
_diffz = _diffz + _diffz;


//hint format ["\nmoving next third %1 %2 %3",_destination,_diffx, _i];

_i = _i + 1;

if (_i >= 3 ) exitWith
{

//{[_x, _x] call _hideaway} forEach units _reccegroup;
//problem is if i uncomment the above the ai only run for cover. how to get them to first run to marker and then move to cover?

};

};









« Last Edit: 28 Feb 2009, 04:48:41 by twisted »