battleship 11 Posted June 12, 2017 (edited) Hello , what is the correct addaction for adding groupname in AI script.I have placed a AI group of units named as "GrpOne" not under player as leader. Then in player radio trigger - null = [player,grpone] execVM "script.sqf"; script.sqf _unit= _this select 0;\\player _grp = _this select 1;\\AI group sleep 1; act1 = _unit addaction ["orderAI", "AIscript.sqf"] ;\\ player addaction. How should i add groupname "grpone" in AIscript.sqf so that grpone can use script.commands such as "grpone move getpos _pos;". Edited June 13, 2017 by battleship Share this post Link to post Share on other sites
Sgt.Spunkmeyer 14 Posted July 7, 2017 What are you trying to do? Maybe trying to make GroupOne to move?. How did you create the group? . Via script or Trigger?: Script: GroupOne = CreateGroup west; lead1 = GroupOne createUnit ["US_Soldier_TL_EP1", getpos player, [], 2 "NONE"]; sold2 = GroupOne createUnit ["US_Soldier_AR_EP1", getpos player, [], 2 "FORM"]; sold3 = GroupOne createUnit ["US_Soldier_AR_EP1", getpos player, [], 2 "FORM"]; sold4 = GroupOne createUnit ["US_Soldier_AR_EP1", getpos player, [], 2, "FORM"]; lead1 = leader GroupOne; lead1 setRank "Sargeant"; lead1 setSkill 1; // smart guy GroupOne setformation "Column"; And now what else you want?. To order them to move some point?. Just use your: act1 = PLAYER addaction ["orderToMoveAI", "AIscript.sqf"] ; \\ player addaction. Then AIscript: _end = false; // Variable // Action moving = { _pos = [_this select 0, _this select 1,_this select 2]; point1 = GroupOne addwaypoint [position [_pos select 0, _pos select 1, 0], 0]]; // the previous mark on map point1 setwaypointtype "Move"; openMap [false, false]; TitleText [ format["GroupOne is moving to position."], "PLAIN DOWN"]; _end = true; }; // Choosing where to move TitleText "Click on the map to set where you want GroupOne to move."; if(!(visibleMap)) then { openMap [true, false]; }; onMapSingleClick '[_pos select 0, _pos select 1, _pos select 2] call moving'; waitUntil {_end || !(visibleMap)}; onMapSingleClick ""; GroupOne should be moving to the selected waypoint. Share this post Link to post Share on other sites
battleship 11 Posted July 8, 2017 Will this script work for non-spawned multiple infantry groups as well which are already placed on map and named as grpone, grptwo etc.? Like using multiple radio triggers for each group with player addaction as above. Share this post Link to post Share on other sites
Sgt.Spunkmeyer 14 Posted July 8, 2017 It should work aswell. The radio Trigger manages this action: " null = [grpOne] execVM "script.sqf"; " in On Act. So try to add more radio triggers for every group: "null = [grpTwo] execVM "script.sqf";" Then script.sqf: _group = _this select 0; player addAction ["orderToMoveAI", "AIscript.sqf", _group]; And then AIscript.sqf: _grp = _this select 3; // Group _end = false; // Variable // Action moving = { _pos = [_this select 0, _this select 1,_this select 2]; _gridpos = mapgridposition _pos; point1 = _grp addwaypoint [position [_pos select 0, _pos select 1, 0], 0]]; // the previous mark on map point1 setwaypointtype "Move"; openMap [false, false]; TitleText format ["The Group is moving to grid: %1.", _gridpos]; _end = true; }; // Choosing where to move TitleText "Click on the map to set where you want the group to move."; if(!(visibleMap)) then { openMap [true, false]; }; onMapSingleClick '[_pos select 0, _pos select 1, _pos select 2] call moving'; waitUntil {_end || !(visibleMap)}; onMapSingleClick ""; Share this post Link to post Share on other sites
opusfmspol 282 Posted July 14, 2017 This page on the wiki explains the addAction command and its optional arguments that can be used. First two arguments are required (title, script name), the others are optional. Variables passed into the addaction come third in the array. act1 = _this addAction ["Title", "script.sqf", [grpOne]]; Or a single variable can be passed without an array. act1 = _this addAction ["Title", "script.sqf", grpOne]; But note that within the action script that is being run, the passed param(s) would be _this select 3. In an action script: _object_with_addAction = _this select 0; _calling_Player = _this select 1; _action_ID_Number = _this select 2; _params_passed_in = _this select 3; For a single variable it would be "_grp = _this select 3;". To select the first argument from a passed array, it would be "_grp = (_this select 3) select 0;". Or by defining, it would be " _params = _this select 3; _grp = _params select 0;". And if the action is only supposed to appear when a certain condition is being met, condition comes eighth in the array. The defaults can be used to make up the other arguments. But the condition itself has to be made a string. act1 = _this addAction ["Title", "script.sqf", [grpOne], 1.5, true, true, "", "({alive _x} count (units grpOne)) > 0"]; Share this post Link to post Share on other sites
Sgt.Spunkmeyer 14 Posted July 14, 2017 Yeah. you 're right. I was thinking i missed _this select 3 for the passed input. I fix now. Share this post Link to post Share on other sites