-
Notifications
You must be signed in to change notification settings - Fork 740
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
base: master
Are you sure you want to change the base?
Conversation
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"); |
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.
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.
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"); |
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.
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.
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.
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
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.
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)
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.
Current issue with handling multiple muzzles, it breaks disposables
private _launcherAmmo = (currentMagazine _unit) select { | ||
_x in getArray (configFile >> "CfgWeapons" >> _launcherClassname >> "magazines") | ||
}; |
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.
_unit
is undefined (another undefined_unit
exists further below).currentMagazine
is a string. I'm guessing you wantedmagazines
?- Ammo counts are disregarded, when they need to be taken into account (some Halo launchers use magazines with multiple rounds).
- 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?
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.
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
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.
There is, currentMagazineDetails
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.
Don't use currentMagazineDetail
, you have to do parsing to get the ammo count.
weaponState
gives you both magazine classname and ammo count.
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.
I said the same thing on discord and Drofresh said that, completely forgot about weaponState again
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.
yeah, im using weaponState rn
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"); |
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.
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.
Co-authored-by: Jouni Järvinen <[email protected]>
Right now this PR is on hold, as support for multiple muzzles breaks disposables |
thanks to johnb, this PR should be good to go |
When merged this pull request will:
IMPORTANT
Component - Add|Fix|Improve|Change|Make|Remove {changes}
.