Replace more of createUnit with F_createManagedUnit

This commit is contained in:
Filip Maciejewski 2019-10-05 14:45:33 +02:00
parent f2bd5ae71a
commit 3aa06587ad
7 changed files with 26 additions and 17 deletions

View File

@ -26,7 +26,7 @@ while { GRLIB_endgame == 0 } do {
if ( random 100 < 33) then {
_civnumber = 1 + (floor (random 2));
while { count units _grp < _civnumber } do {
(selectRandom civilians) createUnit [ markerpos _spawnsector, _grp, "this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
[selectRandom civilians, markerPos _spawnsector, _grp, "PRIVATE", 0.5] call F_createManagedUnit;
};
_grpspeed = "LIMITED";
} else {
@ -39,7 +39,7 @@ while { GRLIB_endgame == 0 } do {
_spawnpos = getpos _nearestroad;
(selectRandom civilians) createUnit [_spawnpos, _grp, "this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
[selectRandom civilians, _spawnpos, _grp, "PRIVATE", 0.5] call F_createManagedUnit;
_civveh = (selectRandom civilian_vehicles) createVehicle _spawnpos;
_civveh setpos _spawnpos;
_civveh addMPEventHandler ['MPKilled', {_this spawn kill_manager}];
@ -117,4 +117,4 @@ while { GRLIB_endgame == 0 } do {
};
sleep 150 + (random (150));
};
};

View File

@ -30,7 +30,7 @@ while { GRLIB_endgame == 0 } do {
_grp = createGroup [GRLIB_side_enemy, true];
_squad = ["army"] call F_getAdaptiveSquadComp;
{
_x createUnit [_sector_spawn_pos, _grp,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
[_x, _sector_spawn_pos, _grp, "PRIVATE", 0.5] call F_createManagedUnit;
} foreach _squad;
} else {
@ -80,4 +80,4 @@ while { GRLIB_endgame == 0 } do {
sleep (600.0 / GRLIB_difficulty_modifier);
};
};
};

View File

@ -21,7 +21,7 @@ _newvehicle addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
{_x addMPEventHandler ["MPKilled", {_this spawn kill_manager}];} forEach (crew _newvehicle);
while {(count (units _para_group)) < 8} do {
opfor_paratrooper createUnit [getmarkerpos _spawnsector, _para_group, "this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]"];
[opfor_paratrooper, markerPos _spawnsector, _para_group] call F_createManagedUnit;
};
{removeBackpack _x; _x addBackPack "B_parachute"; _x moveInCargo _newvehicle;} forEach (units _para_group);

View File

@ -76,7 +76,9 @@ _waypoint setWaypointType "CYCLE";
_waypoint setWaypointCompletionRadius 50;
private _troops_group = createGroup [GRLIB_side_enemy, true];
{_x createUnit [_spawnpos, _troops_group,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];} foreach (["army"] call F_getAdaptiveSquadComp);
{
[_x, _spawnpos, _troops_group, "PRIVATE", 0.5] call F_createManagedUnit;
} foreach (["army"] call F_getAdaptiveSquadComp);
{_x moveInCargo _troop_vehicle} foreach (units _troops_group);
private _convoy_marker = createMarkerLocal [ format [ "convoymarker%1", round time], getpos _transport_vehicle ];

View File

@ -85,10 +85,10 @@ while {(count _idxselected) < _defenders_amount && (count _idxselected) < (count
];
_nextpos = [((_base_position select 0) + (_nextpos select 0)), ((_base_position select 1) + (_nextpos select 1)), (_nextpos select 2)];
_nextclass createUnit [_nextpos, _grpdefenders, "nextdefender = this; this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
nextdefender setdir _nextdir;
nextdefender setpos _nextpos;
[nextdefender] spawn building_defence_ai;
private _nextDefender = [_nextclass, _nextpos, _grpdefenders, "PRIVATE", 0.5] call F_createManagedUnit;
_nextDefender setdir _nextdir;
_nextDefender setpos _nextpos;
[_nextDefender] spawn building_defence_ai;
} forEach _idxselected;
private _sentryMax = ceil ((3 + (floor (random 4))) * (sqrt (GRLIB_unitcap)));
@ -96,7 +96,7 @@ private _sentryMax = ceil ((3 + (floor (random 4))) * (sqrt (GRLIB_unitcap)));
_grpsentry = createGroup [GRLIB_side_enemy, true];
_base_sentry_pos = [(_base_position select 0) + ((_base_corners select 0) select 0), (_base_position select 1) + ((_base_corners select 0) select 1), 0];
for [{_idx=0}, {_idx < _sentryMax}, {_idx=_idx+1}] do {
opfor_sentry createUnit [_base_sentry_pos, _grpsentry,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
[opfor_sentry, _base_sentry_pos, _grpsentry, "PRIVATE", 0.5] call F_createManagedUnit;
};
while {(count (waypoints _grpsentry)) != 0} do {deleteWaypoint ((waypoints _grpsentry) select 0);};

View File

@ -17,10 +17,13 @@ _helofire setpos (getpos _helowreck);
private _pilotsGrp = createGroup [GRLIB_side_enemy, true];
private _pilotsPos = (getpos _helowreck) getPos [25, random 360];
pilot_classname createUnit [ _pilotsPos, _pilotsGrp,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
[pilot_classname, _pilotsPos, _pilotsGrp, "PRIVATE", 0.5] call F_createManagedUnit;
sleep 0.2;
pilot_classname createUnit [_pilotsPos getPos [1, random 360], _pilotsGrp,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
[pilot_classname, _pilotsPos getPos [1, random 360], _pilotsGrp, "PRIVATE", 0.5] call F_createManagedUnit;
sleep 2;
private _pilotUnits = units _pilotsGrp;
{
[ _x, true ] spawn prisonner_ai;
@ -36,7 +39,9 @@ private _patrolcorners = [
[ (getpos _helowreck select 0) - 40, (getpos _helowreck select 1) + 40, 0 ]
];
{ _x createUnit [ _patrolcorners select 0, _grppatrol,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"]; } foreach (["army"] call F_getAdaptiveSquadComp);
{
[_x, _patrolcorners select 0, _grppatrol, "PRIVATE", 0.5] call F_createManagedUnit;
} foreach (["army"] call F_getAdaptiveSquadComp);
while {(count (waypoints _grppatrol)) != 0} do {deleteWaypoint ((waypoints _grppatrol) select 0);};
{
@ -56,7 +61,7 @@ private _grpsentry = createGroup [GRLIB_side_enemy, true];
private _nbsentry = 2 + (floor (random 3));
for [ {_idx=0},{_idx < _nbsentry},{_idx=_idx+1} ] do {
opfor_sentry createUnit [_pilotsPos getPos [1, random 360], _grpsentry,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
[opfor_sentry, _pilotsPos getPos [1, random 360], _grpsentry, "PRIVATE", 0.5] call F_createManagedUnit;
};
(leader _grpsentry) setDir (random 360);

View File

@ -8,7 +8,9 @@ if ( _ownership != GRLIB_side_enemy ) exitWith {};
if ( GRLIB_blufor_defenders ) then {
_grp = creategroup [GRLIB_side_friendly, true];
{ _x createUnit [ _thispos, _grp,'this addMPEventHandler ["MPKilled", {_this spawn kill_manager}]']; } foreach blufor_squad_inf;
{
[_x, _thispos, _grp] call F_createManagedUnit;
} foreach blufor_squad_inf;
sleep 3;
_grp setBehaviour "COMBAT";
};