initial files

This commit is contained in:
Samuele Lorefice
2025-05-24 16:17:33 +02:00
commit 9e023649ac
477 changed files with 118566 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
/*
File: fn_initCuratorHandlers.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-08-07
Last Update: 2020-08-30
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Initialize curator handlers.
Parameter(s):
NONE
Returns:
Function reached the end [BOOL]
*/
#define ZEUSVAR(var) (format ["KPLIB_zeus_%1", var])
if (isServer) then {
// delete old Liberation mission placed Zeus module
deleteVehicle zm1;
// add curator assign EventHandler
[true, "KPLIB_createZeus", {
params [
["_player", objNull, [objNull]],
["_limited", false, [true]]
];
if (isNull _player) exitWith {};
private _uid = getPlayerUID _player;
// check if there's already a managed zeus module for this player, if so we can just reassign
private _oldManagedZeus = missionNamespace getVariable [ZEUSVAR(_uid), objNull];
if (!isNull _oldManagedZeus && {_limited isEqualTo (_oldManagedZeus getVariable ["KPLIB_limited", -1])}) exitWith {
_player assignCurator _oldManagedZeus;
[true, "KPLIB_zeusAssigned", [_oldManagedZeus]] remoteExecCall ["BIS_fnc_callScriptedEventHandler", _player];
};
// remove currently assigned curator
private _oldZeus = getAssignedCuratorLogic _player;
unassignCurator _oldZeus;
deleteVehicle _oldZeus;
private _group = createGroup [sideLogic, true];
private _zeus = _group createUnit ["ModuleCurator_F", [-7580, -7580, 0], [], 0, "NONE"];
missionNamespace setVariable [ZEUSVAR(_uid), _zeus];
if (_limited) then {
_zeus setVariable ["Addons", 0, true];
_zeus setVariable ["BIS_fnc_initModules_disableAutoActivation", false];
_zeus setCuratorCoef ["Place", -1e8];
_zeus setCuratorCoef ["Edit", -1e8];
_zeus setCuratorCoef ["Destroy", -1e8];
_zeus setCuratorCoef ["Delete", 0];
} else {
_zeus setVariable ["Addons", 3, true];
_zeus setVariable ["BIS_fnc_initModules_disableAutoActivation", false];
_zeus setCuratorCoef ["Place", 0];
_zeus setCuratorCoef ["Delete", 0];
removeAllCuratorAddons _zeus;
};
_zeus setVariable ["KPLIB_limited", _limited];
_player assignCurator _zeus;
[true, "KPLIB_zeusAssigned", [_zeus, _limited]] remoteExecCall ["BIS_fnc_callScriptedEventHandler", _player];
}] call BIS_fnc_addScriptedEventHandler;
[true, "KPLIB_activateZeusAddons", {
params [
["_zeus", objNull, [objNull]],
["_addons", [], [[]]]
];
_zeus addCuratorAddons _addons;
}] call BIS_fnc_addScriptedEventHandler;
// remove the assigned curator on player disconnect
addMissionEventHandler ["HandleDisconnect", {
params ["", "", "_uid"];
private _zeus = missionNamespace getVariable ZEUSVAR(_uid);
if (!isNil "_zeus") then {
deleteVehicle _zeus;
missionNamespace setVariable [ZEUSVAR(_uid), nil];
};
}];
};
if (hasInterface) then {
[true, "KPLIB_zeusAssigned", {
params [
["_zeus", objNull, [objNull]],
["_limited", false, [true]]
];
if !(_zeus getVariable ["KPLIB_drawCuratorLocations", false]) then {
_zeus setVariable ["KPLIB_drawCuratorLocations", true];
[_zeus] call BIS_fnc_drawCuratorLocations;
};
if (!_limited) then {
private _allAddons = ("true" configClasses (configFile >> "CfgPatches")) apply {configName _x};
[true, "KPLIB_activateZeusAddons", [_zeus, _allAddons]] remoteExecCall ["BIS_fnc_callScriptedEventHandler", 2];
};
}] call BIS_fnc_addScriptedEventHandler;
};
true

View File

@@ -0,0 +1,24 @@
/*
File: fn_requestZeus.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-08-07
Last Update: 2020-08-07
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Request Curator functionality from server.
Parameter(s):
_player - Player requesting Curator functionality [OBJECT, defaults to player]
Returns:
Function reached the end [BOOL]
*/
params [
["_player", player, [objNull]]
];
[true, "KPLIB_createZeus", [_player, KP_liberation_limited_zeus]] remoteExecCall ["BIS_fnc_callScriptedEventHandler", 2];
true

View File

@@ -0,0 +1,56 @@
/*
File: fn_addActionsFob.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-13
Last Update: 2020-04-13
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Adds build action to FOB box and repackage action to FOB building.
Parameter(s):
_obj - FOB box/truck/building to add the deploy/repack action to [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_obj", objNull, [objNull]]
];
if (isNull _object) exitWith {["Null object given"] call BIS_fnc_error; false};
if (isNil "FOB_build_in_progress") then {FOB_build_in_progress = false;};
if ((typeOf _obj) isEqualTo FOB_typename) exitWith {
_obj addAction [
["<t color='#FFFF00'>", localize "STR_FOB_REPACKAGE", "</t> <img size='2' image='res\ui_deployfob.paa'/>"] joinString "",
"scripts\client\actions\do_repackage_fob.sqf",
nil,
-754,
false,
true,
"",
"isNull (objectParent _this) && {player getVariable ['KPLIB_hasDirectAccess', false]}",
20
];
true
};
if ((typeOf _obj) in [FOB_box_typename, FOB_truck_typename]) exitWith {
_obj addAction [
["<t color='#FFFF00'>", localize "STR_FOB_ACTION", "</t> <img size='2' image='res\ui_deployfob.paa'/>"] joinString "",
"scripts\client\build\do_build_fob.sqf",
nil,
-752,
false,
true,
"",
"isNull (objectParent _this) && {!FOB_build_in_progress} && {player getVariable ['KPLIB_hasDirectAccess', false] || {[3] call KPLIB_fnc_hasPermission}} && {player getVariable ['KPLIB_isAwayFromStart', false]} && {!(surfaceIsWater getPos player)}",
10
];
true
};
false

View File

@@ -0,0 +1,373 @@
/*
File: fn_addActionsPlayer.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-13
Last Update: 2020-08-07
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Adds Liberation player actions to the given player.
Parameter(s):
_player - Player to add the actions to [OBJECT, defaults to player]
Returns:
Function reached the end [BOOL]
*/
params [
["_player", player, [objNull]]
];
if !(isPlayer _player) exitWith {["No player given"] call BIS_fnc_error; false};
if (isNil "KP_liberation_resources_global") then {KP_liberation_resources_global = false;};
// Tutorial
_player addAction [
["<t color='#80FF80'>", localize "STR_TUTO_ACTION", "</t>"] joinString "",
{howtoplay = 1;},
nil,
-700,
false,
true,
"",
"
alive _originalTarget
&& {_originalTarget getVariable ['KPLIB_isNearStart', false]}
"
];
// HALO
_player addAction [
["<t color='#80FF80'>", localize "STR_HALO_ACTION", "</t><img size='2' image='res\ui_redeploy.paa'/>"] joinString "",
"scripts\client\spawn\do_halo.sqf",
nil,
-710,
false,
true,
"",
"
GRLIB_halo_param > 0
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_fobDist', 99999] < 20
|| {_originalTarget getVariable ['KPLIB_isNearStart', false]}
}
&& {build_confirmed isEqualTo 0}
"
];
// Redeploy
_player addAction [
["<t color='#80FF80'>", localize "STR_DEPLOY_ACTION", "</t><img size='2' image='res\ui_redeploy.paa'/>"] joinString "",
{GRLIB_force_redeploy = true;},
nil,
-720,
false,
true,
"",
"
isNull (objectParent _originalTarget)
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_fobDist', 99999] < 20
|| {_originalTarget getVariable ['KPLIB_isNearMobRespawn', false]}
|| {_originalTarget getVariable ['KPLIB_isNearStart', false]}
}
&& {build_confirmed isEqualTo 0}
"
];
// Squad management
_player addAction [
["<t color='#80FF80'>", localize "STR_SQUAD_MANAGEMENT_ACTION", "</t><img size='2' image='\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\modeGroups_ca.paa'/>"] joinString "",
"scripts\client\ui\squad_management.sqf",
nil,
-730,
false,
true,
"",
"
isNull (objectParent _originalTarget)
&& {alive _originalTarget}
&& {!((units group _originalTarget) isEqualTo [_originalTarget])}
&& {(leader group _originalTarget) isEqualTo _originalTarget}
&& {build_confirmed isEqualTo 0}
"
];
// Arsenal
_player addAction [
["<t color='#FFFF00'>", localize "STR_ARSENAL_ACTION", "</t><img size='2' image='res\ui_arsenal.paa'/>"] joinString "",
"scripts\client\actions\open_arsenal.sqf",
nil,
-740,
false,
true,
"",
"
isNull (objectParent _originalTarget)
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_fobDist', 99999] < 20
|| {_originalTarget getVariable ['KPLIB_isNearArsenal', false]}
|| {_originalTarget getVariable ['KPLIB_isNearMobRespawn', false]}
|| {_originalTarget getVariable ['KPLIB_isNearStart', false]}
}
&& {build_confirmed isEqualTo 0}
"
];
// Build
_player addAction [
["<t color='#FFFF00'>", localize "STR_BUILD_ACTION", "</t><img size='2' image='res\ui_build.paa'/>"] joinString "",
"scripts\client\build\open_build_menu.sqf",
nil,
-750,
false,
true,
"",
"
isNull (objectParent _originalTarget)
&& {alive _originalTarget}
&& {_originalTarget getVariable ['KPLIB_fobDist', 99999] < (GRLIB_fob_range * 0.8)}
&& {
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
|| {[3] call KPLIB_fnc_hasPermission}
}
&& {build_confirmed isEqualTo 0}
"
];
// Secondary missions
_player addAction [
["<t color='#FFFF00'>", localize "STR_SECONDARY_OBJECTIVES", "</t>"] joinString "",
"scripts\client\ui\secondary_ui.sqf",
nil,
-760,
false,
true,
"",
"
isNull (objectParent _originalTarget)
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_fobDist', 99999] < 20
|| {_originalTarget getVariable ['KPLIB_isNearStart', false]}
}
&& {
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
|| {[5] call KPLIB_fnc_hasPermission}
}
&& {build_confirmed isEqualTo 0}
"
];
// Build sector storage
_player addAction [
["<t color='#FFFF00'>", localize "STR_SECSTORAGEBUILD_ACTION", "</t>"] joinString "",
"scripts\client\build\do_sector_build.sqf",
[KP_liberation_small_storage_building],
-770,
false,
true,
"",
"
!(_originalTarget getVariable ['KPLIB_nearProd', []] isEqualTo [])
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
|| {[3] call KPLIB_fnc_hasPermission}
}
&& {(_originalTarget getVariable ['KPLIB_nearProd', []] select 3) isEqualTo []}
&& {build_confirmed isEqualTo 0}
"
];
// Build supply facility
_player addAction [
["<t color='#FFFF00'>", localize "STR_SECSUPPLYBUILD_ACTION", "</t>"] joinString "",
"scripts\client\build\do_sector_build.sqf",
["supply"],
-780,
false,
true,
"",
"
!(_originalTarget getVariable ['KPLIB_nearProd', []] isEqualTo [])
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
|| {[3] call KPLIB_fnc_hasPermission}
}
&& {!((_originalTarget getVariable ['KPLIB_nearProd', []] select 3) isEqualTo [])}
&& {!((_originalTarget getVariable ['KPLIB_nearProd', []]) select 4)}
&& {build_confirmed isEqualTo 0}
"
];
// Build ammo facility
_player addAction [
["<t color='#FFFF00'>", localize "STR_SECAMMOBUILD_ACTION", "</t>"] joinString "",
"scripts\client\build\do_sector_build.sqf",
["ammo"],
-790,
false,
true,
"",
"
!(_originalTarget getVariable ['KPLIB_nearProd', []] isEqualTo [])
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
|| {[3] call KPLIB_fnc_hasPermission}
}
&& {!((_originalTarget getVariable ['KPLIB_nearProd', []] select 3) isEqualTo [])}
&& {!((_originalTarget getVariable ['KPLIB_nearProd', []]) select 5)}
&& {build_confirmed isEqualTo 0}
"
];
// Build fuel facility
_player addAction [
["<t color='#FFFF00'>", localize "STR_SECFUELBUILD_ACTION", "</t>"] joinString "",
"scripts\client\build\do_sector_build.sqf",
["fuel"],
-800,
false,
true,
"",
"
!(_originalTarget getVariable ['KPLIB_nearProd', []] isEqualTo [])
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
|| {[3] call KPLIB_fnc_hasPermission}
}
&& {!((_originalTarget getVariable ['KPLIB_nearProd', []] select 3) isEqualTo [])}
&& {!((_originalTarget getVariable ['KPLIB_nearProd', []]) select 6)}
&& {build_confirmed isEqualTo 0}
"
];
// Switch global/local resources
_player addAction [
["<t color='#FFFF00'>", localize "STR_RESOURCE_GLOBAL_ACTION", "</t>"] joinString "",
{KP_liberation_resources_global = !KP_liberation_resources_global},
nil,
-810,
false,
true,
"",
"
alive _originalTarget
&& {_originalTarget getVariable ['KPLIB_fobDist', 99999] < (GRLIB_fob_range * 0.8)}
&& {build_confirmed isEqualTo 0}
"
];
// Production
_player addAction [
["<t color='#FF8000'>", localize "STR_PRODUCTION_ACTION", "</t>"] joinString "",
"scripts\client\commander\open_production.sqf",
nil,
-820,
false,
true,
"",
"
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {!(KP_liberation_production isEqualTo [])}
&& {
_originalTarget getVariable ['KPLIB_fobDist', 99999] < (GRLIB_fob_range * 0.8)
|| {!(_originalTarget getVariable ['KPLIB_nearProd', []] isEqualTo [])}
}
&& {build_confirmed isEqualTo 0}
"
];
// Logistic
_player addAction [
["<t color='#FF8000'>", localize "STR_LOGISTIC_ACTION", "</t>"] joinString "",
"scripts\client\commander\open_logistic.sqf",
nil,
-830,
false,
true,
"",
"
KP_liberation_ailogistics
&& {_originalTarget getVariable ['KPLIB_hasDirectAccess', false]}
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {_originalTarget getVariable ['KPLIB_fobDist', 99999] < (GRLIB_fob_range * 0.8)}
&& {!(
GRLIB_all_fobs isEqualTo []
|| KP_liberation_production isEqualTo []
)}
&& {build_confirmed isEqualTo 0}
"
];
// Permissions
_player addAction [
["<t color='#FF8000'>", localize "STR_COMMANDER_ACTION", "</t><img size='2' image='\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\modeGroups_ca.paa'/>"] joinString "",
"scripts\client\commander\open_permissions.sqf",
nil,
-840,
false,
true,
"",
"
GRLIB_permissions_param
&& {_originalTarget getVariable ['KPLIB_hasDirectAccess', false]}
&& {alive _originalTarget}
&& {build_confirmed isEqualTo 0}
"
];
// Reassign Zeus
if (player == ([] call KPLIB_fnc_getCommander)) then {
_player addAction [
["<t color='#FF0000'>", localize "STR_REASSIGN_ZEUS", "</t>"] joinString "",
{[] call KPLIB_fnc_requestZeus},
nil,
-870,
false,
true,
"",
"
alive _originalTarget
&& {isNull (_originalTarget getVariable ['KPLIB_ownedZeusModule', objNull])}
&& {build_confirmed isEqualTo 0}
"
];
};
// Create FOB clearance
_player addAction [
["<t color='#FFFF00'>", localize "STR_CLEARANCE_ACTION", "</t>"] joinString "",
{[player getVariable ["KPLIB_fobPos", [0, 0, 0]], GRLIB_fob_range * 0.9, true] call KPLIB_fnc_createClearanceConfirm;},
nil,
-850,
false,
true,
"",
"
_originalTarget getVariable ['KPLIB_hasDirectAccess', false]
&& {isNull (objectParent _originalTarget)}
&& {alive _originalTarget}
&& {_originalTarget getVariable ['KPLIB_fobDist', 99999] < (GRLIB_fob_range * 0.8)}
&& {build_confirmed isEqualTo 0}
"
];
true

View File

