Category:Use Actions

From Divinity Engine Wiki
Revision as of 16:57, 4 December 2017 by LarIlya (talk | contribs)
Jump to: navigation, search

WIP

Overview

In the item sidebar, there is a "Use Actions" entry. This defines what interaction with the item does, for NPCs and PCs alike.

Things that block use of items

A character cannot use an item if any of the following is true:

  • the item has been marked as only usable by its owner, and _Character is not its owner.
  • the item is stuck. An item is stuck if it has the FROZEN or PETRIFIED status.
  • the item is locked and _Character, nor anyone in their party in case of a player character, has the key.

Also (see below), players cannot use items if they are set to non-interactable.

Interaction with Osiris

Osiris scripting can react to items being used, make characters use items, and intercept attempts to use an items. For more details on each call and event, see its documentation.

Events to Osiris

Whenever a character interacts with an item, a CharacterUsedItem event is sent to Osiris.
If the character fails to use the item, a CharacterUsedItemFailed event is sent to Osiris.
The CanUseItem event is sent as a character attempts to use an item. The Shared Story scripting intercepts this to call the ProcBlockUseOfItem procedure. If this procedure sets the DB_CustomUseItemResponse((CHARACTERGUID)_Char,(ITEMGUID)_Item,(INTEGER)_Result) with _Result equal to 1, the item use is blocked.

Calls from Osiris

The CharacterUseItem call makes a character use an item. If necessary, the character first moves to the item.
The ItemSetCanInteract makes it impossible for players to interact with an item by clicking on it. It remains possible to interact with the item through script, however.

Interaction with Behaviour Script

Behaviour script can react to items being used and make character use items.

Events to Behaviour Script

OnUseItem(CHARACTER:source, ITEM:item) is thrown when a character uses an item.

Calls from Behaviour Script

CharacterUseItem(ITEM:item [, INTEGER:LongPath]) makes a character use an item, moving to it if necessary.
ItemSetCanInteract(ITEM:item, INTEGER:bool) changes whether or not an item can be interacted with by the player. Script can still make a character interact with such an item.

Queries from Behaviour Script

CharacterCanUseItem(CHARACTER:source, ITEM:item[, INT:ignoreActionPoints=0]) checks if a character is capable of using an item in the world.
CharacterCanUseItemInInventory(CHARACTER:source, ITEM:item[, INT:ignoreActionPoints=0]) checks if a character is capable of using an item in their inventory.