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

Interaction - Add Interaction to take another players launcher #10541

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Cplhardcore
Copy link
Contributor

When merged this pull request will:

  • Allow players to take launchers off others backs, without needing to go through the inventory

IMPORTANT

  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
  • Development Guidelines are read, understood and applied.
  • Title of this PR uses our standard template Component - Add|Fix|Improve|Change|Make|Remove {changes}.

Comment on lines 28 to 45
private _CfgWeapons = configFile >> "CfgWeapons" >> _launcher;
private _attachments = _target weaponAccessories _launcher;
private _launcherAmmo = (currentMagazine _unit) select {
_x in getArray (configFile >> "CfgWeapons" >> _launcherClassname >> "magazines")
};
_target removeWeapon _launcher;
{
_unit removeMagazine _x;
} forEach _launcherAmmo;

_player addWeapon _launcher;
{_player addSecondaryWeaponItem _x;} forEach _attachments;
{_unit addMagazine _x;} forEach _launcherAmmo;

if (_animate) then {[_player, "PutDown"] call EFUNC(common,doGesture)};

private _playerName = [_player] call EFUNC(common,getName);
private _displayName = getText (_cfgWeapons >> "displayName");
Copy link
Contributor

@DartRuffian DartRuffian Dec 13, 2024

Choose a reason for hiding this comment

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

I'm not sure if that _x in getArray (...) check is necessary, are there times where a launcher has a non-compatible magazine loaded?

addMagazine should probably use a CBA / ACE function that also checks if the magazine can be added, and drops on the ground if it can't be.

Suggested change
private _CfgWeapons = configFile >> "CfgWeapons" >> _launcher;
private _attachments = _target weaponAccessories _launcher;
private _launcherAmmo = (currentMagazine _unit) select {
_x in getArray (configFile >> "CfgWeapons" >> _launcherClassname >> "magazines")
};
_target removeWeapon _launcher;
{
_unit removeMagazine _x;
} forEach _launcherAmmo;
_player addWeapon _launcher;
{_player addSecondaryWeaponItem _x;} forEach _attachments;
{_unit addMagazine _x;} forEach _launcherAmmo;
if (_animate) then {[_player, "PutDown"] call EFUNC(common,doGesture)};
private _playerName = [_player] call EFUNC(common,getName);
private _displayName = getText (_cfgWeapons >> "displayName");
private _weaponConfig = configFile >> "CfgWeapons" >> _launcher;
private _attachments = _target weaponAccessories _launcher;
private _magazines = magazines _unit select {
_x in getArray (_weaponConfig >> "magazines")
};
_target removeWeapon _launcher;
{ _unit removeMagazine _x } forEach _magazines;
_player addWeapon _launcher;
{ _player addSecondaryWeaponItem _x } forEach _attachments;
{ _unit addMagazine _x } forEach _magazines;
if (_animate) then {[_player, "PutDown"] call EFUNC(common,doGesture)};
private _playerName = [_player] call EFUNC(common,getName);
private _displayName = getText (_weaponConfig >> "displayName");

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if that _x in getArray (...) check is necessary, are there times where a launcher has a non-compatible magazine loaded?

addMagazine should probably use a CBA / ACE function that also checks if the magazine can be added, and drops on the ground if it can't be.

Note: the config path in the line 31 of the suggested change should be saved into a var to avoid a potentially repeated lookup.

Copy link
Contributor

Choose a reason for hiding this comment

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

I left that part as is for the same reason john commented later, that select statement doesn't account for compatible magazines added through magazine wells.

If I had to guess, CBA / ACE has some function that also takes this into account

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use (getArray ... "magazines") because it doesn't support mag wells (which I think are used for some rpgs?)
just use compatibleMagazines

also need to think about 2nd muzzle (smaw)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Current issue with handling multiple muzzles, it breaks disposables

addons/interaction/functions/fnc_takeLauncher.sqf Outdated Show resolved Hide resolved
Comment on lines 30 to 32
private _launcherAmmo = (currentMagazine _unit) select {
_x in getArray (configFile >> "CfgWeapons" >> _launcherClassname >> "magazines")
};
Copy link
Contributor

@johnb432 johnb432 Dec 13, 2024

Choose a reason for hiding this comment

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

  1. _unit is undefined (another undefined _unit exists further below).
  2. currentMagazine is a string. I'm guessing you wanted magazines?
  3. Ammo counts are disregarded, when they need to be taken into account (some Halo launchers use magazines with multiple rounds).
  4. This code disregards any compatible ammo added via magwells.

I'm honestly not sure what you're trying to achieve here. Are you trying to just pass the loaded magazine or are you trying to pass all compatible magazines for the launcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to get the currently loaded magazine in the launcher, but from what I can tell there isn't a command to do that, so I'm looking at using magazines

Copy link
Contributor

Choose a reason for hiding this comment

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

There is, currentMagazineDetails

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use currentMagazineDetail, you have to do parsing to get the ammo count.
weaponState gives you both magazine classname and ammo count.

Copy link
Contributor

Choose a reason for hiding this comment

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

I said the same thing on discord and Drofresh said that, completely forgot about weaponState again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, im using weaponState rn

addons/interaction/functions/fnc_takeLauncher.sqf Outdated Show resolved Hide resolved
addons/interaction/functions/fnc_canTakeLauncher.sqf Outdated Show resolved Hide resolved
addons/interaction/functions/fnc_canTakeLauncher.sqf Outdated Show resolved Hide resolved
addons/interaction/functions/fnc_takeLauncher.sqf Outdated Show resolved Hide resolved
Comment on lines 28 to 45
private _CfgWeapons = configFile >> "CfgWeapons" >> _launcher;
private _attachments = _target weaponAccessories _launcher;
private _launcherAmmo = (currentMagazine _unit) select {
_x in getArray (configFile >> "CfgWeapons" >> _launcherClassname >> "magazines")
};
_target removeWeapon _launcher;
{
_unit removeMagazine _x;
} forEach _launcherAmmo;

_player addWeapon _launcher;
{_player addSecondaryWeaponItem _x;} forEach _attachments;
{_unit addMagazine _x;} forEach _launcherAmmo;

if (_animate) then {[_player, "PutDown"] call EFUNC(common,doGesture)};

private _playerName = [_player] call EFUNC(common,getName);
private _displayName = getText (_cfgWeapons >> "displayName");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if that _x in getArray (...) check is necessary, are there times where a launcher has a non-compatible magazine loaded?

addMagazine should probably use a CBA / ACE function that also checks if the magazine can be added, and drops on the ground if it can't be.

Note: the config path in the line 31 of the suggested change should be saved into a var to avoid a potentially repeated lookup.

@Cplhardcore
Copy link
Contributor Author

Right now this PR is on hold, as support for multiple muzzles breaks disposables

@Cplhardcore
Copy link
Contributor Author

thanks to johnb, this PR should be good to go

@Cplhardcore Cplhardcore marked this pull request as ready for review January 5, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants