edited January 2020 in ORK Scripting
In my game, when a player character gives an item from his inventory to another player character, I'd like to know which character just gave the item and the item shortcut of the given item. Right now, I use a combatant.Inventory.ContentChanged delegate to know when an object is added to an inventory, but I have a hard time figuring if this object comes from the game world or if it is given by another party member. Also, I'd like to check an item variable on the given item, so I need to have the item shortcut. Right now, the ContentChanged delegate only gives me the inventory, the item type, the item id, the level and the quantity, but no shortcut and no source (the combatant who game the item).

Alternatively, is there a way to catch a specific "give" action instead of checking if the inventory has changed?
Post edited by ArsMagika on
  • edited January 2020
    If you register to ContentChanged on both combatants, you should get one change from each in that order:
    - on the receiver a positive quantity
    - on the giver a negative quantity
    Adding is done first, as the item will only be removed if the receiver could actually get it (e.g. due to space/quantity limits).
    You know that it was a give if you get both with matching information and +/- quantity, so you'd have to remember positive changes and check them on negative ones immediately after (e.g. using a float to remember the Time.realTimeSinceStartup).

    Getting that specific shortcut is probably not possible currently - you can get a shortcut based on the passed on information (type, id, etc.), but there's no guarantee that it'll be the same one.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ok! Thanks! I'll find a workaround for the item variable check.
  • I'll look into making it possible to at least get the shortcut of the item with the other information.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Great! It will certainly help, because some instances of some objects might have different variables...
  • Next update will also pass on the shortcut (as an IInventoryShortcut), which you can cast in the other shortcut classes (e.g. based on the ItemDropType, Item would be an ItemShortcut).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Great! However, I think I'll figure out a way to work with different items instead of using an item variable. This way, it should work right away.

    Might still be useful to be able to retrieve the shortcut itself though...
  • I have another question about giving items... Suppose I’d like to only allow giving an object in battle if two combatants are in adjacent hexes? Is there a way (through code or ORK editor) to intercept the intention to give an object and then validate it only if a certain condition is met?
  • Thinking of it, maybe I could simply disable giving object from the shortcut menu during battles and create an ability that would do it instead? This way I guess I could check for conditions before an item is given...
  • Hm, using an ability for giving items might be the best way for this - otherwise there is no way to put a distance limit to it.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.