@@ -0,0 +1,56 @@
/*
File: fn_addObjectInit.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-05-08
Last Update: 2020-04-29
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Applies code from kp_objectInits.sqf to given object. Returns true if some code was applied, false if object has no KPLIB init code.
Parameter(s):
_object - Object which should get init code applied, if there is any defined [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_object", objNull, [objNull]]
];
if (isNull _object) exitWith {["Null object given"] call BIS_fnc_error; false};
// Create objectInitsCache object for this machine, if not present
if (isNil "KPLIB_objectInitsCache") then {KPLIB_objectInitsCache = createSimpleObject ["a3\weapons_f\empty.p3d", [-7580, -7580, 0], true];};
private _elements = KPLIB_objectInitsCache getVariable typeOf _object;
// Find and cache matching objectInits
if (isNil "_elements") then {
_elements = KPLIB_objectInits select {
_x params ["_classes", "", ["_inheritance", false]];
if (_inheritance) then {
{
if (_object isKindOf _x) exitWith {true};
false
} forEach _classes // return
} else {
// return
(toLower (typeOf _object)) in (_classes apply {toLower _x})
};
};
KPLIB_objectInitsCache setVariable [typeOf _object, _elements];
};
if (_elements isEqualTo []) exitWith {
false
};
{
_object call (_x select 1);
} forEach _elements;
true

View File

@@ -0,0 +1,35 @@
/*
File: fn_addRopeAttachEh.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-09
Last Update: 2020-04-10
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Adds a ropeAttach EH if given vehicle is able to slingload objects.
The EH will make sure that the slingloaded cargo is local to the
helicopter pilot to avoid a rope breaking due to desyncs.
Parameter(s):
_obj - Object to apply the EH to [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_obj", objNull, [objNull]]
];
if (isNull _obj) exitWith {["Null object given"] call BIS_fnc_error; false};
if (getNumber (configfile >> "CfgVehicles" >> (typeOf _obj) >> "slingLoadMaxCargoMass") > 0) then {
_obj addEventHandler ["RopeAttach", {
params ["_heli", "_rope", "_cargo"];
if !((owner _heli) isEqualTo (owner _cargo)) then {
_cargo setOwner (owner _heli);
};
}];
};
true

View File

@@ -0,0 +1,27 @@
/*
File: fn_allowCrewInImmobile.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-09-05
Last Update: 2019-12-03
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Allows crew in immobile vehicle depending on AllowEnemiesInImmobile parameters.
Parameter(s):
_vehicle - Vehicle which should allow immobile crew [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_vehicle", objNull, [objNull]]
];
if (isNull _vehicle) exitWith {["Null object given"] call BIS_fnc_error; false};
// KP_liberation_allowEnemiesInImmobile (0-50-100)
_vehicle allowCrewInImmobile (random 100 < KP_liberation_allowEnemiesInImmobile);
true

View File

@@ -0,0 +1,29 @@
/*
File: fn_checkClass.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2020-04-16
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Checks if given classname is available in currently loaded modset.
Parameter(s):
_classname - Classname of class to check [STRING, defaults to ""]
Returns:
Classname in config [BOOL]
*/
params [
["_classname", "", [""]]
];
if (_classname isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; false};
if (isClass (configFile >> "CfgVehicles" >> _classname)) then {
true
} else {
if (isServer) then {[format ["%1 not found in CfgVehicles", _classname], "PRESETS"] call KPLIB_fnc_log;};
false
};

View File

@@ -0,0 +1,33 @@
/*
File: fn_checkCrateValue.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-05-26
Last Update: 2019-12-03
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Checks content of given crate and displays a hint about it.
Additionally it makes sure that ropeAttach is enabled on the crate.
Parameter(s):
_crate - Crate to check [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
if (isDedicated) exitWith {};
params [
["_crate", objNull, [objNull]]
];
if (isNull _crate) exitWith {["Null object given"] call BIS_fnc_error; false};
hint format [localize "STR_ACTION_CRATE_VALUE_HINT", _crate getVariable ["KP_liberation_crate_value", 0]];
if !(ropeAttachEnabled _crate) then {
[_crate, true] remoteExec ["enableRopeAttach"];
};
true

View File

@@ -0,0 +1,125 @@
/*
File: fn_checkGear.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-11-22
Last Update: 2020-04-16
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Checks the players gear for blacklisted items.
Found items are removed from the loadout.
Furthermore a hint with the found items is displayed to the player
while a server log entry is created for the admin.
Parameter(s):
_backpack - Backpack classname of the players current backpack [STRING, defaults to ""]
Returns:
Player checked without findings [BOOL]
*/
params [
["_backpack", "", [""]]
];
private _removedItems = [];
// Check single item slots
if !(toLower (headgear player) in KP_liberation_allowed_items) then {
_removedItems pushBack (headgear player);
removeHeadgear player;
};
if !(toLower (goggles player) in KP_liberation_allowed_items) then {
_removedItems pushBack (goggles player);
removeGoggles player;
};
if !(toLower (uniform player) in KP_liberation_allowed_items) then {
_removedItems pushBack (uniform player);
removeUniform player;
};
if !(toLower (vest player) in KP_liberation_allowed_items) then {
_removedItems pushBack (vest player);
removeVest player;
};
if (!(toLower (backpack player) in KP_liberation_allowed_items) && ((backpack player) != _backpack)) then {
_removedItems pushBack (backpack player);
removeBackpack player;
};
// Check items
private _items = assignedItems player;
_items append ((getItemCargo (uniformContainer player)) select 0);
_items append ((getItemCargo (vestContainer player)) select 0);
_items append ((getItemCargo (backpackContainer player)) select 0);
_items = _items apply {toLower _x};
{
_removedItems pushBack _x;
player unassignItem _x;
player removeItems _x;
} forEach (((_items arrayIntersect _items) - KP_liberation_allowed_items) select {!([_x] call KPLIB_fnc_isRadio)});
// Check magazines
_items = ((getMagazineCargo (uniformContainer player)) select 0);
_items append ((getMagazineCargo (vestContainer player)) select 0);
_items append ((getMagazineCargo (backpackContainer player)) select 0);
_items = _items apply {toLower _x};
{
_removedItems pushBack _x;
player removeMagazines _x;
} forEach ((_items arrayIntersect _items) - KP_liberation_allowed_items);
// Check weapons stored in inventory containers
{
if (!isNull _x) then {_removedItems append ([_x] call KPLIB_fnc_checkWeaponCargo);};
} forEach [uniformContainer player, vestcontainer player, backpackContainer player];
// Check equipped weapons
_items = (weapons player) apply {toLower ([_x] call BIS_fnc_baseWeapon)};
{
_removedItems pushBack _x;
player removeWeapon _x;
} forEach (_items - KP_liberation_allowed_items);
// Check weapon items of primary weapon
_items = primaryWeaponItems player;
_items append primaryWeaponMagazine player;
_items = _items apply {toLower _x};
{
_removedItems pushBack _x;
player removePrimaryWeaponItem _x;
} forEach (_items - KP_liberation_allowed_items);
// Check weapon items of secondary weapon
_items = secondaryWeaponItems player;
_items append secondaryWeaponMagazine player;
_items = _items apply {toLower _x};
{
_removedItems pushBack _x;
player removeSecondaryWeaponItem _x;
} forEach (_items - KP_liberation_allowed_items);
// Check weapon items of handgun
_items = handgunItems player;
_items append handgunMagazine player;
_items = _items apply {toLower _x};
{
_removedItems pushBack _x;
player removeHandgunItem _x;
} forEach (_items - KP_liberation_allowed_items);
// Remove duplicates and empty strings
_removedItems = (_removedItems arrayIntersect _removedItems) - [""];
// Show hint and log list, if something was found
if !(_removedItems isEqualTo []) exitWith {
[_removedItems] spawn {
params ["_removedItems"];
[format ["Found %1 at player %2", _removedItems, name player], "BLACKLIST"] remoteExecCall ["KPLIB_fnc_log", 2];
hint format [localize "STR_BLACKLISTED_ITEM_FOUND", _removedItems joinString "\n"];
sleep 6;
hintSilent "";
};
false
};
true

View File

@@ -0,0 +1,107 @@
/*
File: fn_removeWeaponCargo.sqf
Author: Zharf - https://github.com/zharf
Date: 2019-06-21
Last Update: 2020-04-13
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Removes weapons not found in KP_liberation_allowed_items from a cargo space.
Warning: All weapon attachments/magazines in container will become detached.
Warning: Preset weapons without non-preset parents will get their attachments readded (engine limitation).
Parameter(s):
_container - Object with cargo [OBJECT, defaults to objNull]
Returns:
Removed items [ARRAY]
*/
params [
["_container", objNull, [objNull]]
];
if (isNull _container) exitWith {["Null object given"] call BIS_fnc_error; []};
private _removed = [];
private _weaponsItemsCargo = weaponsItemsCargo _container;
clearWeaponCargoGlobal _container;
{
_x params ["_weapon", "_muzzle", "_pointer", "_optic", "_magazine", "_magazineGL", "_bipod"];
// Some weapons don't have non-preset parents
_components = _weapon call KPLIB_fnc_getWeaponComponents;
private _weaponNonPreset = _components select 0;
if (_weaponNonPreset == "") then {
_weaponNonPreset = _weapon;
};
if ((toLower ([_x] call BIS_fnc_baseWeapon)) in KP_liberation_allowed_items) then {
_container addWeaponCargoGlobal [_weaponNonPreset, 1];
// If weapon does not have a non-preset parent, only add attachments that were custom added
// Removed attachments cannot be handled (engine limitation) and will be readded due to having to readd preset weapon
private _presetAttachments = [];
if (_weaponNonPreset == _weapon) then {
_presetAttachments = _components;
};
if !(toLower _muzzle in _presetAttachments) then {
if (toLower _muzzle in KP_liberation_allowed_items) then {
_container addItemCargoGlobal [_muzzle, 1];
} else {
_removed pushBack _muzzle;
}
};
if !(toLower _pointer in _presetAttachments) then {
if (toLower _pointer in KP_liberation_allowed_items) then {
_container addItemCargoGlobal [_pointer, 1];
} else {
_removed pushBack _pointer;
}
};
if !(toLower _optic in _presetAttachments) then {
if (toLower _optic in KP_liberation_allowed_items) then {
_container addItemCargoGlobal [_optic, 1];
} else {
_removed pushBack _optic;
}
};
if !(toLower _bipod in _presetAttachments) then {
if (toLower _bipod in KP_liberation_allowed_items) then {
_container addItemCargoGlobal [_bipod, 1];
} else {
_removed pushBack _bipod;
}
};
_magazine params [["_magazineClass", ""], ["_magazineAmmoCount", 0]];
if (_magazineClass != "") then {
if (toLower _magazineClass in KP_liberation_allowed_items) then {
_container addMagazineAmmoCargo [_magazineClass, 1, _magazineAmmoCount];
} else {
_removed pushBack _magazineClass;
}
};
_magazineGL params [["_magazineGLClass", ""], ["_magazineGLAmmoCount", 0]];
if (_magazineGLClass != "") then {
if (toLower _magazineGLClass in KP_liberation_allowed_items) then {
_container addMagazineAmmoCargo [_magazineGLClass, 1, _magazineGLAmmoCount];
} else {
_removed pushBack _magazineGLClass;
}
};
} else {
_removed pushBack _weapon;
}
} forEach _weaponsItemsCargo;
_removed;

View File

@@ -0,0 +1,28 @@
/*
File: fn_cleanOpforVehicle.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2020-04-20
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Deletes given vehicle, if not an opfor vehicle captured by players.
Parameter(s):
_veh - Vehicle to delete if not captured [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_veh", objNull, [objNull]]
];
if (isNull _veh) exitWith {["Null object given"] call BIS_fnc_error; false};
if !(_veh getVariable ["KPLIB_captured", false]) then {
deleteVehicle _veh;
};
true

View File

@@ -0,0 +1,34 @@
/*
File: fn_clearCargo.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-03-30
Last Update: 2020-03-30
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Clears the cargo of given object while providing
a toggle to skip the paramter and ace crate check.
Parameter(s):
_obj - Object for cargo clearing [OBJECT, defaults to objNull]
_force - Skip the paramter and ACE crate check [BOOL, defaults to false]
Returns:
Function reached the end [BOOL]
*/
params [
["_obj", objNull, [objNull]],
["_force", false, [false]]
];
if (isNull _obj) exitWith {["Null object given"] call BIS_fnc_error; false};
if (_force || {!((typeOf _obj) in KP_liberation_ace_crates) && {KP_liberation_clear_cargo || {!((typeOf _obj) isKindOf "AllVehicles")}}}) then {
clearWeaponCargoGlobal _obj;
clearMagazineCargoGlobal _obj;
clearBackpackCargoGlobal _obj;
clearItemCargoGlobal _obj;
};
true

View File

@@ -0,0 +1,56 @@
/*
File: fn_crAddAceAction.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-22
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Adds action for healing with ACE field dressing to a given object.
Parameter(s):
_civ - Civilian to add the healing action to [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_civ", objNull, [objNull]]
];
if (isNull _civ) exitWith {["Null object given"] call BIS_fnc_error; false};
if (KP_liberation_civrep_debug > 0) then {[format ["ace_action called on: %1", debug_source], "CIVREP"] remoteExecCall ["KPLIB_fnc_log", 2];};
_civ addAction [
"<t color='#FF0000'>" + localize "STR_CR_ACE_ACTION" + "</t>",
{
params ["_target", "_caller"];
private _items = [
"ACE_elasticBandage",
"ACE_fieldDressing",
"ACE_packingBandage",
"ACE_quikclot"
] arrayIntersect (vestItems _caller + uniformItems _caller + backpackItems _caller);
if !(_items isEqualTo []) then {
_caller removeItem (selectRandom _items);
_target setDamage 0;
} else {
hint localize "STR_CR_ACE_ACTION_FAIL";
sleep 3;
hintSilent "";
};
},
nil,
1.5,
true,
true,
"",
"(damage _target) >= 0.5",
3
];
true

View File

@@ -0,0 +1,18 @@
/*
File: fn_crGetMulti.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-10-08
Last Update: 2019-12-04
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns the current multiplier of the civilian reputation.
Parameter(s):
NONE
Returns:
Reputation multiplier [NUMBER]
*/
3 min (floor (abs (KP_liberation_civ_rep / 25)))

View File

@@ -0,0 +1,36 @@
/*
File: fn_crGlobalMsg.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-17
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
No description added yet.
Parameter(s):
_msgType - Type of message to display [NUMBER, defaults to -1]
_data - Data which is needed in the selected msgType [ARRAY, defaults to []]
Returns:
Function reached the end [BOOL]
*/
params [
["_msgType", -1, [0]],
["_data", [], []]
];
if (KP_liberation_civrep_debug > 0) then {[format ["globalMsg called on: %1 - Parameters: [%2, %3]", debug_source, _msgType, _data], "CIVREP"] remoteExecCall ["KPLIB_fnc_log", 2];};
switch (_msgType) do {
case 0: {systemChat localize "STR_CR_VEHICLEMSG";};
case 1: {systemChat (format [localize "STR_CR_BUILDINGMSG", (_data select 0)]);};
case 2: {systemChat (format [localize "STR_CR_KILLMSG", (_data select 0)]);};
case 3: {systemChat (format [localize "STR_CR_RESISTANCE_KILLMSG", (_data select 0)]);};
case 4: {systemChat (format [localize "STR_CR_HEALMSG", (_data select 0)]);};
case 5: {["lib_asymm_guerilla_incoming", _data] call BIS_fnc_showNotification;};
default {[format ["globalMsg without valid msgType - %1", _msgType], "CIVREP"] remoteExecCall ["KPLIB_fnc_log", 2];};
};
true

View File

@@ -0,0 +1,74 @@
/*
File: fn_crateFromStorage.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-03-27
Last Update: 2020-04-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Unloads given crate type from storage area.
Parameter(s):
_cratetype - Crate type [STRING, defaults to ""]
_storage - Storage [OBJECT, defaults to objNull]
_update - Update sector resources [BOOL, defaults to false]
Returns:
Function reached the end [BOOL]
*/
params [
["_cratetype", "", [""]],
["_storage", objNull, [objNull]],
["_update", false, [false]]
];
// Validate parameters
if !((toLower _cratetype) in KPLIB_crates) exitWith {["Invalid craty type given: %1", _cratetype] call BIS_fnc_error; false};
if (isNull _storage) exitWith {["Null object given"] call BIS_fnc_error; false};
// Get correct storage positions
([_storage] call KPLIB_fnc_getStoragePositions) params ["_storagePositions", "_unloadDist"];
// Check for next empty unload position
private _i = 0;
private _dir = (getDir _storage) - 180;
private _unloadPos = _storage getPos [_unloadDist, _dir];
while {!((nearestObjects [_unloadPos, KPLIB_crates, 1]) isEqualTo [])} do {
_i = _i + 1;
_unloadPos = _storage getPos [_unloadDist + _i * 1.8, _dir];
};
// Fetch all stored crates
private _storedCrates = attachedObjects _storage;
reverse _storedCrates;
private _crate = _storedCrates deleteAt (_storedCrates findIf {(typeOf _x) == _crateType});
// Exit if desired crate isn't stored
if (isNil "_crate") exitWith {false};
// Unload crate
detach _crate;
[_crate, true] call KPLIB_fnc_clearCargo;
_crate setPos _unloadPos;
[_crate, true] remoteExec ["enableRopeAttach"];
if (KP_liberation_ace) then {[_crate, true, [0, 1.5, 0], 0] remoteExec ["ace_dragging_fnc_setCarryable"];};
// Fill the possible gap in the storage area
reverse _storedCrates;
_i = 0;
{
detach (_x select 0);
(_x select 0) attachTo [_storage, [(_storagePositions select _i) select 0, (_storagePositions select _i) select 1, _x select 1]];
_i = _i + 1;
} forEach (_storedCrates apply {[_x, [typeOf _x] call KPLIB_fnc_getCrateHeight]});
// Update sector resources
if (_update) then {
if ((_storage getVariable ["KP_liberation_storage_type", -1]) == 1) then {
recalculate_sectors = true;
publicVariable "recalculate_sectors";
};
};
true

View File

