Skip to content
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

Added interaction to quickly pass a magazine #2390

Merged
merged 11 commits into from
Nov 25, 2015

Conversation

BaerMitUmlaut
Copy link
Member

This adds an interaction that lets you quickly pass a magazine to another player (or AI unit). It automatically chooses the magazine that still has the most ammo, fits into the other units weapon and also still fits into his inventory.

I have not added the possibility to pass on ammunition for launchers, since this is more for when somebody runs out of ammo in combat, and I don't think you can't really quickly pass on a rocket. It would be easy to add though if so desired.

_filterFunc = compile format ["((_this select 0) in %1) && (!(_this select 2))", _compatibleMags];
_filteredMags = [magazinesAmmoFull _player, _filterFunc] call EFUNC(common,filter);

if (count _filteredMags > 0) then {
Copy link
Member

Choose a reason for hiding this comment

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

if (_filteredMags isEqualTo [])

Copy link
Member

Choose a reason for hiding this comment

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

  1. Has to be inverted
  2. Why? Count is fine imho

Copy link
Member

Choose a reason for hiding this comment

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

count is slower as isEqualTo and yes posible

Copy link
Member Author

Choose a reason for hiding this comment

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

I tested both with empty and non-empty arrays, with the added ! the performance difference is always around 0.0003ms. I think that's fine...

Copy link
Contributor

Choose a reason for hiding this comment

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

I love how you guys discuss count == 0 vs isEqualTo [] and completely ignore the compile.

@commy2 commy2 added status/WIP kind/feature Release Notes: **ADDED:** labels Sep 10, 2015
@thojkooi thojkooi added this to the Backlog milestone Sep 11, 2015
_filteredMags = [magazinesAmmoFull _player, _filterFunc] call EFUNC(common,filter);

//select magazine with most ammo
_magToPass = _filteredMags select 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use params for this

@kymckay
Copy link
Member

kymckay commented Sep 11, 2015

I'm in two minds about this addition.

Passing a magazine to someone in close proximity can be done already with the inventory and being honest I can use the inventory much quicker than I can use the interaction menu on a person 😛

@bux
Copy link
Member

bux commented Sep 11, 2015

I'm in two minds about this addition.

agree

on the other hand IRL you could "throw" magazines much further

@BaerMitUmlaut
Copy link
Member Author

If neither you nor the other person have a backpack and you're in tall grass, dropping and picking up magazines becomes a pita. Without backpacks I'm pretty sure this would be way faster.

@commy2
Copy link
Contributor

commy2 commented Sep 11, 2015

I can use the inventory much quicker than I can use the interaction menu on a person

And I can't use Arma 3's inventory system at all on remote units in MP. Half of the time nothing happens and I have to close and re-open the menu. Sometimes I have to use drag and drop, other times it only works with right-clicking. Occasionally the item disappears (especially magazines) or duplicates pop up.

With addMagazine and removeMagazine we at least know that it works if scripted correctly.

@kymckay
Copy link
Member

kymckay commented Sep 11, 2015

Both points seem reasonable 👍

@jonpas
Copy link
Member

jonpas commented Sep 11, 2015

Make it optional then.

@kymckay
Copy link
Member

kymckay commented Sep 11, 2015

Isn't it inherently optional? :P

@BaerMitUmlaut
Copy link
Member Author

No need to make this optional. If you think the other way is faster, don't use the interaction menu.

@jonpas
Copy link
Member

jonpas commented Sep 11, 2015

It still clogs up the interaction menu though, not really a problem, I just like it clean. 😁

({_target canAdd (_x select 0)} count _filteredMags) > 0
} else {
false
};
Copy link
Contributor

Choose a reason for hiding this comment

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

could be simplified to:
!(_filteredMags isEqualTo []) && {{_target canAdd (_x select 0)} count _filteredMags > 0}

true
} else {
false
};
Copy link
Contributor

Choose a reason for hiding this comment

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

if (BOOL) then {true} else {false}
: - )

Copy link
Member

Choose a reason for hiding this comment

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

BOOL :D !(_filteredMags isEqualTo []) && {{_target canAdd (_x select 0)} count _filteredMags > 0} without if

Copy link
Member Author

Choose a reason for hiding this comment

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

duh

@BaerMitUmlaut
Copy link
Member Author

How about this?

@BaerMitUmlaut
Copy link
Member Author

Merge conflicts have been resolved, also fixed an error in a header. This is no more WIP unless you see something wrong with it.

@@ -35,6 +35,32 @@ class CfgVehicles {
icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa";
selection = "pelvis";

class ACE_PassMagazine {
displayName = CSTRING(PassMagazine);
condition = QUOTE([ARR_3(_player,_target,primaryWeapon _target)] call FUNC(canPassMagazine) || [ARR_3(_player,_target,handgunWeapon _target)] call FUNC(canPassMagazine));
Copy link
Contributor

Choose a reason for hiding this comment

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

Parent condition can be empty string or just true.
If there are no children, it won't show because statement is {}
Will save checking the conditions twice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@PabstMirror PabstMirror modified the milestones: 3.4.0, Backlog Oct 6, 2015
@PabstMirror
Copy link
Contributor

I guess I wouldn't mind this simplified down to currentWeapon instead of the tree, but that's just me.
Either way it looks good.

@thojkooi
Copy link
Contributor

Thanks for the change @BaerMitUmlaut 👍

thojkooi added a commit that referenced this pull request Nov 25, 2015
Added interaction to quickly pass a magazine
@thojkooi thojkooi merged commit 08c5374 into acemod:master Nov 25, 2015
@BaerMitUmlaut BaerMitUmlaut deleted the pass-magazine branch December 3, 2015 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Release Notes: **ADDED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants