Osiris/Shared/ProcBlockUseOfItem

From Divinity Engine Wiki
Jump to: navigation, search
Full Definition(s)
  • PROC ProcBlockUseOfItem((CHARACTERGUID)_Char,(ITEMGUID)_Item)
Description

This procedure is called every time a character (_Char) attempts to use an interactable item (_Item) in the game world (in response to a CanUseItem event sent by Osiris). As the name implies, you can overload it to dynamically block the default use action of said item, but you can also use it to completely change the way the item interaction behaves.

The default implementation of this procedure is a dummy that does nothing. In order to affect the interaction with the item, you can override this procedure with your own implementation. Then, inside its body, perform the actions you wish to happen as a result of using this item (if any), and set the following DB:

  • DB_CustomUseItemResponse((CHARACTERGUID)_Char,(ITEMGUID)_Item,(INTEGER)_Result)

Specify the parameters received via this call as _Char and _Item. Specify 1 as _Result if you want Osiris to perform the default action of the item after your procedure returns, or 0 if you do not wish this to happen. Other result values are undefined.

Return Values
  • /
Notes
  • Use with restraint, as in general item behaviour should be systemic/consistent, and not change depending on many different conditions.
  • This routine is also called if an NPC uses the item, not just players. Especially in case of doors or stairs, note that this can happen in reaction to an NPC fleeing out of sight.
  • Setting the DB_CustomUseItemResponse() database entry will block any further handling of this use-action by generic routines in the Shared mod, such as the crime handling system. You can also carry out a number of checks and/or actions and not set DB_CustomUseItemResponse(). In this case, the default Shared mode story functionality of using an item will still be executed.
  • The CharacterUsedItem event is only thrown if this proc did not block the use of the item.
See Also