@@ -0,0 +1,64 @@
/*
File: fn_crateToStorage.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-03-27
Last Update: 2020-04-23
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Attach given crate at storage area.
Parameter(s):
_crate - Crate [OBJECT, defaults to objNull]
_storage - Storage [OBJECT, defaults to objNull]
_update - Update sector resources [BOOL, defaults to false]
Returns:
Function reached the end [BOOL]
*/
params [
["_crate", objNull, [objNull]],
["_storage", objNull, [objNull]],
["_update", false, [false]]
];
// Validate parameters
if (isNull _crate) exitWith {["Null object given"] call BIS_fnc_error; false};
// Handle return values from nearestObjects of function call in ammobox action manager
if (!isNull _storage) then {
// Get storage and crate specific values
([_storage] call KPLIB_fnc_getStoragePositions) params ["_storage_positions", "_unload_distance"];
private _height = [typeOf _crate] call KPLIB_fnc_getCrateHeight;
// Remove possible cargo from crate
[_crate, true] call KPLIB_fnc_clearCargo;
// Check for enough space in storage
private _crates_count = count (attachedObjects _storage);
if (_crates_count >= (count _storage_positions)) exitWith {if (!isDedicated) then {[] spawn {hint localize "STR_BOX_CANTSTORE"; sleep 2; hintSilent "";};};};
// Store crate
_crate attachTo [_storage, [(_storage_positions select _crates_count) select 0, (_storage_positions select _crates_count) select 1, _height]];
[_crate, false] remoteExec ["enableRopeAttach"];
if(KP_liberation_ace) then {[_crate, false, [0, 1.5, 0], 0] remoteExec ["ace_dragging_fnc_setCarryable"];};
// Update sector resource values, if requested
if (_update) then {
if ((_storage getVariable ["KP_liberation_storage_type", -1]) == 1) then {
recalculate_sectors = true;
publicVariable "recalculate_sectors";
};
};
} else {
if (!isDedicated) then {
[] spawn {
hint localize "STR_BOX_CANTSTORE";
sleep 2;
hintSilent "";
};
};
};
true

View File

@@ -0,0 +1,53 @@
/*
File: fn_crawlAllItems.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-19
Last Update: 2020-04-19
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Crawls through CfgWeapons, CfgMagazines, CfgVehicles and CfgGlasses to fetach all
weapon, magazine, item and backpack classnames available in the arsenal.
Parameter(s):
NONE
Returns:
Array of classnames for weapons, magazines, items and backpacks [ARRAY]
*/
private _weapons = [];
private _magazines = [];
private _items = [];
private _backpacks = [];
private _configClasses = [];
private _type = [];
{
_configClasses append (
"
_type = (configName _x) call BIS_fnc_itemType;
(getNumber(_x >> 'scope') isEqualTo 2) && !(((_type select 0) isEqualTo '') || ((_type select 0) isEqualTo 'VehicleWeapon'))
" configClasses _x
);
} forEach [
(configFile >> "CfgWeapons"),
(configFile >> "CfgMagazines"),
(configFile >> "CfgVehicles"),
(configFile >> "CfgGlasses")
];
private _classnames = _configClasses apply {configName _x};
{
_type = _x call BIS_fnc_itemType;
switch (_type select 0) do {
case "Weapon": {if ((_x call BIS_fnc_baseWeapon) isEqualTo _x) then {_weapons pushBackUnique _x;};};
case "Mine";
case "Magazine": {_magazines pushBackUnique _x;};
case "Item";
case "Equipment": {if ((_type select 1) isEqualTo "Backpack") then {_backpacks pushBackUnique _x;} else {_items pushBackUnique _x;};};
};
} forEach _classnames;
[_weapons, _magazines, _items, _backpacks]

View File

@@ -0,0 +1,45 @@
/*
File: fn_createClearance.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-10
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Adds a terrain objects clearance around given position with given radius.
If the save switch is set to true, the clearance will be saved during the campaign.
Parameter(s):
_centerPos - Position for the clearance [POSITION, defaults to [0, 0, 0]]
_radius - Radius of the clearance around the center [NUMBER, defaults to 0]
_save - Switch to decide if the clearance should be persistent [BOOL, defaults to false]
Returns:
Function reached the end [BOOL]
*/
if (!isServer) exitWith {false};
params [
["_centerPos", [0, 0, 0], [[]], [3]],
["_radius", 0, [0]],
["_save", false, [false]]
];
if (_centerPos isEqualTo [0, 0, 0]) exitWith {["Zero position given"] call BIS_fnc_error; false};
if (_radius isEqualTo 0) exitWith {["Zero radius given"] call BIS_fnc_error; false};
if (save_is_loaded && {(KP_liberation_clearances findIf {(_x select 0) isEqualTo _centerPos}) != -1}) exitWith {false};
{
_x switchLight "OFF";
_x hideObjectGlobal true;
_x allowDamage false;
} forEach (nearestTerrainObjects [_centerPos, [], _radius, false, true]);
if (_save) then {
KP_liberation_clearances pushBackUnique [_centerPos, _radius];
publicVariable "KP_liberation_clearances";
};
true

View File

@@ -0,0 +1,52 @@
/*
File: fn_createClearanceConfirm.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-10
Last Update: 2020-04-10
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Displays a confirmation dialog for the create clearance action.
If confirmed, the clearance will be created by the server.
Parameter(s):
_centerPos - Position for the clearance [POSITION, defaults to [0, 0, 0]]
_radius - Radius of the clearance around the center [NUMBER, defaults to 0]
_save - Switch to decide if the clearance should be persistent [BOOL, defaults to false]
Returns:
Creation confirmed [BOOL]
*/
params [
["_centerPos", [0, 0, 0], [[]], [3]],
["_radius", 0, [0]],
["_save", false, [false]]
];
if (_centerPos isEqualTo [0, 0, 0]) exitWith {["Zero position given"] call BIS_fnc_error; false};
if (_radius isEqualTo 0) exitWith {["Zero radius given"] call BIS_fnc_error; false};
if (!canSuspend) exitWith {_this spawn KPLIB_fnc_createClearanceConfirm};
private _text = format [
localize "STR_CONFIRM_CLEARANCE_TEXT",
count (nearestTerrainObjects [_centerPos, [], _radius, false, true]),
floor _radius,
["FOB", [_centerPos] call KPLIB_fnc_getFobName] joinString " "
];
private _confirmed = [
_text,
localize "STR_CONFIRM_CLEARANCE_TITLE",
localize "STR_CONFIRM",
localize "STR_RECYCLING_CANCEL",
nil,
false,
false
] call BIS_fnc_guiMessage;
if (_confirmed) then {
[_centerPos, _radius, true] remoteExecCall ["KPLIB_fnc_createClearance", 2];
};
_confirmed

View File

@@ -0,0 +1,44 @@
/*
File: fn_createCrate.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-10-11
Last Update: 2020-04-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns a resource crate of given type and with given amount at given position.
Parameter(s):
_resource - Type of resource [STRING, defaults to KP_liberation_supply_crate]
_amount - Resource amount [NUMBER, defaults to 100]
_pos - Position where to spawn the crate [POSITION, defaults to getPos player]
Returns:
Created crate [OBJECT]
*/
params [
["_resource", KP_liberation_supply_crate, [""]],
["_amount", 100, [0]],
["_pos", getPos player, [[]], [2, 3]]
];
// Check if resource is valid
if !((toLower _resource) in KPLIB_crates) exitWith {
["Invalid resource param given: %1", _resource] call BIS_fnc_error;
objNull
};
// Create crate
private _crate = _resource createVehicle _pos;
_crate setMass 500;
_crate setVariable ["KP_liberation_crate_value", _amount, true];
[_crate, true] call KPLIB_fnc_clearCargo;
// Add ACE carry functionality
if (KP_liberation_ace) then {[_crate, true, [0, 1.5, 0], 0] remoteExec ["ace_dragging_fnc_setCarryable"];};
// Process KP object init
[_crate] call KPLIB_fnc_addObjectInit;
_crate

View File

@@ -0,0 +1,48 @@
/*
File: fn_createManagedUnit.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-10-04
Last Update: 2019-12-04
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Creates unit managed by kill tracker.
Parameter(s):
_type - Type of unit [STRING, defaults to ""]
_spawnPos - Where to spawn [ARRAY|OBJECT|GROUP, defaults to [0, 0, 0]]
_group - Group to add the unit to [GROUP, defaults to grpNull]
_rank - Unit rank [STRING, defaults to "PRIVATE"]
_placement - Placement radius [NUMBER, defaults to 0]
Returns:
Created unit [OBJECT]
*/
params [
["_type", "", [""]],
["_spawnPos", [0, 0, 0], [[], objNull, grpNull], [2, 3]],
["_group", grpNull, [grpNull]],
["_rank", "PRIVATE", [""]],
["_placement", 0, [0]]
];
private ["_unit"];
isNil {
// Create temp group, as we need to let the unit join the "correct side group".
// If we use the "correct side group" for the createUnit, the group would switch to the side of the unit written in the config.
private _groupTemp = createGroup [CIVILIAN, true];
_unit = _groupTemp createUnit [_type, _spawnPos, [], _placement, "FORM"];
_unit addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
_unit setRank _rank;
// Join to target group to preserve Side
[_unit] joinSilent _group;
deleteGroup _groupTemp;
// Process KP object init
[_unit] call KPLIB_fnc_addObjectInit;
};
_unit

View File

@@ -0,0 +1,40 @@
/*
File: fn_doSave.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-03-29
Last Update: 2020-05-08
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Save mission state to profileNamespace.
Parameter(s):
NONE
Returns:
Data was saved [BOOL]
*/
if (!isServer) exitWith {false};
if (!KPLIB_init) exitWith {
["Framework is not initalized, skipping save!", "SAVE"] call KPLIB_fnc_log;
false
};
if (missionNamespace getVariable ["kp_liberation_saving", false]) exitWith {
["Saving already in progress, skipping save!", "SAVE"] call KPLIB_fnc_log;
false
};
kp_liberation_saving = true;
private _saveData = [] call KPLIB_fnc_getSaveData;
// Write data in the server profileNamespace
profileNamespace setVariable [GRLIB_save_key, str _saveData];
saveProfileNamespace;
kp_liberation_saving = false;
true

View File

@@ -0,0 +1,56 @@
/*
File: fn_fillStorage.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-05-04
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Fills given storage with given amounts of resources.
Parameter(s):
_supply - Amount of supply resource [NUMBER, defaults to 0]
_ammo - Amount of ammo resource [NUMBER, defaults to 0]
_fuel - Amount of fuel resource [NUMBER, defaults to 0]
_storage - Storage object to fill [OBJECT, defaults to objNull]
_delay - Enable a small delay between crate create and attach to storage [BOOL, defaults to false]
Returns:
Function reached the end [BOOL]
*/
params [
["_supply", 0, [0]],
["_ammo", 0, [0]],
["_fuel", 0, [0]],
["_storage", objNull, [objNull]],
["_delay", false, [false]]
];
if (isNull _storage) exitWith {["Null object given"] call BIS_fnc_error; false};
// Make sure it's scheduled, if delay is enabled
if (_delay && {!canSuspend}) exitWith {_this spawn KPLIB_fnc_fillStorage};
private _amount = 0;
private _crate = objNull;
private _pos = getPos _storage;
{
while {_x > 0} do {
_amount = 100 min _x;
_x = _x - _amount;
_crate = [
KPLIB_crates select _forEachIndex,
_amount,
_pos
] call KPLIB_fnc_createCrate;
if (_delay) then {sleep 0.1;};
[_crate, _storage] call KPLIB_fnc_crateToStorage;
};
} forEach [_supply, _ammo, _fuel];
true

View File

@@ -0,0 +1,49 @@
/*
File: fn_forceBluforCrew.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-12-04
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Creates vehicle crew from vehicle config.
If the crew isn't the same side as the players, it'll create a player side crew.
Parameter(s):
_veh - Vehicle to add the blufor crew to [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_veh", objNull, [objNull]]
];
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) != GRLIB_side_friendly) then {
{deleteVehicle _x} forEach (units _grp);
_grp = createGroup [GRLIB_side_friendly, true];
while {count units _grp < 3} do {
[crewman_classname, 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);
};
// Set the crew to safe behaviour
_grp setBehaviour "SAFE";
true

View File

@@ -0,0 +1,18 @@
/*
File: fn_getAdaptiveVehicle.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-11-26
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Provides a vehicle classname depending on the combat readiness.
Parameter(s):
NONE
Returns:
Vehicle classname [STRING]
*/
selectRandom ([opfor_vehicles, opfor_vehicles_low_intensity] select (combat_readiness < 40))

View File

@@ -0,0 +1,32 @@
/*
File: fn_getBluforRatio.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-12-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the ratio of blufor units in the given sector to the total number of units.
Parameter(s):
_sector - Sector to get the blufor / opfor ratio from [STRING, defaults to ""]
Returns:
Blufor ratio [NUMBER]
*/
params [
["_sector", "", [""]]
];
if (_sector isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; -1};
private _range = [GRLIB_capture_size, GRLIB_capture_size * 1.4] select (_sector in sectors_bigtown);
private _red = [(markerPos _sector), _range, GRLIB_side_enemy] call KPLIB_fnc_getUnitsCount;
private _blue = [(markerPos _sector), _range, GRLIB_side_friendly] call KPLIB_fnc_getUnitsCount;
if (_blue > 0 || _red > 0) then {
_blue / (_blue + _red)
} else {
[0, 1] select (_sector in blufor_sectors)
};

View File

@@ -0,0 +1,18 @@
/*
File: fn_getCommander.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-11-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns the actual commander object.
Parameter(s):
NONE
Returns:
Commander [OBJECT]
*/
missionNamespace getVariable ["commandant", objNull]

View File

@@ -0,0 +1,33 @@
/*
File: fn_getCrateHeight.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-03-26
Last Update: 2020-03-26
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the height for the relative positioning of a crate.
Parameter(s):
_crateClass - Classname of the crate to get the height for [STRING, defaults to ""]
Returns:
Height for given class [NUMBER]
*/
params [
["_crateClass", "", [""]]
];
if (_crateClass isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; 0};
private _height = 0;
switch (_crateClass) do {
case KP_liberation_supply_crate: {_height = 0.4;};
case KP_liberation_ammo_crate: {_height = 0.6;};
case KP_liberation_fuel_crate: {_height = 0.3;};
default {_height = 0.6;};
};
_height

View File

@@ -0,0 +1,22 @@
/*
File: fn_getFobName.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the FOB name in accordance to the military alphabet set in init presets.
Parameter(s):
_fob - Position of FOB to get the name from [POSITION, defaults to [0, 0, 0]]
Returns:
FOB name [STRING]
*/
params [
["_fob", [0, 0, 0], [[]], [2, 3]]
];
military_alphabet param [GRLIB_all_fobs findIf {(_x distance2d _fob) < 100}, ""]

View File

@@ -0,0 +1,24 @@
/*
File: fn_getFobResources.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-05-08
Last Update: 2020-05-09
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the FOB resource data in format [<POSITION>, <SUPPLIES>, <AMMO>, <FUEL>, <HAS_AIR_BUILD>, <HAS_REC_WORKSHOP>].
Parameter(s):
_fob - Position of FOB to get resources of [POSITION, defaults to [0, 0, 0]]
Returns:
FOB resource data [ARRAY]
*/
#define NO_RESULT [[0, 0, 0], 0, 0, 0, false, false]
params [
["_fob", [0, 0, 0], [[]], [2, 3]]
];
KP_liberation_fob_resources param [KP_liberation_fob_resources findIf {(_x select 0) isEqualTo _fob}, NO_RESULT] // return

View File

@@ -0,0 +1,50 @@
/*
File: fn_getGroupType.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2020-04-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the type of a given group.
Can be infantry, light, heavy, air, support, static or UAV.
Parameter(s):
_grp - Group to get the type from [GROUP, defaults to grpNull]
Returns:
Group type [STRING]
*/
params [
["_grp", grpNull, [grpNull]]
];
if (isNull _grp) exitWith {["Null group given"] call BIS_fnc_error; ""};
private _grpType = "infantry";
private _vehType = "";
// Get vehicle type, if at least one group member is in a crew seat
private _parent = objNull;
{
_parent = objectParent _x;
if (!(isNull _parent) && {_x in [driver _parent, gunner _parent, commander _parent]}) exitWith {
_vehType = typeOf (objectParent _x);
};
} forEach (units _grp);
// Exit with infantry, if not as crew in objectParent
if (_vehType isEqualTo "") exitWith {_grpType};
// Otherwise continue to get the type of the vehicle
[] call {
if ((toLower _vehType) in KPLIB_b_light_classes) exitWith {_grpType = "light";};
if ((toLower _vehType) in KPLIB_b_heavy_classes) exitWith {_grpType = "heavy";};
if ((toLower _vehType) in KPLIB_b_air_classes) exitWith {_grpType = "air";};
if ((toLower _vehType) in KPLIB_b_static_classes) exitWith {_grpType = "static";};
if ((toLower _vehType) in KPLIB_b_support_classes) exitWith {_grpType = "support";};
if ([_vehType] call KPLIB_fnc_isClassUAV) exitWith {_grpType = "uav";};
};
_grpType

View File

@@ -0,0 +1,31 @@
/*
File: fn_getLessLoadedHC.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns the HC with the current less load.
Parameter(s):
NONE
Returns:
Less loaded HC [OBJECT]
*/
private _hcArray = [];
private _hc = objNull;
{
_hc = _x;
_hcArray pushBack [count (allUnits select {(owner _x) isEqualTo (owner _hc)}), _hc];
} forEach (entities "HeadlessClient_F");
if !(_hcArray isEqualTo []) then {
_hcArray sort true;
(_hcArray select 0) select 1
} else {
objNull
};

