CfgFunction Copy/Paste as TODOs

This commit is contained in:
Wyqer 2019-11-25 18:34:21 +01:00
parent 34594ddf9e
commit e0d78e7a93
No known key found for this signature in database
GPG Key ID: D7E2F8BD7F1E48FA
28 changed files with 584 additions and 435 deletions

View File

@ -8,6 +8,13 @@ class KPLIB
class forceBluforCrew {};
class getAdaptiveVehicle {};
class getCommander {};
class getFobName {};
class getForceRatio {};
class getGroupType {};
class getLoadout {};
class getLocationName {};
class getMobileRespawns {};
class getNearbyPlayers {};
class getOpforFactor {};
class getOpforSpawnPoint {};
class getPlayerCount {};

View File

@ -0,0 +1,36 @@
/*
File: fn_getFobName.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
params [ "_fob" ];
private [ "_fobindex", "_currentidx", "_fobname" ];
_fobname = "";
_fobindex = -1;
_currentidx = 0;
{
if ( _x distance _fob < 100 ) then {
_fobindex = _currentidx;
};
_currentidx = _currentidx + 1;
} foreach GRLIB_all_fobs;
_fobname = "";
if ( _fobindex != -1 ) then {
_fobname = military_alphabet select _fobindex;
};
_fobname

View File

@ -0,0 +1,40 @@
/*
File: fn_getForceRatio.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
params [ "_sector" ];
private [ "_actual_capture_size", "_red_forces", "_blue_forces", "_ratio" ];
_actual_capture_size = GRLIB_capture_size;
if ( _sector in sectors_bigtown ) then {
_actual_capture_size = GRLIB_capture_size * 1.4;
};
_red_forces = [ (markerpos _sector), _actual_capture_size, GRLIB_side_enemy ] call F_getUnitsCount;
_blue_forces = [ (markerpos _sector), _actual_capture_size, GRLIB_side_friendly ] call F_getUnitsCount;
_ratio = -1;
if (_red_forces > 0) then {
_ratio = _blue_forces / ( _red_forces + _blue_forces );
} else {
if ( _sector in blufor_sectors || _blue_forces != 0 ) then {
_ratio = 1;
} else {
_ratio = 0;
};
};
_ratio

View File

@ -0,0 +1,79 @@
/*
File: fn_getGroupType.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
params [ "_grp" ];
private [ "_grouptype", "_vehicletype" ];
_grouptype = 'infantry';
_vehicletype = '';
{
if ( vehicle _x != _x && _vehicletype == '' ) then {
if ( ((gunner vehicle _x) == _x) || ((driver vehicle _x) == _x) || ((commander vehicle _x) == _x) ) then {
_vehicletype = typeof vehicle _x;
};
};
} foreach units _grp;
if ((_grouptype == 'infantry') && (_vehicletype != '')) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'heavy';
};
} foreach heavy_vehicles;
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'air';
};
} foreach air_vehicles;
};
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'light';
};
} foreach light_vehicles;
};
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'support';
};
} foreach support_vehicles;
};
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'static';
};
} foreach static_vehicles;
};
// Check if vehicle config says it's an UAV, if it is always set its _grouptype to 'uav'
if ( (_vehicletype call F_isClassUAV) ) then {
_grouptype = 'uav';
};
};
_grouptype

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,28 @@
/*
File: fn_getLocationName.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
params [ "_attacked_position" ];
private [ "_attacked_string" ];
_attacked_string = [_attacked_position] call KPLIB_fnc_getFobName;
if ( _attacked_string == "" ) then {
_attacked_string = markerText ( [50, _attacked_position ] call F_getNearestSector );
} else {
_attacked_string = format [ "FOB %1", _attacked_string ];
};
_attacked_string

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-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
private _respawn_trucks_unsorted = vehicles select {
(typeof _x == Respawn_truck_typename || typeof _x == huron_typename ) &&
_x distance2d startbase > 500 &&
!surfaceIsWater (getpos _x) &&
(isTouchingGround _x || {5 > ((getPos _x) select 2)}) &&
alive _x &&
speed _x < 5
};
[_respawn_trucks_unsorted, [], {(getpos _x) select 0}, 'ASCEND'] call BIS_fnc_sortBy

View File

@ -0,0 +1,20 @@
/*
File: fn_getNearbyPlayers.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
params [ "_searchposition", "_distance"];
allPlayers select {alive _x && _x distance _searchposition < _distance}

View File

@ -0,0 +1,30 @@
/*
File: fn_getSectorRange.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
params ["_opforcount"];
private _corrected_sector_size = GRLIB_sector_size;
if (_opforcount >= (0.5 * GRLIB_sector_cap)) then {
if (_opforcount <= GRLIB_sector_cap) then {
_corrected_sector_size = GRLIB_sector_size - (GRLIB_sector_size * 0.5 * ((_opforcount / GRLIB_sector_cap) - 0.5));
} else {
_corrected_sector_size = GRLIB_sector_size * 0.75;
};
};
_corrected_sector_size

View File

@ -95,7 +95,7 @@ while { dialog && (alive player) && edit_loadout == 0 } do {
};
if ( respawn_loadout > 0 ) then {
GRLIB_respawn_loadout = [ player, ["repetitive"] ] call F_getLoadout;
GRLIB_respawn_loadout = [ player, ["repetitive"] ] call KPLIB_fnc_getLoadout;
hint localize "STR_MAKE_RESPAWN_LOADOUT_HINT";
respawn_loadout = 0;
};
@ -103,7 +103,7 @@ while { dialog && (alive player) && edit_loadout == 0 } do {
if ( load_from_player >= 0 ) then {
private _playerselected = ( _loadplayers select load_from_player ) select 1;
if ( alive _playerselected ) then {
[ player, [ _playerselected, ["repetitive"] ] call F_getLoadout ] call F_setLoadout;
[player, [_playerselected, ["repetitive"]] call KPLIB_fnc_getLoadout] call F_setLoadout;
hint format [ localize "STR_LOAD_PLAYER_LOADOUT_HINT", name _playerselected ];
};
load_from_player = -1;

View File

@ -24,7 +24,7 @@ while {true} do {
};
if (KP_liberation_mobilerespawn) then {
private _respawn_trucks = [] call F_getMobileRespawns;
private _respawn_trucks = [] call KPLIB_fnc_getMobileRespawns;
if (count _markers_mobilespawns != count _respawn_trucks) then {
{deleteMarkerLocal _x;} forEach _markers_mobilespawns;

View File

@ -18,7 +18,7 @@ while { true } do {
(count units _x > 0) && (side _x == GRLIB_side_friendly && (((leader _x) distance (getmarkerpos GRLIB_respawn_marker) > 100) && ((leader _x) distance startbase > 500))))) then {
clearGroupIcons _x;
_localgroup = _x;
_grouptype = [_localgroup] call F_getGroupType;
_grouptype = [_localgroup] call KPLIB_fnc_getGroupType;
_groupicon = "";
switch (_grouptype) do {
case "infantry": { _groupicon = "b_inf" };

View File

@ -5,7 +5,7 @@ if ( isNil "sector_timer" ) then { sector_timer = 0 };
params [ "_fob", "_status" ];
private [ "_fobname" ];
_fobname = [ _fob ] call F_getFobName;
_fobname = [_fob] call KPLIB_fnc_getFobName;
if ( _status == 0 ) then {
[ "lib_fob_built", [ _fobname ] ] call BIS_fnc_showNotification;
@ -27,4 +27,4 @@ if ( _status == 3 ) then {
[ "lib_fob_safe", [ _fobname ] ] call BIS_fnc_showNotification;
"opfor_capture_marker" setMarkerPosLocal markers_reset;
sector_timer = 0;
};
};

View File

@ -9,7 +9,7 @@ if ( time > GRLIB_last_incoming_notif_time + 60 ) then {
GRLIB_last_incoming_notif_time = time;
private [ "_attack_location_name" ];
_attack_location_name = [ _attack_destination ] call F_getLocationName;
_attack_location_name = [_attack_destination] call KPLIB_fnc_getLocationName;
[ "lib_incoming", [ _attack_location_name ] ] call BIS_fnc_showNotification;
@ -20,4 +20,4 @@ if ( time > GRLIB_last_incoming_notif_time + 60 ) then {
sleep 250;
deleteMarkerLocal _mrk;
};
};

View File

@ -92,7 +92,7 @@ while {true} do {
if (KP_liberation_mobilerespawn) then {
if (KP_liberation_respawn_time <= time) then {
private _respawn_trucks = call F_getMobileRespawns;
private _respawn_trucks = [] call KPLIB_fnc_getMobileRespawns;
for [ {_idx=0},{_idx < count _respawn_trucks},{_idx=_idx+1} ] do {
choiceslist = choiceslist + [[format ["%1 - %2", localize "STR_RESPAWN_TRUCK",mapGridPosition (getposATL (_respawn_trucks select _idx))],getposATL (_respawn_trucks select _idx),(_respawn_trucks select _idx)]];

View File

@ -101,7 +101,7 @@ while { true } do {
KP_liberation_ammo = KP_liberation_ammo_global;
KP_liberation_fuel = KP_liberation_fuel_global;
} else {
_resource_area = toUpper ([_nearfob] call F_getFobName);
_resource_area = toUpper ([_nearfob] call KPLIB_fnc_getFobName);
KP_liberation_supplies = ((_actual_fob select 0) select 1);
KP_liberation_ammo = ((_actual_fob select 0) select 2);
KP_liberation_fuel = ((_actual_fob select 0) select 3);
@ -125,7 +125,7 @@ while { true } do {
if ((getmarkerpos "opfor_capture_marker") distance markers_reset > 100 ) then {
private [ "_attacked_string" ];
_attacked_string = [ markerpos "opfor_capture_marker" ] call F_getLocationName;
_attacked_string = [markerpos "opfor_capture_marker"] call KPLIB_fnc_getLocationName;
((uiNamespace getVariable 'GUI_OVERLAY') displayCtrl (401)) ctrlShow true;
((uiNamespace getVariable 'GUI_OVERLAY') displayCtrl (402)) ctrlSetText _attacked_string;
@ -216,7 +216,7 @@ while { true } do {
if ( [ markerpos _nearest_active_sector, _zone_size ] call F_sectorOwnership == GRLIB_side_resistance ) then { _colorzone = "ColorCivilian" };
"zone_capture" setmarkercolorlocal _colorzone;
_ratio = [_nearest_active_sector] call F_getForceRatio;
_ratio = [_nearest_active_sector] call KPLIB_fnc_getForceRatio;
_barwidth = 0.084 * safezoneW * _ratio;
_bar = (uiNamespace getVariable 'GUI_OVERLAY') displayCtrl (244);
_bar ctrlSetPosition [(ctrlPosition _bar) select 0,(ctrlPosition _bar) select 1,_barwidth,(ctrlPosition _bar) select 3];

View File

@ -10,7 +10,7 @@ private _range = 40;
while {_move_is_disabled && local _unit && alive _unit && !(captive _unit)} do {
if !(_sector isEqualTo "") then {
_ratio = [_sector] call F_getForceRatio;
_ratio = [_sector] call KPLIB_fnc_getForceRatio;
};
_range = floor (linearConversion [0, 1, _ratio, 0, GRLIB_capture_size / 3 * 2, true]);

View File

@ -11,7 +11,7 @@ private _markers = [];
for "_i" from 1 to _count do {
private _pos = (markerPos _sector) getPos [(50 + (random 150)), (random 360)];
while {(surfaceIsWater _pos) || ((count ([_pos, 30] call F_getNearbyPlayers)) > 0)} do {
while {(surfaceIsWater _pos) || ((count ([_pos, 30] call KPLIB_fnc_getNearbyPlayers)) > 0)} do {
_pos = (markerPos _sector) getPos [(50 + (random 200)), (random 360)];
};
private _civ = [selectRandom civilians, _pos, _grp] call F_createManagedUnit;

View File

@ -13,7 +13,7 @@ while { GRLIB_endgame == 0 } do {
_spawnsector = "";
_usable_sectors = [];
{
if ( ( ( [ getmarkerpos _x , 1000 , GRLIB_side_friendly ] call F_getUnitsCount ) == 0 ) && ( count ( [ getmarkerpos _x , 3500 ] call F_getNearbyPlayers ) > 0 ) ) then {
if ((([getmarkerpos _x, 1000, GRLIB_side_friendly] call F_getUnitsCount) == 0) && (count ([getmarkerpos _x, 3500] call KPLIB_fnc_getNearbyPlayers) > 0)) then {
_usable_sectors pushback _x;
}
@ -56,7 +56,7 @@ while { GRLIB_endgame == 0 } do {
_sectors_patrol = [];
_patrol_startpos = getpos (leader _grp);
{
if ( (_patrol_startpos distance (markerpos _x) < 5000 ) && ( count ( [ getmarkerpos _x , 4000 ] call F_getNearbyPlayers ) > 0 ) ) then {
if ((_patrol_startpos distance (markerpos _x) < 5000) && (count ([getmarkerpos _x, 4000] call KPLIB_fnc_getNearbyPlayers) > 0)) then {
_sectors_patrol pushback _x;
};
} foreach (sectors_bigtown + sectors_capture + sectors_factory);
@ -99,11 +99,11 @@ while { GRLIB_endgame == 0 } do {
waitUntil {
sleep (30 + (random 30));
( ( ( { alive _x } count ( units _grp ) ) == 0 ) || ( count ( [ getpos leader _grp , 4000 ] call F_getNearbyPlayers ) == 0 ) )
((({alive _x} count (units _grp)) == 0) || (count ([getpos leader _grp, 4000] call KPLIB_fnc_getNearbyPlayers) == 0))
};
if ( count (units _grp) > 0 ) then {
if ( count ( [ getpos leader _grp , 4000 ] call F_getNearbyPlayers ) == 0 ) then {
if (count ([getpos leader _grp, 4000] call KPLIB_fnc_getNearbyPlayers) == 0) then {
if ( !(isNull _civveh) ) then {
if ( { ( alive _x ) && (side group _x == GRLIB_side_friendly ) } count (crew _civveh) == 0 ) then {

View File

@ -1,19 +0,0 @@
params [ "_fob" ];
private [ "_fobindex", "_currentidx", "_fobname" ];
_fobname = "";
_fobindex = -1;
_currentidx = 0;
{
if ( _x distance _fob < 100 ) then {
_fobindex = _currentidx;
};
_currentidx = _currentidx + 1;
} foreach GRLIB_all_fobs;
_fobname = "";
if ( _fobindex != -1 ) then {
_fobname = military_alphabet select _fobindex;
};
_fobname

View File

@ -1,23 +0,0 @@
params [ "_sector" ];
private [ "_actual_capture_size", "_red_forces", "_blue_forces", "_ratio" ];
_actual_capture_size = GRLIB_capture_size;
if ( _sector in sectors_bigtown ) then {
_actual_capture_size = GRLIB_capture_size * 1.4;
};
_red_forces = [ (markerpos _sector), _actual_capture_size, GRLIB_side_enemy ] call F_getUnitsCount;
_blue_forces = [ (markerpos _sector), _actual_capture_size, GRLIB_side_friendly ] call F_getUnitsCount;
_ratio = -1;
if (_red_forces > 0) then {
_ratio = _blue_forces / ( _red_forces + _blue_forces );
} else {
if ( _sector in blufor_sectors || _blue_forces != 0 ) then {
_ratio = 1;
} else {
_ratio = 0;
};
};
_ratio

View File

@ -1,62 +0,0 @@
params [ "_grp" ];
private [ "_grouptype", "_vehicletype" ];
_grouptype = 'infantry';
_vehicletype = '';
{
if ( vehicle _x != _x && _vehicletype == '' ) then {
if ( ((gunner vehicle _x) == _x) || ((driver vehicle _x) == _x) || ((commander vehicle _x) == _x) ) then {
_vehicletype = typeof vehicle _x;
};
};
} foreach units _grp;
if ((_grouptype == 'infantry') && (_vehicletype != '')) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'heavy';
};
} foreach heavy_vehicles;
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'air';
};
} foreach air_vehicles;
};
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'light';
};
} foreach light_vehicles;
};
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'support';
};
} foreach support_vehicles;
};
if ( _grouptype == 'infantry' ) then {
{
if ( _vehicletype == (_x select 0)) then {
_grouptype = 'static';
};
} foreach static_vehicles;
};
// Check if vehicle config says it's an UAV, if it is always set its _grouptype to 'uav'
if ( (_vehicletype call F_isClassUAV) ) then {
_grouptype = 'uav';
};
};
_grouptype

View File

@ -1,280 +0,0 @@
/*
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

@ -1,11 +0,0 @@
params [ "_attacked_position" ];
private [ "_attacked_string" ];
_attacked_string = [ _attacked_position ] call F_getFobName;
if ( _attacked_string == "" ) then {
_attacked_string = markerText ( [50, _attacked_position ] call F_getNearestSector );
} else {
_attacked_string = format [ "FOB %1", _attacked_string ];
};
_attacked_string

View File

@ -1,10 +0,0 @@
private _respawn_trucks_unsorted = vehicles select {
(typeof _x == Respawn_truck_typename || typeof _x == huron_typename ) &&
_x distance2d startbase > 500 &&
!surfaceIsWater (getpos _x) &&
(isTouchingGround _x || {5 > ((getPos _x) select 2)}) &&
alive _x &&
speed _x < 5
};
[_respawn_trucks_unsorted, [], {(getpos _x) select 0}, 'ASCEND'] call BIS_fnc_sortBy

View File

@ -1,3 +0,0 @@
params [ "_searchposition", "_distance"];
allPlayers select {alive _x && _x distance _searchposition < _distance}

View File

@ -1,5 +1,5 @@
params [ "_unit1", "_unit2" ];
private [ "_loadout" ];
_loadout = [ _unit1, ["repetitive"] ] call F_getLoadout;
[ _unit2, _loadout ] call F_setLoadout;
_loadout = [_unit1, ["repetitive"]] call KPLIB_fnc_getLoadout;
[ _unit2, _loadout ] call F_setLoadout;

View File

@ -1,9 +1,6 @@
F_getNearestFob = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getNearestFob.sqf";
F_getMobileRespawns = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getMobileRespawns.sqf";
F_getUnitsCount = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getUnitsCount.sqf";
F_spartanScan = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_spartanScan.sqf";
F_getGroupType = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getGroupType.sqf";
F_getForceRatio = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getForceRatio.sqf";
F_localCap = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_localCap.sqf";
F_opforCap = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_opforCap.sqf";
F_getNearestSector = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getNearestSector.sqf";
@ -19,20 +16,16 @@ F_squadRespawn = compileFinal preprocessFileLineNumbers "scripts\shared\function
F_swapInventory = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_swapInventory.sqf";
F_spawnRegularSquad = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_spawnRegularSquad.sqf";
F_spawnCivilians = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_spawnCivilians.sqf";
F_getNearbyPlayers = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getNearbyPlayers.sqf";
F_lessLoadedHC = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_lessLoadedHC.sqf";
F_setMass = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_setMass.sqf";
F_getFobName = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getFobName.sqf";
F_objectProtection = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_objectProtection.sqf";
F_isBigtownActive = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_isBigtownActive.sqf";
F_getUnitPositionId = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getUnitPositionId.sqf";
LARs_fnc_addAllVirtualCargo = compileFinal preprocessFileLineNumbers "scripts\shared\functions\LARs_fnc_addAllVirtualCargo.sqf";
F_isAdmin = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_isAdmin.sqf";
F_getLoadout = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getLoadout.sqf";
F_setLoadout = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_setLoadout.sqf";
F_rearmVehicle = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_rearmVehicle.sqf";
F_setFuel = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_setFuel.sqf";
F_getLocationName = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getLocationName.sqf";
F_crateToStorage = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_crate_to_storage.sqf";
F_fillStorage = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_fillStorage.sqf";
F_crateFromStorage = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_crate_from_storage.sqf";