-
Notifications
You must be signed in to change notification settings - Fork 735
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
CSW - Fix and Improve reloading #9234
base: master
Are you sure you want to change the base?
Conversation
The public functions were made with ZEN compatibility for CSW Artillery in mind, I intend to make another PR for the remainder of that. Sorry for the scope on this, but it'd have been merge conflict or PR-dependency hell otherwise. |
private _carryMagazines = createHashMap; // hashmap for constant lookup | ||
{ | ||
private _weapon = _x; | ||
if !(_weapon in GVAR(compatibleMagsCache)) then {continue}; | ||
_carryMagazines merge [GVAR(compatibleMagsCache) get _weapon, true]; | ||
} forEach _weapons; |
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.
1. Add comment describing that this is handling proxy weapons. That's some bullshit I wrote, it handles carry magazines.
2. GVAR(compatibleMagsCache)
is not a good name for this imo, should be renamed to something that includes "proxyWeapon" (e.g. GVAR(compatibleCarryMags)
).
clearItemCargoGlobal _container; | ||
clearWeaponCargoGlobal _container; | ||
clearBackpackCargoGlobal _container; | ||
clearMagazineCargoGlobal _container; |
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 the container has forceSupply
set to 1
and you empty it (either by using the commands above or using other cargo manipulation commands), it will be marked for deletion, regardless of if you add items after the execution of this command.
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
if (_turretPath isEqualTo []) then { | ||
_turretPath = [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.
Why?
FUNC(reload_getLoadableMagazines)
doesn't follow the same logic, which could lead to a desync of information.
if (_clearForcedMag) then { | ||
_vehicle setVariable [QGVAR(forcedMag), nil, 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.
Description of _clearForcedMag
is Clear forced magazine after reloading
. However, in line 46 it can still fail. Furthermore, this variable technically reset before reload. Do we need to absolutely reset it after the reload has finished (so when the turret events are called) or can it be called just after line 53?
// Cache compatible magazines | ||
if !(_proxyWeapon in GVAR(compatibleMagsCache)) then { | ||
private _compatibleMagazines = compatibleMagazines _proxyWeapon; | ||
GVAR(compatibleVehicleMagsCache) set [_proxyWeapon, _compatibleMagazines]; |
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.
GVAR(compatibleVehicleMagsCache)
is only used inFUNC(getVehicleMagazine)
, which in turn is only called when mags are either loaded or unloaded. Imo caching this is not necessary.- Both
GVAR(compatibleVehicleMagsCache)
andGVAR(compatibleMagsCache)
don't save magazines belonging to non-proxy weapons.
When merged this pull request will:
FUNC(reload_canLoadMagazine)
conditions.nearSupplies
check. 10 meters was excessive._unit
param in events and logging.FUNC(getNearbySources)
.FUNC(getSourceCompatibleMags)
: returns a source's compatible carry magazines with ammo count.FUNC(compatibleMagazines)
: returns a CSW's compatible carry magazines.FUNC(reload_getLoadableMagazines)
. Done to optimize the checks for best ammo to send.FUNC(getCarryMagazine)
public.FUNC(reload_getLoadableMagazines)
by making use of new functions.FUNC(ai_reload)
useFUNC(reload_getLoadableMagazines)
directly: parameter was added to use the turret path in the latter._staticWeapon
in parameters to_vehicle
.FUNC(getAvailableAmmo)
: returns nearby compatible magazine types and sum of their ammo. Intended for ZEN compatibility.ace_csw_forcedMag
.FUNC(unloadMagazines)
: unloads magazines in turret path.FUNC(ai_switchMagazine)
: forces AI to reload specified magazine.MP tested and objNull/no container/full inventory-resistant.
I did not intend for this to grow so much, but here we are.
Review after #9238 and #9255.
IMPORTANT
Component - Add|Fix|Improve|Change|Make|Remove {changes}
.