View File

@@ -0,0 +1,297 @@
/*
File: fn_getLoadout.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-11-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
No description added yet.
Parameter(s):
_localVariable - Description [DATATYPE, defaults to DEFAULTVALUE]
Returns:
Function reached the end [BOOL]
*/
// TODO
/*
AUTHOR: aeroson
NAME: get_loadout.sqf
VERSION: 3.4
DOWNLOAD & PARTICIPATE:
https://github.com/aeroson/a3-loadout
http://forums.bistudio.com/showthread.php?148577-GET-SET-Loadout-(saves-and-loads-pretty-much-everything)
DESCRIPTION:
I guarantee backwards compatibility.
These scripts allows you set/get (load/save)all of the unit's gear, including:
uniform, vest, backpack, contents of it, all quiped items, all three weapons with their attachments, currently loaded magazines and number of ammo in magazines.
All this while preserving order of items.
Useful for saving/loading loadouts.
Ideal for revive scripts where you have to set exactly the same loadout to newly created unit.
Uses workaround with placeholders to add vest/backpack items, so items stay where you put them.
PARAMETER(S):
0 : target unit
1 : (optional) array of options, default [] :
"ammo" will save ammo count of partially emptied magazines
"repetitive" intended for repetitive use, will not use selectWeapon, means no visible effect on solder, but will not save magazines of assigned items such as laser designator batteries
RETURNS:
Array : array of strings/arrays containing target unit's loadout, to be used by fnc_set_loadout.sqf
addAction support:
Saves player's loadout into global var loadout
*/
private ["_target","_options","_saveMagsAmmo","_isRepetitive","_isOnFoot","_currentWeapon","_currentMode","_isFlashlightOn","_isIRLaserOn","_magazinesAmmo","_loadedMagazines","_saveWeaponMagazines","_getMagsAmmo","_backPackItems","_assignedItems","_data"];
_options = [];
// addAction support
if(count _this < 4) then {
#define PARAM_START private ["_PARAM_INDEX"]; _PARAM_INDEX=0;
#define PARAM_REQ(A) if (count _this <= _PARAM_INDEX) exitWith { systemChat format["required param '%1' not supplied in file:'%2' at line:%3", #A ,__FILE__,__LINE__]; }; A = _this select _PARAM_INDEX; _PARAM_INDEX=_PARAM_INDEX+1;
#define PARAM(A,B) A = B; if (count _this > _PARAM_INDEX) then { A = _this select _PARAM_INDEX; }; _PARAM_INDEX=_PARAM_INDEX+1;
PARAM_START
PARAM_REQ(_target)
PARAM(_options,[])
} else {
_target = player;
};
_saveMagsAmmo = "ammo" in _options;
_isRepetitive = "repetitive" in _options;
_isOnFoot = vehicle _target == _target;
_currentWeapon = "";
_currentMode = "";
_isFlashlightOn = false;
_isIRLaserOn = false;
_magazinesAmmo = magazinesAmmoFull _target;
// save weapon mode and muzzle
if(_isOnFoot) then {
_currentWeapon = currentMuzzle _target;
_currentMode = currentWeaponMode _target;
_isFlashlightOn = _target isFlashlightOn _currentWeapon;
_isIRLaserOn = _target isIRLaserOn _currentWeapon;
} else {
_currentWeapon = currentWeapon _target;
};
_loadedMagazines=[];
// universal weapon saving
_saveWeaponMagazines = {
private ["_weapon","_magazines","_muzzles","_saveMagazine"];
_weapon = _this select 0;
_magazines = [];
_saveMagazine = { // find, save and eat mag for _weapon
private ["_weapon","_magazine","_ammo"];
_weapon = _this select 0;
_magazine = "";
_ammo = 0;
{
if((_x select 4)==_weapon) then {
_magazine = _x select 0;
_ammo = _x select 1;
_x = -1;
};
} forEach _magazinesAmmo;
_magazinesAmmo = _magazinesAmmo - [-1];
if(_magazine!="") then {
if(_saveMagsAmmo) then {
_magazines set [count _magazines, [_magazine, _ammo]];
} else {
_magazines set [count _magazines, _magazine];
};
};
};
if(_weapon != "") then {
[_weapon] call _saveMagazine;
_muzzles = configFile>>"CfgWeapons">>_weapon>>"muzzles";
if(isArray(_muzzles)) then {
{ // add one mag for each muzzle
if (_x != "this") then {
[_x] call _saveMagazine;
};
} forEach getArray(_muzzles);
};
};
_loadedMagazines set [count _loadedMagazines, _magazines];
};
// save loaded mags for each weapon separetely, since some weapons can use same magazines
[primaryWeapon _target] call _saveWeaponMagazines;
[handgunWeapon _target] call _saveWeaponMagazines;
[secondaryWeapon _target] call _saveWeaponMagazines;
_getMagsAmmo = { // default function with _saveMagsAmmo == false
_this select 0;
};
if(_saveMagsAmmo) then {
// check if input array contains magazine, if it does, find it add ammo count
_getMagsAmmo = {
private ["_items","_location","_item","_itemIndex"];
_items = _this select 0;
_location = _this select 1;
{
_item = _x;
_itemIndex = _forEachIndex;
{
if((_x select 4)==_location && (_x select 0)==_item) then {
_items set[_itemIndex, [_item, _x select 1]];
_x = -1;
};
} forEach _magazinesAmmo;
_magazinesAmmo = _magazinesAmmo - [-1];
} forEach _items;
_items;
};
};
// get backpack items
_cargo = getbackpackcargo (unitbackpack _target);
_backpacks = [];
{
for "_i" from 1 to ((_cargo select 1) select _foreachindex) do {
_backpacks set [count _backpacks, _x];
};
} foreach (_cargo select 0);
_backPackItems = (backpackitems _target) + _backpacks;
// get assigned items, headgear and goggles is not part of assignedItems
_assignedItems = assignedItems _target;
_headgear = headgear _target;
_goggles = goggles _target;
if((_headgear != "") && !(_headgear in _assignedItems)) then {
_assignedItems set [count _assignedItems, _headgear];
};
if((_goggles != "") && !(_goggles in _assignedItems)) then {
_assignedItems set [count _assignedItems, _goggles];
};
/*
// use this once magazinesAmmoFull is fixed and shows magazines of assignedItems
// get magazines of everything else except weapons, most likely assigned items
// only ["Uniform","Vest","Backpack"] locations remain, weapon locations have already been eaten
_magazines = [];
{
if(_x select 2) then {
if(_saveMagsAmmo) then {
_magazines set[count _magazines, [_x select 0, _x select 1]];
} else {
_magazines set[count _magazines, _x select 0];
};
_x = -1;
};
} forEach _magazinesAmmo;
_magazinesAmmo = _magazinesAmmo - [-1];
_loadedMagazines set [3, _magazines];
*/
// old method using selectWeapon, cycles and tries to selectWeapon all assigned items
if(!_isRepetitive) then {
private ["_weaponHasChanged"];
_weaponHasChanged = false;
// get magazines of all assigned items
_magazines = [];
{
_target selectWeapon _x;
if(currentWeapon _target==_x) then {
_weaponHasChanged = true;
_magazine = currentMagazine _target;
if(_magazine != "") then {
if(_saveMagsAmmo) then {
_magazines set[count _magazines, [_magazine, _target ammo _x]];
} else {
_magazines set[count _magazines, _magazine];
};
};
};
} forEach _assignedItems;
_loadedMagazines set [3, _magazines];
// select back originaly selected weapon and mode, only if weapon has changed
if(_weaponHasChanged) then {
if(_isOnFoot) then {
if(_currentWeapon != "" && _currentMode != "") then {
_muzzles = 0;
while{ (_currentWeapon != currentMuzzle _target || _currentMode != currentWeaponMode _target ) && _muzzles < 200 } do {
_target action ["SWITCHWEAPON", _target, _target, _muzzles];
_muzzles = _muzzles + 1;
};
if(_isFlashlightOn) then {
_target action ["GunLightOn"];
} else {
_target action ["GunLightOff"];
};
if(_isIRLaserOn) then {
_target action ["IRLaserOn"];
} else {
_target action ["IRLaserOff"];
};
};
} else {
_currentMode = "";
};
if(_currentMode == "") then {
if(_currentWeapon=="") then {
_target action ["SWITCHWEAPON", _target, _target, 0];
} else {
_target selectWeapon _currentWeapon;
};
};
};
};
_data = [
_assignedItems, //0 []
primaryWeapon _target, //1 ""
primaryWeaponItems _target, //2 []
handgunWeapon _target, //3 ""
handgunItems _target, //4 []
secondaryWeapon _target, //5 ""
secondaryWeaponItems _target, //6 []
uniform _target, //7 ""
[uniformItems _target, "Uniform"] call _getMagsAmmo, //8 ["magazine without ammo count",["magazine with ammo count",30], ....]
vest _target, //9 ""
[vestItems _target, "Vest"] call _getMagsAmmo, //10
backpack _target, //11 ""
[_backPackItems, "Backpack"] call _getMagsAmmo, //12
_loadedMagazines, //13 (optional) [[primary mags],[handgun mags],[secondary mags],[other mags]]
_currentWeapon, //14 (optional) ""
_currentMode //15 (optional) ""
];
// addAction support
if(count _this < 4) then {
_data;
} else {
loadout = _data;
//playSound3D ["A3\Sounds_F\sfx\ZoomOut.wav", _target];
};

View File

@@ -0,0 +1,18 @@
/*
File: fn_getLocalCap.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the current blufor unit cap.
Parameter(s):
NONE
Returns:
Blufor unit cap [NUMBER]
*/
(round (infantry_cap / 2)) min GRLIB_blufor_cap

View File

@@ -0,0 +1,28 @@
/*
File: fn_getLocationName.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-12-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the name of the nearest FOB/sector from given position.
Parameter(s):
_pos - Position to get the location name from [POSITION, defaults to [0, 0, 0]]
Returns:
Location name [STRING]
*/
params [
["_pos", [0, 0, 0], [[]], [2, 3]]
];
private _name = [_pos] call KPLIB_fnc_getFobName;
if (_name isEqualTo "") then {
markerText ([50, _pos] call KPLIB_fnc_getNearestSector)
} else {
["FOB", _name] joinString " "
};

View File

@@ -0,0 +1,37 @@
/*
File: fn_getMilitaryId.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-09-14
Last Update: 2019-12-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Converts a number to an ID string.
Parameter(s):
_number - ID number to convert (starts with 0 as first character) [NUMBER, defaults to -1]
Returns:
Military ID [STRING]
*/
params [
["_number", -1, [0]]
];
if (_number isEqualTo -1) exitWith {["No valid number given"] call BIS_fnc_error; ""};
_number = _number + 1;
private _return = [];
private _alphabetCount = count military_alphabet;
private _remain = 0;
while {_number > 0} do {
_remain = _number % _alphabetCount;
_number = floor (_number / _alphabetCount);
_return append [_remain - 1];
};
reverse _return;
(_return apply {military_alphabet select _x}) joinString " "

View File

@@ -0,0 +1,27 @@
/*
File: fn_getMobileRespawns.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-12-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets all mobile respawn vehicles sorted by their positions X value.
Parameter(s):
NONE
Returns:
Mobile respawns [ARRAY]
*/
private _respawn_trucks = vehicles select {
(typeOf _x) in [Respawn_truck_typename, huron_typename] &&
{alive _x} &&
{_x distance2d startbase > 500} &&
{abs (speed _x) < 5} &&
{(isTouchingGround _x || {5 > ((getPos _x) select 2)})} &&
{!surfaceIsWater (getPos _x)}
};
[_respawn_trucks, [], {(getPos _x) select 0}, 'ASCEND'] call BIS_fnc_sortBy

View File

@@ -0,0 +1,24 @@
/*
File: fn_getNearbyPlayers.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-12-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets all alive players inside given radius to given position.
Parameter(s):
_pos - Center position to search from [POSITION, defaults to [0, 0, 0]]
_radius - Radius from center position to search from [NUMBER, defaults to 100]
Returns:
Nearby alive players [ARRAY]
*/
params [
["_pos", [0, 0, 0], [[2, 3]]],
["_radius", 100, [0]]
];
allPlayers select {alive _x && {(_x distance2d _pos) < _radius}}

View File

@@ -0,0 +1,28 @@
/*
File: fn_getNearestBluforObjective.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-11
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the position of the nearest blufor sector/fob from given position.
Parameter(s):
_pos - Position to check for nearest blufor sector/fob [POSITION, defaults to [0, 0, 0]]
Returns:
Nearest blufor sector/fob position [POSITION]
*/
params [
["_pos", [0, 0, 0], [[]], [2, 3]]
];
if (GRLIB_all_fobs isEqualTo [] && blufor_sectors isEqualTo []) exitWith {[]};
private _objectives = GRLIB_all_fobs + (blufor_sectors apply {markerPos _x});
_objectives = _objectives apply {[_x distance2d _pos, _x]};
_objectives sort true;
(_objectives select 0) select 1

View File

@@ -0,0 +1,28 @@
/*
File: fn_getNearestFob.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the nearest FOB position to given position.
Parameter(s):
_pos - Position to find the nearest FOB from [POSITION, defaults to getPos player]
Returns:
Nearest FOB position [POSITION]
*/
params [
["_pos", getPos player, [[]], [2, 3]]
];
if !(GRLIB_all_fobs isEqualTo []) then {
private _fobs = GRLIB_all_fobs apply {[_pos distance2d _x, _x]};
_fobs sort true;
(_fobs select 0) select 1
} else {
[]
};

View File

@@ -0,0 +1,31 @@
/*
File: fn_getNearestSector.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-11
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the marker of the nearest sector from given position inside given radius.
Parameter(s):
_radius - Radius in which to look for the nearest sector [NUMBER, defaults to 1000]
_pos - Position to look from for the nearest sector [POSITION, defaults to getPos player]
Returns:
Marker of nearest sector [STRING]
*/
params [
["_radius", 1000, [0]],
["_pos", getPos player, [[]], [2, 3]]
];
private _sectors = sectors_allSectors select {((markerPos _x) distance2d _pos) < _radius};
if (_sectors isEqualTo []) exitWith {""};
_sectors = _sectors apply {[(markerPos _x) distance2d _pos, _x]};
_sectors sort true;
(_sectors select 0) select 1

View File

@@ -0,0 +1,30 @@
/*
File: fn_getNearestTower.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets nearest radio tower marker occupied by given side inside given radius from given position.
Parameter(s):
_pos - Position from which to look for the nearest radio tower [POSITION, defaults to [0, 0, 0]]
_side - Side of owner for nearest radio tower [SIDE, defaults to GRLIB_side_enemy]
_radius - Radius in which to look for the nearest radio tower [NUMBER, defaults to 1000]
Returns:
Marker of nearest radio tower [STRING]
*/
params [
["_pos", [0, 0, 0], [[]], [2, 3]],
["_side", GRLIB_side_enemy, [sideEmpty]],
["_radius", 1000, [0]]
];
private _towers = [sectors_tower select {_x in blufor_sectors}, sectors_tower - blufor_sectors] select (_side == GRLIB_side_enemy);
_towers = (_towers apply {[(markerPos _x) distance2d _pos, _x]}) select {(_x select 0) <= _radius};
_towers sort true;
(_towers select 0) select 1

View File

@@ -0,0 +1,24 @@
/*
File: fn_getNearestViVTransport.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-05-08
Last Update: 2019-12-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets nearest object that can transport given object via ViV.
Parameter(s):
_object - Object to get a transport vehicle for [OBJECT, defaults to objNull]
_radius - Radius to look for a transport vehicle [NUMBER, defaults to 15]
Returns:
Closest transport or objNull [OBJECT]
*/
params [
["_object", objNull, [objNull]],
["_radius", 15, [0]]
];
((nearestObjects [_object, ["AllVehicles"], _radius]) select {(_x canVehicleCargo _object) select 0}) param [0, objNull]

View File

@@ -0,0 +1,18 @@
/*
File: fn_getOpforCap.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets current amount of total opfor units.
Parameter(s):
NONE
Returns:
Total opfor units [NUMBER]
*/
GRLIB_side_enemy countSide allUnits

View File

@@ -0,0 +1,22 @@
/*
File: fn_getOpforFactor.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-11-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns the opfor factor to scale down enemy forces, if "adapt to player count" mission param is enabled.
Parameter(s):
NONE
Returns:
Opfor factor [NUMBER]
*/
if !(GRLIB_adaptive_opfor) exitWith {1};
private _bluforcount = (0.2 * (GRLIB_side_friendly countSide allUnits)) + ([] call KPLIB_fnc_getPlayerCount);
(0.5 + (_bluforcount / 25.0)) min 1

View File

