Skip to content

Commit

Permalink
retry logic for creation of units at events
Browse files Browse the repository at this point in the history
  • Loading branch information
theace0296 committed Nov 12, 2021
1 parent 3571b6d commit 9e2f8a7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
2 changes: 0 additions & 2 deletions RandFramework/Global/common/fn_createUnit.sqf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// private _fnc_scriptName = "TRGM_GLOBAL_fnc_createUnit";
params [["_group", grpNull, [grpNull]], ["_type", nil, [""]], ["_position", nil, [nil, objNull, grpNull, []]], ["_markers", [], [[]]], ["_placement", 0, [0]], ["_special", "NONE", [""]], ["_disableDynamicShowHide", false, [false]]];



if (isNull _group || _type isEqualTo "" || isNil "_position") exitWith {objNull};

if !(_markers isEqualType []) then {
Expand Down
30 changes: 30 additions & 0 deletions RandFramework/Server/objectives/fn_setDownConvoyEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ while {_iteration <= 3} do {

private _group = createGroup civilian;
private _downedCiv = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],0,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
private _iterations = 0;
while {isNil "_downedCiv" || {isNull _downedCiv}} do {
_downedCiv = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],0,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCiv setDamage 0.8;
[_downedCiv, "Acts_CivilInjuredGeneral_1"] remoteExec ["switchMove", 0];

Expand All @@ -143,6 +149,12 @@ while {_iteration <= 3} do {
};

private _downedCivMedic = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],0,"CAN_COLLIDE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCivMedic" || {isNull _downedCivMedic}} do {
_downedCivMedic = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],0,"CAN_COLLIDE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCivMedic playmove "Acts_TreatingWounded02";
_downedCivMedic disableAI "anim";
_downedCivMedic attachTo [_downedCiv, [0.5,-0.3,-0.1]];
Expand Down Expand Up @@ -181,11 +193,23 @@ while {_iteration <= 3} do {

if (_iteration isEqualTo 1) then {
private _downedCivMedic2 = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],8,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCivMedic2" || {isNull _downedCivMedic2}} do {
_downedCivMedic2 = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],8,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCivMedic2 playmove "Acts_CivilListening_2";
_downedCivMedic2 disableAI "anim";
_downedCivMedic2 addEventHandler ["killed", {_this spawn TRGM_SERVER_fnc_paramedicKilled;}]; //ParamedicKilled

private _downedCiv2 = [_group, selectRandom (call FriendlyCheckpointUnits),([_downedCivMedic2] call TRGM_GLOBAL_fnc_getRealPos),[],2,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCiv2" || {isNull _downedCiv2}} do {
_downedCiv2 = [_group, selectRandom (call FriendlyCheckpointUnits),([_downedCivMedic2] call TRGM_GLOBAL_fnc_getRealPos),[],2,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCiv2 playmove "Acts_CivilTalking_2";
_downedCiv2 disableAI "anim";
_downedCiv2 addEventHandler ["killed", {_this spawn TRGM_SERVER_fnc_civKilled;}]; //ParamedicKilled
Expand All @@ -197,6 +221,12 @@ while {_iteration <= 3} do {
};
if (_iteration isEqualTo 2) then {
private _downedCiv3 = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],25,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCiv3" || {isNull _downedCiv3}} do {
_downedCiv3 = [_group, selectRandom (call FriendlyCheckpointUnits),_backOfVehArea,[],25,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCiv3 playmove "Acts_CivilShocked_1";
_downedCiv3 disableAI "anim";
_downedCiv3 setDir (floor(random 360));
Expand Down
6 changes: 6 additions & 0 deletions RandFramework/Server/objectives/fn_setDownedChopperEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ while {_iCount > 0} do {
private _flatPos2 = [_flatPos , 10, 25, 3, 0, 0.5, 0,[],[[0,0,0],[0,0,0]],_sVictim] call TRGM_GLOBAL_fnc_findSafePos;
private _group = createGroup civilian;
private _downedCiv = [_group, _sVictim,_flatPos2,[],0,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
private _iterations = 0;
while {isNil "_downedCiv" || {isNull _downedCiv}} do {
_downedCiv = [_group, _sVictim,_flatPos2,[],0,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};

[_downedCiv,[localize "STR_TRGM2_fnpostinit_JoinGroup",{
private _civ = _this select 0;
Expand Down
42 changes: 42 additions & 0 deletions RandFramework/Server/objectives/fn_setMedicalEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ while {_iteration <= 2} do {
//use these to lay down guys, cones, rubbish, barriers, lights etc...
private _group = createGroup civilian;
private _downedCiv = [_group, selectRandom sCivilian,_backOfVehArea,[],0,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
private _iterations = 0;
while {isNil "_downedCiv" || {isNull _downedCiv}} do {
_downedCiv = [_group, selectRandom sCivilian,_backOfVehArea,[],0,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCiv setDamage 0.8;
[_downedCiv, "Acts_CivilInjuredGeneral_1"] remoteExec ["switchMove", 0];

Expand All @@ -198,6 +204,12 @@ while {_iteration <= 2} do {

//Paramedics object1 attachTo [object2, offset, memPoint]
private _downedCivMedic = [_group, selectRandom Paramedics,_backOfVehArea,[],0,"CAN_COLLIDE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCivMedic" || {isNull _downedCivMedic}} do {
_downedCivMedic = [_group, selectRandom Paramedics,_backOfVehArea,[],0,"CAN_COLLIDE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCivMedic playmove "Acts_TreatingWounded02";
_downedCivMedic disableAI "anim";
_downedCivMedic attachTo [_downedCiv, [0.5,-0.3,-0.1]];
Expand Down Expand Up @@ -229,11 +241,23 @@ while {_iteration <= 2} do {
private _Crater = createVehicle ["Crater", _backOfVehArea, [], 20, "CAN_COLLIDE"];

private _downedCivMedic2 = [_group, selectRandom sCivilian,_backOfVehArea,[],8,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCivMedic2" || {isNull _downedCivMedic2}} do {
_downedCivMedic2 = [_group, selectRandom sCivilian,_backOfVehArea,[],8,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCivMedic2 playmove "Acts_CivilListening_2";
_downedCivMedic2 disableAI "anim";
_downedCivMedic2 addEventHandler ["killed", {_this spawn TRGM_SERVER_fnc_paramedicKilled;}]; //ParamedicKilled

private _downedCiv2 = [_group, selectRandom Paramedics,([_downedCivMedic2] call TRGM_GLOBAL_fnc_getRealPos),[],2,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCiv2" || {isNull _downedCiv2}} do {
_downedCiv2 = [_group, selectRandom Paramedics,([_downedCivMedic2] call TRGM_GLOBAL_fnc_getRealPos),[],2,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCiv2 playmove "Acts_CivilTalking_2";
_downedCiv2 disableAI "anim";
_downedCiv2 addEventHandler ["killed", {_this spawn TRGM_SERVER_fnc_civKilled;}]; //ParamedicKilled
Expand All @@ -244,13 +268,25 @@ while {_iteration <= 2} do {
};
if (_iteration isEqualTo 2) then {
_downedCiv2 = [_group, selectRandom sCivilian,_backOfVehArea,[],8,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCiv2" || {isNull _downedCiv2}} do {
_downedCiv2 = [_group, selectRandom sCivilian,_backOfVehArea,[],8,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCiv2 playmove "Acts_CivilHiding_2";
_downedCiv2 disableAI "anim";
_downedCiv2 addEventHandler ["killed", {_this spawn TRGM_SERVER_fnc_civKilled;}]; //ParamedicKilled
_directionFromCiv2ToMed2 = [_downedCiv2, _downedCiv] call BIS_fnc_DirTo;
_downedCiv2 setDir _directionFromCiv2ToMed2;

private _downedCiv3 = [_group, selectRandom sCivilian,_backOfVehArea,[],25,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_downedCiv3" || {isNull _downedCiv3}} do {
_downedCiv3 = [_group, selectRandom sCivilian,_backOfVehArea,[],25,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_downedCiv3 playmove "Acts_CivilShocked_1";
_downedCiv3 disableAI "anim";
_downedCiv3 setDir (floor(random 360));
Expand Down Expand Up @@ -301,6 +337,12 @@ while {_iteration <= 2} do {
private _flatPosPolice1 = [_vehPos , 30, 50, 10, 0, 0.5, 0,[],[[0,0,0],[0,0,0]],selectRandom PoliceVehicles] call TRGM_GLOBAL_fnc_findSafePos;
private _carPolice = createVehicle [selectRandom PoliceVehicles, _flatPosPolice1, [], 0, "NONE"];
private _manPolice = [createGroup civilian, selectRandom Police,([_carPolice] call TRGM_GLOBAL_fnc_getRealPos),[],15,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
_iterations = 0;
while {isNil "_manPolice" || {isNull _manPolice}} do {
_manPolice = [createGroup civilian, selectRandom Police,([_carPolice] call TRGM_GLOBAL_fnc_getRealPos),[],15,"NONE"] call TRGM_GLOBAL_fnc_createUnit;
if (_iterations > 5) exitWith {};
_iterations = _iterations + 1;
};
_manPolice setDir (floor(random 360));
[_manPolice] call TRGM_GLOBAL_fnc_makeNPC;
};
Expand Down

0 comments on commit 9e2f8a7

Please sign in to comment.