Home   Help Search Login Register  

Author Topic: Infantry group get a position?  (Read 1642 times)

0 Members and 1 Guest are viewing this topic.

Offline NightJay0044

  • Former Staff
  • ****
  • Let's make OFPEC great again
    • My Steam Workshop
Infantry group get a position?
« 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..
Who's hyped for Arma4, long live Arma!

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Infantry group get a position?
« Reply #1 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:
try { return true; } finally { return false; }

Offline NightJay0044

  • Former Staff
  • ****
  • Let's make OFPEC great again
    • My Steam Workshop
Re: Infantry group get a position?
« Reply #2 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..
Who's hyped for Arma4, long live Arma!

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Infantry group get a position?
« Reply #3 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 for the parameters. Some are different than in the editor, e.g. "DIAMOND" instead "DELTA" for setWaypointFormation.

HTH
« Last Edit: 03 Feb 2009, 04:21:11 by Worldeater »
try { return true; } finally { return false; }

Offline Rommel92

  • Members
  • *
Re: Infantry group get a position?
« Reply #4 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
« Last Edit: 03 Feb 2009, 22:12:00 by Rommel92 »

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Infantry group get a position?
« Reply #5 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 will happily accept an object instead of a position.

 :whistle:

« Last Edit: 03 Feb 2009, 09:12:36 by Worldeater »
try { return true; } finally { return false; }

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Infantry group get a position?
« Reply #6 on: 03 Feb 2009, 17:44:57 »
I think in the case of addWaypoint, specifying an object just means that the objects position is taken instead of requiring a position to be input instead.

Biki updated accordingly


Planck
« Last Edit: 03 Feb 2009, 18:03:53 by Planck »
I know a little about a lot, and a lot about a little.