@@ -0,0 +1,108 @@
/*
File: fn_getOpforSpawnPoint.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2020-04-17
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets a random opfor spawn point marker name respecting following conditions:
* Wasn't used already in the current session (server restart to server restart)
* Distance to blufor FOBs and sectors is more than given min distance
* Distance to blufor FOBs and sectors is less than given max distance
* Distance to an opfor sector is less than 2000m (to avoid strange spawn in blufor territory)
* If nearest is set to true, the valid spawn point which is nearest to any blufor sector/FOB is returned
* If a position is given, the closest valid spawn point to that position is returned
Parameter(s):
_min - Minimum distance to any blufor sector or FOB [NUMBER, defaults to 2000]
_max - Maximum distance to any blufor sector or FOB [NUMBER, defaults to 20000]
_nearest - Provide the nearest spawn point of valid points [BOOL, defaults to false]
_pos - Position if the nearest spawn point to this should be selected [POSITION, defaults to [0, 0, 0]]
Returns:
Opfor spawn point [STRING]
*/
params [
["_min", 2000, [0]],
["_max", 20000, [0]],
["_nearest", false, [false]],
["_pos", [0, 0, 0], [[]], [2, 3]]
];
private _possibleSpawns = [];
// Only check for opfor spawn points which aren't used already in the current session
private _spawnsToCheck = sectors_opfor;
if (!isNil "used_positions") then {
_spawnsToCheck = sectors_opfor - used_positions;
};
private ["_valid", "_current", "_distances"];
{
_valid = true;
_current = _x;
// Shouldn't be too close to the current/last position of a secondary mission
if (!isNil "secondary_objective_position" && _valid) then {
if !(secondary_objective_position isEqualTo []) then {
_valid = !(((markerPos _current) distance2d secondary_objective_position) < 500);
};
};
if (_valid) then {
// Fetch distances to FOBs
_distances = (GRLIB_all_fobs apply {(markerPos _current) distance2d _x}) select {_x < _max};
// Fetch distances to blufor sectors
_distances append ((blufor_sectors apply {(markerPos _current) distance2d (markerPos _x)}) select {_x < _max});
// Invalid, if all sectors and FOBs are further away than given max distance
if (_distances isEqualTo []) then {
_valid = false;
} else {
// Invalid, if one sector or FOB is closer than min distance
_distances sort true;
if ((_distances select 0) < _min) then {
_valid = false;
};
};
};
// Make sure that there is an opfor sector in sensible range to spawn
if (_valid) then {
if ((sectors_allSectors - blufor_sectors) findIf {((markerPos _current) distance2D (markerPos _x)) < 2000} < 0) then {
_valid = false;
};
};
// Make sure that there is no blufor unit inside min dist to spawn
if (_valid) then {
if (([markerpos _current, _min, GRLIB_side_friendly] call KPLIB_fnc_getUnitsCount) > 0) then {
_valid = false;
};
};
// Add distance and marker name to possible spawn, if still valid
if (_valid) then {
_possibleSpawns pushBack [_distances select 0, _current];
};
} forEach _spawnsToCheck;
// Return empty string, if no possible spawn point was found
if (_possibleSpawns isEqualTo []) exitWith {["No opfor spawn point found", "WARNING"] call KPLIB_fnc_log; ""};
// Return nearest spawn point to a blufor sector/FOB, if selected via parameter
if (_nearest) exitWith {
_possibleSpawns sort true;
(_possibleSpawns select 0) select 1
};
// Return nearest spawn point to given position, if provided
if !(_pos isEqualTo [0, 0, 0]) exitWith {
([_possibleSpawns apply {_x select 1}, [_pos] , {_input0 distance (markerPos _x)} , "ASCEND"] call BIS_fnc_sortBy) select 0
};
// Return random spawn point
(selectRandom _possibleSpawns) select 1

View File

@@ -0,0 +1,18 @@
/*
File: fn_getPlayerCount.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-11-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns the number of connected players without counting headless clients.
Parameter(s):
NONE
Returns:
Amount of players [NUMBER]
*/
count (allPlayers - entities "HeadlessClient_F")

View File

@@ -0,0 +1,22 @@
/*
File: fn_getResistanceTier.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-10-08
Last Update: 2019-12-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns the current tier level of the resistance forces.
Parameter(s):
NONE
Returns:
Tier level [NUMBER]
*/
switch (true) do {
case (KP_liberation_guerilla_strength >= KP_liberation_resistance_tier3): {3};
case (KP_liberation_guerilla_strength >= KP_liberation_resistance_tier2): {2};
default {1};
};

View File

@@ -0,0 +1,208 @@
/*
File: fn_getSaveData.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-03-29
Last Update: 2020-08-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gather current session data for saving.
Parameter(s):
NONE
Returns:
Save data [ARRAY]
*/
private _objectsToSave = [];
private _resourceStorages = [];
private _aiGroups = [];
private _allObjects = [];
private _allStorages = [];
private _allMines = [];
private _allCrates = [];
// Get all blufor groups
private _allBlueGroups = allGroups select {
(side _x == GRLIB_side_friendly) && // Only blufor groups
{isNull objectParent (leader _x)} && // Make sure it's an infantry group
{!(((units _x) select {alive _x}) isEqualTo [])} // At least one unit has to be alive
};
// Fetch all objects and AI groups near each FOB
private ["_fobPos", "_fobObjects", "_grpUnits", "_fobMines"];
{
_fobPos = _x;
_fobObjects = (_fobPos nearObjects (GRLIB_fob_range * 1.2)) select {
((toLower (typeof _x)) in KPLIB_classnamesToSave) && // Exclude classnames which are not in the presets
{alive _x} && // Exclude dead or broken objects
{getObjectType _x >= 8} && // Exclude preplaced terrain objects
{speed _x < 5} && // Exclude moving objects (like civilians driving through)
{isNull attachedTo _x} && // Exclude attachTo'd objects
{((getpos _x) select 2) < 10} && // Exclude hovering helicopters and the like
{!(_x getVariable ["KP_liberation_edenObject", false])} && // Exclude all objects placed via editor in mission.sqm
{!(_x getVariable ["KP_liberation_preplaced", false])} && // Exclude preplaced (e.g. little birds from carrier)
{!((toLower (typeOf _x)) in KPLIB_crates)} // Exclude storage crates (those are handled separately)
};
_allObjects = _allObjects + (_fobObjects select {!((toLower (typeOf _x)) in KPLIB_storageBuildings)});
_allStorages = _allStorages + (_fobObjects select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0});
// Process all groups near this FOB
{
// Get only living AI units of the group by excluding possible POWs currently in the player group
_grpUnits = (units _x) select {!(isPlayer _x) && (alive _x) && !((typeOf _x) in KPLIB_o_inf_classes) && !((typeOf _x) in militia_squad)};
// Add to save array
_aiGroups pushBack [getPosATL (leader _x), (_grpUnits apply {typeOf _x})];
} forEach (_allBlueGroups select {(_fobPos distance2D (leader _x)) < (GRLIB_fob_range * 1.2)});
// Save all mines around FOB
_fobMines = allMines inAreaArray [_fobPos, GRLIB_fob_range * 1.2, GRLIB_fob_range * 1.2];
_allMines append (_fobMines apply {[
getPosWorld _x,
[vectorDirVisual _x, vectorUpVisual _x],
typeOf _x,
_x mineDetectedBy GRLIB_side_friendly
]});
} forEach GRLIB_all_fobs;
// Save all fetched objects
private ["_savedPos", "_savedVecDir", "_savedVecUp", "_class", "_hasCrew"];
{
// Position data
_savedPos = getPosWorld _x;
_savedVecDir = vectorDirVisual _x;
_savedVecUp = vectorUpVisual _x;
_class = typeOf _x;
_hasCrew = false;
// Determine if vehicle is crewed
if ((toLower _class) in KPLIB_b_allVeh_classes) then {
if (({!isPlayer _x} count (crew _x) ) > 0) then {
_hasCrew = true;
};
};
// Only save player side, seized or captured objects
if (
(!(_class in civilian_vehicles) || {_x getVariable ["KPLIB_seized", false]}) &&
(!((toLower _class) in KPLIB_o_allVeh_classes) || {_x getVariable ["KPLIB_captured", false]})
) then {
_objectsToSave pushBack [_class, _savedPos, _savedVecDir, _savedVecUp, _hasCrew];
};
} forEach _allObjects;
// Save all storages and resources
private ["_supplyValue", "_ammoValue", "_fuelValue"];
{
// Position data
_savedPos = getPosWorld _x;
_savedVecDir = vectorDirVisual _x;
_savedVecUp = vectorUpVisual _x;
_class = typeOf _x;
// Resource variables
_supplyValue = 0;
_ammoValue = 0;
_fuelValue = 0;
// Sum all stored resources of current storage
{
switch ((typeOf _x)) do {
case KP_liberation_supply_crate: {_supplyValue = _supplyValue + (_x getVariable ["KP_liberation_crate_value",0]);};
case KP_liberation_ammo_crate: {_ammoValue = _ammoValue + (_x getVariable ["KP_liberation_crate_value",0]);};
case KP_liberation_fuel_crate: {_fuelValue = _fuelValue + (_x getVariable ["KP_liberation_crate_value",0]);};
default {[format ["Invalid object (%1) at storage area", (typeOf _x)], "ERROR"] call KPLIB_fnc_log;};
};
} forEach (attachedObjects _x);
// Add to saving with corresponding resource values
_resourceStorages pushBack [_class, _savedPos, _savedVecDir, _savedVecUp, _supplyValue, _ammoValue, _fuelValue];
} forEach _allStorages;
// Save crates at blufor sectors which spawn crates on activation
{
_allCrates append (
((nearestObjects [markerPos _x, KPLIB_crates, GRLIB_capture_size]) select {isNull attachedTo _x}) apply {
[typeOf _x, _x getVariable ["KP_liberation_crate_value", 0], getPosATL _x]
}
);
} forEach (blufor_sectors select {_x in sectors_factory || _x in sectors_capture});
// Pack all stats in one array
private _stats = [
stats_ammo_produced,
stats_ammo_spent,
stats_blufor_soldiers_killed,
stats_blufor_soldiers_recruited,
stats_blufor_teamkills,
stats_blufor_vehicles_built,
stats_blufor_vehicles_killed,
stats_civilian_buildings_destroyed,
stats_civilian_vehicles_killed,
stats_civilian_vehicles_killed_by_players,
stats_civilian_vehicles_seized,
stats_civilians_healed,
stats_civilians_killed,
stats_civilians_killed_by_players,
stats_fobs_built,
stats_fobs_lost,
stats_fuel_produced,
stats_fuel_spent,
stats_hostile_battlegroups,
stats_ieds_detonated,
stats_opfor_killed_by_players,
stats_opfor_soldiers_killed,
stats_opfor_vehicles_killed,
stats_opfor_vehicles_killed_by_players,
stats_player_deaths,
stats_playtime,
stats_prisoners_captured,
stats_readiness_earned,
stats_reinforcements_called,
stats_resistance_killed,
stats_resistance_teamkills,
stats_resistance_teamkills_by_players,
stats_secondary_objectives,
stats_sectors_liberated,
stats_sectors_lost,
stats_spartan_respawns,
stats_supplies_produced,
stats_supplies_spent,
stats_vehicles_recycled
];
// Pack the weights in one array
private _weights = [
infantry_weight,
armor_weight,
air_weight
];
// Pack the save data in the save array
[
kp_liberation_version,
date,
_objectsToSave,
_resourceStorages,
_stats,
_weights,
_aiGroups,
blufor_sectors,
combat_readiness,
GRLIB_all_fobs,
GRLIB_permissions,
GRLIB_vehicle_to_military_base_links,
KP_liberation_civ_rep,
KP_liberation_clearances,
KP_liberation_guerilla_strength,
KP_liberation_logistics,
KP_liberation_production,
KP_liberation_production_markers,
resources_intel,
_allMines,
_allCrates,
KPLIB_sectorTowers
] // return

View File

@@ -0,0 +1,93 @@
/*
File: fn_getSaveableParam.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-01-27
Last Update: 2020-04-17
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Saves/loads/fetches mission parameter from profileNamespace depending on "_action" argument.
If no action provided value from "KP_load_params" variable is used.
On SP enviroment saving/loading is disabled.
Parameter(s):
_paramName - Name of parameter [STRING, defaults to ""]
_defaultValue - Default value if parameter not found or no saved value [NUMBER, defaults to 0]
_action - Should save(0)/load(1) from profile namespace or get(2) from selected param value [NUMBER, defaults to nil]
Returns:
Parameter value [BOOL]
*/
params [
["_paramName", "", [""]],
["_defaultValue", 0, [0]],
["_action", nil, [0]]
];
private _saveKey = "KP_LIBERATION_" + (toUpper worldName) + "_SAVE_PARAMS";
private _value = nil;
// Use lobby value if no action specified
if(isNil "_action") then {_action = KP_load_params;};
// We propably shoud not load parameters on SP environment
if(!isMultiplayer) then {_action = 2};
switch (_action) do {
// Save to profileNamespace
case 0: {
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
private _savedParams = profileNamespace getVariable _saveKey;
if(isNil "_savedParams") then {
if (KP_liberation_savegame_debug > 0) then {["Param save data is corrupted, creating new.", "PARAM"] call KPLIB_fnc_log;};
// Create new "associative" array
_savedParams = [[_paramName, _value]];
} else {
private _singleParam = (_savedParams select {(_x select 0) == _paramName}) select 0;
if(isNil "_singleParam") then {
if (KP_liberation_savegame_debug > 0) then {[format ["Saving value: %1 for param: %2", _value, _paramName], "PARAM"] call KPLIB_fnc_log;};
_savedParams pushBack [_paramName, _value];
} else {
if (KP_liberation_savegame_debug > 0) then {[format ["Overwriting value: %1 with: %2 for param: %3", (_singleParam select 1), _value, _paramName], "PARAM"] call KPLIB_fnc_log;};
// _singleparam is an reference to array in _savedParams, we can use "set"
_singleParam set [1, _value];
};
};
// Save params to profile namespace
profileNamespace setVariable [_saveKey, _savedParams];
saveProfileNamespace;
};
// Load from profileNamespace
case 1: {
private _savedParams = profileNamespace getVariable _saveKey;
if(isNil "_savedParams") then {
if (KP_liberation_savegame_debug > 0) then {["Param save data is corrupted, can't load!", "PARAM"] call KPLIB_fnc_log;};
// Fix param save data
profileNamespace setVariable [_saveKey, []];
if (KP_liberation_savegame_debug > 0) then {[format ["No saved value for param: %1, fetching value.", _paramName], "PARAM"] call KPLIB_fnc_log;};
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
} else {
private _singleParam = (_savedParams select {(_x select 0) == _paramName}) select 0;
if(isNil "_singleParam") then {
if (KP_liberation_savegame_debug > 0) then {[format ["No saved value for param: %1, fetching value.", _paramName], "PARAM"] call KPLIB_fnc_log;};
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
} else {
if (KP_liberation_savegame_debug > 0) then {[format ["Found value: %1 for param: %2,", (_singleParam select 1), _paramName], "PARAM"] call KPLIB_fnc_log;};
_value = _singleParam select 1;
};
};
};
// Get param
default {
if (KP_liberation_savegame_debug > 0) then {[format ["Fetching selected value for param: %1", _paramName], "PARAM"] call KPLIB_fnc_log;};
_value = [_paramName, _defaultValue] call bis_fnc_getParamValue;
};
};
// Return param value
_value;

View File

@@ -0,0 +1,39 @@
/*
File: fn_getSectorOwnership.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-05-02
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the side of the owner of a given position with given radius.
Parameter(s):
_pos - Position to get owner [POSITION, defaults to [0, 0, 0]]
_radius - Radius to count units [NUMBER, defaults to GRLIB_capture_size]
Returns:
Owner of the position [SIDE]
*/
params [
["_pos", [0, 0, 0], [[]], [2, 3]],
["_radius", GRLIB_capture_size, [0]]
];
private _capCount = 3;
private _capRatio = 0.85;
private _capRatioMin = 0.51;
private _blufor = [_pos, _radius, GRLIB_side_friendly] call KPLIB_fnc_getUnitsCount;
private _opfor = [_pos, _radius, GRLIB_side_enemy] call KPLIB_fnc_getUnitsCount;
private _ratio = 0;
if (_blufor + _opfor != 0) then {
_ratio = _blufor / (_blufor + _opfor);
};
if (_blufor > 0 && {(_opfor <= _capCount && _ratio > _capRatioMin) || _ratio > _capRatio}) exitWith {GRLIB_side_friendly};
if (_blufor == 0 && _opfor > _capCount) exitWith {GRLIB_side_enemy};
if (_blufor == 0 && _opfor <= _capCount) exitWith {GRLIB_side_civilian};
GRLIB_side_resistance

View File

@@ -0,0 +1,25 @@
/*
File: fn_getSectorRange.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2019-12-07
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the sector size with taking the given amount of units into account.
Parameter(s):
_unitCount - Number of units to take into account [NUMBER, defaults to 0]
Returns:
Calculated sector size [NUMBER]
*/
params [
["_unitCount", 0, [0]]
];
if (_unitCount < (GRLIB_sector_cap / 2)) exitWith {GRLIB_sector_size};
if (_unitCount <= GRLIB_sector_cap) exitWith {GRLIB_sector_size - (GRLIB_sector_size * 0.5 * ((_unitCount / GRLIB_sector_cap) - 0.5))};
GRLIB_sector_size * 0.75

View File

