LucasForums (
-   Holowan Laboratories (
-   -   [KotOR 1 WIP] Shopkeepers are Expendable (

RogueSplinterCell 08-29-2012 01:17 AM

Shopkeepers are Expendable
Starting up a new game in KotOR i thought "I sure wish i could just slaughter this clueless shopkeeper and take all his goods." Well i want to have that made possible so first things first...

Where should i start? I havent the slightest clue where to find the shopkeepers files at, i would like to start trying to modify the first shop owner in the abandoned apartment on Taris.

Anyone know where those files are? I obviously need to add the items somehow where his Kiosk is set up at to what is originally in his inventory and to make it to where he fights you if you decide to take his supplies by force.

I would appreciate any assistance from you guys at Holowan Labs = )

JCarter426 08-29-2012 03:28 AM

I don't believe stores have an inventory in the traditional sense, so there would be no way to move their items from one place to another. You could open the store with a script that tells it to give you a 100% discount, but then you would still be able to sell items to any merchant that usually sells items, and then buy them back for free.

RogueSplinterCell 08-29-2012 04:13 AM

Think theres a way to remove the character that sells items after you kill them and add the items that they had in a "loot bag" where the body was?

JCarter426 08-29-2012 04:21 AM

No, because it isn't the character that had the items in the first place.

Hassat Hunter 08-29-2012 04:52 AM

You'll manually have to add the entire stock to the characters inventory for this to work...

Canderis 08-29-2012 06:37 AM

And what you already bought would be duplicated

Nick Vader 08-29-2012 08:03 AM

As stated above, you could insert a dialog option that would make it look like you killed the shopkeeper, then a dialog option appears allowing you to loot the shopkeepers bbody. There you could attach a script that would either give you the items, or open up the shop with no cost for any items. In that script, however you will also have tto actually kill the NPC, or just make him vanish.

CptPriceless 08-29-2012 06:16 PM

The script would be tedious; if you want to make it even more realistic, not only would you have to script in all the original items manually, but you'd also have to script:

If PLAYER bought ___, then ___ will not appear in loot. Obviously that's no code, but you get the idea.

Even so, I really like this concept. :)

RogueSplinterCell 08-29-2012 06:29 PM

Hmm... Yeah i can do tedious work because i got nothing else better to do with my time. As soon as i find a starting point im on it. Thanks for the information, i see that the shopkeeper doesnt have an actual inventory but like Hassat Hunter said im willing to manually insert all the items, but the problem i expected to encounter is what CptPriceless said. If you purchase an item then it shouldnt appear in the bag thats left from the body.

Fallen Guardian 08-29-2012 07:29 PM

I guess you could set the on death script of the merchants to run this:


void main()

object oPC = GetFirstPC();
OpenStore(object oStore, oPC, 0, 100);


You'd have to find the merchant's UTM file (their store file) and put it in for object oStore but this would basically make it, I think, so that once the player killed the merchant the store would pop up and everything would be free.

RogueSplinterCell 08-29-2012 08:51 PM

Thanks, where would someone find the store files? I cant look in KotOR Tool right now cause my Desktop is being used at the moment and my laptop is riddled with problems.

JCarter426 08-29-2012 09:21 PM

As I said though, the sell function should still be there. I'm not entirely sure how the bonus markup or markdown affects selling, but I believe you would be able to buy back any items you sell for free, which would lead to abuse. Not to mention it makes no sense to get cash for selling to a dead guy. I guess it's worth a try though.

But if you attach the script to the NPC's OnDeath, you'd only be able to access it once. Yeah, you could take everything at once, but some NPCs have an infinite supply of certain items, so it would be better to keep the store open, so to speak. So I would suggest spawning an invisible placeable that triggers the store, somewhere that would make sense like over their kiosk or on a shelf.

The store files are UTM files, found in the _s.rim of each module.

Fallen Guardian 08-29-2012 09:58 PM

JC, couldn't you use the clone inventory script that you created, to clone whatever merchant's inventory you wanted over to a new, blank, generic UTM file that would have the OnlySells flag set to true?

JCarter426 08-29-2012 10:36 PM

That's a nice thought, but I've been unable to get the game to recognize an item from a UTM's inventory. That probably would be the best option in order to account for infinite items, but the games refuse to do it. I can get them to recognize the UTM, but not anything it might have. For the record I wasn't using the same functions, though. I used GetItemInSlot for cloning, but UTMs don't have inventory slots (or at least I don't think they do) so I tried GetFirstItemInInventory and GetNextItemInInventory, both of which worked for the PC's inventory but not for a UTM's. Maybe GetItemPossessedBy would work, but I didn't try that as it requires you input the item tag. I guess I could give it a try later. EDIT: Didn't work, probably limited to creatures, though the other two say they support stores in NWScript. I can, however, confirm that

DelayCommand(0.1, OpenStore(oStore, GetFirstPC(), -100, 0));
does work, but you can indeed sell items for their regular price and then buy them back for free.

I feel like there must be something more to this, though. K2 doesn't have static merchant inventories, which would imply there's a way to script items into the UTM. One would expect the reverse to be true, but I never expect the expected when it comes to these games.

I suppose you could change every merchant to "only sells" and then have a merchant on every planet you can sell to that's unkillable.

RogueSplinterCell 08-30-2012 12:54 AM

So what your saying is that you wouldn't be able to sell items to the merchants that you can kill to prevent abuse? I thought that after you killed them the interactions with the merchants would cease to exist.

JCarter426 08-30-2012 01:26 AM

It doesn't matter if the character is dead or alive, because the stores are their own objects, not dependent on any specific character. Because of this, it's possible to use two different merchants to open the same store - I did this a while back to let you access Samhan's secret stash after he's been arrested, by talking to his brother Dendis - or to access it via a placeable or anything else that is capable of firing a script. With the OpenStore function you can reduce the buy price of all items down to zero, but it does not seem to support reducing the sell price at all.

The details are a bit complex, but the short answer is if there were a way to do what you say, to move items from a store to a placeable, then you would also be able to move them from a store to another store and, as Fallen Guardian suggested, set the new one to "only sells". The advantage is you would have access to an infinite supply of whatever items of which the store had an infinite supply. But they are both hindered by one problem - I can't figure out how to grab an item from a store's inventory inside a script.

RogueSplinterCell 08-30-2012 10:01 PM

Oh okay i think i got it now, i dont suppose its possible to remove or negate a script and replace it with your own. Uh an example here:

Say you wanted the infinite items that are in a script replaced with yours that makes the infinite items into a set number like 1. And leave a few shopkeepers unmodified so that some of their infinite items are still purchasable throughout the game. Is that a possibility?

JCarter426 08-31-2012 01:17 AM

I'm not sure if I follow. You can edit the merchant files to remove infinite items, yes, but that doesn't resolve any problems here.

All times are GMT -4. The time now is 07:39 AM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
LFNetwork, LLC ©2002-2011 - All rights reserved.