brunohxcx 21 Posted February 26, 2015 hi, im spawning a group of ai by a trigger, that loads a .sqf inside the mission with this inside unitinit.sqf _myGroup = createGroup east; _tempSoldier = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.8,"Sergeant"]; _tempSoldier setVehicleVarName "Soldier1" ; _tempSoldier2 = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.6,"Private"]; _tempSoldier2 setVehicleVarName "Soldier2" ; _tempSoldier3 = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.6,"Private"]; _tempSoldier3 setVehicleVarName "Soldier3" ; _tempSoldier4 = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.6,"Private"]; _tempSoldier4 setVehicleVarName "Soldier4" ; _nul = [leader _myGroup] execVM "LV\patrol-vD.sqf"; the ai is spawning, the group leader start patrol but the others dont follow him. im trying to group them up by using join or joinsilent but dont know how to put inside the script.. [_soldier2, _soldier3, _soldier4] join _mygroup; [_soldier2, _soldier3, _soldier4] joinsilent _mygroup; can anyone help? thanks Share this post Link to post Share on other sites
jshock 512 Posted February 26, 2015 When you use createUnit you have the group parameter for a reason, so the units created to "_mygroup" in this case are already apart of "_mygroup" once created/spawned. Share this post Link to post Share on other sites
brunohxcx 21 Posted February 26, 2015 When you use createUnit you have the group parameter for a reason, so the units created to "_mygroup" in this case are already apart of "_mygroup" once created/spawned. oh! thanks but how can i spawn them in formation? so they can follow theyer leader? Share this post Link to post Share on other sites
jshock 512 Posted February 27, 2015 https://community.bistudio.com/wiki/setFormation Share this post Link to post Share on other sites
brunohxcx 21 Posted February 27, 2015 https://community.bistudio.com/wiki/setFormation so i added to the botton, now they are in formation, but dont follow the leader unit.. _myGroup = createGroup east; _tempSoldier = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.8,"Sergeant"]; _tempSoldier setVehicleVarName "Soldier1" ; _tempSoldier2 = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.6,"Private"]; _tempSoldier2 setVehicleVarName "Soldier2" ; _tempSoldier3 = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.6,"Private"]; _tempSoldier3 setVehicleVarName "Soldier3" ; _tempSoldier4 = _myGroup createUnit ["O_officer_F",getmarkerpos "m1",[],0.6,"Private"]; _tempSoldier4 setVehicleVarName "Soldier4" ; _nul = [leader _myGroup] execVM "LV\patrol-vD.sqf"; _mygroup setFormation "LINE" maybe there is an other way to do that? Share this post Link to post Share on other sites
Larrow 2779 Posted February 27, 2015 createUnit Array Parameters are.. group createUnit [type, position, markers, placement, special] You have a rank at the end of your parameters rather than special which should be "FORM" to spawn them in formation. If you need to set their rank after using createUnit Array then use the command setRank. Also setVehicleVarName is not enough in its self to be able to reference the soldier in script by that name. You also have to link the name (global variable) to reference the unit. e.g.. missionNamespace setvariable [ "Soldier1", _tempSoldier ]; and then publicVariable it if you need a reference on other machines. Heres a quick rewrite of your script incorporating a foreach loop to create what you need. _myGroup = createGroup east; { _soldierName = _x select 0; _soldierRank = _x select 1; //Create unit _tempSoldier = _myGroup createUnit [ "O_officer_F", getMarkerPos "m1", [], 0, "FORM" ]; //Set units rank _tempSoldier setRank _soldierRank; //set object var name _tempSoldier setVehicleVarName _soldierName; //set global variable name to reference object missionNamespace setVariable [ _soldierName, _tempSoldier ]; //sync global variable to all machines publicVariable _soldierName; }forEach [ //[ soldier name, soldier rank ] [ "soldier1", "SERGEANT" ], [ "soldier2", "PRIVATE" ], [ "soldier3", "PRIVATE" ], [ "soldier4", "PRIVATE" ] ]; _nul = [leader _myGroup] execVM "LV\patrol-vD.sqf"; 1 Share this post Link to post Share on other sites
brunohxcx 21 Posted February 27, 2015 (edited) thanks for the fast replys u guys help me a lot. still only the leader start the patrol, and the others just stand on spawn point, i ll keep trying to figure how to fix. Edited February 27, 2015 by brunohxcx Share this post Link to post Share on other sites
f2k sel 164 Posted February 27, 2015 _nul = [leader _myGroup] execVM "LV\patrol-vD.sqf"; Isn't that just telling the leader to patrol. You would usually just pass the group _nul = [_myGroup] execVM "LV\patrol-vD.sqf"; but not knowing what's in the other script it's impossible to know if it will work. Share this post Link to post Share on other sites
Larrow 2779 Posted February 27, 2015 (edited) but not knowing what's in the other script it's impossible to know if it will work. Aye just went and had a look for this script as i was not sure who's it was. It is part of spunFIN's AI script pack. Calling the script with a unit is correct (it is meant as a single unit patrol) but unfortunately the script uses doMove to control A unit, this has the effect that unit goes it alone, so even though the leader runs off his subordinates are not going to follow until he has reached his destination where he will silently call them to regroup on him, which is the default operation of doMove. Going to have to find yourself a different patrol script brunohxcx, unless spunFIN's pack has a group oriented patrol feature, although i didnt see one but i only quickly opened up the other few files called patrol**.sqf. Maybe BIS_fnc_taskPatrol ? Very simple patrol but depends what you need. [ _myGroup, getMarkerPos "m1", 100 ] call BIS_fnc_taskPatrol Creates random number of waypoints (2-5), around the marker position, each waypoint is atleast 100m away from the last, the group then cycles these waypoints. Sure there are plenty out there one of which will suit your needs. Edited February 27, 2015 by Larrow Share this post Link to post Share on other sites
brunohxcx 21 Posted February 27, 2015 (edited) i changed the ai script for UPSMON, now the patrol works fine.. thank u all im trying to randomize the spawn point so i did.. _myGroup = createGroup civilian; { _soldierName = _x select 0; _soldierRank = _x select 1; _position = [getMarkerPos "s1", random 150, random 360 ] call BIS_fnc_relPos; //Create unit _tempSoldier = _myGroup createUnit [ "C_man_1", [color="#FF0000"]_position[/color], [], 0, "FORM" ]; //Set units rank _tempSoldier setRank _soldierRank; //set object var name _tempSoldier setVehicleVarName _soldierName; //set global variable name to reference object missionNamespace setVariable [ _soldierName, _tempSoldier ]; //sync global variable to all machines publicVariable _soldierName; }forEach [ //[ soldier name, soldier rank ] [ "soldier1", "SERGEANT" ], [ "soldier2", "PRIVATE" ], [ "soldier3", "PRIVATE" ], [ "soldier4", "PRIVATE" ] ]; { // forEach removeHeadgear _x: removeGoggles _x; removeUniform _x; removeVest _x; removeBackpack _x; removeAllWeapons _x: removeAllAssignedItems _x; _x forceAddUniform "U_C_Driver_3"; _x addheadgear "H_PilotHelmetFighter_O"; _x addbackpack "B_FieldPack_blk"; _X addVest "V_PlateCarrier1_blk"; _x addMagazines ["30Rnd_65x39_caseless_mag", 10]; _x addMagazine "HandGrenade", 3; _X addWeapon "arifle_MX_Black_F"; _x addPrimaryWeaponItem "optic_ACO_grn"; } foreach (units _mygroup); _nul = [leader _myGroup, "area1", "RAMDOM", "SAFE", "LINE", "NORMAL"] execVM "scripts\upsmon.sqf"; but it randomizes every single unit, can i spawn the entire group together but random? im also looking for a way to add setskill to this. Edited February 28, 2015 by brunohxcx Share this post Link to post Share on other sites
Larrow 2779 Posted February 28, 2015 _myGroup = createGroup civilian; [color="#008000"]_position = [getMarkerPos "s1", random 150, random 360 ] call BIS_fnc_relPos;[/color] { _soldierName = _x select 0; _soldierRank = _x select 1; //Create unit _tempSoldier = _myGroup createUnit [ "C_man_1", _position, [], 0, "FORM" ]; //Set units rank _tempSoldier setRank _soldierRank; //set object var name _tempSoldier setVehicleVarName _soldierName; //set global variable name to reference object missionNamespace setVariable [ _soldierName, _tempSoldier ]; //sync global variable to all machines publicVariable _soldierName; [color="#008000"]{ _tempSoldier setSkill _x }forEach [ [ "aimingAccuracy", 0.75 ], [ "aimingShake", 0.75 ], [ "aimingSpeed", 0.75 ], [ "spotDistance", 1 ], [ "spotTime", 1 ], [ "courage", 1 ], [ "reloadSpeed", 0.75 ], [ "commanding", 1 ], [ "general", 0.75 ] ];[/color] }forEach [ //[ soldier name, soldier rank ] [ "soldier1", "SERGEANT" ], [ "soldier2", "PRIVATE" ], [ "soldier3", "PRIVATE" ], [ "soldier4", "PRIVATE" ] ]; { // forEach removeHeadgear _x: removeGoggles _x; removeUniform _x; removeVest _x; removeBackpack _x; removeAllWeapons _x: removeAllAssignedItems _x; _x forceAddUniform "U_C_Driver_3"; _x addHeadgear "H_PilotHelmetFighter_O"; _x addBackpack "B_FieldPack_blk"; _x addVest "V_PlateCarrier1_blk"; _x addMagazines ["30Rnd_65x39_caseless_mag", 10]; _x addMagazine [color="#008000"][ "HandGrenade", 3 ];[/color] _x addWeapon "arifle_MX_Black_F"; _x addPrimaryWeaponItem "optic_ACO_grn"; }forEach (units _mygroup); _nul = [leader _myGroup, "area1", "RAMDOM", "SAFE", "LINE", "NORMAL"] execVM "scripts\upsmon.sqf"; Moved the _position above the forEach loop so it will be the same for each unit created. Added a setSkill ARRAY so you can set individual skill levels. You were missing [] around your addMagazine for HandGrenade. 1 Share this post Link to post Share on other sites
brunohxcx 21 Posted February 28, 2015 (edited) thank u Larrow :bounce3: works very well Edited February 28, 2015 by brunohxcx Share this post Link to post Share on other sites