@@ -0,0 +1,58 @@
/*
File: fn_getSquadComp.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2020-04-24
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Provides an infantry squad composition of classnames in accordance to the current weights to adapt to the players playstyle.
Parameter(s):
_type - Type of infantry. Army or militia [STRING, defaults to "army"]
Returns:
Array of infantry classnames [ARRAY]
*/
params [
["_type", "army", [""]]
];
private _squadcomp = [];
if (_type == "army") then {
private _selected = false;
private _randomchance = 0;
_squadcomp = KPLIB_o_squadStd;
if (armor_weight > 40 && !_selected) then {
_randomchance = (armor_weight - 35) * 1.4;
if ((random 100) < _randomchance) then {
_selected = true;
_squadcomp = KPLIB_o_squadTank;
};
};
if (air_weight > 40 && !_selected) then {
_randomchance = (air_weight - 35) * 1.4;
if ((random 100) < _randomchance) then {
_selected = true;
_squadcomp = KPLIB_o_squadAir;
};
};
if (infantry_weight > 40 && !_selected) then {
_randomchance = (infantry_weight - 35) * 1.4;
if ((random 100) < _randomchance) then {
_selected = true;
_squadcomp = KPLIB_o_squadInf;
};
};
} else {
private _multiplier = 1;
if (GRLIB_unitcap < 1) then {_multiplier = GRLIB_unitcap;};
while {count _squadcomp < (10 * _multiplier)} do {_squadcomp pushback (selectRandom militia_squad)};
};
_squadcomp

View File

@@ -0,0 +1,31 @@
/*
File: fn_getStoragePositions.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-03-27
Last Update: 2020-03-30
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the storage positions and the unload distance for given storage object.
Parameter(s):
_storage - Storage object [OBJECT, defaults to objNull]
Returns:
Positions array and unload distance [ARRAY]
*/
params [
["_storage", objNull, [objNull]]
];
if (isNull _storage) exitWith {["Null object given"] call BIS_fnc_error; [[], 0]};
private _data = [
[KP_liberation_small_storage_building, [KP_liberation_small_storage_positions, 4]],
[KP_liberation_large_storage_building, [KP_liberation_large_storage_positions, 6.5]]
] select {(typeOf _storage) isEqualTo (_x select 0)};
if (_data isEqualTo []) exitWith {["No valid storage object given"] call BIS_fnc_error; [[], 0]};
(_data select 0) select 1

View File

@@ -0,0 +1,29 @@
/*
File: fn_getUnitPositionId.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-07
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the position ID of given unit with vehicleVarName bypassing.
Parameter(s):
_unit - Unit to get the position ID from [OBJECT, defaults to objNull]
Returns:
Position ID [NUMBER]
*/
params [
["_unit", objNull, [objNull]]
];
if (isNull _unit) exitWith {["Null object given"] call BIS_fnc_error; -1};
private _vvn = vehicleVarName _unit;
_unit setVehicleVarName "";
private _str = str _unit;
_unit setVehicleVarName _vvn;
parseNumber (_str select [(_str find ":") + 1])

View File

@@ -0,0 +1,31 @@
/*
File: fn_getUnitsCount.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-05-08
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Gets the amount of units of given side inside given radius of given position.
Parameter(s):
_pos - Description [POSITION, defaults to [0, 0, 0]
_radius - Description [NUMBER, defaults to 100]
_side - Description [SIDE, defaults to GRLIB_side_friendly]
Returns:
Amount of units [NUMBER]
*/
params [
["_pos", [0, 0, 0], [[]], [2, 3]],
["_radius", 100, [0]],
["_side", GRLIB_side_friendly, [sideEmpty]]
];
private _amount = _side countSide ((_pos nearEntities ["Man", _radius]) select {!(captive _x) && ((getpos _x) select 2 < 500)});
{
_amount = _amount + (_side countSide (crew _x));
} forEach ((_pos nearEntities [["Car", "Tank", "Air", "Boat"], _radius]) select {((getpos _x) select 2 < 500) && count (crew _x) > 0});
_amount

View File

@@ -0,0 +1,53 @@
/*
File: fn_getWeaponComponents.sqf
Author: Zharf - https://github.com/zharf
Date: 2019-06-21
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Snatched from CBA since we don't depend on it yet.
Reports class name of base weapon without attachments and all attachments belonging to a pre equipped weapon.
Base weapon and attachments are reported in lower case capitalization.
Fixed version of BIS_fnc_weaponComponents.
Parameter(s):
_weapon - A weapons class name with attachments build in [STRING, defaults to ""]
Returns:
Weapon components [ARRAY]
*/
params [
["_weapon", "", [""]]
];
if (_weapon isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; []};
private _config = configFile >> "CfgWeapons" >> _weapon;
// Return empty array if the weapon doesn't exist
if (!isClass _config) exitWith {
[];
};
// get attachments
private _attachments = [];
{
_attachments pushBack toLower getText (_x >> "item");
} forEach ("true" configClasses (_config >> "LinkedItems")); // inheritance is apparently disabled for these
// get first parent without attachments
private _baseWeapon = "";
while {isClass _config && {getNumber (_config >> "scope") > 0}} do { // Some preset weapons are scope = 1
if (count (_config >> "LinkedItems") == 0) exitWith {
_baseWeapon = configName _config;
};
_config = inheritsFrom _config;
};
private _components = [toLower _baseWeapon];
_components append _attachments;
_components

View File

@@ -0,0 +1,54 @@
/*
File: fn_handlePlacedZeusObject.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-11
Last Update: 2020-04-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Applies all KP Liberation values and functionalities for crates, units and vehicles.
Parameter(s):
_obj - Object to add the functionalities and values to [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_obj", objNull, [objNull]]
];
// Identify kind of placed object once
private _unit = _obj in allUnits;
private _vehicle = _obj in vehicles;
private _crate = (toLower (typeOf _obj)) in KPLIB_crates;
// Exit if building and no resource crate
if !(_unit || _vehicle || _crate) exitWith {false};
// For a vehicle apply clear cargo
if (_vehicle) then {
[_obj] call KPLIB_fnc_clearCargo;
// Add kill manager and object init to possible crew units
{
_x addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
[_x] call KPLIB_fnc_addObjectInit;
} forEach (crew _obj);
};
// Apply kill manager, if it's not a crate
if !(_crate) then {
_obj addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
} else {
// Otherwise apply all needed values/functionalities
_obj setMass 500;
_obj setVariable ["KP_liberation_crate_value", 100, true];
[_obj, true] call KPLIB_fnc_clearCargo;
if (KP_liberation_ace) then {[_obj, true, [0, 1.5, 0], 0] remoteExec ["ace_dragging_fnc_setCarryable"];};
};
// Add object init codes
[_obj] call KPLIB_fnc_addObjectInit;
true

View File

@@ -0,0 +1,38 @@
/*
File: fn_hasPermission.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-11-25
Last Update: 2020-04-09
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Checks if local player has the given permission granted.
Parameter(s):
_permission - Permission to check [NUMBER, defaults to -1]
Returns:
Has permission granted [BOOL]
*/
params [
["_permission", -1, [0]]
];
if (_permission isEqualTo -1) exitWith {["No permission number given"] call BIS_fnc_error; false};
if (!GRLIB_permissions_param) exitWith {true};
if (isNil "GRLIB_last_permission_check_time") then {GRLIB_last_permission_check_time = -1000;};
if (time > GRLIB_last_permission_check_time + 10) then {
GRLIB_last_permission_check_time = time;
GRLIB_permissions_cache = ((GRLIB_permissions select {(_x select 0) isEqualTo (getPlayerUID player)}) select 0) select 2;
};
if (isNil "GRLIB_permissions_cache") exitWith {false};
if (count GRLIB_permissions_cache > _permission) then {
GRLIB_permissions_cache select _permission
} else {
false
};

View File

@@ -0,0 +1,39 @@
/*
File: fn_initSectors.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-29
Last Update: 2020-04-29
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Sorts the placed sector markers to their category array.
Parameter(s):
NONE
Returns:
Function reached the end [BOOL]
*/
sectors_airspawn = [];
sectors_allSectors = [];
sectors_bigtown = [];
sectors_capture = [];
sectors_factory = [];
sectors_military = [];
sectors_opfor = [];
sectors_tower = [];
{
switch (true) do {
case (_x find "bigtown" == 0): {sectors_bigtown pushBack _x; sectors_allSectors pushBack _x;};
case (_x find "capture" == 0): {sectors_capture pushBack _x; sectors_allSectors pushBack _x;};
case (_x find "factory" == 0): {sectors_factory pushBack _x; sectors_allSectors pushBack _x;};
case (_x find "military" == 0): {sectors_military pushBack _x; sectors_allSectors pushBack _x;};
case (_x find "opfor_airspawn" == 0): {sectors_airspawn pushBack _x;};
case (_x find "opfor_point" == 0): {sectors_opfor pushBack _x;};
case (_x find "tower" == 0): {sectors_tower pushBack _x; if (isServer) then {_x setMarkerText format ["%1 %2",markerText _x, mapGridPosition (markerPos _x)];}; sectors_allSectors pushBack _x;};
};
} forEach allMapMarkers;
true

View File

@@ -0,0 +1,18 @@
/*
File: fn_isBigtownActive.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-11
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Checks if a bigtown (capital) is currently activated.
Parameter(s):
NONE
Returns:
Bigtown currently activated [BOOL]
*/
(active_sectors findIf {_x in sectors_bigtown}) != -1

View File

@@ -0,0 +1,24 @@
/*
File: fn_isClassUAV.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-11-17
Last Update: 2019-12-07
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns if given vehicle class is an UAV.
Parameter(s):
_class - Class of object which will be checked if it is an UAV [STRING, defaults to ""]
Returns:
Class is UAV [BOOL]
*/
params [
["_class", "", [""]]
];
if (_class isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; false};
(getNumber (configFile >> "CfgVehicles" >> _class >> "isUav")) == 1

View File

@@ -0,0 +1,32 @@
/*
File: fn_isRadio.sqf
Author: Zharf - https://github.com/zharf
Date: 2019-07-07
Last Update: 2020-05-03
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns whether the classname is a TFAR/ACRE radio or not.
Parameter(s):
_class - Description [STRING, defaults to ""]
Returns:
Item is a radio [BOOL]
*/
params [
["_class", "", [""]]
];
if (_class isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; false};
if ((isClass (configFile >> "CfgPatches" >> "tfar_core")) || (isClass (configFile >> "CfgPatches" >> "task_force_radio"))) exitWith {
_class call TFAR_fnc_isRadio
};
if (isClass (configFile >> "CfgPatches" >> "acre_api")) exitWith {
[_class] call acre_api_fnc_isRadio
};
false

View File

@@ -0,0 +1,35 @@
/*
File: fn_log.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-16
Last Update: 2020-04-20
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Logs given string to the rpt of the machine while adding KP Liberation prefix.
Parameter(s):
_text - Text to write into log [STRING, defaults to ""]
_tag - Tag to display between KPLIB prefix and text [STRING, defaults to "INFO"]
Returns:
Function reached the end [BOOL]
*/
params [
["_text", "", [""]],
["_tag", "INFO", [""]]
];
if (_text isEqualTo "" || _tag isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; false};
private _msg = text ([
"[KPLIB] [",
_tag,
"] ",
_text
] joinString "");
diag_log _msg;
true

View File

@@ -0,0 +1,23 @@
/*
File: fn_potatoScan.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-07
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Returns the current Potato 01, if alive.
Parameter(s):
NONE
Returns:
Potato 01 [OBJECT]
*/
private _potatoes = vehicles select {typeof _x == huron_typename && alive _x};
if !(_potatoes isEqualTo []) then {
_potatoes select 0
} else {
objNull
};

View File

@@ -0,0 +1,29 @@
/*
File: fn_protectObject.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2019-12-08
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Given object will get damage and simulation enabled/disabled.
Parameter(s):
_obj - Object to (un)protect [OBJECT, defaults to objNull]
_enable - Enable/Disable [BOOL, defaults to true]
Returns:
Function reached the end [BOOL]
*/
params [
["_obj", objNull, [objNull]],
["_enable", true, [false]]
];
if (isNull _obj) exitWith {["Null object given"] call BIS_fnc_error; false};
_obj allowDamage _enable;
_obj enableSimulation _enable;
true

View File

@@ -0,0 +1,30 @@
/*
File: fn_secondsToTimer.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-03
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Converts given amount of seconds to a MM:SS string.
Parameter(s):
_amount - Amount of seconds to convert [NUMBER, defaults to 0]
Returns:
MM:SS [STRING]
*/
params [
["_amount", 0, [0]]
];
if (_amount isEqualTo 0) exitWith {"00:00"};
private _minutes = floor (_amount / 60);
private _seconds = _amount % 60;
if (_minutes < 10) then {_minutes = ["0", _minutes] joinString "";};
if (_seconds < 10) then {_seconds = ["0", _seconds] joinString "";};
[_minutes, _seconds] joinString ":"

View File

@@ -0,0 +1,36 @@
/*
File: fn_setDiscordState.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-10
Last Update: 2020-04-18
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Updated the Discord rich presence state with given string.
If empty string is given, the state is determined by player variables.
Parameter(s):
_state - New state which should be applied to rich presence [STRING, defaults to ""]
Returns:
Function reached the end [BOOL]
*/
params [
["_state", "", [""]]
];
if (_state isEqualTo "") then {
_state = "In the field";
[] call {
if (player getVariable ["KPLIB_isNearStart", false]) exitWith {_state = "Startbase";};
if !(player getVariable ["KPLIB_fobName", ""] isEqualTo "") exitWith {_state = player getVariable "KPLIB_fobName";};
if !(player getVariable ["KPLIB_nearSector", ""] isEqualTo "") exitWith {_state = markerText (player getVariable "KPLIB_nearSector");};
};
};
[
["UpdateState", _state]
] call (missionNamespace getVariable ["DiscordRichPresence_fnc_update", {}]);
true

View File

@@ -0,0 +1,35 @@
/*
File: fn_setFobMass.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-12-02
Last Update: 2020-04-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Sets mass of FOB box to Max slingload weight of "huron_typename" lowered by 100.
If max slingload mass is lower than 1000 its set to 1000.
If it is higher than 3000 it's set to 3000.
Parameter(s):
_box - FOB Box on which mass will be set [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_box", objNull, [objNull]]
];
if (isNull _box) exitWith {["Null object given"] call BIS_fnc_error; false};
private _boxMass = getNumber(configFile >> "CfgVehicles" >> huron_typename >> "slingLoadMaxCargoMass") - 100;
_boxMass = 1000 max (_boxMass min 3000);
if (local _box) then {
_box setMass _boxMass;
} else {
[_box, _boxMass] remoteExec ["setMass", _box];
};
true

View File

@@ -0,0 +1,75 @@
/*
File: fn_setLoadableViV.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-05-08
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Adds ViV load/unload actions to object.
Parameter(s):
_object - Object to add actions to [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_object", objNull, [objNull]]
];
if (isNull _object) exitWith {["Null object given"] call BIS_fnc_error; false};
private _loadFnc = {
params ["_target"];
(_target call KPLIB_fnc_getNearestViVTransport) setVehicleCargo _target;
};
// Add "Load" action
_object addAction [
"<t color='#FFFF00'>" + localize "STR_ACTION_LOAD_VIV" + "</t>",
_loadFnc,
nil,
-991,
false,
true,
"",
"(isNull objectParent player) && {!isNull (_target call KPLIB_fnc_getNearestViVTransport)}",
10
];
// Add "No transports nearby action"
_object addAction [
"<t color='#FF0000'>" + localize "STR_ACTION_NOTRANSPORT_VIV" + "</t>",
{},
nil,
-991,
false,
true,
"",
"(isNull objectParent player) && {isNull (_target call KPLIB_fnc_getNearestViVTransport)} && {isNull isVehicleCargo _target}",
10
];
private _unloadFnc = {
params ["_target"];
objNull setVehicleCargo _target;
};
// Add "Unload" action
_object addAction [
"<t color='#FFFF00'>" + localize "STR_ACTION_UNLOAD_VIV" + "</t>",
_unloadFnc,
nil,
-991,
false,
true,
"",
"(isNull objectParent player) && {!isNull isVehicleCargo _target}",
10
];
true

View File

@@ -0,0 +1,342 @@
/*
File: fn_setLoadout.sqf
Author: aeroson - https://github.com/aeroson
Date: 2014-03-25
Last Update: 2019-12-03
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
I guarantee backwards compatibility.
These scripts allows you set/get (load/save)all of the unit's gear, including:
uniform, vest, backpack, contents of it, all quiped items, all three weapons with their attachments, currently loaded magazines and number of ammo in magazines.
All this while preserving order of items.
Useful for saving/loading loadouts.
Ideal for revive scripts where you have to set exactly the same loadout to newly created unit.
Uses workaround with placeholders to add vest/backpack items, so items stay where you put them.
Parameter(s):
_localVariable - Description [DATATYPE, defaults to DEFAULTVALUE]
Returns:
Function reached the end [BOOL]
*/
// TODO
private ["_target","_options","_loadMagsAmmo","_data","_loadedMagazines","_placeholderCount","_loadBeforeAdd","_add","_outfit","_addWeapon","_addPrimary","_addHandgun","_addSecondary","_addOrder","_currentWeapon","_currentMode"];
_options = [];
// addAction support
if(count _this < 4) then {
#define PARAM_START private ["_PARAM_INDEX"]; _PARAM_INDEX=0;
#define PARAM_REQ(A) if (count _this <= _PARAM_INDEX) exitWith { systemChat format["required param '%1' not supplied in file:'%2' at line:%3", #A ,__FILE__,__LINE__]; }; A = _this select _PARAM_INDEX; _PARAM_INDEX=_PARAM_INDEX+1;
#define PARAM(A,B) A = B; if (count _this > _PARAM_INDEX) then { A = _this select _PARAM_INDEX; }; _PARAM_INDEX=_PARAM_INDEX+1;
PARAM_START
PARAM_REQ(_target)
PARAM_REQ(_data)
PARAM(_options,[])
} else {
_target = player;
_data = loadout;
//playSound3D ["A3\Sounds_F\sfx\ZoomIn.wav", _target];
};
if(isNil{_data}) exitWith {
systemChat "you are trying to set/load empty loadout";
};
if(count _data < 13) exitWith {
systemChat "you are trying to set/load corrupted loadout";
};
#define QUOTE(A) #A
#define EL(A,B) ((A) select (B))
#define _THIS(A) EL(_this,A)
// placeholders
#define PLACEHOLDER_BACKPACK QUOTE(B_Kitbag_mcamo) // any backpack with capacity>0
#define PLACEHOLDER_ITEM QUOTE(ItemWatch) // addItem placeholder should be smallest item possible
_loadMagsAmmo = "ammo" in _options;
_loadedMagazines = [];
if(count _data > 13) then {
if(typeName(_data select 13)=="ARRAY") then {
_loadedMagazines = _data select 13;
};
};
_currentWeapon = "";
if(count _data > 14) then {
_currentWeapon = _data select 14;
};
_currentMode = "";
if(count _data > 15) then {
_currentMode = _data select 15;
};
_placeholderCount = 0;
// basic add function intended for use with uniform and vest
_add = {
private ["_target","_item","_callback"];
_target = _this select 0;
_item = _this select 1;
_callback = _this select 2;
if(typename _item == "ARRAY") then {
if(_item select 0 != "") then {
if(_loadMagsAmmo) then {
_target addMagazine _item;
} else {
(_item select 0) call _callback;
};
};
} else {
if(_item != "") then {
_item call _callback;
};
};
};
// remove clothes to prevent incorrect mag loading
removeUniform _target;
removeVest _target;
removeBackpack _target;
_outfit = PLACEHOLDER_BACKPACK; // we need to add items somewhere before we can assign them
_target addBackpack _outfit;
clearAllItemsFromBackpack _target;
removeAllAssignedItems _target;
removeHeadgear _target;
removeGoggles _target;
// add loaded magazines of assigned items
if(count _loadedMagazines>=3) then {
{
[_target, _x, { _target addItemToBackpack _x }] call _add;
} forEach (_loadedMagazines select 3);
};
// add assigned items
{
[_target, _x, { _target addItemToBackpack _x }] call _add;
_target assignItem _x;
} forEach (_data select 0);
clearAllItemsFromBackpack _target;
// get assigned items, headgear and goggles is not part of assignedItems
private ["_assignedItems","_headgear","_goggles"];
_assignedItems = assignedItems _target;
_headgear = headgear _target;
_goggles = goggles _target;
if((_headgear != "") && !(_headgear in _assignedItems)) then {
_assignedItems set [count _assignedItems, _headgear];
};
if((_goggles != "") && !(_goggles in _assignedItems)) then {
_assignedItems set [count _assignedItems, _goggles];
};
// add asigned items that could not be added with assign item
// asuming each assigned item can be put only into one slot
{
if(!(_x in _assignedItems)) then {
_target addWeapon _x;
}
} forEach (_data select 0);
// universal add weapon to hands
_addWeapon = {
private ["_weapon","_magazines","_muzzles"];
clearAllItemsFromBackpack _target;
_target removeWeapon ([] call _THIS(0));
_weapon = _data select _THIS(1);
if(_weapon != "") then {
if(isClass(configFile>>"CfgWeapons">>_weapon)) then {
if (_currentWeapon == "") then {
_currentWeapon = _weapon;
};
if(count _loadedMagazines > 0) then {
_magazines = _loadedMagazines select _THIS(5); // get loaded magazines from saved loadout
if(typename _magazines != "ARRAY") then { // backwards compatibility, make sure _magazines is array
if(_magazines=="") then {
_magazines = [];
} else {
_magazines = [_magazines];
};
};
} else {
_magazines = [getArray(configFile>>"CfgWeapons">>_weapon>>"magazines") select 0]; // generate weapon magazine
_muzzles = configFile>>"CfgWeapons">>_weapon>>"muzzles";
if(isArray(_muzzles)) then { // generate magazine for each muzzle
{
if (_x != "this") then {
_magazines set [count _magazines, toLower(getArray(configFile>>"CfgWeapons">>_weapon>>_x>>"magazines") select 0)];
};
} forEach getArray(_muzzles);
};
};
{
[_target, _x, { _target addItemToBackpack _x }] call _add;
} forEach _magazines; // add magazines
_target addWeapon _weapon;
{
if(_x!="" && !(_x in ([] call _THIS(3)))) then {
_x call _THIS(4);
};
} forEach (_data select (1+_THIS(1))); // add weapon items
} else {
systemchat format["%1 %2 doesn't exist",_THIS(2),_weapon];
if (_currentWeapon == _weapon) then {
_currentWeapon = "";
_currentMode = "";
};
};
};
};
// add primary weapon, add primary weapon loaded magazine, add primary weapon items
_addPrimary = {
[
{ primaryWeapon _target }, // 0 // get current weapon
1, // 1 //weapon classname index in _data
"primary", // 2 // weapon debug type
{ primaryWeaponItems _target }, // 3 // weapon items
{ _target addPrimaryWeaponItem _this }, // 4 // add weapon item
0 // 5 // index in _loadedMagazines
] call _addWeapon;
};
// add handgun weapon, add handgun weapon loaded magazine, add handgun weapon items
_addHandgun = {
[
{ handgunWeapon _target }, // 0 // get current weapon
3, // 1 //weapon classname index in _data
"handgun", // 2 // weapon debug type
{ handgunItems _target }, // 3 // weapon items
{ _target addHandgunItem _this }, // 4 // add weapon item
1 // 5 // index in _loadedMagazines
] call _addWeapon;
};
// add secondary weapon, add secondary weapon loaded magazine, add secondary weapon items
_addSecondary = {
[
{ secondaryWeapon _target }, // 0 // get current weapon
5, // 1 //weapon classname index in _data in _data
"secondary", // 2 // weapon debug type
{ secondaryWeaponItems _target }, // 3 // weapon items
{ _target addSecondaryWeaponItem _this }, // 4 // add weapon item
2 // 5 // index in _loadedMagazines
] call _addWeapon;
};
// first added weapon is selected weapon, order add functions to firstly add currently selected weapon
_addOrder=[_addPrimary,_addHandgun,_addSecondary];
if(_currentWeapon!="") then {
_addOrder = switch _currentWeapon do {
case (_data select 3): {[_addHandgun,_addPrimary,_addSecondary]};
case (_data select 5): {[_addSecondary,_addPrimary,_addHandgun]};
default {_addOrder};
};
};
{
[] call _x;
} forEach _addOrder;
// select weapon and firing mode
if(vehicle _target == _target && _currentWeapon != "" && _currentMode != "") then {
_muzzles = 0;
while { (_currentWeapon != currentMuzzle _target || _currentMode != currentWeaponMode _target ) && _muzzles < 100 } do {
_target action ["SWITCHWEAPON", _target, _target, _muzzles];
_muzzles = _muzzles + 1;
};
if(_muzzles >= 100) then {
systemchat format["mode %1 for %2 doesn't exist", _currentMode, _currentWeapon];
_currentMode = "";
};
} else {
_currentMode = "";
};
if(_currentMode == "" && _currentWeapon != "") then {
_target selectWeapon _currentWeapon;
};
clearAllItemsFromBackpack _target;
// add uniform, add uniform items and fill uniform with item placeholders
_outfit = _data select 7;
if(_outfit != "") then {
if(isClass(configFile>>"CfgWeapons">>_outfit)) then {
_target forceAddUniform _outfit;
_target addItem PLACEHOLDER_ITEM;
if(loadUniform _target > 0) then {
_placeholderCount = _placeholderCount + 1;
{
[_target, _x, { _target addItemToUniform _x }] call _add;
} forEach (_data select 8);
while{true} do {
_loadBeforeAdd = loadUniform _target;
_target addItem PLACEHOLDER_ITEM;
if(loadUniform _target == _loadBeforeAdd) exitWith {};
_placeholderCount = _placeholderCount + 1;
};
};
} else {
systemchat format["uniform %1 doesn't exist",_outfit];
};
};
// add vest, add vest items and fill vest with item placeholders
_outfit = _data select 9;
if(_outfit != "") then {
if(isClass(configFile>>"CfgWeapons">>_outfit)) then {
_target addVest _outfit;
_target addItem PLACEHOLDER_ITEM;
if(loadVest _target > 0) then {
_placeholderCount = _placeholderCount + 1;
{
[_target, _x, { _target addItemToVest _x }] call _add;
} forEach (_data select 10);
while{true} do {
_loadBeforeAdd = loadVest _target;
_target addItem PLACEHOLDER_ITEM;
if(loadVest _target == _loadBeforeAdd) exitWith {};
_placeholderCount = _placeholderCount + 1;
};
};
} else {
systemchat format["vest %1 doesn't exist",_outfit];
};
};
// add backpack and add backpack items
removeBackpack _target;
_outfit = _data select 11;
if(_outfit != "") then {
if(getNumber(configFile>>"CfgVehicles">>_outfit>>"isbackpack")==1) then {
_target addBackpack _outfit;
clearAllItemsFromBackpack _target;
_target addItem PLACEHOLDER_ITEM;
_placeholderCount = _placeholderCount + 1;
if(loadBackpack _target > 0) then {
{
[_target, _x, { _target addItemToBackpack _x }] call _add;
} forEach (_data select 12);
};
} else {
systemchat format["backpack %1 doesn't exist",_outfit];
};
};
// remove item placeholders
for "_i" from 1 to _placeholderCount do {
_target removeItem PLACEHOLDER_ITEM;
};
// make loadout visible fix?
if(vehicle _target == _target) then {
//_target switchMove (getArray(configFile>>"CfgMovesMaleSdr">>"States">>animationState player>>"ConnectTo") select 0);
_target setPosATL (getPosATL _target);
};

View File

@@ -0,0 +1,38 @@
/*
File: fn_setVehicleCaptured.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-10
Last Update: 2020-04-26
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Sets the captured variable on given vehicle, if vehicle class
is in enemy preset.
Parameter(s):
_veh - Vehicle to capture [OBJECT, defaults to objNull]
Returns:
Vehicles is set to captured [BOOL]
*/
params [
["_veh", objNull, [objNull]]
];
if (isNull _veh) exitWith {["Null object given"] call BIS_fnc_error; false};
private _type = typeOf _veh;
if !((toLower _type) in KPLIB_o_allVeh_classes) exitWith {false};
if !(_veh getVariable ["KPLIB_captured", false]) then {
_veh setVariable ["KPLIB_captured", true, true];
[
format ["%1 captured an enemy %2 (%3)", name player, getText (configFile >> "CfgVehicles" >> _type >> "displayName"), _type],
"CAPTURED"
] remoteExecCall ["KPLIB_fnc_log", 2];
};
true

View File

@@ -0,0 +1,42 @@
/*
File: fn_setVehicleSeized.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-20
Last Update: 2020-04-26
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Sets the seized variable on given vehicle, if vehicle class
is in civilian preset.
Parameter(s):
_veh - Vehicle to seize [OBJECT, defaults to objNull]
Returns:
Vehicles is set to seized [BOOL]
*/
params [
["_veh", objNull, [objNull]]
];
if (isNull _veh) exitWith {["Null object given"] call BIS_fnc_error; false};
private _type = typeOf _veh;
if !(_type in civilian_vehicles) exitWith {false};
if !(_veh getVariable ["KPLIB_seized", false]) then {
_veh setVariable ["KPLIB_seized", true, true];
[0] remoteExec ["KPLIB_fnc_crGlobalMsg"];
[KP_liberation_cr_vehicle_penalty, true] remoteExec ["F_cr_changeCR", 2];
stats_civilian_vehicles_seized = stats_civilian_vehicles_seized + 1;
publicVariable "stats_civilian_vehicles_seized";
[
format ["%1 seized a civilian %2 (%3)", name player, getText (configFile >> "CfgVehicles" >> _type >> "displayName"), _type],
"CAPTURED"
] remoteExecCall ["KPLIB_fnc_log", 2];
};
true

View File

@@ -0,0 +1,41 @@
/*
File: fn_sortStorage.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-06-09
Last Update: 2020-04-17
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Stack and sort the resources inside a storage area.
Parameter(s):
_storage - Storage to sort [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_storage", objNull, [objNull]]
];
if (isNull _storage) exitWith {["Null object given"] call BIS_fnc_error; false};
private _supply = 0;
private _ammo = 0;
private _fuel = 0;
{
switch (typeOf _x) do {
case KP_liberation_supply_crate: {_supply = _supply + (_x getVariable ["KP_liberation_crate_value",0]);};
case KP_liberation_ammo_crate: {_ammo = _ammo + (_x getVariable ["KP_liberation_crate_value",0]);};
case KP_liberation_fuel_crate: {_fuel = _fuel + (_x getVariable ["KP_liberation_crate_value",0]);};
default {[format ["Invalid object (%1) at storage area", (typeOf _x)], "ERROR"] call KPLIB_fnc_log;};
};
detach _x;
deleteVehicle _x;
} forEach (attachedObjects _storage);
[_supply, _ammo, _fuel, _storage, true] spawn KPLIB_fnc_fillStorage;
true

View File

@@ -0,0 +1,56 @@
/*
File: fn_spawnBuildingSquad.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns given amount of infantry in buildings of given sector at given building positions.
Parameter(s):
_type - Type of infantry. Either "militia" or "army" [STRING, defaults to "army"]
_amount - Amount of infantry units to spawn [NUMBER, defaults to 0]
_positions - Array of building positions [ARRAY, defaults to []]
_sector - Sector where to spawn the units [STRING, defaults to ""]
Returns:
Spawned units [ARRAY]
*/
params [
["_type", "army", [""]],
["_amount", 0, [0]],
["_positions", [], [[]]],
["_sector", "", [""]]
];
if (_sector isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; []};
// Get classnames array
private _classnames = [[] call KPLIB_fnc_getSquadComp, militia_squad] select (_type == "militia");
// Adjust amount, if needed
if (_amount > floor ((count _positions) * GRLIB_defended_buildingpos_part)) then {
_amount = floor ((count _positions) * GRLIB_defended_buildingpos_part)
};
// Spawn units
private _grp = createGroup [GRLIB_side_enemy, true];
private _pos = markerPos _sector;
private _unit = objNull;
private _units = [];
for "_i" from 1 to _amount do {
// Create new group, if current group has 10 units
if (count (units _grp) >= 10) then {
_grp = createGroup [GRLIB_side_enemy, true];
};
_unit = [selectRandom _classnames, _pos, _grp] call KPLIB_fnc_createManagedUnit;
_unit setDir (random 360);
_unit setPos (_positions deleteAt (random (floor (count _positions) - 1)));
[_unit, _sector] spawn building_defence_ai;
_units pushBack _unit;
};
_units

View File

@@ -0,0 +1,52 @@
/*
File: fn_spawnCivilians.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns civilians at given sector.
Parameter(s):
_sector - Sector to spawn the civilians at [STRING, defaults to ""]
Returns:
Spawned civilian units [ARRAY]
*/
params [
["_sector", "", [""]]
];
if (_sector isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; []};
private _civs = [];
private _sPos = markerPos _sector;
// Amount and spread depending if capital or city/factory
private _amount = round ((3 + (floor (random 7))) * GRLIB_civilian_activity);
private _spread = 1;
if (_sector in sectors_bigtown) then {
_amount = _amount + 10;
_spread = 2.5;
};
_amount = _amount * (sqrt (GRLIB_unitcap));
// Spawn civilians
private _grp = grpNull;
for "_i" from 1 to _amount do {
_grp = createGroup [GRLIB_side_civilian, true];
_civs pushBack (
[
selectRandom civilians,
[(((_sPos select 0) + (75 * _spread)) - (random (150 * _spread))), (((_sPos select 1) + (75 * _spread)) - (random (150 * _spread))), 0],
_grp
] call KPLIB_fnc_createManagedUnit
);
[_grp] call add_civ_waypoints;
};
_civs

View File

