OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: NightJay0044 on 03 Feb 2009, 00:37:56

Title: Infantry group get a position?
Post by: NightJay0044 on 03 Feb 2009, 00:37:56
Hi how do I get a whole group to get the position of a game logic?

Doesn't it go like ;

Quote
"_x getpos Gamelogic" foreach units group1

Something like that? Thanks..
Title: Re: Infantry group get a position?
Post by: Worldeater on 03 Feb 2009, 01:41:28
I'm not sure I understood the problem correctly, but if you want to "beam" a group to the position of a game logic it's:

Code: [Select]
{_x setPos (getPos Gamelogic)} forEach units group1;
One thing: the first time I tested this Scotty f*cked up. One guy was missing and all other guys ran to a position 500m to the north. I'm pretty sure the missing guy was their squad leader and they just tried to keep formation. The really strange thing this is that I cannot reproduce this anymore.

 :blink:
Title: Re: Infantry group get a position?
Post by: NightJay0044 on 03 Feb 2009, 03:03:44
Well I want a group to get a position from their current position. Walk or run, whichever, but not teleport..but I think that will work..
Title: Re: Infantry group get a position?
Post by: Worldeater on 03 Feb 2009, 04:19:27
Got it!

From the editor you could use a classic waypoint that requires some condition to be true. Or you could use a script to create one:

Code: (createWaypoint.sqf) [Select]
/* createWaypoint.sqf
 *
 * Example:
 * [group1,getPos Gamelogic,"MOVE","GREEN","COLUMN","LIMITED","SAFE",0] execVM "createWaypoint.sqf";
 */

private ["_group","_pos","_type","_mode","_form","_speed","_behav","_rad"];

_group = _this select 0;
_pos   = _this select 1;
_type  = _this select 2;
_mode  = _this select 3;
_form  = _this select 4;
_speed = _this select 5;
_behav = _this select 6;
_rad   = _this select 7; // Placement radius

_wp = _group addWaypoint [_pos, _rad];

_wp setWaypointType       _type;
_wp setWaypointCombatMode _mode;
_wp setWaypointFormation  _form;
_wp setWaypointSpeed      _speed;
_wp setWaypointBehaviour  _behav;

_wp; // return value

If you use this script check the waypoint commands (http://community.bistudio.com/wiki/Category:Command_Group:_Waypoints) for the parameters. Some are different than in the editor, e.g. "DIAMOND" instead "DELTA" for setWaypointFormation (http://community.bistudio.com/wiki/setWaypointFormation).

HTH
Title: Re: Infantry group get a position?
Post by: Rommel92 on 03 Feb 2009, 06:15:55
I find a nice little safe guard nowadays is it to add in the following code to allow for the common mistake of simply putting a unit in instead of a position (happens a lot).

Code: [Select]
if (typeName (_this select 1) != "ARRAY") then {
if(typeName (_this select 2) == "OBJECT" then {
_pos = position (_this select 1);
}else{
//[West, "HQ"] globalchat format ["%1 is not TYPE ARRAY / OBJECT! Check Execution", _this select 1];
};
}else{
_pos = _this select 1;
};

edit: fixed line 2 bug
Title: Re: Infantry group get a position?
Post by: Worldeater on 03 Feb 2009, 09:08:39
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
  -- Antoine de Saint-Exupéry

1. Adding code adds bugs (like the one in line 2).
2. This code is not necessary here because addWaypoint (http://community.bistudio.com/wiki/addWaypoint) will happily accept an object instead of a position.

 :whistle:

Title: Re: Infantry group get a position?
Post by: Planck on 03 Feb 2009, 17:44:57
I think in the case of addWaypoint (http://www.ofpec.com/COMREF/index.php?action=details&id=395), specifying an object just means that the objects position is taken instead of requiring a position to be input instead.

Biki updated accordingly


Planck