-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CBA_fnc_uniqueUnitItems #902
Conversation
maybe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to getUniqueItems
or getUnitUniqueItems
(former could work on boxes too if that makes sense).
_allItems append (primaryWeaponItems _unit); | ||
_allItems append (secondaryWeaponItems _unit); | ||
_allItems append (handgunItems _unit); | ||
_allItems append [ primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array contents to new line, one indent right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_allItems append [
primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit,
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit
];
Or
_allItems append [
primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit,
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit
];
? I'm confused now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_allItems append [
primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit,
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit
];
_allItems append (handgunItems _unit); | ||
_allItems append [ primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, | ||
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same indent as _allItems append ...
.
_allItems append (secondaryWeaponItems _unit); | ||
_allItems append (handgunItems _unit); | ||
_allItems append [ primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, | ||
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one indent right.
Same thing in ACRE, will be beneficial. |
Great idea. So maybe this can be a starter to offer a unique ID framework within CBA? |
And ACE BFT as well |
How does this compare to: params [["_unit", objNull, [objNull]];
private _items = items _unit;
_items arrayIntersect _items // return ? |
Naming sheme:
So my suggestions are: CBA_fnc_getUnitItemsUnique
CBA_fnc_unitItemsUnique
CBA_fnc_getItemsUnique
CBA_fnc_itemsUnique |
This function does not report the |
Function: CBA_fnc_getUniquePlayerItems | ||
|
||
Description: | ||
A function used to retrieve a unique list of items in the units inventory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A function used to [R]etrieve[s] a unique list of items in the units inventory[.]
In default settings aka no weapon items it should be the same. I used it in TFAR as a replacement for exactly that.
No. Not at all. To the names |
|
|
@commy2 In the end you decide anyway. Want me to just go for your variant or want me to keep arguing that it's so ambiguous because the "unit" is missing. |
It's not "arguing", but throwing out ideas. Sadly you only have one shot and are stuck with the function name later, because bwc. |
Let's vote? |
Since we are (hobby) programmers, we should at least use instant-runoff voting instead of this archaic method barely good enough to decide who runs a country. |
Pushed back, because #902 (comment) is still unaddressed. |
@commy2 it's supposed to replace items player. Does that return binocularMagazine? |
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit | ||
]; | ||
_allItems pushBack (_unit call CBA_fnc_binocularMagazine); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (_weaponItems) then {
_allItems append [
primaryWeapon _unit,
secondaryWeapon _unit,
handgunWeapon _unit
];
_allItems append primaryWeaponItems _unit;
_allItems append secondaryWeaponItems _unit;
_allItems append handgunItems _unit;
_allItems append primaryWeaponMagazine _unit;
_allItems append secondaryWeaponMagazine _unit;
_allItems append handgunMagazine _unit;
_allItems pushBack (_unit call CBA_fnc_binocularMagazine);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember that primaryWeaponMagazine
-no S etc. report ARRAY, exactly like the XItems versions.
private _allItems = (assignedItems _unit); | ||
if (_uniform) then {_allItems append ((getItemCargo (uniformContainer _unit)) select 0);}; | ||
if (_vest) then {_allItems append ((getItemCargo (vestContainer _unit)) select 0);}; | ||
if (_backpack) then {_allItems append ((getItemCargo (backpackContainer _unit)) select 0);}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parenthesis aaaaa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfectly fine here to quickly see the order they are executed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaaaa
if (_uniform) then {
_allItems append (getItemCargo uniformContainer _unit select 0);
};
if (_vest) then {
_allItems append (getItemCargo vestContainer _unit select 0);
};
if (_backpack) then {
_allItems append (getItemCargo backpackContainer _unit select 0);
};
T_T
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getItemCargo uniformContainer _unit select 0
this is just unreadable IMO.
#include "script_component.hpp" | ||
SCRIPT(uniqueUnitItems); | ||
|
||
params [["_unit", objNull, [objNull]], ["_weaponItems", true, [true]], ["_backpack", true, [true]], ["_vest", true, [true]], ["_uniform", true, [true]]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah!
["_weaponItems", true, [true]]
default false? duh..
Btw here is some perf data about the use-case I made this for: acemod/ACEX#114 (comment) |
Default settings return the same as
items _unit
but without duplicates.iterating over items unit like in
https://github.com/acemod/ACE3/blob/8548ff7eb8fd055c5013225b6acb620c753892a4/addons/tagging/functions/fnc_addTagActions.sqf#L36
Can be very expensive if you are just searching for whether the player has one item. Because it returns all items and multiple items as multiple strings.
Was a total perf killer in TFAR when someone had a backpack with ACE medical supplies. I'm sure this can be useful for many things.
Also made it configurable as you might want to exclude backpack or include weapon items.
I don't know how I could make unit tests for this. And I also don't quite like the current Name. My creativity has it's limits.