Skip to content

Commit e14a389

Browse files
carlmyloveteran29PiG13BR
committed
Replace createVehicleCrew with fn_createCrew
Adapted from main KP-Liberation PR. Only edits were to adjust the player custom.sqf file as we use our own array setup. As the original PR says, we'll need to add the new variables in presets (KPLIB_o_crewman, KPLIB_o_pilot, KPLIB_b_crewStatic). More info here: KillahPotatoes#963 Co-Authored-By: Filip Maciejewski <4293906+veteran29@users.noreply.github.com> Co-Authored-By: PiG13BR <170875982+pig13br@users.noreply.github.com>
1 parent b4d3db0 commit e14a389

File tree

8 files changed

+105
-33
lines changed

8 files changed

+105
-33
lines changed

Missionframework/CfgFunctions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class KPLIB {
2121
class createClearance {};
2222
class createClearanceConfirm {};
2323
class createCrate {};
24+
class createCrew {};
2425
class createManagedUnit {};
2526
class crGetMulti {};
2627
class crGlobalMsg {};
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
File: fn_createCrew.sqf
3+
Author: PiG13BR - https://github.com/PiG13BR/
4+
Date: 2024-26-08
5+
Last Update: 2024-27-08
6+
License: MIT License - http://www.opensource.org/licenses/MIT
7+
8+
Description:
9+
Creates vehicle crew based on preset configuration only
10+
11+
Parameter(s):
12+
_vehicle - Vehicle to add crew
13+
_side - crew side: KPLIB_side_enemy or KPLIB_side_player (Default: KPLIB_side_enemy)
14+
15+
Returns:
16+
Array - [Crew created, group]
17+
*/
18+
19+
params[
20+
["_vehicle", objNull, [objNull]],
21+
["_side", KPLIB_side_enemy, [sideUnknown]]
22+
23+
];
24+
25+
if (isNull _vehicle) exitWith {["No vehicle provided"] call BIS_fnc_error};
26+
27+
private _typeCrew = "";
28+
29+
// Placeholder types
30+
switch (_side) do {
31+
case KPLIB_side_enemy : {
32+
_typeCrew = KPLIB_o_rifleman;
33+
};
34+
case KPLIB_side_player : {
35+
_typeCrew = KPLIB_b_crewUnit;
36+
}
37+
};
38+
39+
/*
40+
Save it for later changes
41+
switch (_side) do {
42+
case KPLIB_side_enemy : {
43+
if (_vehicle isKindOf "Air") then {
44+
_typeCrew = KPLIB_o_pilot;
45+
} else {
46+
if ((_vehicle isKindOf "Tank") || {_vehicle isKindOf "Wheeled_APC_F"}) then {
47+
_typeCrew = KPLIB_o_crewman;
48+
} else {
49+
_typeCrew = KPLIB_o_rifleman;
50+
}
51+
}
52+
};
53+
case KPLIB_side_player : {
54+
if (_vehicle isKindOf "Air") then {
55+
_typeCrew = KPLIB_b_heliPilotUnit;
56+
} else {
57+
if ((_vehicle isKindOf "Tank") || {_vehicle isKindOf "Wheeled_APC_F"}) then {
58+
_typeCrew = KPLIB_b_crewUnit;
59+
} else {
60+
_typeCrew = KPLIB_b_crewStatic;
61+
}
62+
}
63+
}
64+
};
65+
*/
66+
67+
private _grp = createGroup [_side, true];
68+
private _allCrew = [];
69+
70+
{
71+
private _crew = [_typeCrew, getPosATL _vehicle, _grp] call KPLIB_fnc_createManagedUnit;
72+
_allCrew pushBack _crew;
73+
74+
if (_x isEqualTo [-1]) then {
75+
_crew assignAsDriver _vehicle;
76+
_crew moveInDriver _vehicle;
77+
} else {
78+
_crew assignAsTurret [_vehicle, _x];
79+
_crew moveInTurret [_vehicle, _x];
80+
};
81+
} forEach (_vehicle call BIS_fnc_vehicleCrewTurrets);
82+
83+
84+
// Return all the vehicle crew and its group
85+
[_allCrew, _grp]
86+

Missionframework/functions/fn_forceBluforCrew.sqf

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
File: fn_forceBluforCrew.sqf
33
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
44
Date: 2019-11-25
5-
Last Update: 2020-05-25
5+
Last Update: 2024-11-16
66
License: MIT License - http://www.opensource.org/licenses/MIT
77
88
Description:
@@ -22,26 +22,10 @@ params [
2222

2323
if (isNull _veh) exitWith {["Null object given"] call BIS_fnc_error; false};
2424

25-
// Create regular config crew
26-
private _grp = createVehicleCrew _veh;
27-
28-
// If the config crew isn't the correct side, replace it with the crew classnames from the preset
29-
if ((side _grp) != KPLIB_side_player) then {
30-
deleteVehicleCrew _veh;
31-
32-
_grp = createGroup [KPLIB_side_player, true];
33-
while {count units _grp < 3} do {
34-
[KPLIB_b_crewUnit, getPos _veh, _grp] call KPLIB_fnc_createManagedUnit;
35-
};
36-
((units _grp) select 0) moveInDriver _veh;
37-
((units _grp) select 1) moveInGunner _veh;
38-
((units _grp) select 2) moveInCommander _veh;
39-
40-
// Delete crew which isn't in the vehicle due to e.g. no commander seat
41-
{
42-
if (isNull objectParent _x) then {deleteVehicle _x};
43-
} forEach (units _grp);
44-
};
25+
// Create crew
26+
_crew = [_veh, KPLIB_side_player] call KPLIB_fnc_createCrew;
27+
28+
_grp = _crew select 1;
4529

4630
// Set the crew to safe behaviour
4731
_grp setBehaviour "SAFE";

Missionframework/functions/fn_spawnVehicle.sqf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
File: fn_spawnVehicle.sqf
33
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
44
Date: 2019-12-03
5-
Last Update: 2023-11-14
5+
Last Update: 2024-11-16
66
License: MIT License - http://www.opensource.org/licenses/MIT
77
88
Description:
@@ -80,11 +80,7 @@ _newvehicle addItemCargoGlobal ["toolkit", 1];
8080
if (_classname in KPLIB_o_militiaVehicles) then {
8181
[_newvehicle] call KPLIB_fnc_spawnMilitiaCrew;
8282
} else {
83-
private _grp = createGroup [KPLIB_side_enemy, true];
84-
private _crew = units (createVehicleCrew _newvehicle);
85-
_crew joinSilent _grp;
86-
sleep 0.1;
87-
{_x addMPEventHandler ["MPKilled", {_this spawn kill_manager}];} forEach _crew;
83+
[_newvehicle, KPLIB_side_enemy] call KPLIB_fnc_createCrew;
8884
};
8985

9086
// Add MPKilled and GetIn EHs and enable damage again

Missionframework/presets/enemies/custom.sqf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
File: custom.sqf
33
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
44
Date: 2017-10-07
5-
Last Update: 2020-05-15
5+
Last Update: 2024-11-16
66
License: MIT License - http://www.opensource.org/licenses/MIT
77
88
Description:
@@ -33,6 +33,8 @@ KPLIB_o_aaSpecialist = "O_Soldier_AA_F"; // AA Sp
3333
KPLIB_o_medic = "O_medic_F"; // Combat Life Saver
3434
KPLIB_o_engineer = "O_engineer_F"; // Engineer
3535
KPLIB_o_paratrooper = "O_soldier_PG_F"; // Paratrooper
36+
KPLIB_o_crewman = "O_crew_F"; // Crewman
37+
KPLIB_o_pilot = "O_helipilot_F"; // Pilot
3638

3739
// Enemy vehicles used by secondary objectives.
3840
KPLIB_o_mrap = "O_MRAP_02_F"; // Ifrit

Missionframework/presets/players/custom.sqf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
File: custom.sqf
33
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
44
Date: 2017-10-07
5-
Last Update: 2020-05-25
5+
Last Update: 2024-11-16
66
License: MIT License - http://www.opensource.org/licenses/MIT
77
88
Description:
@@ -33,10 +33,11 @@ KPLIB_b_fobBuilding = "Land_Cargo_HQ_V1_F"; // This
3333
KPLIB_b_fobBox = "B_Slingload_01_Cargo_F"; // This is the FOB as a container.
3434
KPLIB_b_fobTruck = "B_Truck_01_box_F"; // This is the FOB as a vehicle.
3535
KPLIB_b_arsenal = "B_supplyCrate_F"; // This is the virtual arsenal as portable supply crates.
36-
KPLIB_b_mobileRespawn = "B_Truck_01_medical_F"; // This is the mobile respawn (and medical) truck.
36+
KPLIB_b_mobileRespawn = ["B_Truck_01_medical_F", "C_Boat_Civil_01_F", "I_Heli_light_03_unarmed_F"]; // Array of three mobile respawns: Truck, Boat, Helicopter.
3737
KPLIB_b_potato01 = "B_Heli_Transport_03_unarmed_F"; // This is Potato 01, a multipurpose mobile respawn as a helicopter.
3838
KPLIB_b_crewUnit = "B_crew_F"; // This defines the crew for vehicles.
3939
KPLIB_b_heliPilotUnit = "B_Helipilot_F"; // This defines the pilot for helicopters.
40+
KPLIB_b_crewStatic = "B_Soldier_F"; // This defines the crew for static weapons and light vehicles
4041
KPLIB_b_addHeli = "B_Heli_Light_01_F"; // These are the additional helicopters which spawn on the Freedom or at Chimera base.
4142
KPLIB_b_addBoat = "B_Boat_Transport_01_F"; // These are the boats which spawn at the stern of the Freedom.
4243
KPLIB_b_logiTruck = "B_Truck_01_transport_F"; // These are the trucks which are used in the logistic convoy system.
@@ -314,7 +315,9 @@ KPLIB_b_objectsDeco = [
314315

315316
KPLIB_b_vehSupport = [
316317
[KPLIB_b_arsenal,100,200,0],
317-
[KPLIB_b_mobileRespawn,200,0,100],
318+
[(KPLIB_b_mobileRespawn select 0),150,0,100],
319+
[(KPLIB_b_mobileRespawn select 1),200,0,100],
320+
[(KPLIB_b_mobileRespawn select 2),300,0,100],
318321
[KPLIB_b_fobBox,300,500,0],
319322
[KPLIB_b_fobTruck,300,500,75],
320323
[KPLIB_b_smallStorage,0,0,0],

Missionframework/scripts/server/battlegroup/spawn_air.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ for "_i" from 1 to _planes_number do {
1616
_spawnPos = markerPos _spawnPoint;
1717
_spawnPos = [(((_spawnPos select 0) + 500) - random 1000), (((_spawnPos select 1) + 500) - random 1000), 200];
1818
_plane = createVehicle [_class, _spawnPos, [], 0, "FLY"];
19-
createVehicleCrew _plane;
19+
[_plane, KPLIB_side_enemy] call KPLIB_fnc_createCrew;
2020
_plane flyInHeight (120 + (random 180));
2121
_plane addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
2222
[_plane] call KPLIB_fnc_addObjectInit;

Missionframework/scripts/server/patrols/send_paratroopers.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (isNull _chopper_type) then {
2020
};
2121

2222
_newvehicle = createVehicle [_chopper_type, markerpos _spawnsector, [], 0, "FLY"];
23-
createVehicleCrew _newvehicle;
23+
[_newvehicle, KPLIB_side_enemy] call KPLIB_fnc_createCrew;
2424
sleep 0.1;
2525

2626
_pilot_group = createGroup [KPLIB_side_enemy, true];

0 commit comments

Comments
 (0)