Skip to content

Getting a Placeable to drop an item?

So I'm trying to make it so a tree will drop planks of wood when it is destroyed. However, you can only target a placeable if it is set to useable. I don't want the player to click on it and open up an inventory. So I have Has Inventory set to false. I have an existing 'loot drop system' in place that seems to work for placeables and creatures as long as they have an inventory. I've found a function that checks if an object is a placeable and another function that checks if a placeable has an inventory. My current loot system places objects into the inventory of the dying creature using CreateItemOnObject but this won't work if the object doesn't have an inventory.

I am trying to find a function that will give a placeable object an inventory. Does one exist? If not I'll probably make a separate loot thing that handles placeables without inventories. The existing loot system would be difficult to make adjustments to account for objects without inventories otherwise.

Comments

  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited March 2022
    So I'm trying to make it so a tree will drop planks of wood when it is destroyed
    Something kinda like so?

    //Placeable OnDeath drop stuff
    void main()
    {
    location lLoc = GetLocation(OBJECT_SELF);
    CreateObject(OBJECT_TYPE_ITEM, "res ref of item", lLoc);
    }
  • Dragonfolk2000Dragonfolk2000 Member Posts: 377
    So I'm trying to make it so a tree will drop planks of wood when it is destroyed
    Something kinda like so?

    //Placeable OnDeath drop stuff
    void main()
    {
    location lLoc = GetLocation(OBJECT_SELF);
    CreateObject(OBJECT_TYPE_ITEM, "res ref of item", lLoc);
    }

    That's what I ended up doing. But this method requires making extra scripts for the objects that don't normally have inventories.
  • meaglynmeaglyn Member Posts: 149
    One extra script maybe (really that could easily be avoided too). "res ref of item" cries out to just be a variable on the placeable...
  • sunxresunxre Member Posts: 23
    Just add onto your loot system. No need for 2 scripts....
    switch(hasinventory(yourobject))
    {
      case FALSE:
    //stick createobject section here
        break;
      default:
    //shove your original code here for objects with inventories.
        break;
    }
    
Sign In or Register to comment.