Starker 8 Posted April 21, 2018 Is the following possible to do with a trigger and scripts? 1 Duplicate a random unit or a group of units from a list of variable names in a radius around the player 2 Tell the unit to attack the player 3 Repeat the above steps when the spawned unit is killed This should continue indefinitely as long as the spawned units continue to be killed. I have already tried this: Custom Dynamic AI Spawn System appears to only work with the default units. About half the time it doesn't work at all. I assume this is because it is very outdated. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted April 22, 2018 You can use something like this: //init.sqf or wherever you seem fit missionNamespace setVariable ["GOM_fnc_respawnAIEnabled",true,true];//enables the AI respawning GOM_fnc_attackAndRespawn = { params ["_unit","_side","_target",["_radius",150]]; _unit setVariable ["GOM_fnc_attackAndRespawnParams",_this]; _unit addEventHandler ["Killed",{ params ["_unit"]; if !(GOM_fnc_respawnAIEnabled) exitWith {false}; _params = _unit getVariable ["GOM_fnc_attackAndRespawnParams",[]]; if (_params isEqualTo []) exitWith {false}; _params params ["_unit","_side","_target",["_respawnDelay",5],["_radius",150]]; _newUnit = (createGroup _side) createUnit [typeof _unit, (_target getPos [_radius,random 360]), [], 0, "NONE"]; _params set [0,_newUnit]; _reAdd = _params call GOM_fnc_attackAndRespawn; _newUnit doMove getPosATL _target; true }]; true }; Now in the AI units init field: _respawn = [this,side this,player,100] call GOM_fnc_attackAndRespawn; This will make the AI respawn at 100m randomly around the players position. If you want the respawning to stop simply use this: missionNamespace setVariable ["GOM_fnc_respawnAIEnabled",false,true]; You can also randomize the type of the respawning unit by adjusting the createUnit line. Cheers 1 Share this post Link to post Share on other sites
Starker 8 Posted May 25, 2018 I created "init.sqf" with the your recommended script in it and placed it in "C:\Users\(username)\Documents\Arma 3\mpmissions\(mission name)" I placed "_respawn = [this,side this,player,100] call GOM_fnc_attackAndRespawn;" in "Init" for a fire team (group of four soldiers). I then started the scenario, playing as a soldier, killed them all, and none appeared to respawn. I placed "_respawn = [this,side this,player,100] call GOM_fnc_attackAndRespawn;" into "init" of a single soldier. I started the scenario and killed him and he did not respawn. I really appreciate your help and I will continue to test this in case I made a mistake. Share this post Link to post Share on other sites
Starker 8 Posted May 26, 2018 I tried putting the script into a trigger that is activated by player presence. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted May 26, 2018 It won't work due to the initialization order. When the function is called during object initialization, it hasn't been defined yet, since that only happens inside init.sqf, which will be initialized at a later time. To fix this only a few adjustments are needed: init.sqf: missionNamespace setVariable ["GOM_fnc_respawnAIEnabled",true,true];//enables the AI respawning GOM_fnc_attackAndRespawn = { params ["_unit","_side","_target",["_radius",150]]; _unit setVariable ["GOM_fnc_attackAndRespawnParams",_this]; _unit addEventHandler ["Killed",{ params ["_unit"]; if !(GOM_fnc_respawnAIEnabled) exitWith {false}; _params = _unit getVariable ["GOM_fnc_attackAndRespawnParams",[]]; if (_params isEqualTo []) exitWith {false}; _params params ["_unit","_side","_target",["_respawnDelay",5],["_radius",150]]; _newUnit = (createGroup _side) createUnit [typeof _unit, (_target getPos [_radius,random 360]), [], 0, "NONE"]; _params set [0,_newUnit]; _reAdd = _params call GOM_fnc_attackAndRespawn; _newUnit doMove getPosATL _target; true }]; true }; { _attack = [_x,side _x,player] call GOM_fnc_attackAndRespawn; } forEach (allUnits select {_x getVariable ["GOM_fnc_attackAndRespawnUnit",false]}); unit init field: this setVariable ["GOM_fnc_attackAndRespawnUnit",true,true]; Most likely the better way to handle this without defining your own function library. Cheers 1 Share this post Link to post Share on other sites
Starker 8 Posted May 26, 2018 The new script works for individual infantry. Groups of units will not respawn if "this setVariable ["GOM_fnc_attackAndRespawnUnit",true,true];" is placed in the init for the whole group. Crewed vehicles will not respawn when "this setVariable ["GOM_fnc_attackAndRespawnUnit",true,true];" is placed in their "Init". Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted May 26, 2018 42 minutes ago, Starker said: The new script works for individual infantry. Groups of units will not respawn if "this setVariable ["GOM_fnc_attackAndRespawnUnit",true,true];" is placed in the init for the whole group. Crewed vehicles will not respawn when "this setVariable ["GOM_fnc_attackAndRespawnUnit",true,true];" is placed in their "Init". The snippets provided were examples on how this could work on a single unit. You need to adapt this for your own needs and purposes. If you want someone to script a solution for you I recommend a more appropriate forum. Cheers Share this post Link to post Share on other sites