1para{god-father} 105 Posted October 8, 2013 (edited) Having an issue trying to use Groups it seem that the group does not Exist - trying to get a AI group to chase playable Group called "Delta" Example... AI Group Leader INIT chaser = group this INIT of players this setGroupId ["Delta"]; _hunted = Delta ; _null = [] spawn { while {true} do { chaser domove getpos(_hunted); sleep 10; }; }; Strange if I check the groups I get "B Delta" ?? _PlayableGroups = []; { if (isPlayer (leader _x)) then { _PlayableGroups= _PlayableGroups + [_x]; }; } forEach allGroups; Hint format["%1", _PlayableGroups]; now I am lost ! Edited October 8, 2013 by 1PARA{God-Father} Share this post Link to post Share on other sites
engima 328 Posted October 8, 2013 (edited) An example. One thing you missed is to send variables into the spawned thread. What spawn does is to start a new executing thread, and your reference to _hunted may be lost. In my example the abc_chasingLeader is the vehicle variable name set in the editor and the player is the one to be hunted. (Haven't tried this, so there might be a semicolon missing or similar). private ["_chaserGroup", "_huntedGroup"]; _chaserGroup = group abc_chasingLeader; _huntedGroup = group player; _null = [_chaserGroup, _huntedGroup] spawn { private [_chaserGroup, "_huntedGroup"]; _chaserGroup = _this select 0; _huntedGroup = _this select 1; while {true} do { _chaserGroup domove getpos _huntedGroup; sleep 10; }; }; Edited October 8, 2013 by Engima Share this post Link to post Share on other sites
1para{god-father} 105 Posted October 8, 2013 Thanks, OK getting my lists of Groups , but it still does not seem to work its like the group does not Exist still , if i use an object or player it all works but not when I try a Group - any idea's //// get list of playable Groups _PlayableGroups = []; { if (isPlayer (leader _x)) then { _PlayableGroups= _PlayableGroups + [_x]; }; } forEach allGroups; Hint format["%1", _PlayableGroups]; _randomGroup = _PlayableGroups call BIS_fnc_selectRandom; private ["_chaserGroup", "_huntedGroup"]; _chaserGroup = group Aigrouptemp; _huntedGroup = group _randomGroup; _null = [_chaserGroup, _huntedGroup] spawn { private [_chaserGroup, "_huntedGroup"]; _chaserGroup = _this select 0; _huntedGroup = _this select 1; while {true} do { _chaserGroup domove getpos _huntedGroup; sleep 10; }; }; error Error in expression <roup", "_huntedGroup"]; _chaserGroup = group Aigrouptemp; _huntedGroup = group > Error position: <group Aigrouptemp; _huntedGroup = group > Error group: Type Group, expected Object Share this post Link to post Share on other sites
shuko 59 Posted October 8, 2013 Your error is from trying to get the group of a group (Aigrouptemp). But, if we go back to the first post. Why not do: this setGroupId ["Delta"]; grpDelta = group this; Then you can do: [] spawn { while {true} do { chaser domove getpos(leader grpDelta); sleep 10; }; }; Share this post Link to post Share on other sites
2nd ranger 282 Posted October 8, 2013 Edit: never mind, ninja'd! Share this post Link to post Share on other sites
inlesco 233 Posted October 8, 2013 Keep in mind that what you set "setgroupid [""]" is no referenceable object that has a position, state or such. Share this post Link to post Share on other sites
1para{god-father} 105 Posted October 8, 2013 (edited) Your error is from trying to get the group of a group (Aigrouptemp).But, if we go back to the first post. Why not do: this setGroupId ["Delta"]; grpDelta = group this; Then you can do: [] spawn { while {true} do { chaser domove getpos(leader grpDelta); sleep 10; }; }; Thanks working --- but my list of groups shows "B GrpDelta" not GrpDelta ?, so going back to my List of Groups how can I get a list of Groups that I am using - as i am populating a combo-box to select from. no idea where the "B" comes from or how to remove it private ["_group","_playableGroups"]; _playableGroups = []; { _group = group _x; if !(_group in _playableGroups) then { _playableGroups set [count _playableGroups,_group]; } } foreach playableunits; Hint format["%1", _PlayableGroups]; Edited October 8, 2013 by 1PARA{God-Father} Share this post Link to post Share on other sites
shuko 59 Posted October 8, 2013 (edited) Well, at least in Arma 2, if you wanted to display a list of group names (without manually up-keeping a separate list). You'd need to use some string & array commands to remove the first 2 characters from the name to clean it up. I doubt there has been any improvement on it in A3. Something like this: _name = toArray str _group; _name set [0,"DEL"]; _name set [1,"DEL"]; _name = _name - ["DEL"]; _name = toString _name; Edited October 8, 2013 by Shuko Share this post Link to post Share on other sites
1para{god-father} 105 Posted October 8, 2013 OK Getting closer :) OK I am filling my Dialogue and it works fine now shows "grpDelta" { if (isPlayer (leader _x)) then { _name = toArray str _x; _name set [0,"DEL"]; _name set [1,"DEL"]; _name = _name - ["DEL"]; _name = toString _name; _extrabox3Index= _extrabox3 lbAdd _name; }; } forEach allGroups; Then from my selections I am passing that to my script , but I am still getting an error _spawnpos= _this select 0; //////_hunted = getpos(leader grpDelta); //// this works fine ! /////below does not work _groupname=_this select 1 Hint format["%1", _groupname]; /// Displays grpDelta as expected _hunted = getpos (leader_groupname); //// does NOT works - not an object Share this post Link to post Share on other sites
RoryRothon 8 Posted August 11, 2018 I'm working on something similar. Ive thrown up my initServer.sqf code that you can look at and pull apart if it helps :) RAZ_fnc_spawnHuntingInfantry = { params [ "_unit", [ "_side", EAST ] ]; _sideID = _side call BIS_fnc_sideID; _faction = East; if ( _sideID == 0 ) then { _faction = _faction }; if ( _sideID == 1 ) then { _faction = West }; if ( _sideID == 2 ) then { _faction = Independent }; _pos = getPosATL _unit; _huntingGroups = _unit getVariable [ "RAZ_fnc_isBeingHunted", 0 ]; _huntingGroups = _huntingGroups + 1; _unit setVariable [ "RAZ_fnc_isBeingHunted", _huntingGroups, true ]; _spawnPos = _pos getPos [ 600, random 360 ]; _spawnPos = [ _spawnPos, 1, 1000, 1, 0, 45, 0 ] call BIS_fnc_findSafePos; _grp = [ _spawnPos, _faction, ( selectRandom (RAZ_fnc_infantryConfigs select _sideID) ) ] call BIS_fnc_spawnGroup; { _x setUnitAbility 0.1; _x setskill ["aimingAccuracy",0.01]; _x setskill ["aimingShake",0.9]; _x setskill ["aimingSpeed",0.01]; _x setskill ["Endurance",0.5]; _x setskill ["spotDistance",0.5]; _x setskill ["spotTime",0.5]; _x setskill ["courage",0.1]; _x setskill ["reloadSpeed",0.1]; if (side _x == east) then { _x unassignItem "NVGoggles_OPFOR"; _x removeItem "NVGoggles_OPFOR"; }; if (side _x == Independent) then { _x unassignItem "NVGoggles_INDEP"; _x removeItem "NVGoggles_INDEP"; }; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceOn"; } forEach units _grp; { gm addCuratorEditableObjects [ [_x], true ]; } forEach units _grp; _searchWp = [ getPos _unit, random 500, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [_searchWp, 0]; [_grp, 1] setWaypointType "SAD"; [_grp, 1] setWaypointSpeed "NORMAL"; while { ( { alive _x } count units _grp ) >= 1 } do { _timer = time + 10; if ( alive _unit ) then { _unit = _unit }; if ( !alive _unit ) then { _unit setVariable [ "RAZ_fnc_isBeingHunted", _huntingGroups, false ]; sleep 2; _unit = selectRandom ( allPlayers select { alive _x } ); while { ( count ( waypoints _grp ) ) > 0 } do { deleteWaypoint ( ( waypoints _grp ) select 0 ); }; _searchWp = [ getPos _unit, random 600, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [ _searchWp, 0 ]; [ _grp, 1 ] setWaypointType "SAD"; [ _grp, 1 ] setWaypointType "NORMAL"; }; waitUntil { sleep 120; position _unit distance _spawnpos > 30 OR time > _timer OR ({alive _x} count units _grp) isEqualTo 0 }; deleteWaypoint [_grp, 1]; _searchWp = [ getPos _unit, random 300, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [_searchWp, 1]; [_grp, 1] setWaypointType "SAD"; [_grp, 1] setWaypointSpeed "NORMAL"; }; sleep 1; _huntingGroups = _unit getVariable ["RAZ_fnc_isBeingHunted",0]; _huntingGroups = _huntingGroups - 1; _unit setVariable ["RAZ_fnc_isBeingHunted",_huntingGroups,true]; }; _spawningEnemies = [] spawn { _players = []; _spawnHunters = true; format [ "Operation Missdrop By [BZ] Pte R.Rothon" ] remoteExec ["systemChat"]; format [ "System Initialized" ] remoteExec ["systemChat"]; waitUntil {time > 0}; while { _spawnHunters } do { waitUntil { sleep 3; (count (allplayers - switchableUnits) > 0) }; _players = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHunted",0]) isEqualTo 0}; _players apply { _hunt = [_x,East] spawn RAZ_fnc_spawnHuntingInfantry; _hunt = [_x,Independent] spawn RAZ_fnc_spawnHuntingInfantry; }; }; }; // END GAME SCRIPTING ------------------------------------------------------------------------------------------------ _endGameTimer = 600; waitUntil { time > _endGameTimer && count (allPlayers select {group _x isEqualTo group (allPlayers select 0)}) isEqualTo count allPlayers; }; format ["All soldiers found. Receiving intel on extraction point, ETA 10 mins!"] remoteExec ["hint"]; sleep 600; // SPAWN EXTRACTION CHOPPER 1 Share this post Link to post Share on other sites
RoryRothon 8 Posted August 12, 2018 This might be of help too. I have compiled an array of groups from cfgGroups that works with sidID for the above function.. RAZ_fnc_infantryConfigs = [ [], [], [] ]; _allConfigGrpSides = ("true" configClasses (configFile >> "CfgGroups") apply {configname _x}); { _cfgGrpSide = _x; _allcfgGrpFactions = ("true" configClasses (configFile >> "CfgGroups" >> _cfgGrpSide) apply {configname _x}); { _cfgGrpFaction = _x; _allcfgGrpCategories = ("true" configClasses (configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction) apply {configname _x}); { _cfgGrpType = _x; _allcfgGrpCategories = ("true" configClasses (configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType) apply {configname _x}); _eastConfigs = "getNumber( _x >> 'side' ) isEqualTo 0"configClasses( configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType ); _westConfigs = "getNumber( _x >> 'side' ) isEqualTo 1"configClasses( configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType ); _indepConfigs = "getNumber( _x >> 'side' ) isEqualTo 2"configClasses( configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType ); RAZ_fnc_infantryConfigs select 0 append _eastConfigs; RAZ_fnc_infantryConfigs select 1 append _westConfigs; RAZ_fnc_infantryConfigs select 2 append _indepConfigs; } forEach _allcfgGrpCategories; } forEach _allcfgGrpFactions; } forEach _allConfigGrpSides; Share this post Link to post Share on other sites