@@ -0,0 +1,80 @@
/*
File: fn_spawnGuerillaGroup.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-10-08
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns a group of guerilla units with random gear depending on guerilla strength.
Parameter(s):
_pos - Position where to spawn the group [POSITION, defaults to [0, 0, 0]]
_amount - Amount of units for the group. 0 for automatic calculation [NUMBER, defaults to 0]
Returns:
Spawned group [GROUP]
*/
params [
["_pos", [0, 0, 0], []],
["_amount", 0, []]
];
// Get tier and civilian reputation depending values
private _tier = [] call KPLIB_fnc_getResistanceTier;
private _cr_multi = [] call KPLIB_fnc_crGetMulti;
if (_amount == 0) then {_amount = (6 + (round (random _cr_multi)) + (round (random _tier)));};
private _weapons = missionNamespace getVariable ("KP_liberation_guerilla_weapons_" + str _tier);
private _uniforms = missionNamespace getVariable ("KP_liberation_guerilla_uniforms_" + str _tier);
private _vests = missionNamespace getVariable ("KP_liberation_guerilla_vests_" + str _tier);
private _headgear = missionNamespace getVariable ("KP_liberation_guerilla_headgear_" + str _tier);
// Spawn guerilla units
private _grp = createGroup [GRLIB_side_resistance, true];
private _unit = objNull;
private _weapon = [];
for "_i" from 1 to _amount do {
// Create unit
_unit = [selectRandom KP_liberation_guerilla_units, _pos, _grp, "PRIVATE", 5] call KPLIB_fnc_createManagedUnit;
// Clear inventory
removeAllWeapons _unit;
removeAllItems _unit;
removeAllAssignedItems _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
removeHeadgear _unit;
removeGoggles _unit;
// Add uniform etc.
_unit forceAddUniform (selectRandom _uniforms);
_unit addItemToUniform "FirstAidKit";
_unit addItemToUniform "MiniGrenade";
_unit addVest (selectRandom _vests);
_unit addHeadgear (selectRandom _headgear);
if (_tier > 1) then {_unit addGoggles (selectRandom KP_liberation_guerilla_facegear);};
// Add standard items
_unit linkItem "ItemMap";
_unit linkItem "ItemCompass";
_unit linkItem "ItemWatch";
_unit linkItem "ItemRadio";
// Add weapon
_weapon = selectRandom _weapons;
_unit addWeapon (_weapon select 0);
for "_i" from 1 to (_weapon select 2) do {_unit addItemToVest (_weapon select 1);};
_unit addPrimaryWeaponItem (_weapon select 3);
_unit addPrimaryWeaponItem (_weapon select 4);
// Add possible RPG launcher
if ((_tier > 1) && ((random 100) <= KP_liberation_resistance_at_chance)) then {
_unit addBackpack "B_FieldPack_cbr";
for "_i" from 1 to 3 do {_unit addItemToBackpack "RPG7_F";};
_unit addWeapon "launch_RPG7_F";
};
};
_grp

View File

@@ -0,0 +1,45 @@
/*
File: fn_spawnMilitaryPostSquad.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns soldiers inside military cargo towers around given position.
Parameter(s):
_pos - Center position of the area to look for military cargo towers [ARRAY, defaults to [0, 0, 0]]
Returns:
Spawned units [ARRAY]
*/
params [
["_pos", [0, 0, 0], [[]]]
];
if (_pos isEqualTo [0, 0, 0]) exitWith {["No or zero pos given"] call BIS_fnc_error; []};
// Get all military patrol towers near given position
private _allPosts = (
nearestObjects [_pos, ["Land_Cargo_Patrol_V1_F","Land_Cargo_Patrol_V2_F","Land_Cargo_Patrol_V3_F","Land_Cargo_Patrol_V4_F"], GRLIB_capture_size, true]
) select {alive _x};
// Exit if no patrol towers were found
if (_allPosts isEqualTo []) exitWith {[]};
// Spawn units
private _grp = createGroup [GRLIB_side_enemy, true];
private _unit = objNull;
private _units = [];
{
_unit = [[opfor_marksman, opfor_machinegunner] select (random 100 > 50), _pos, _grp] call KPLIB_fnc_createManagedUnit;
_unit setdir (180 + (getdir _x));
_unit setpos (([_x] call BIS_fnc_buildingPositions) select 1);
[_unit] spawn building_defence_ai;
_unit setUnitPos 'UP';
_units pushback _unit;
} forEach _allPosts;
_units

View File

@@ -0,0 +1,43 @@
/*
File: fn_spawnMilitiaCrew.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns a militia crew for given vehicle.
Parameter(s):
_vehicle - Vehicle to spawn the crew for [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_vehicle", objNull, [objNull]]
];
if (isNull _vehicle) exitWith {["Null object given"] call BIS_fnc_error; false};
// Spawn units
private _grp = createGroup [GRLIB_side_enemy, true];
private _units = [];
for "_i" from 1 to 3 do {
_units pushBack ([selectRandom militia_squad, getPos _vehicle, _grp] call KPLIB_fnc_createManagedUnit);
};
// Assign to vehicle
(_units select 0) moveInDriver _vehicle;
(_units select 1) moveInGunner _vehicle;
(_units select 2) moveInCommander _vehicle;
// Remove possible leftovers
{
if (isNull objectParent _x) then {
deleteVehicle _x;
};
} forEach _units;
true

View File

@@ -0,0 +1,51 @@
/*
File: fn_spawnRegularSquad.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-05-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns a regular enemy squad with given soldier classnames at given sector.
Parameter(s):
_sector - Sector to spawn the squad at [STRING, defaults to ""]
_classnames - Classnames of units to spawn in squad [ARRAY, defaults to []]
Returns:
Created squad [GROUP]
*/
params [
["_sector", "", [""]],
["_classnames", [], [[]]]
];
if (_sector isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; grpNull};
// Get spawn position for squad
private _sectorPos = (markerPos _sector) getPos [random 100, random 360];
private _spawnPos = [];
private _i = 0;
while {_spawnPos isEqualTo []} do {
_i = _i + 1;
_spawnPos = (_sectorPos getPos [random 50, random 360]) findEmptyPosition [5, 100, "B_Heli_Light_01_F"];
if (_i isEqualTo 10) exitWith {};
};
if (_spawnPos isEqualTo zeroPos) exitWith {
["No suitable spawn position found."] call BIS_fnc_error;
[format ["Couldn't find infantry spawn position for sector %1", _sector], "WARNING"] call KPLIB_fnc_log;
grpNull
};
// Spawn units of squad
private _corrected_amount = round ((count _classnames) * ([] call KPLIB_fnc_getOpforFactor));
private _grp = createGroup [GRLIB_side_enemy, true];
{
if (_forEachIndex < _corrected_amount) then {
[_x, _spawnPos, _grp] call KPLIB_fnc_createManagedUnit;
};
} forEach _classnames;
_grp

View File

@@ -0,0 +1,96 @@
/*
File: fn_spawnVehicle.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-05-06
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Spawns a vehicle with all needed Liberation connections/dependencies.
Parameter(s):
_pos - Position to spawn the vehicle [POSITION, defaults to [0, 0, 0]]
_classname - Classname of the vehicle to spawn [STRING, defaults to ""]
_precise - Selector if the vehicle should spawned precisely on given position [BOOL, defaults to false]
_rndDir - Selector if the direction should be randomized [BOOL, defaults to true]
Returns:
Spawned vehicle [OBJECT]
*/
params [
["_pos", [0, 0, 0], [[]], [2, 3]],
["_classname", "", [""]],
["_precise", false, [false]],
["_rndDir", true, [false]]
];
if (_pos isEqualTo [0, 0, 0]) exitWith {["No or zero pos given"] call BIS_fnc_error; objNull};
if (_classname isEqualTo "") exitWith {["Empty string given"] call BIS_fnc_error; objNull};
if (!canSuspend) exitWith {_this spawn KPLIB_fnc_spawnVehicle};
private _newvehicle = objNull;
private _spawnpos = [];
if (_precise) then {
// Directly use given pos, if precise placement is true
_spawnpos = _pos;
} else {
// Otherwise find a suitable position for vehicle spawning near given pos
private _i = 0;
while {_spawnPos isEqualTo []} do {
_i = _i + 1;
_spawnpos = (_pos getPos [random 150, random 360]) findEmptyPosition [10, 100, _classname];
if (_i isEqualTo 10) exitWith {};
};
};
if (_spawnPos isEqualTo zeroPos) exitWith {
["No suitable spawn position found."] call BIS_fnc_error;
[format ["Couldn't find spawn position for %1 around position %2", _classname, _pos], "WARNING"] call KPLIB_fnc_log;
objNull
};
// If it's a chopper, spawn it flying
if (_classname in opfor_choppers) then {
_newvehicle = createVehicle [_classname, _spawnpos, [], 0, 'FLY'];
_newvehicle flyInHeight (80 + (random 120));
_newvehicle allowDamage false;
} else {
_newvehicle = _classname createVehicle _spawnpos;
_newvehicle allowDamage false;
[_newvehicle] call KPLIB_fnc_allowCrewInImmobile;
// Randomize direction and reset position and vector
if (_rndDir) then {
_newvehicle setDir (random 360);
};
_newvehicle setPos _spawnpos;
_newvehicle setVectorUp surfaceNormal position _newvehicle;
};
// Clear cargo, if enabled
[_newvehicle] call KPLIB_fnc_clearCargo;
// Process KP object init
[_newvehicle] call KPLIB_fnc_addObjectInit;
// Spawn crew of vehicle
if (_classname in militia_vehicles) then {
[_newvehicle] call KPLIB_fnc_spawnMilitiaCrew;
} else {
private _grp = createGroup [GRLIB_side_enemy, true];
private _crew = units (createVehicleCrew _newvehicle);
_crew joinSilent _grp;
sleep 0.1;
{_x addMPEventHandler ["MPKilled", {_this spawn kill_manager}];} forEach _crew;
};
// Add MPKilled and GetIn EHs and enable damage again
_newvehicle addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
sleep 0.1;
_newvehicle allowDamage true;
_newvehicle setDamage 0;
_newvehicle

View File

@@ -0,0 +1,28 @@
/*
File: fn_swapInventory.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2019-12-03
Last Update: 2020-04-05
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Sets loadout of one given unit to the loadout of second given unit.
Parameter(s):
_from - Unit to get the loadout from [OBJECT, defaults to objNull]
_to - Unit which should get the loadout applied [OBJECT, defaults to objNull]
Returns:
Function reached the end [BOOL]
*/
params [
["_from", objNull, [objNull]],
["_to", objNull, [objNull]]
];
if (isNull _from || isNull _to) exitWith {["Null object given"] call BIS_fnc_error; false};
[_to, [_from, ["repetitive"]] call KPLIB_fnc_getLoadout] call KPLIB_fnc_setLoadout;
true

View File

@@ -0,0 +1,75 @@
#include "script_components.hpp"
/*
File: fn_overlayUpdateResources.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-05-01
Last Update: 2020-08-25
License: MIT License - http://www.opensource.org/licenses/MIT
Description:
Update resources overlay.
Parameter(s):
_overlay - Overlay display [DISPLAY, defaults to displayNull]
_show - Should the resources controls be shown [BOOL, defaults to true]
_updateValues - Should values controls be updated with data [BOOL, defaults to true]
_resourceArea - Name of resource area to be shown [STRING, defaults ""]
Returns:
Resources overlay visible [BOOL]
*/
params [
["_overlay", displayNull, [displayNull]],
["_show", true, [true]],
["_updateValues", true, [true]],
["_resourceArea", "", [""]]
];
if (isNull _overlay) exitWith {
["Null overlay given"] call BIS_fnc_error;
false
};
if (!_show) exitWith {
{
(_overlay displayCtrl _x) ctrlShow false;
} forEach OVERLAY_RSC_IDCS;
false
};
if (_updateValues) then {
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_FOB) ctrlSetText toUpper (_resourceArea select [4]);
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_SUPPLIES) ctrlSetText str floor KP_liberation_supplies;
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_AMMO) ctrlSetText str floor KP_liberation_ammo;
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_FUEL) ctrlSetText str floor KP_liberation_fuel;
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_UNITCAP) ctrlSetText ([unitcap, "/", [] call KPLIB_fnc_getLocalCap] joinString "");
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_HELIPAD) ctrlSetText ([KP_liberation_heli_count, "/", KP_liberation_heli_slots] joinString "");
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_PLANE) ctrlSetText ([KP_liberation_plane_count, "/", KP_liberation_plane_slots] joinString "");
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_ALERT) ctrlSetText ([round combat_readiness, "%"] joinString "");
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_CIVREP) ctrlSetText ([KP_liberation_civ_rep,"%"] joinString "");
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_INTEL) ctrlSetText str round resources_intel;
private _color_readiness = [0.8,0.8,0.8,1];
if (combat_readiness >= 25) then {_color_readiness = [0.8,0.8,0,1]};
if (combat_readiness >= 50) then {_color_readiness = [0.8,0.6,0,1]};
if (combat_readiness >= 75) then {_color_readiness = [0.8,0.3,0,1]};
if (combat_readiness >= 100) then {_color_readiness = [0.8,0,0,1]};
(_overlay displayCtrl IDC_OVERLAY_RSC_PIC_ALERT) ctrlSetTextColor _color_readiness;
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_ALERT) ctrlSetTextColor _color_readiness;
private _color_reputation = [0.8,0.8,0.8,1];
if (KP_liberation_civ_rep >= 25) then {_color_reputation = [0,0.7,0,1]};
if (KP_liberation_civ_rep <= -25) then {_color_reputation = [0.7,0,0,1]};
(_overlay displayCtrl IDC_OVERLAY_RSC_PIC_CIVREP) ctrlSetTextColor _color_reputation;
(_overlay displayCtrl IDC_OVERLAY_RSC_LABEL_CIVREP) ctrlSetTextColor _color_reputation;
};
{
(_overlay displayCtrl _x) ctrlShow true;
} forEach OVERLAY_RSC_IDCS;
true

View File

@@ -0,0 +1,78 @@
#define IDC_OVERLAY_RSC_PIC_BG 758001
#define IDC_OVERLAY_RSC_PIC_FOB 758002
#define IDC_OVERLAY_RSC_PIC_FOB_SHADOW 758003
#define IDC_OVERLAY_RSC_PIC_SUPPLIES 758005
#define IDC_OVERLAY_RSC_PIC_SUPPLIES_SHADOW 758006
#define IDC_OVERLAY_RSC_PIC_AMMO 758008
#define IDC_OVERLAY_RSC_PIC_AMMO_SHADOW 758009
#define IDC_OVERLAY_RSC_PIC_FUEL 758011
#define IDC_OVERLAY_RSC_PIC_FUEL_SHADOW 758012
#define IDC_OVERLAY_RSC_PIC_UNITCAP 758014
#define IDC_OVERLAY_RSC_PIC_UNITCAP_SHADOW 758015
#define IDC_OVERLAY_RSC_PIC_HELIPAD 758017
#define IDC_OVERLAY_RSC_PIC_HELIPAD_SHADOW 758018
#define IDC_OVERLAY_RSC_PIC_PLANE 758020
#define IDC_OVERLAY_RSC_PIC_PLANE_SHADOW 758021
// Combat readiness / enemy altertness
#define IDC_OVERLAY_RSC_PIC_ALERT 758023
#define IDC_OVERLAY_RSC_PIC_ALERT_SHADOW 758024
#define IDC_OVERLAY_RSC_PIC_CIVREP 758026
#define IDC_OVERLAY_RSC_PIC_CIVREP_SHADOW 758027
#define IDC_OVERLAY_RSC_PIC_INTEL 758029
#define IDC_OVERLAY_RSC_PIC_INTEL_SHADOW 758030
#define IDC_OVERLAY_RSC_LABEL_FOB 758004
#define IDC_OVERLAY_RSC_LABEL_SUPPLIES 758007
#define IDC_OVERLAY_RSC_LABEL_AMMO 758010
#define IDC_OVERLAY_RSC_LABEL_FUEL 758013
#define IDC_OVERLAY_RSC_LABEL_UNITCAP 758016
#define IDC_OVERLAY_RSC_LABEL_HELIPAD 758019
#define IDC_OVERLAY_RSC_LABEL_PLANE 758022
#define IDC_OVERLAY_RSC_LABEL_ALERT 758025
#define IDC_OVERLAY_RSC_LABEL_CIVREP 758028
#define IDC_OVERLAY_RSC_LABEL_INTEL 758031
#define OVERLAY_RSC_IDCS [\
IDC_OVERLAY_RSC_PIC_BG,\
IDC_OVERLAY_RSC_PIC_FOB,\
IDC_OVERLAY_RSC_PIC_FOB_SHADOW,\
IDC_OVERLAY_RSC_LABEL_FOB,\
IDC_OVERLAY_RSC_PIC_SUPPLIES,\
IDC_OVERLAY_RSC_PIC_SUPPLIES_SHADOW,\
IDC_OVERLAY_RSC_LABEL_SUPPLIES,\
IDC_OVERLAY_RSC_PIC_AMMO,\
IDC_OVERLAY_RSC_PIC_AMMO_SHADOW,\
IDC_OVERLAY_RSC_LABEL_AMMO,\
IDC_OVERLAY_RSC_PIC_FUEL,\
IDC_OVERLAY_RSC_PIC_FUEL_SHADOW,\
IDC_OVERLAY_RSC_LABEL_FUEL,\
IDC_OVERLAY_RSC_PIC_UNITCAP,\
IDC_OVERLAY_RSC_PIC_UNITCAP_SHADOW,\
IDC_OVERLAY_RSC_LABEL_UNITCAP,\
IDC_OVERLAY_RSC_PIC_HELIPAD,\
IDC_OVERLAY_RSC_PIC_HELIPAD_SHADOW,\
IDC_OVERLAY_RSC_LABEL_HELIPAD,\
IDC_OVERLAY_RSC_PIC_PLANE,\
IDC_OVERLAY_RSC_PIC_PLANE_SHADOW,\
IDC_OVERLAY_RSC_LABEL_PLANE,\
IDC_OVERLAY_RSC_PIC_ALERT,\
IDC_OVERLAY_RSC_PIC_ALERT_SHADOW,\
IDC_OVERLAY_RSC_LABEL_ALERT,\
IDC_OVERLAY_RSC_PIC_CIVREP,\
IDC_OVERLAY_RSC_PIC_CIVREP_SHADOW,\
IDC_OVERLAY_RSC_LABEL_CIVREP,\
IDC_OVERLAY_RSC_PIC_INTEL,\
IDC_OVERLAY_RSC_PIC_INTEL_SHADOW,\
IDC_OVERLAY_RSC_LABEL_INTEL\
]