Spawning a Merchant

Discussion in 'General Modification' started by marc1967, Feb 20, 2015.

Remove all ads!
  1. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    I'm trying to create a wandering encounter with a merchant, but I don't think it can be done. It was simple enough to spawn the merchant and his chest, and to fill the chest with inventory, but making the connection without using a MOB seems impossible.

    The World Builder asks for the name of a specific MOB of a container within the merchants MOB itself, in the "Substitute Inventory Container (for merchants)" check box. Since the container I am spawning is not a MOB, is there a way to tell the merchant "connect your inventory to this chest I just spawned right there"?

    I tried delving into calling obj.obj_get_int(obj_f_npc_substitute_inventory), but just accessing it made a crash, though most call don't make a crash, so it knew I was digging to deeply, hehe.

    I'll gladly hear "give up and move on" if that's the case, but if someone has done this let me know, Thanks.
     
  2. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    obj_f_npc_substitute_inventory is a GUID field (the data is stored as 6 Double Words), and thus inaccessible with the 32bit obj_set_int/obj_get_int. Unfortunately there is no python command for reading that kind of field... yet ;)

    It's one of my first goals for DLL hax0ring after I'm through with the reversing stage and moving onto the modification stage. Can't guarantee anything, but there's at least a chance it will be possible in the future.

    For now you can work around it via either trading through dialogue, or creating a talking chest a la the shopmap.
     
  3. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    Or.... if it's a wandering encounter, create new clothes protos that are set NO_LOOT etc so they don't display ion his inventory, then give him all his stuff in his inventory so he is selling right off his person. This, I think, is how Liv made the Lareth merchant in the days before ToEEWB. The only downside is he may be appalingly encumbered - or you could create it all in his inventory when you start a conversation.
     
  4. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    A talking chest wouldn't have to be as cludgy as it sounds. Have the chest initiate dialogue with the merchant on its heartbeat, make a null statement ("..." or whatever), and switch to the merchant so he can do all the talking, then switch back to the chest for the barter.
     
  5. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    As usual, the Three Modsketeers come to my aid! Thanks guys, I needed all that help.

    I have it working very well as a chest sitting next to the merchant which does the selling like in the shop map. So the merchant just tells the pc to look through the chest(or chests) for the goods, though the merchant may have smaller goods on his own person like gems and other trinkets. Eventually I can use Gaer's idea to redirect the dialog between the merchant and the chest for more realistic feel.

    Interesting observations:

    1) The chests in the shop map are npc's, not containers (but you knew that), but still they don't hold their own inventory for some reason. Just like other human merchants, they keep their inventory in an invisible nearby container which is set as a "Substitute Inventory Container".

    2) Ted: When putting "goods" into the npc (whether human or chest), the game seems to automatically reserve one item of each type to equip onto the npc and he won't sell. It won't sell these items, and it also (nicely) slides them way down to the bottom of the nps's trade stock so you can't see them when trading. But even if you do slide all the way down, a message will pop up over the item saying "I won't trade this item". So If i stock it with 12 weapons, 10 hats, 6 suits of armor, and 4 pairs of boots. Only 11,9,5, and 3 respectively of those items will be for sale, while 1 of each will be unsellable at the very bottom.

    This may be why the shop chests use a "Substitute Inventory Container" instead of keeping the items in their own loot. But I was able to avoid this by setting the ONF_NO_EQUIP flag on the chest, so there are now no un-sellable items.


    Now I can use all this to make my random encounter of a roadside goblin festival with all sorts of odd venders, tolub-style solo combat challenges with the goblin chief, and some self-contained quests within the encounter.
     
  6. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Cool, I'd always wanted non-combat random encounters a la Fallout.

    Re. the Tolub-style combat (brawling), IIRC it was a one-time use thing - Gaear tried applying something similar to an enhanced Jayfie scenario, but it turned out that it bugged the Tolub brawl as a consequence.
     
  7. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    Yeah, the dll actually refers specifically to py00116Tolub.py rather than just a particular command (for memory).

    I'd suggest Gaear used a substitute thing on the shop map to stop people killing and looting the chest NPCs ;) Just guessing though. Whatever works - that's modding! :)

    EDIT: An idea that made the rounds some years back was a random encounter of a tower or cave, that then sent you to a randomly generated cave or tower complex with level-specific spawned monsters (great idea but lots of work & would have played havoc with balancing). You could do something similar, in as much as having the players meet a goblin while some fair music plays, chat to said goblin, get invited to the fair, goblin runs off by script for players to follow then you get teleported to a pre-prepared fair map with as many mobs as you like. Not as elegant as a full random encounter but you could then have a map with fairground background graphics.
     
  8. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    I'll definitely do that for the more complex encounters, good idea, I hadn't thought of that. But I don't want to use up a map slot for each one, since I want to have many of these unique encounters, so I'll keep most of them to the 8 random maps.

    I've heavily changed the random_encounter.py file to make random encounters easier to add, and allow for more control. One of the nice things I've added is to specify which map to create the encounter on, and to give each creature a specific spawn coordinate if desired, just like a regular map.

    This would make encounters like the Robin Hood confrontation more challenging, as the various men can be spread out and positioned in exact spots, instead of in a big circle waiting for fireball type spells. So you could put archers hidden behind trees, melee guys out front, rogues strategically positioned, etc.
     
  9. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    The shopmap chests are NPCs so you can barter with them and be charged for buying your starting equipment. Without, you'd just loot the chests. ;)

    AFAIK, all merchants have a chest assigned to them, so that's normal behavior. (Otherwise you'd just trade for their personal gear, like Ted said. I can think of some story-specifc type reasons to do that, but for the most part, you want them to have chests, and they're always the "substitute inventory" thing.)
     
  10. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60

    Without a "substitute inventory" container, an NPC (human or chest) will still barter with you and not sell their personal gear. See what I wrote in posting # 5 above, where it says " 2) ".

    So for an NPC merchant as a Chest:

    As long as the chest is set to ONF_NO_EQUIP, it will sell everything.
    And setting OF_INVULNERABLE will make it impossible to kill and loot.

    There's probably lots of cheats I can't think of, like picking it's pockets, or other such things. I'm not sure how invulnerable the OF_INVULNERABLE actually makes it.

    But using the substitue chest is the safest way to go.
     
  11. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    I think the invulnerable flag is absolute. At least I've never managed to injure anything that had that flag set.
     
  12. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    There's a NO_PICKPOCKET flag isn't there?
     
  13. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Having dispatched the pack of stirges, our brave heroes were positively nonplussed when out of nowhere, Brother Smyth appeared, right in the middle of the swamp.

    [​IMG]

    They were furthermore quite baffled that he wasn't even carrying any items for sale save for his pocket change. Isn't that his purpose in life?

    [​IMG]

    The mystery deepened as a locked chest then materialized out of thin air!

    [​IMG]

    Brother Smyth cackled at the shock on our heroes' faces, and soon turned to monetizing the situation.

    [​IMG]

    "Wait a minute. Wasn't that gear in my backpack a second ago? Is this like that Dala bullshit again?"

    [​IMG]

    Indeed it was, Regdar. Indeed it was.


    ---------------------


    Don't try this at home, because it won't work ;)
    In present day ToEE, you can read the substitute_inventory ( via obj.substitute_inventory - returns a handle for the container), but now thanks to DS's framework in the soon to be announced TemplePlus project, we will also be able to modify it! :yes: I see no reason why this can't be exposed to most, if not all, other non-32bit fields. Looking good!
     
  14. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    Oh wow that'll be nice. Do you think there's a reason they made them read only, and not modifiable in the first place? - repercussions up the chain that can't be seen beyond setting the value. Or was it just laziness/sloppiness on the original designers' part.

    I really can't wait to get to some of those other non 32-bit guys.

    Pardon my ignorance, but who is DS?
     
  15. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    DS = DarkStorm

    Note that these fields aren't read only per se, there's just no python implementation for modifying them via script. It's a missing feature rather than a restriction, because these functions do exist in the internal DLL code.
     
Our Host!