diff --git a/Missionframework/CfgFunctions.hpp b/Missionframework/CfgFunctions.hpp index 2749daa07..3ce64d607 100644 --- a/Missionframework/CfgFunctions.hpp +++ b/Missionframework/CfgFunctions.hpp @@ -20,6 +20,7 @@ class KPLIB { class createClearance {}; class createClearanceConfirm {}; class createCrate {}; + class createCrew {}; class createManagedUnit {}; class crGetMulti {}; class crGlobalMsg {}; diff --git a/Missionframework/functions/fn_createCrew.sqf b/Missionframework/functions/fn_createCrew.sqf new file mode 100644 index 000000000..45086bbb4 --- /dev/null +++ b/Missionframework/functions/fn_createCrew.sqf @@ -0,0 +1,86 @@ +/* + File: fn_createCrew.sqf + Author: PiG13BR - https://github.com/PiG13BR/ + Date: 2024-26-08 + Last Update: 2024-27-08 + License: MIT License - http://www.opensource.org/licenses/MIT + + Description: + Creates vehicle crew based on preset configuration only + + Parameter(s): + _vehicle - Vehicle to add crew + _side - crew side: KPLIB_side_enemy or KPLIB_side_player (Default: KPLIB_side_enemy) + + Returns: + Array - [Crew created, group] +*/ + +params[ + ["_vehicle", objNull, [objNull]], + ["_side", KPLIB_side_enemy, [sideUnknown]] + +]; + +if (isNull _vehicle) exitWith {["No vehicle provided"] call BIS_fnc_error}; + +private _typeCrew = ""; + +// Placeholder types +switch (_side) do { + case KPLIB_side_enemy : { + _typeCrew = KPLIB_o_rifleman; + }; + case KPLIB_side_player : { + _typeCrew = KPLIB_b_crewUnit; + } +}; + +/* +Save it for later changes +switch (_side) do { + case KPLIB_side_enemy : { + if (_vehicle isKindOf "Air") then { + _typeCrew = KPLIB_o_pilot; + } else { + if ((_vehicle isKindOf "Tank") || {_vehicle isKindOf "Wheeled_APC_F"}) then { + _typeCrew = KPLIB_o_crewman; + } else { + _typeCrew = KPLIB_o_rifleman; + } + } + }; + case KPLIB_side_player : { + if (_vehicle isKindOf "Air") then { + _typeCrew = KPLIB_b_heliPilotUnit; + } else { + if ((_vehicle isKindOf "Tank") || {_vehicle isKindOf "Wheeled_APC_F"}) then { + _typeCrew = KPLIB_b_crewUnit; + } else { + _typeCrew = KPLIB_b_crewStatic; + } + } + } +}; +*/ + +private _grp = createGroup [_side, true]; +private _allCrew = []; + +{ + private _crew = [_typeCrew, getPosATL _vehicle, _grp] call KPLIB_fnc_createManagedUnit; + _allCrew pushBack _crew; + + if (_x isEqualTo [-1]) then { + _crew assignAsDriver _vehicle; + _crew moveInDriver _vehicle; + } else { + _crew assignAsTurret [_vehicle, _x]; + _crew moveInTurret [_vehicle, _x]; + }; +} forEach (_vehicle call BIS_fnc_vehicleCrewTurrets); + + +// Return all the vehicle crew and its group +[_allCrew, _grp] + diff --git a/Missionframework/functions/fn_forceBluforCrew.sqf b/Missionframework/functions/fn_forceBluforCrew.sqf index bebf29b38..56c9393fd 100644 --- a/Missionframework/functions/fn_forceBluforCrew.sqf +++ b/Missionframework/functions/fn_forceBluforCrew.sqf @@ -2,7 +2,7 @@ File: fn_forceBluforCrew.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-11-25 - Last Update: 2020-05-25 + Last Update: 2024-08-27 License: MIT License - http://www.opensource.org/licenses/MIT Description: @@ -22,26 +22,10 @@ params [ if (isNull _veh) exitWith {["Null object given"] call BIS_fnc_error; false}; -// Create regular config crew -private _grp = createVehicleCrew _veh; - -// If the config crew isn't the correct side, replace it with the crew classnames from the preset -if ((side _grp) != KPLIB_side_player) then { - {deleteVehicle _x} forEach (units _grp); - - _grp = createGroup [KPLIB_side_player, true]; - while {count units _grp < 3} do { - [KPLIB_b_crewUnit, getPos _veh, _grp] call KPLIB_fnc_createManagedUnit; - }; - ((units _grp) select 0) moveInDriver _veh; - ((units _grp) select 1) moveInGunner _veh; - ((units _grp) select 2) moveInCommander _veh; - - // Delete crew which isn't in the vehicle due to e.g. no commander seat - { - if (isNull objectParent _x) then {deleteVehicle _x}; - } forEach (units _grp); -}; +// Create crew +_crew = [_veh, KPLIB_side_player] call KPLIB_fnc_createCrew; + +_grp = _crew select 1; // Set the crew to safe behaviour _grp setBehaviour "SAFE"; diff --git a/Missionframework/functions/fn_spawnVehicle.sqf b/Missionframework/functions/fn_spawnVehicle.sqf index 6c9454703..7a0579f92 100644 --- a/Missionframework/functions/fn_spawnVehicle.sqf +++ b/Missionframework/functions/fn_spawnVehicle.sqf @@ -2,7 +2,7 @@ File: fn_spawnVehicle.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-12-03 - Last Update: 2023-10-28 + Last Update: 2024-08-27 License: MIT License - http://www.opensource.org/licenses/MIT Description: @@ -80,15 +80,7 @@ if (_classname in KPLIB_o_helicopters) then { if (_classname in KPLIB_o_militiaVehicles) then { [_newvehicle] call KPLIB_fnc_spawnMilitiaCrew; } else { - private _grp = createGroup [KPLIB_side_enemy, true]; - private _crew = units (createVehicleCrew _newvehicle); - _crew joinSilent _grp; - { - _x addMPEventHandler ["MPKilled", { - params ["_unit", "_killer"]; - ["KPLIB_manageKills", [_unit, _killer]] call CBA_fnc_localEvent; - }]; - } forEach _crew; + [_newvehicle, KPLIB_side_enemy] call KPLIB_fnc_createCrew; }; // Add Killed and GetIn EHs and enable damage again diff --git a/Missionframework/presets/enemies/custom.sqf b/Missionframework/presets/enemies/custom.sqf index c6cee9085..5d19a49fa 100644 --- a/Missionframework/presets/enemies/custom.sqf +++ b/Missionframework/presets/enemies/custom.sqf @@ -33,6 +33,8 @@ KPLIB_o_aaSpecialist = "O_Soldier_AA_F"; // AA Sp KPLIB_o_medic = "O_medic_F"; // Combat Life Saver KPLIB_o_engineer = "O_engineer_F"; // Engineer KPLIB_o_paratrooper = "O_soldier_PG_F"; // Paratrooper +KPLIB_o_crewman = "O_crew_F"; // Crewman +KPLIB_o_pilot = "O_helipilot_F"; // Pilot // Enemy vehicles used by secondary objectives. KPLIB_o_mrap = "O_MRAP_02_F"; // Ifrit diff --git a/Missionframework/presets/players/custom.sqf b/Missionframework/presets/players/custom.sqf index 0e22a8dee..c349cdf98 100644 --- a/Missionframework/presets/players/custom.sqf +++ b/Missionframework/presets/players/custom.sqf @@ -37,6 +37,7 @@ KPLIB_b_mobileRespawn = "B_Truck_01_medical_F"; // This KPLIB_b_potato01 = "B_Heli_Transport_03_unarmed_F"; // This is Potato 01, a multipurpose mobile respawn as a helicopter. KPLIB_b_crewUnit = "B_crew_F"; // This defines the crew for vehicles. KPLIB_b_heliPilotUnit = "B_Helipilot_F"; // This defines the pilot for helicopters. +KPLIB_b_crewStatic = "B_Soldier_F"; // This defines the crew for static weapons and light vehicles KPLIB_b_addHeli = "B_Heli_Light_01_F"; // These are the additional helicopters which spawn on the Freedom or at Chimera base. KPLIB_b_addBoat = "B_Boat_Transport_01_F"; // These are the boats which spawn at the stern of the Freedom. KPLIB_b_logiTruck = "B_Truck_01_transport_F"; // These are the trucks which are used in the logistic convoy system. diff --git a/Missionframework/scripts/client/misc/fn_initArsenal.sqf b/Missionframework/scripts/client/misc/fn_initArsenal.sqf index 8d1fe70f2..7cf95b1da 100644 --- a/Missionframework/scripts/client/misc/fn_initArsenal.sqf +++ b/Missionframework/scripts/client/misc/fn_initArsenal.sqf @@ -67,12 +67,12 @@ if (KPLIB_param_useArsenalPreset) then { if !(configProperties [configFile >> "CBA_DisposableLaunchers"] isEqualTo []) then { private _disposableLaunchers = ["CBA_FakeLauncherMagazine"]; { - private _loadedLauncher = cba_disposable_LoadedLaunchers getVariable _x; + private _loadedLauncher = cba_disposable_LoadedLaunchers get _x; if (!isNil "_loadedLauncher") then { _disposableLaunchers pushBack _loadedLauncher; }; - private _normalLauncher = cba_disposable_NormalLaunchers getVariable _x; + private _normalLauncher = cba_disposable_NormalLaunchers get _x; if (!isNil "_normalLauncher") then { _normalLauncher params ["_loadedLauncher"]; _disposableLaunchers pushBack _loadedLauncher; diff --git a/Missionframework/scripts/server/battlegroup/spawn_air.sqf b/Missionframework/scripts/server/battlegroup/spawn_air.sqf index f32a55247..26b0dac8c 100644 --- a/Missionframework/scripts/server/battlegroup/spawn_air.sqf +++ b/Missionframework/scripts/server/battlegroup/spawn_air.sqf @@ -16,7 +16,7 @@ for "_i" from 1 to _planes_number do { _spawnPos = markerPos _spawnPoint; _spawnPos = [(((_spawnPos select 0) + 500) - random 1000), (((_spawnPos select 1) + 500) - random 1000), 200]; _plane = createVehicle [_class, _spawnPos, [], 0, "FLY"]; - createVehicleCrew _plane; + [_plane, KPLIB_side_enemy] call KPLIB_fnc_createCrew; _plane flyInHeight (120 + (random 180)); [_plane] call KPLIB_fnc_addObjectInit; diff --git a/Missionframework/scripts/server/patrols/send_paratroopers.sqf b/Missionframework/scripts/server/patrols/send_paratroopers.sqf index a10c86a68..00ed2d3fc 100644 --- a/Missionframework/scripts/server/patrols/send_paratroopers.sqf +++ b/Missionframework/scripts/server/patrols/send_paratroopers.sqf @@ -20,7 +20,7 @@ if (isNull _chopper_type) then { }; _newvehicle = createVehicle [_chopper_type, markerpos _spawnsector, [], 0, "FLY"]; - createVehicleCrew _newvehicle; + [_newvehicle, KPLIB_side_enemy] call KPLIB_fnc_createCrew; sleep 0.1; _pilot_group = createGroup [KPLIB_side_enemy, true];