Difference between revisions of "Osiris/API/ItemScatterAt"
From Divinity Engine Wiki
(Documented ItemScatterAt) |
m |
||
Line 8: | Line 8: | ||
* If ('''_X''', '''_Y''', '''_Z''') is different from the item's current position, it will first be (internally) teleported there and resulting [[Osiris/API/ItemLeftTrigger|ItemLeftTrigger]] and [[Osiris/API/ItemEnteredTrigger|ItemEnteredTrigger]] events will be thrown as appropriate (no [[Osiris/API/ItemMoved|ItemMoved]] though). | * If ('''_X''', '''_Y''', '''_Z''') is different from the item's current position, it will first be (internally) teleported there and resulting [[Osiris/API/ItemLeftTrigger|ItemLeftTrigger]] and [[Osiris/API/ItemEnteredTrigger|ItemEnteredTrigger]] events will be thrown as appropriate (no [[Osiris/API/ItemMoved|ItemMoved]] though). | ||
* The scatter operation itself is a regular move task, similar to [[Osiris/API/ItemMoveToPosition|ItemMoveToPosition]] with '''_DoHits''' = 1, except that the item will move in an arc rather than in a straight line. The remarks for that call therefore also apply to this one. In particular, if the item's movement is blocked in the randomly chosen direction, it may not move at all. You will still get an [[Osiris/API/ItemMoved|ItemMoved]] event in this case, as an item move operation was started and completed. | * The scatter operation itself is a regular move task, similar to [[Osiris/API/ItemMoveToPosition|ItemMoveToPosition]] with '''_DoHits''' = 1, except that the item will move in an arc rather than in a straight line. The remarks for that call therefore also apply to this one. In particular, if the item's movement is blocked in the randomly chosen direction, it may not move at all. You will still get an [[Osiris/API/ItemMoved|ItemMoved]] event in this case, as an item move operation was started and completed. | ||
− | * Due to implementation issues, scattering an item right after [[Osiris/API/CreateItemTemplateAtPosition|creating]] it | + | * Due to implementation issues, scattering an item right after [[Osiris/API/CreateItemTemplateAtPosition|creating]] it will never change its position (it will still throw an [[Osiris/API/ItemMoved|ItemMoved]] event). A workaround is to scatter it again after receiving the [[Osiris/API/ItemMoved|ItemMoved]] event from the first scatter operation. |
===== See Also ===== | ===== See Also ===== | ||
* [[Osiris/API/ItemDragToPosition|ItemDragToPosition]] | * [[Osiris/API/ItemDragToPosition|ItemDragToPosition]] |
Latest revision as of 17:30, 14 July 2018
Full Definition(s)
- call ItemScatterAt((ITEMGUID)_Item, (REAL)_X, (REAL)_Y, (REAL)_Z)
Description
Makes _Item move from the position (_X, _Y, _Z) in an arc to a random location around the source position. This location is picked by first selecting a position within a 10 metre square around the position, and then looking for a valid (green) AI-grid position at most 5 metres from this spot.
Notes
- If no valid (green) AI-grid position can be found with the above constraints, this call will not do anything nor result in any events.
- If the item is currently in an inventory or equipped, it gets dropped and ItemRemovedFromCharacter, ItemTemplateRemovedFromCharacter, ItemRemovedFromContainer, ItemTemplateRemovedFromContainer, and ItemDropped events get thrown as appropriate.
- If (_X, _Y, _Z) is different from the item's current position, it will first be (internally) teleported there and resulting ItemLeftTrigger and ItemEnteredTrigger events will be thrown as appropriate (no ItemMoved though).
- The scatter operation itself is a regular move task, similar to ItemMoveToPosition with _DoHits = 1, except that the item will move in an arc rather than in a straight line. The remarks for that call therefore also apply to this one. In particular, if the item's movement is blocked in the randomly chosen direction, it may not move at all. You will still get an ItemMoved event in this case, as an item move operation was started and completed.
- Due to implementation issues, scattering an item right after creating it will never change its position (it will still throw an ItemMoved event). A workaround is to scatter it again after receiving the ItemMoved event from the first scatter operation.