View Full Version : How do i create a Merchant to buy items from

Darth Bos Pity
11-30-2007, 01:28 PM
I've crerated an item For KOTOR but insted of using the KSE or cheats, i want to add a merchan to the game to buy the item from, so how do i do this.

please help

Darth Xander
11-30-2007, 03:00 PM
Do you want to add this new item of yours to a current merhant's inventory or make a new one. If you want to create a new merchant I would recommend you follow these steps by stoffe. For example, in KotorTool, open RIMs --> Modules --> 202TEL_s.rim --> Blueprint, Merchant. Select the file named m_202_003.utm and press the Extract button. This is the merchant template for Samhan Dobo, the "immoral" Duros Merchant on Citadel Station.

Now, rename this file to something unique and then open it in the GFF Editor. Change the fields in the GFF Editor to match how you want your Store to work:

BuySellFlag (BYTE):
Determines if the merchant will sell items, buy items or do both.
1 = Only sells
2 = Only buys
3 = Buys and Sells

I think this is the Palette ID in the toolset for Stores, but since we have no toolset it probably makes no difference. It's always set to 5 for Stores as far as I can see, so I suggest you leave it at that.

LocName (CExoLocString):
Set this string to the name of the store. This is usually the name of the merchant NPC who owns the store.

MarkDown (INT):
Set this to the percentage of the base item value that the store will pay for items you sell to it. 50 makes the store give you 50% of the item's base value for it.

MarkUp (INT):
Set this to the percentage of the base item value that the store will charge for an item when you buy it. 100 makes the store sell items for their base value, 125 will make items 25% more expensive than their base value.

OnOpenStore (CResRef):
This is a Resref (filename) to a script that will be triggered when the Store is started. Unless you want something special to happen whenever the store is opened, just leave this blank.

Resref (CResRef):
This should be set to match the name of the file exactly, but without the .UTM suffix. If you renamed the file above to "st_customstore.utm", then you'd set this field to "st_customstore". Note that Resrefs shouldn't be longer than 16 characters.

Tag (CExoLocString):
This is an identifier that scripts can use to access your store. For simplicity you'll probably want to set this to the same value as the Resref field, unless you have a good reason not to.

ItemList (List):
This category contains a list of all the items the stort will initially contain. The easiest way is to just modify the item entries that are already in the list from the store you copied, and change the InventoryRes field to point to the items you wish the store to contain. Delete any leftover entries from the old store when you are done.

If you need to add more entries, select one of those presently in the list and click "Copy Node/Subtree" in the Edit menu. Then click on the "ItemList" top entry and click "Paste as child node" in the Edit menu. Now select your newly created entry and in the panel to the right in the GFF Editor, change the value in the "FieldID" field to a value one higher than the highest of the indexes of the already existing entries. I.e. if the last entry was 30, type 31 here.

Each entry in this list contains the fields:
* InventoryRes (CResRef): A Resref (filename) to the item blueprint for this item. For example putting "a_robe_08" here would place a standard Jedi Robe in the store.

* Repos_PosX, Repos_PosY (WORD): X and Y coordinates for where in the store the item should appear. I don't know if they are actually used or merely leftovers from Neverwinter Nights since KOTOR/TSL uses a list to present inventory content. Just in case make sure that no items have the same set of X/Y coordinates.

* Infinite (BYTE): This field is optional, but if it exists and is set to 1, the store will have an infinite supply of this item.

Note that if you want more than one of a specific item in the store, but don't want an infinite supply, you'll have to create a separate entry for each of the duplicate items, and set the InventoryRes of the entries to point to the same item blueprint.


Now you've created the blueprint for your store. Place it in the override folder. In order to actually use this store in the game though, you'll need to do two things. First you need to create an object of your store in-game, then you'll need to create or add onto an NPCs conversation that will start the store.

This is done the easiest way through a script that you attach to the dialog node that will start your store. I believe a script like this would work:


// ST: st_startstore.nss

void main() {
object oStore = GetObjectByTag("TAG_OF_STORE_HERE");

if (!GetIsObjectValid(oStore))

if (GetIsObjectValid(oStore))
DelayCommand(0.5, OpenStore(oStore, GetPCSpeaker()));

Edit the script and put the tag you specified above where it says "TAG_OF_STORE_HERE", and put the resref you specified above where it says "RESREF_OF_STORE_HERE".

Then name the script something unique, compile the script and put it in the override folder. In your Dialog file, where you want the store to start, put the name of this file in the field labeled "Script #1" if you are using the DLG Editor.

Darth Bos Pity
11-30-2007, 07:01 PM
Thats for KOTOR II, it's very different when i do it for KOTOR I, plus i cannot find the custom Item that i made anywhere to put in?

Edit: Ok i managed to do it, but now i need to create dialogue for the merchant, but i havn't got a clue on how to do this, all the tutorials seem like they are talking about how it is done, rather than how to do it & where things are located, eg;

1. Go to the tools menu
2. Select the text editor.
3. Then in the text editor window, go to the script menu, select your game (kotor 1 or kotor 2)
4. make your script, save with a .nss extension.
5. Either go to the script menu and select compile or simply press F5
6. The compilation should output a .ncs file.

HOW, i know i wan't to make a script but i want you to tell me how, not to tell me to make one.

what i need is for someone to volunteer to make this for me, your help will be greatly appreciated.

Just PM me & i'll give you the Details

please help, i just need it done for me so i can learn from this, you will be credited greatly, if the mod is ok & works so i can release it, or we can release it.

please help?

Darth Xander
11-30-2007, 07:53 PM
void main() {
object oStore = GetObjectByTag("TAG_OF_STORE_HERE");

if (!GetIsObjectValid(oStore))

if (GetIsObjectValid(oStore))
DelayCommand(0.5, OpenStore(oStore, GetPCSpeaker()));

Darth Bos Pity
11-30-2007, 10:41 PM
That makes no sence to me at all, sorry, but i'm a real NooB

Darth Xander
12-01-2007, 09:03 AM
ok what is the tag and resref of your store? If you have already made the store itself.

Darth Bos Pity
12-01-2007, 10:05 AM
Tag: lannic_vecto
Resref: lannic_vecto

Don't know, but have i done that wrong?

Darth Xander
12-05-2007, 02:39 AM
No I don't think so, use this script to open the storebut you will need to compile it

void main() {
object oStore = GetObjectByTag("lannic_vecto");

if (!GetIsObjectValid(oStore))
oStore = CreateObject(OBJECT_TYPE_STORE, "lannic_vecto", GetLocation(OBJECT_SELF));

if (GetIsObjectValid(oStore))
DelayCommand(0.5, OpenStore(oStore, GetPCSpeaker()));