Console command for deleting/removing items from inventory

Discussion in 'General Modification' started by Buffed Rabbit, Jan 14, 2023.

Remove all ads!
  1. Buffed Rabbit

    Buffed Rabbit Established Member

    Joined:
    Jun 11, 2021
    Messages:
    111
    Likes Received:
    28
    Hello fellow ToEE-iers,

    is there a console command (or any other method) that can remove inventory items from PCs or/and NPCs?

    thanks!
     
  2. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    You can always just drop the item.

    If the game won't let you drop it, then there is some flag set on the item that won't let it leave thet character's inventory. From that point there are many ways of getting rid of the item.

    If the item is equipable, then you can just equip the item and destroy it. The example below is to destroy whatever armor is worn in the armor slot, by the first character in party, shown at the bottom of the screen
    Code:
    game.party[0].item_worn_at(5).destroy() 
    Change the slot number based on which slot the item is in:
    0=head, 1=neck, 2=gloves, 3=weapon1, 4=weapon2, 5=armor, 6=ring1, 7=ring2,
    8=boots, 9=ammo, 10=cloak, 11=shield, 12=robe, 13=bracers, 14=bard, 15=tools​
    Hope I got those number right. o_O
    Also, just to clarify, this destroys the item WORN AT THAT SLOT, it doesn't just destroy any armor found in the inventory.

    If you want to destroy a non-equipable item, like a gem or a wand, then things get a little more interesting.
    You'll need to know the proto number of the item. So if you you want to destroy a diamond (proto 12036), in the first party member's inventory, type this:
    Code:
    game.party[0].item_find_by_proto(12036).destroy()
    To be safer, you can find the item first, the destroy it after you're sure you have the right item:
    Code:
    item = game.party[0].item_find_by_proto(12036)
    item
    Diamond(2144269588522)  <--- console response, don't type this
    item.destroy()
    Hope that helps.
     
    Buffed Rabbit likes this.
  3. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    Another method, is to remove the flags that are preventing the item from being dropped or transferred. If that is what the problem is.

    Once you find the item with the function item_find_by_proto() function like I showed above, and have the variable "item" set to the item. From there you can unset any flags from that item that are trapping it in the inventory. Usually, OIF_NO_DROP and/or OIF_NO_TRANSFER are the culprits.

    So for the example with the diamond, try this:
    Code:
    item = game.party[0].item_find_by_proto(12036)
    item.item_flag_unset(OIF_NO_DROP)
    item.item_flag_unset(OIF_NO_TRANSFER)
    Other flags that might be trapping the item are OIF_WONT_SELL, OIF_NO_PICKPOCKET, OIF_NO_DISPLAY, OIF_NO_LOOT. But unsetting the two flags shown above almost always work.
     
    Buffed Rabbit likes this.
  4. Buffed Rabbit

    Buffed Rabbit Established Member

    Joined:
    Jun 11, 2021
    Messages:
    111
    Likes Received:
    28
    Thank you again Marc!
     
Our Host!