Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Missionframework/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class KPLIB {
class createClearance {};
class createClearanceConfirm {};
class createCrate {};
class createCrew {};
class createManagedUnit {};
class crGetMulti {};
class crGlobalMsg {};
Expand Down
86 changes: 86 additions & 0 deletions Missionframework/functions/fn_createCrew.sqf
Original file line number Diff line number Diff line change
@@ -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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All opfor crew is riflemen?

};
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;
}
}
}
};
*/
Comment on lines +39 to +65
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be commented out?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be commented out?

If you want to add those new variables in presets, then yes. The original version uses them. I tested a lot and works just fine.


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]

26 changes: 5 additions & 21 deletions Missionframework/functions/fn_forceBluforCrew.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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-11-16
License: MIT License - http://www.opensource.org/licenses/MIT

Description:
Expand All @@ -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 {
deleteVehicleCrew _veh;

_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";
Expand Down
8 changes: 2 additions & 6 deletions Missionframework/functions/fn_spawnVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
File: fn_spawnVehicle.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2023-11-14
Last Update: 2024-11-16
License: MIT License - http://www.opensource.org/licenses/MIT

Description:
Expand Down Expand Up @@ -80,11 +80,7 @@ _newvehicle addItemCargoGlobal ["toolkit", 1];
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;
sleep 0.1;
{_x addMPEventHandler ["MPKilled", {_this spawn kill_manager}];} forEach _crew;
[_newvehicle, KPLIB_side_enemy] call KPLIB_fnc_createCrew;
};

// Add MPKilled and GetIn EHs and enable damage again
Expand Down
4 changes: 3 additions & 1 deletion Missionframework/presets/enemies/custom.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
File: custom.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-10-07
Last Update: 2020-05-15
Last Update: 2024-11-16
License: MIT License - http://www.opensource.org/licenses/MIT

Description:
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions Missionframework/presets/players/custom.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
File: custom.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-10-07
Last Update: 2020-05-25
Last Update: 2024-11-16
License: MIT License - http://www.opensource.org/licenses/MIT

Description:
Expand Down Expand Up @@ -33,10 +33,11 @@ KPLIB_b_fobBuilding = "Land_Cargo_HQ_V1_F"; // This
KPLIB_b_fobBox = "B_Slingload_01_Cargo_F"; // This is the FOB as a container.
KPLIB_b_fobTruck = "B_Truck_01_box_F"; // This is the FOB as a vehicle.
KPLIB_b_arsenal = "B_supplyCrate_F"; // This is the virtual arsenal as portable supply crates.
KPLIB_b_mobileRespawn = "B_Truck_01_medical_F"; // This is the mobile respawn (and medical) truck.
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.
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.
Expand Down Expand Up @@ -314,7 +315,9 @@ KPLIB_b_objectsDeco = [

KPLIB_b_vehSupport = [
[KPLIB_b_arsenal,100,200,0],
[KPLIB_b_mobileRespawn,200,0,100],
[(KPLIB_b_mobileRespawn select 0),150,0,100],
[(KPLIB_b_mobileRespawn select 1),200,0,100],
[(KPLIB_b_mobileRespawn select 2),300,0,100],
[KPLIB_b_fobBox,300,500,0],
[KPLIB_b_fobTruck,300,500,75],
[KPLIB_b_smallStorage,0,0,0],
Expand Down
2 changes: 1 addition & 1 deletion Missionframework/scripts/server/battlegroup/spawn_air.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
[_plane] call KPLIB_fnc_addObjectInit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down