mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
replace more filter with select
This commit is contained in:
parent
2ebd2f9046
commit
41e39c9c3a
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
params [["_array", [], [[]]], ["_code", {}, [{}]]];
|
params [["_array", [], [[]]], ["_code", {}, [{}]]];
|
||||||
|
|
||||||
ACE_DEPRECATED("ace_common_fnc_filter","3.7.0","apply");
|
ACE_DEPRECATED("ace_common_fnc_map","3.7.0","apply");
|
||||||
|
|
||||||
// copy array to not alter the original one
|
// copy array to not alter the original one
|
||||||
_array = + _array;
|
_array = + _array;
|
||||||
|
@ -21,10 +21,7 @@ params ["_player", "_target", "_weapon"];
|
|||||||
private ["_compatibleMags", "_filteredMags", "_magToPass", "_magToPassIndex", "_playerName", "_magToPassDisplayName"];
|
private ["_compatibleMags", "_filteredMags", "_magToPass", "_magToPassIndex", "_playerName", "_magToPassDisplayName"];
|
||||||
|
|
||||||
_compatibleMags = getArray (configfile >> "CfgWeapons" >> _weapon >> "magazines");
|
_compatibleMags = getArray (configfile >> "CfgWeapons" >> _weapon >> "magazines");
|
||||||
_filteredMags = [magazinesAmmoFull _player, {
|
_filteredMags = magazinesAmmoFull _player select {(_x select 0) in _compatibleMags && {!(_x select 2)}};
|
||||||
params ["_className", "", "_loaded"];
|
|
||||||
_className in _compatibleMags && !_loaded
|
|
||||||
}] call EFUNC(common,filter);
|
|
||||||
|
|
||||||
//select magazine with most ammo
|
//select magazine with most ammo
|
||||||
_magToPass = _filteredMags select 0;
|
_magToPass = _filteredMags select 0;
|
||||||
|
@ -17,14 +17,14 @@ if (GVAR(BFT_Enabled) and {(!isNil "ACE_player") and {alive ACE_player}}) then {
|
|||||||
_playerSide = call EFUNC(common,playerSide);
|
_playerSide = call EFUNC(common,playerSide);
|
||||||
|
|
||||||
if !(GVAR(BFT_HideAiGroups)) then {
|
if !(GVAR(BFT_HideAiGroups)) then {
|
||||||
_groupsToDrawMarkers = [allGroups, {side _this == _playerSide}] call EFUNC(common,filter);
|
_groupsToDrawMarkers = allGroups select {side _x == _playerSide};
|
||||||
} else {
|
} else {
|
||||||
_groupsToDrawMarkers = [allGroups, {
|
_groupsToDrawMarkers = allGroups select {
|
||||||
_anyPlayers = {
|
_anyPlayers = {
|
||||||
[_x] call EFUNC(common,isPlayer);
|
[_x] call EFUNC(common,isPlayer);
|
||||||
} count units _this;
|
} count units _x;
|
||||||
(side _this == _playerSide) && _anyPlayers > 0
|
(side _x == _playerSide) && _anyPlayers > 0
|
||||||
}] call EFUNC(common,filter);
|
}; // @todo, simplify this
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -95,11 +95,12 @@ TRACE_1("Player is on foot or in an open vehicle","");
|
|||||||
|
|
||||||
|
|
||||||
// Using chemlights
|
// Using chemlights
|
||||||
_nearObjects = [_unit nearObjects ["SmokeShell", 4], {
|
_nearObjects = (_unit nearObjects ["SmokeShell", 4]) select {
|
||||||
alive _this && {(typeOf _this == "Chemlight_red") || {
|
alive _x && {(typeOf _x == "Chemlight_red") || {
|
||||||
(typeOf _this == "Chemlight_green") || {
|
(typeOf _x == "Chemlight_green") || {
|
||||||
(typeOf _this == "Chemlight_blue") || {
|
(typeOf _x == "Chemlight_blue") || {
|
||||||
(typeOf _this == "Chemlight_yellow")}}}}}] call EFUNC(common,filter);
|
(typeOf _x == "Chemlight_yellow")}}}}}; // @todo, simplify this
|
||||||
|
|
||||||
if (count (_nearObjects) > 0) then {
|
if (count (_nearObjects) > 0) then {
|
||||||
_light = _nearObjects select 0;
|
_light = _nearObjects select 0;
|
||||||
|
|
||||||
|
@ -32,6 +32,6 @@ private _maxAmmo = 0;
|
|||||||
|
|
||||||
{
|
{
|
||||||
_maxAmmo = _maxAmmo max (_x select 1);
|
_maxAmmo = _maxAmmo max (_x select 1);
|
||||||
} forEach ([magazinesAmmo _player, {_this select 0 == _magazineType}] call EFUNC(common,filter));
|
} forEach (magazinesAmmo _player select {_x select 0 == _magazineType});
|
||||||
|
|
||||||
_maxAmmo > 0
|
_maxAmmo > 0
|
||||||
|
@ -32,7 +32,7 @@ private _maxAmmo = 0;
|
|||||||
|
|
||||||
{
|
{
|
||||||
_maxAmmo = _maxAmmo max (_x select 1);
|
_maxAmmo = _maxAmmo max (_x select 1);
|
||||||
} forEach ([magazinesAmmo _player, {_this select 0 == _magazineType}] call EFUNC(common,filter));
|
} forEach (magazinesAmmo _player select {_x select 0 == _magazineType});
|
||||||
|
|
||||||
if (_maxAmmo == 0) exitWith {};
|
if (_maxAmmo == 0) exitWith {};
|
||||||
|
|
||||||
|
@ -25,4 +25,4 @@ _magazines = magazines _unit;
|
|||||||
_magazines = [_magazines, {toLower _this}] call EFUNC(common,map);
|
_magazines = [_magazines, {toLower _this}] call EFUNC(common,map);
|
||||||
|
|
||||||
// get reloaders magazine types compatible with targets launcher. No duplicates.
|
// get reloaders magazine types compatible with targets launcher. No duplicates.
|
||||||
[getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"), {toLower _this in _magazines}] call EFUNC(common,filter)
|
getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines") select {toLower _x in _magazines} // return
|
||||||
|
@ -25,7 +25,7 @@ private _leave = false;
|
|||||||
|
|
||||||
if (GVAR(EnableSafeZone)) then {
|
if (GVAR(EnableSafeZone)) then {
|
||||||
private _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers);
|
private _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers);
|
||||||
private _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter);
|
private _nearestEnemyPlayers = _allNearestPlayers select {((side GVAR(OriginalGroup)) getFriend side _x < 0.6) && !(_x getVariable [QGVAR(IsPlayerControlled), false])};
|
||||||
|
|
||||||
if (count _nearestEnemyPlayers > 0) exitWith {
|
if (count _nearestEnemyPlayers > 0) exitWith {
|
||||||
_leave = true;
|
_leave = true;
|
||||||
|
@ -57,9 +57,9 @@ private _nextGrenade = _grenades select _nextGrenadeIndex;
|
|||||||
if (_currentGrenade == _nextGrenade) exitWith {false};
|
if (_currentGrenade == _nextGrenade) exitWith {false};
|
||||||
|
|
||||||
// current best method to select a grenade: remove all grenades except the one you want to select, then add them back
|
// current best method to select a grenade: remove all grenades except the one you want to select, then add them back
|
||||||
private _uniformGrenades = [uniformItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter);
|
private _uniformGrenades = uniformItems _unit select {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}};
|
||||||
private _vestGrenades = [vestItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter);
|
private _vestGrenades = vestItems _unit select {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}};
|
||||||
private _backpackGrenades = [backpackItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter);
|
private _backpackGrenades = backpackItems _unit select {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}};
|
||||||
|
|
||||||
// remove all grenades except those we are switching to --> this breaks the selector
|
// remove all grenades except those we are switching to --> this breaks the selector
|
||||||
{_unit removeItemFromUniform _x; false} count _uniformGrenades;
|
{_unit removeItemFromUniform _x; false} count _uniformGrenades;
|
||||||
|
Loading…
Reference in New Issue
Block a user