sabot10.5mm 47 Posted May 7, 2017 Spoiler _myGroup = createGroup west; _waypoint0 = _myGroup addwaypoint[getmarkerpos"West_WP1",0]; _waypoint0 setwaypointtype"Move"; _waypoint1 = _myGroup addwaypoint[getmarkerpos"West_WP2",0]; _waypoint1 setwaypointtype"Move"; _waypoint2 = _myGroup addwaypoint[getmarkerpos"West_WP3",0]; _waypoint2 setwaypointtype"SAD"; _waypoint3 = _myGroup addwaypoint[getmarkerpos"West_WP4",0]; _waypoint3 setwaypointtype"CYCLE"; _position = [getMarkerPos "s1", random 5, random 5 ] call BIS_fnc_relPos; { _soldierName = _x select 0; _soldierRank = _x select 1; //Create unit _tempSoldier = _myGroup createUnit [ "B_Protagonist_VR_F", _position, [], 0, "NONE" ]; //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; Grpgary = group _tempSoldier; { _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 ] ]; }forEach [ //[ soldier name, soldier rank ] [ "soldier1", "SERGEANT" ], [ "soldier2", "PRIVATE" ], [ "soldier3", "PRIVATE" ], [ "soldier4", "PRIVATE" ], [ "soldier5", "PRIVATE" ], [ "soldier6", "PRIVATE" ], [ "soldier7", "PRIVATE" ], [ "soldier8", "PRIVATE" ], [ "soldier8", "PRIVATE" ], [ "soldier10", "PRIVATE" ], [ "soldier11", "PRIVATE" ], [ "soldier12", "PRIVATE" ], [ "soldier13", "PRIVATE" ] ]; { // forEach removeHeadgear _x: removeGoggles _x; removeUniform _x; removeVest _x; removeBackpack _x; removeAllWeapons _x: removeAllAssignedItems _x; _x forceAddUniform "U_B_Protagonist_VR"; //_x addHeadgear "H_PilotHelmetFighter_O"; //_x addBackpack "B_FieldPack_blk"; //_x addVest "V_PlateCarrier1_blk"; _x addMagazines ["30Rnd_45ACP_Mag_SMG_01_Tracer_green",15]; //_x addMagazine [color="#008000"][ "HandGrenade", 3 ];[/color] _x addWeapon "SMG_01_Holo_pointer_snds_F"; _x setSpeaker "NoVoice"; }forEach (units _mygroup); this script spawns soldiers on a marker named s1 and it works well, but there are a few things i would like to do to keep the action going. for instance my current respawn script only works by waiting until the group count gets to 3, and the respawns the entire group. Spoiler private["_Count"]; while{true}do{ //infinite loop _Count = {alive _x} count units Grpgary; if(_Count <= 3)then{ _nul = [] execVM "scripts\SpawnB.sqf"; }; sleep 4; //loops in 4s cycle }; kind of stuck here on this idea of respawning individual ai killed instead of waiting for most of group the to be killed before respawning an entire group. any help appreciated Share this post Link to post Share on other sites
BlindNavigator 4 Posted May 7, 2017 Have you checked out event handlers, like the "Killed" for example: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed You can put it on the objects and do something like this: SOLDIER addEventHandler ["Killed",{ YOUR_FUNCTION }]; It will trigger once the SOLDIER dies and run YOUR_FUNCTION which spawns a new one (soldier). The group cant be _local though I'm pretty sure. You can put it in a forEach-loop too, and you wont be needing any while loops since the event handler will do the triggering. I would probably also create a new, separate .sqf called something like setUpSoldier.sqf where I put all the skill and gear stuff and later on call it (or execVM). The function can be defined like this, in init.sqf for example: YOUR_FUNCTION = { ... _tempSoldier = _myGroup createUnit [ "B_Protagonist_VR_F", _position, [], 0, "NONE" ]; ... }; That way you can always reach it by: [] call YOUR_FUNCTION; // call can't use sleep or while loops. or [] spawn YOUR_FUNCTION; // Same rules as execVM, sleep and loops can be used. This is probably not the smoothest way to do what you want. And you would have to change the structure of the scripting quite a bit. At least it gives an alternative! Share this post Link to post Share on other sites
sabot10.5mm 47 Posted May 9, 2017 On 5/7/2017 at 4:33 PM, BlindNavigator said: Have you checked out event handlers, like the "Killed" for example: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed You can put it on the objects and do something like this: SOLDIER addEventHandler ["Killed",{ YOUR_FUNCTION }]; It will trigger once the SOLDIER dies and run YOUR_FUNCTION which spawns a new one (soldier). The group cant be _local though I'm pretty sure. You can put it in a forEach-loop too, and you wont be needing any while loops since the event handler will do the triggering. I would probably also create a new, separate .sqf called something like setUpSoldier.sqf where I put all the skill and gear stuff and later on call it (or execVM). The function can be defined like this, in init.sqf for example: YOUR_FUNCTION = { ... _tempSoldier = _myGroup createUnit [ "B_Protagonist_VR_F", _position, [], 0, "NONE" ]; ... }; That way you can always reach it by: [] call YOUR_FUNCTION; // call can't use sleep or while loops. or [] spawn YOUR_FUNCTION; // Same rules as execVM, sleep and loops can be used. This is probably not the smoothest way to do what you want. And you would have to change the structure of the scripting quite a bit. At least it gives an alternative! Thanks I will look into this.. is it ok to have 50 EHs? Silly question.... for some Share this post Link to post Share on other sites
BlindNavigator 4 Posted May 10, 2017 21 hours ago, battlecarrysabot said: Thanks I will look into this.. is it ok to have 50 EHs? Silly question.... for some 50? I am not the one to say. But I'm guessing that the actual AI of the soldiers (especially when engaged) is eating up far more resources than the EH tied to them. Share this post Link to post Share on other sites
pierremgi 4850 Posted May 10, 2017 I wrote a little script on your idea. 1 Share this post Link to post Share on other sites
sabot10.5mm 47 Posted May 11, 2017 On May 10, 2017 at 3:11 PM, pierremgi said: I wrote a little script on your idea. could you comment each command on your script to make it easy to understand? Share this post Link to post Share on other sites
pierremgi 4850 Posted May 12, 2017 5 hours ago, battlecarrysabot said: could you comment each command on your script to make it easy to understand? params is useful to define/check/set by default parameters entry Then a little function inside the main one, frequently called, to determine what kind of "position" it is. Structure: call {if exitWith; if exitWtih, default} this returns [0,0,0] by default, treated later; Then a little code to make something coherent between the number of sides and the number of positions for respawn (you don't want everyone to respawn at the same place (but possible if you repeat the same marker). See isEqualType and pushback I obtain an array looking like [side1,position1,side2,position2,....] Then, I'm working into a endless loop (refreshing) all infantry units, on foot (select {isNull objectParent _x}) and not player. with a simple variable attached to the unit, I can check if this unit is already treated with my script if (!(_x getVariable ["MGIrespOK",false]) ... and then, avoid to treat the same unit twice! Then, the core of treatment for each unit: essentially an event handler killed which trigger a code only when the unit die. Event handlers are very powerful tools. I pass a maximum data on the unit (setvariable). It's convenient to refer to the same variable name but attached to each unit. I use the set/getUnitLoadout commands (recorded at start for initial loadout, or at death (EH firing) for dead loadout. Then I create a unit with createUnit + position, direction... I could add the behavior and skill of the unit as well.... not yet. All commands are here. 1 Share this post Link to post Share on other sites
sabot10.5mm 47 Posted May 12, 2017 10 hours ago, pierremgi said: params is useful to define/check/set by default parameters entry Then a little function inside the main one, frequently called, to determine what kind of "position" it is. Structure: call {if exitWith; if exitWtih, default} this returns [0,0,0] by default, treated later; Then a little code to make something coherent between the number of sides and the number of positions for respawn (you don't want everyone to respawn at the same place (but possible if you repeat the same marker). See isEqualType and pushback I obtain an array looking like [side1,position1,side2,position2,....] Then, I'm working into a endless loop (refreshing) all infantry units, on foot (select {isNull objectParent _x}) and not player. with a simple variable attached to the unit, I can check if this unit is already treated with my script if (!(_x getVariable ["MGIrespOK",false]) ... and then, avoid to treat the same unit twice! Then, the core of treatment for each unit: essentially an event handler killed which trigger a code only when the unit die. Event handlers are very powerful tools. I pass a maximum data on the unit (setvariable). It's convenient to refer to the same variable name but attached to each unit. I use the set/getUnitLoadout commands (recorded at start for initial loadout, or at death (EH firing) for dead loadout. Then I create a unit with createUnit + position, direction... I could add the behavior and skill of the unit as well.... not yet. All commands are here. thanks this help me understand functions better.. i know there is the wiki page, but their examples are lacking for a lot of function commands and even sqf commands. 1 Share this post Link to post Share on other sites