Blue's Inventory Tools

Discussion in 'General Modification' started by Cerulean the Blue, Jul 3, 2006.

Remove all ads!
  1. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    Re: Respawning Unrespawning Inventories

    The script is done. It now handles gems and jewelry entries as well.

    As mentioned at the beginning of this thread, this script removes all existing inventory from the object it is being used on, and then creates a new inventory from a line in InvenSource.mes. It handles the standard " % chance, proto number" type entries, the "pick one item in this list" entries, the "copper", "silver", ... etc. entries, and the "gems" and "jewelry" entries. In fact, I have yet to find anything in a properly configured InvenSource.mes line it doesn't handle. If it does find something it can't intemperate, it will print a warning message, ignore the entry and proceed.

    To use, this script must be in your scr folder, and imported into whatever script you wish to use it in with the call
    Code:
    from InventoryRespawn import *
    at the beginning of the script. You must also have Co8.py from 5.0.0 in your scr folder, as it relies on a function defined therein.

    The standard call is
    Code:
    RespawnInventory(object, num) 
    where "object" is whatever you wish to respawn the inventory of, and "num" is the line number from InvenSource.mes you wish to respawn the inventory from.

    Alternately, you can call it without "num", like
    Code:
    RespawnInventory(object)
    and it will try to use the predefined Inventory Source number (either from the proto, or from a previous
    Code:
    object.obj_set_int(obj_f_container_inventory_source, val)
    call, where "val" is the line number in InvenSource.mes you wish to define as being used for "object"). If no Inventory Source number is defined, the script will terminate, and nothing will happen.

    Next on the agenda, a script that will write custom Invensource.mes lines from in game inventories.

    [EDIT] Fixed a problem with the script 19/7/06.
     

    Attached Files:

    Last edited: Jul 19, 2006
  2. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    Re: Respawning Unrespawning Inventories

    Nice work Bluey :D
     
  3. Agetian

    Agetian Attorney General Administrator

    Joined:
    Aug 14, 2004
    Messages:
    2,526
    Likes Received:
    0
    Re: Respawning Unrespawning Inventories

    Great job, Cerulean! This is really essential given the bug with inventory respawn in original ToEE code! :)

    - Agetian
     
  4. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    Writing InvenSource.mes Lines Automated

    As promised (Allyx) here is a script that will write and InvenSource.mes style line based on the current inventory of an object (NPC or container) in the game.

    The lines are written in a new file created in the data\rules folder, called NewInvenLines.mes. They are of the simple format
    Code:
    {<line number>}{<name>: 100,<item1> 100,<item2> 100,<item3> ... copper,<amount> silver,<amount> ....}
    The script automatically scans both InvenSource.mes and NewInvenLines.mes (if it already exists) and assigns the lowest unused line number for the new line. Items in the objects inventory are parsed by proto number (and destroyed in the process) lowest to highest, and are listed in the line in that order. Money amounts are parsed as well (remember, PC's do not have money in their inventories - only NPCs and containers do). The 100s in the line are the percentage chance of the item occurring in the inventory, and can be manually edited (along with the money amounts) before moving the line into InvenSource.mes.

    To use this script, unzip it into your data\scr folder. Then start the game, open the console and enter
    Code:
    from line import *
    Now you must get a handle on what ever object you want to use the script on. Most modders know how to get a handle on objects in the game. If you don't, ask around. The method can vary depending on the object, but all of them involve the proto name of the object. Some examples are
    Code:
    from utilities import *
    handle = find_npc_near(name, game.party[0])
    and
    Code:
    from utilities import *
    handle = find_container_near(name, game.party[0])
    Both of these require your leftmost party member in the party line-up to be relatively near the object your are looking for.

    Once you have a handle for the object, enter
    Code:
    makeinvline(<handle>, '<name>')
    where handle is, of course, the handle of the object, and name is the name you want listed in the InvenSource.mes line. The name must be in quotes.

    If this is the first time you have used the script, it will tell you that the file data\\rules\\NewInvenLines.mes has been created. It will then tell you that a new line has been written and the line number of the line. If you have used it before, it will just tell you that the new line has been written, and the line number.

    Now you can open NewInvenLines.mes in Notepad or a similar program and edit the percentages and amounts. Then just copy the line into InvenSource.mes, and edit the Container Inventory Source line of the objects proto in World Builder to have the line number of the line you have just created.

    Yes, this process is a little complicated, but when you have an object with a large inventory, such as a shop container, using this is a lot quicker than trying to manually write one out.

    Next on the agenda, a script that will write custom portrait.mes files for PC portraits.

    [EDIT] Fixed a problem with the script 19/7/06.
     

    Attached Files:

    Last edited: Jul 19, 2006
  5. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    Re: Blues Inventory Tools

    :thumbsup: :thumbsup: Got it!
     
  6. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    There was a slight problem with the two scripts posted above. It has been fixed.
     
  7. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    5,001
    Likes Received:
    250
    Thanks Bluey, that script will come in handy, especially if we can figure out a way to get the Tailor to respawn (the shop is too small for a normal respawn like the blacksmith), I could add a respawning container for the owner of the Bizaar.
     
  8. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    This script should force a respawn, Al.
     
Our Host!