Difference between revisions of "Osiris/API/CharacterUseItem"
From Divinity Engine Wiki
m |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 6: | Line 6: | ||
* Using an item results in the following flow: | * Using an item results in the following flow: | ||
** Walk to the item, if necessary. | ** Walk to the item, if necessary. | ||
− | ** If the item is reachable by the character after | + | ** If the item is reachable by the character after walking, |
*** A [[Osiris/API/CanUseItem|CanUseItem]] event is sent to story. | *** A [[Osiris/API/CanUseItem|CanUseItem]] event is sent to story. | ||
*** Story replies using [[Osiris/API/RequestProcessed|RequestProcessed]], which indicates whether the use should fail or succeed. You can hook into this and the previous step in a generic way using Helper [[Osiris/Shared/ProcBlockUseOfItem|ProcBlockUseOfItem]]. | *** Story replies using [[Osiris/API/RequestProcessed|RequestProcessed]], which indicates whether the use should fail or succeed. You can hook into this and the previous step in a generic way using Helper [[Osiris/Shared/ProcBlockUseOfItem|ProcBlockUseOfItem]]. | ||
Line 21: | Line 21: | ||
* [[Osiris/API/CharacterStoppedUsingItem|CharacterStoppedUsingItem]] | * [[Osiris/API/CharacterStoppedUsingItem|CharacterStoppedUsingItem]] | ||
* [[Osiris/API/HasActiveStatus|HasActiveStatus]] | * [[Osiris/API/HasActiveStatus|HasActiveStatus]] | ||
+ | * [[Osiris/API/ItemCanSitOn|ItemCanSitOn]] | ||
* [[Osiris/API/ItemStatusAttempt|ItemStatusAttempt]] | * [[Osiris/API/ItemStatusAttempt|ItemStatusAttempt]] | ||
* [[Osiris/API/ItemStatusChange|ItemStatusChange]] | * [[Osiris/API/ItemStatusChange|ItemStatusChange]] |
Latest revision as of 09:48, 1 July 2019
Full Definition(s)
- call CharacterUseItem((CHARACTERGUID)_Character, (ITEMGUID)_Item, (STRING)_Event)
Description
Makes _Character, which can either be a player character or an NPC, use _Item. If _Item is not in _Character's inventory, _Character will first walk to it if they're too far. Once they have used _Item, the story event _Event will be sent to _Character.
Notes
- Using an item results in the following flow:
- Walk to the item, if necessary.
- If the item is reachable by the character after walking,
- A CanUseItem event is sent to story.
- Story replies using RequestProcessed, which indicates whether the use should fail or succeed. You can hook into this and the previous step in a generic way using Helper ProcBlockUseOfItem.
- If the item was reachable and using it failed, or was blocked using the above, then a CharacterUsedItemFailed event is thrown.
- If the item was _not_ reachable, or using it was successful, a CharacterUsedItem event is thrown, as well as a CharacterUsedItemTemplate event.
- Regardless of whether a CharacterUsedItemFailed or CharacterUsedItem event was thrown, finally a CharacterStoppedUsingItem event indicates when the item is no longer used (happens immediately in case of failure).
- If the item usage fails, _Event will never be thrown.
- _Item can be a consumable or an item in the world.