Page MenuHomeFeedback Tracker

Request for Improved script interface for detailed inventory management
Closed, ResolvedPublic

Description

There appears to be several limitations with the current script
inventory management interface; especially for items such as
magazines and consumables that are defined by not only their name but
also by how much of the items has been used/remains (i.e., the number
of rounds/water/food/etc. remaining), especially when it is also
desirable to know exactly where an item is stored (in a
uniform/vest/backpack/etc.).

There are now commands such as "magazines", that return the names of
magazines in a vehicle/character, but not the objects themselves and
not the amount of ammo remaining. There are similarly specific
commands such as "uniformitems", that list names of all items in
specific containers (but not the objects or specific magazine ammo
counts), and commands such as "magazinesDetail" that shows names and
capacities (but in text format and without any information about
where the magazines are stored).

Getting information about ammo counts for specific magazines also
appears to be difficult, and apart from the information embedded in
text strings (such as from "magazineDetails") it appears that the
primary way of finding out how much ammo exists in a given magazine
is to load it into a used weapon and then use the "ammo"
command, which is somewhat cumbersome and not very intuitive. If one
wants to find out, for example, where magazines are located
AND what their current ammo count is, there appears to be no good way to do
this.

While these limitations can likely be worked around, and looking at
existing addon/mod-code it appears that this is frequently done, the
result is often complicated and not very intuitive code for
operations that should be simple to achieve. Having a simpler and
more generic interface would make inventory management more
accessible and ideally achieved with clear and robust code.

For these reasons, I would like to request that one or more generic
commands are added to the ArmA scripting interface as it would seem
that it should be possible to provide most of the functionality
required for significantly improved scripted inventory management in
a relatively simple way. For example, assuming a new command called
"itemsDetails" was added, with the following semantics:

  itemsDetails [unit, location container type, object type]
   output format: [[item object, container type, container object],
                   [item object2, container type, container object],
                    ...]

  example container type values:
   0 - any location
   1 - item stored in uniform
   2 - item stored in vest
   4 - item stored in backpack
   8 - assigned item (radio/map/etc.)
   16 - primary weapon (e.g., for magazine loaded in primary weapon)
   32 - secondary weapon (e.g., for magazine loaded in secondary weapon)
   ...

  example object type values:
   0 - any item
   1 - normal item (radio etc.)
   2 - weapon
   4 - magazine
   8 - backpack
   ...

The command would take an array with the unit/vehicle to list the
inventory for (mandatory argument), and two optional filter mask
arguments: the container type (uniform, vest, assigned, etc.), and
the item type (normal item, weapon, magazine, etc.).

The output would be an array containing arrays with the item object,
a location identifier, and the container object where the item is
located (when appropriate, e.g., for items in uniforms or backpacks,
nil otherwise).

This interface would make it possible to get a list of all inventory
items, or only items that are stored in a specific container or are
of a specific type. While the filter mechanism is not necessary, it
would seem to be a natural extension that reduces the amount of data
returned and removes the need for many different commands that list
items for specific containers ("uniformitems") or of specific types
("magazines").

Examples:

  _mags = itemsDetails(player, 0, 4);

Would return all magazines carried by the player, and the location
where they are stored/used (including for primary and secondary
weapons).

  _uniformitems = itemsDetails(player, 1, 0);

Would return information on all items stored in any worn uniform.

  _storedweapons = itemsDetails(player, 7, 2);

Would return all weapons stored in either a worn uniform, vest or
backpack (i.e., not actively used).

----------------------------------------------------------------------

For getting ammo counts in an easier way, a variant of the "ammo"
command would ideally also be added that returns the ammo count of a
specific clip object, for example

  ammoMagazine <magazine object>

Would return the number of rounds remaining in the specified
magazine.

----------------------------------------------------------------------

While on the topic of inventory management, similar generic commands
for adding or removing specific items that take objects and inventory
locations as arguments would likely also be useful, for example:

addToInventory [unit, location container type, inventory object]

  return error on failure

removeFromInventory [unit, location container type, inventory object]

  returns removed inventory object
 
  example container type values:
   0 - any location
   1 - worn uniform
   2 - worn vest
   4 - worn backpack
   8 - appropriate assigned slot (radio/map/etc.)
   16 - primary weapon
   32 - secondary weapon
   ...

The first command would add the specified item (regardless of type)
to the specified inventory location, while the second command would
remove the item from the inventory of the vehicle/character and
return it (i.e., it is only removed from the inventory, it does not
stop existing in the game).

An error would presumably be returned if the object could not be
placed in the specified location (e.g., attempting to place a radio
in a primary weapon or a magazine in a assigned slot), or if another
item was already in the location, etc.

----------------------------------------------------------------------

The commands above should make it simple to perform operations such
as moving equipment between players and duplicating loadouts, while
preserving the number of rounds in magazines and similar items.

----------------------------------------------------------------------

The command descriptions above are only suggestions; there are likely
other variations that would also be possible and likely better, but a
more generic approach like the one suggested would seem to be a step
forward compared to the complicated tricks that are needed for
inventory management now.

Details

Legacy ID
1831311324
Severity
None
Resolution
Open
Reproducibility
N/A
Category
Feature Request
Steps To Reproduce

Try to write sqf script code that does exact inventory management, especially attempting to duplicate equipment while preserving item locations and available rounds in magazines.

Event Timeline

andero2 edited Steps To Reproduce. (Show Details)Jul 29 2013, 10:34 PM
andero2 edited Additional Information. (Show Details)
andero2 set Category to Feature Request.
andero2 set Reproducibility to N/A.
andero2 set Severity to None.
andero2 set Resolution to Open.
andero2 set Legacy ID to 1831311324.May 7 2016, 3:44 PM
Bohemia added a subscriber: Bohemia.May 7 2016, 3:44 PM

The new magazinesAmmoFull function provides a solution to most of the problems that motivated this ticket.

A more flexible way of controlling how items are added to the inventory would still be appreciated, but as there already exists tickets for that type of functionality, this ticket can probably be closed, thanks.

MadDogX added a subscriber: MadDogX.May 7 2016, 3:44 PM

Mass closing ancient tickets with no activity for > 12 months; assume fixed or too trivial.

If this issue is still relevant in current dev build, please re-post.