-
Notifications
You must be signed in to change notification settings - Fork 749
Medical - Support Magazine Treatment Items #9816
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
fe4ed52
count treatment items
BrettMayson e88afa6
getCountofItem
BrettMayson d05bb52
getCountofItem fix
BrettMayson 41eafbc
convert painkillers to magazine
BrettMayson 936897e
use isclass
BrettMayson d8cac46
forget to change variable
BrettMayson 5c15384
Update addons/medical_treatment/functions/fnc_hasItem.sqf
BrettMayson 65dfa6b
better magazine adjustment
BrettMayson ef251a4
Update addons/common/functions/fnc_adjustMagazineAmmo.sqf
BrettMayson 5137885
Update addons/medical_treatment/functions/fnc_medication.sqf
BrettMayson 21a6b5b
Update addons/medical_treatment/functions/fnc_treatmentFailure.sqf
BrettMayson 81be584
Update docs/wiki/framework/arsenal-framework.md
BrettMayson a343b38
Update addons/common/functions/fnc_adjustMagazineAmmo.sqf
BrettMayson ee070a6
Header
LinkIsGrim 8a0d64f
use switch statement in fnc_useItem
LinkIsGrim 601524d
Update addons/common/functions/fnc_adjustMagazineAmmo.sqf
johnb432 e488e13
Update addons/common/functions/fnc_adjustMagazineAmmo.sqf
BrettMayson a701251
only check adding to mags that are not full
BrettMayson 7709779
Update addons/common/functions/fnc_adjustMagazineAmmo.sqf
johnb432 cbed198
Update fnc_getCountOfItem.sqf
johnb432 c6ebef8
Optimisations & header fix
johnb432 f53063d
Update addons/common/functions/fnc_adjustMagazineAmmo.sqf
johnb432 f5dc797
Fixed vehicle implementation
johnb432 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: Katalam, Blue, Brett Mayson, johnb43 | ||
| * Handle adjusting a magazine's ammo | ||
| * | ||
| * Arguments: | ||
| * 0: Vehicle or Unit <OBJECT> | ||
| * 1: Item <STRING> | ||
| * 2: Ammo to adjust by <NUMBER> (default: -1) | ||
| * | ||
| * Return Value: | ||
| * How much the ammo was adjusted by <NUMBER> | ||
| * | ||
| * Example: | ||
| * [player, "30Rnd_556x45_Stanag", 1] call ace_common_fnc_adjustMagazineAmmo; | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| params ["_unit", "_magazine", ["_count", -1]]; | ||
|
|
||
| if (_count == 0) exitWith {0}; | ||
|
|
||
| private _containers = if (_unit isKindOf "CAManBase") then { | ||
| [uniformContainer _unit, vestContainer _unit, backpackContainer _unit] | ||
| } else { | ||
| [_unit] | ||
| }; | ||
|
|
||
| scopeName "main"; | ||
|
|
||
| private _originalCount = _count; | ||
| private _container = objNull; | ||
| private _magazinesContainer = []; | ||
| private _newAmmoCount = 0; | ||
| private _removeAmmo = _count < 0; | ||
| private _maxMagazineAmmo = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count"); | ||
|
|
||
| { | ||
| _container = _x; | ||
|
|
||
| // Get all magazines of _magazine type | ||
| _magazinesContainer = (magazinesAmmoCargo _container) select {_x select 0 == _magazine}; | ||
|
|
||
| // Get the ammo count, filter out magazines with 0 ammo | ||
| _magazinesContainer = (_magazinesContainer apply {_x select 1}) select {_x != 0}; | ||
|
|
||
| // If there are none, skip to next container | ||
| if (_magazinesContainer isEqualTo []) then { | ||
| continue; | ||
| }; | ||
|
|
||
| // Sort, smallest first when removing, largest first when adding | ||
| _magazinesContainer sort _removeAmmo; | ||
|
|
||
| if (_removeAmmo) then { | ||
| { | ||
| _count = _x + _count; | ||
|
|
||
| _container addMagazineAmmoCargo [_magazine, -1, _x]; | ||
|
|
||
| if (_count >= 0) then { | ||
| // Only add magazine back if it's not empty | ||
| if (_count != 0) then { | ||
| _container addMagazineAmmoCargo [_magazine, 1, _count]; | ||
| }; | ||
|
|
||
| _originalCount breakOut "main"; | ||
| }; | ||
| } forEach _magazinesContainer; | ||
| } else { | ||
| // This loop only fills up partially filled magazines | ||
| { | ||
| // Fill the magazine to either its max or until all ammo has been added | ||
| _newAmmoCount = (_x + _count) min _maxMagazineAmmo; | ||
|
|
||
| if (_newAmmoCount <= _maxMagazineAmmo) then { | ||
| _container addMagazineAmmoCargo [_magazine, -1, _x]; | ||
| _container addMagazineAmmoCargo [_magazine, 1, _newAmmoCount]; | ||
| }; | ||
|
|
||
| // Remove the ammo that was added | ||
| _count = _count - (_newAmmoCount - _x); | ||
|
|
||
| if (_count <= 0) then { | ||
| _originalCount breakOut "main"; | ||
| }; | ||
| } forEach (_magazinesContainer select {_x < _maxMagazineAmmo}); | ||
| }; | ||
| } forEach _containers; | ||
|
|
||
| // If there is still remaining ammo to add, try add it after having iterated through all containers | ||
| if (!_removeAmmo && _count > 0) then { | ||
| { | ||
| while {_count > 0 && {_x canAdd [_magazine, 1/* 2.18 , true*/]}} do { | ||
| _x addMagazineAmmoCargo [_magazine, 1, _count]; | ||
|
|
||
| _count = _count - _maxMagazineAmmo; | ||
| }; | ||
| } forEach _containers; | ||
|
|
||
| if (_count <= 0) then { | ||
| _originalCount breakOut "main"; | ||
| }; | ||
| }; | ||
|
|
||
| _originalCount - _count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,84 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: mharis001 | ||
| * Returns list of unique items in a unit's inventory. | ||
| * Items are cached if unit is ACE_player. | ||
| * Author: mharis001, Blue, Brett Mayson | ||
| * Returns list of unique items in the target's inventory. | ||
| * | ||
| * Arguments: | ||
| * 0: Unit <OBJECT> | ||
| * 0: Target <OBJECT> | ||
| * 1: Include magazines <NUMBER> | ||
| * 0: No (default) | ||
| * 1: Yes | ||
| * 2: Only magazines | ||
| * | ||
| * Return Value: | ||
| * Items <ARRAY> | ||
| * | ||
| * Example: | ||
| * [player] call ace_common_fnc_uniqueItems | ||
| * [player, 2] call ace_common_fnc_uniqueItems | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| params ["_unit"]; | ||
| params ["_target", ["_includeMagazines", 0]]; | ||
|
|
||
| private _fnc_getItems = { | ||
| private _items = (getItemCargo uniformContainer _unit) select 0; | ||
| _items append ((getItemCargo vestContainer _unit) select 0); | ||
| _items append ((getItemCargo backpackContainer _unit) select 0); | ||
| private _items = []; | ||
|
|
||
| private _inventoryItems = (getItemCargo uniformContainer _target) select 0; | ||
| _inventoryItems append ((getItemCargo vestContainer _target) select 0); | ||
| _inventoryItems append ((getItemCargo backpackContainer _target) select 0); | ||
|
|
||
| _items set [0, _inventoryItems]; | ||
| _items set [1, magazines _target]; | ||
|
|
||
| _items arrayIntersect _items | ||
| }; | ||
|
|
||
| // Use cached items list if unit is ACE_player | ||
| if (_unit isEqualTo ACE_player) then { | ||
| // Cache items list if unit is ACE_player | ||
| if (_target isEqualTo ACE_player) then { | ||
| if (isNil QGVAR(uniqueItemsCache)) then { | ||
| GVAR(uniqueItemsCache) = call _fnc_getItems; | ||
| }; | ||
| +GVAR(uniqueItemsCache) | ||
|
|
||
| switch (_includeMagazines) do { | ||
| case 0: { | ||
| GVAR(uniqueItemsCache) select 0 | ||
| }; | ||
| case 1: { | ||
| (GVAR(uniqueItemsCache) select 1) + (GVAR(uniqueItemsCache) select 0) | ||
| }; | ||
| case 2: { | ||
| GVAR(uniqueItemsCache) select 1 | ||
| }; | ||
| }; | ||
| } else { | ||
| call _fnc_getItems; | ||
| if (_target isKindOf "CAManBase") then { | ||
| private _items = call _fnc_getItems; | ||
|
|
||
| switch (_includeMagazines) do { | ||
| case 0: { | ||
| _items select 0 | ||
| }; | ||
| case 1: { | ||
| (_items select 1) + (_items select 0) | ||
| }; | ||
| case 2: { | ||
| _items select 1 | ||
| }; | ||
| }; | ||
| } else { | ||
| private _items = switch (_includeMagazines) do { | ||
| case 0: { | ||
| itemCargo _target | ||
| }; | ||
| case 1: { | ||
| (magazineCargo _target) + (itemCargo _target) | ||
| }; | ||
| case 2: { | ||
| magazineCargo _target | ||
| }; | ||
| }; | ||
|
|
||
| _items arrayIntersect _items | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| class CfgMagazines { | ||
| class CA_Magazine; | ||
| class ACE_painkillers: CA_Magazine { | ||
| scope = 2; | ||
| author = ECSTRING(common,ACETeam); | ||
| displayName = CSTRING(painkillers_Display); | ||
| model = "\A3\Structures_F_EPA\Items\Medical\PainKillers_F.p3d"; | ||
| picture = QPATHTOF(ui\painkillers_ca.paa); | ||
| descriptionShort = CSTRING(painkillers_Desc_Short); | ||
| descriptionUse = CSTRING(painkillers_Desc_Use); | ||
| ACE_isMedicalItem = 1; | ||
| ACE_asItem = 1; | ||
| count = 10; | ||
| mass = 1; | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.