Page MenuHomeFeedback Tracker

New entity event handler that fires on inventory slots item changes
Feedback, NormalPublic

Description

I'd like to request a new entity event handler that fires each time unit slot items change. This will let us easily find moments when player or unit swaps their gear without having to constantly check player's entire inventory and comparing class names to see if player swapped anything.

Suggested name: InventorySlotChanged
Suggested parameters: params ["_unit", "_slotNumber", "_oldItem", "_newItem"];
_unit being entity that EH is attached to
_slotNumber being item slot number, same as new getSlotItemName command
_oldItem being class name of previous item
_newItem being class name of a new item

Additionally, depending what's is closely reachable in the engine, maybe it could include container where _newItem item was taken from. Also, maybe a supply container entity associated with the item (for uniforms, vests and backpacks)

If possible, having it work on dead units as well would be useful, so you could tell when something was taken off a dead body.

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce

If such EH existed, you'd be able to see it firing in chat when you took off or equipped items in your inventory.

player addEventHandler ["InventorySlotChanged", {
    systemChat str ["InventorySlotChanged", _this];
}];

Event Timeline

SaMatra created this task.Apr 7 2023, 2:20 PM
SaMatra added a comment.EditedApr 8 2023, 10:05 AM

A small correction to the request. It would be useful to also get container where new item was taken from (to remove event handlers off it or delete its items or something).

Max dream arguments:

params ["_unit", "_slotNumber", "_oldItem", "_newItem", "_oldItemSupply", "_newItemSupply", "_newItemTakenFrom"];
BIS_fnc_KK set Ref Ticket to AIII-55650.Apr 8 2023, 7:43 PM

Revision: 150462

SlotItemChanged EH

Known issue (todo): binoculars not supported yet

Ok added binoculars, but the EH is not firing on removeAssignedItems or removeAllWeapons. One of the solution would be to make engine remove items one by one if EH exists which will slow down the removal process. Not liking this. Ideas?

I feel that removing one by one is fine if EH exists. Its not like such removal happens each frame on a 100 units in scripts or in the engine itself, performance difference would be super tiny. Since the engine wasn't designed for such event handlers, this feels like a good solution.

BIS_fnc_KK removed BIS_fnc_KK as the assignee of this task.Apr 10 2023, 11:55 AM
BIS_fnc_KK changed the task status from New to Feedback.
BIS_fnc_KK added a subscriber: BIS_fnc_KK.

Guys, does "SlotItemChanged" EH work? When i try to add it, i recieve the error "unknown enum value".

The update containing the SlotItemChanged EH has not come to the main branch of the game yet. It's still on dev branch, and will be for some time. You are receiving that error because the EH does not exist in the version of the game you have installed.

NikkoJT removed a subscriber: NikkoJT.May 13 2023, 4:37 AM