Page MenuHomeFeedback Tracker

"canAdd" Scripting Command Affected by Weight/Stamina System Even When Disabled
Assigned, WishlistPublic

Description

The "canAdd" scripting command (https://community.bistudio.com/wiki/canAdd) will return false if you have too much "weight", even if you set "_unit enableStamina false;" (https://community.bistudio.com/wiki/enableStamina).

Essentially, even if you disable the stamina system, the "canAdd" function is still limited by it, even though it doesn't factor into the intended gameplay at all.

Details

Legacy ID
4120690425
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

Load into the editor, then paste this into the script console:

player enableStamina true;
{player addWeapon _x;} forEach ["launch_RPG32_F","hgun_Pistol_heavy_01_F","MMG_01_hex_F"];
player addSecondaryWeaponItem "RPG32_HE_F";
{player addPrimaryWeaponItem _x;} forEach ["muzzle_snds_93mmg","acc_pointer_IR","optic_tws","bipod_01_F_blk","150Rnd_93x64_Mag"];
player forceAddUniform "U_I_Protagonist_VR";
player addVest "V_PlateCarrierSpec_rgr";
player addBackpack "B_Carryall_oli";
systemChat format['player canAdd "150Rnd_93x64_Mag": %1 | isStaminaEnabled: %2',player canAdd "150Rnd_93x64_Mag",isStaminaEnabled player];
player enableStamina false;
systemChat "Stamina disabled";
systemChat format['player canAdd "150Rnd_93x64_Mag": %1 | isStaminaEnabled: %2',player canAdd "150Rnd_93x64_Mag",isStaminaEnabled player];
player addItem "150Rnd_93x64_Mag";
systemChat "Added magazine";

In chat, it will say you can't add the Navid ammo both times (With stamina enabled and disabled), even though you have plenty of inventory space, and the stamina system is disabled.

Event Timeline

eraser1 edited Steps To Reproduce. (Show Details)Jan 16 2016, 8:18 PM
eraser1 set Category to Scripting.
eraser1 set Reproducibility to Always.
eraser1 set Severity to None.
eraser1 set Resolution to Open.
eraser1 set Legacy ID to 4120690425.May 8 2016, 1:30 PM
eraser1 edited a custom field.

I'm sorry, but what is this ticket about? canAdd indeed depends on the overall weight of all added items, it works exactly in the way in game inventory does. If you can add item manually with inventory then canAdd will return true. If this doesn't suit your scenario you can simply avoid using canAdd. Does this solve your issue?

eraser1 added a subscriber: eraser1.May 8 2016, 1:30 PM

That is true, however if you disable the stamina/weight system canAdd will return false. The only thing that is making it return false is stamina/weight, however since stamina is disabled, it shouldn't matter.

Essentially, "canAdd" shouldn't check for weight when stamina is disabled.

Does that clear it up?

Each container has weight limit, i.e. how many items you can put in it depends on the summary weight of items. If container is limited to let's say 40 kg, this means when you want to put in it item that together with items already in the container will exceed 40kg, canAdd will return false.

This has nothing to do with stamina, which is a different system. In fact it is stamina that depends on the weight of your items in the container and not weight of items depends on stamina. So switching stamina off should not affect how many items you can put in the container.

However, as I mentioned already, you don't need canAdd command at all. You only need it if you want to make sure when you're adding items by script it is compatible with how inventory does it.

OK, it seeems that I'm still unclear:

If you run the script I provided, your character will have the "stamina weight bar" at the bottom of the inventory menu almost completely full; HOWEVER, the player still has plenty of inventory space: the uniform is almost completely empty, and the chestrig as well as the backpack are completely empty. The player is still able to hold at least half a dozen more Navid boxes, however the "canAdd" command returns false because the stamina bar at the bottom of the inventory is almost full.

What do you mean by player is still able to hold at least half a dozen Navid boxes? What criteria you use to judge this?

Inventory space.

Is it visual space? Because the bar at the bottom is representation of inventory capacity only not geometrical or visual but weight related. It is not a stamina bar but it will affect your stamina greatly when it is full. I hope this makes it more clear.

I mean I can simply drag ammo/items from the ground or other inventory sources into my uniform, vest, or backpack. However, the "canAdd" command returns false, and I can't use the right click "shortcut" to move items into my inventory.

You mean you can still drag items into your uniform even when the load bar at the bottom shows that it is full?

Apparently yes, the dragging works and overrides the limit. I have raised internal ticket about it.

Is the limit supposed to be separate from the stamina system?