Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Creating Merchants (with Kotor Tool)

Page: 1 of 1
 Canaan Sadow
07-14-2010, 3:48 AM
#1
First off, I would suggest that you create a new folder for your mod to go in...

http://i1010.photobucket.com/albums/af221/ViridianBandit/folderscreenshot.jpg)

Then once you've got everything settled in the exact way you want it, then you open up kotor tool and then go to a merchant, similar to what you are creating (like if you're going to create a droid merchant). If you create a droid merchant, you might choose to go to the Taris droid merchant... Kotor I -> RIMS -> Modules -> tar_m02ab_s.rim -> Blueprint, Merchant -> droidshop.utm then go back to the side and then to Extract file and extract it to your folder.

http://i1010.photobucket.com/albums/af221/ViridianBandit/screenshotformakingamerchant.jpg)

http://i1010.photobucket.com/albums/af221/ViridianBandit/instructions.jpg)

Now that you've gotten the file saved in your folder, it's time to go back and rename it. Just right-click on the file and click rename. Rename it to something unique that suits you... you could name it xyz.utm for all it matters. For the intents and purposes of this mod, I renamed it janitorshop.utm (because I'm just going to attatch it to the Janitor in Taris). Now then open up GFF editor (I'll be using the Kotor Tool GFF editor, because in my opinion it looks a little more simplified).

ResRef:
Change the ResRef to the exact same thing that you changed your .UTM file to, only leave off the .utm extension. ie I named my .UTM file to "janitorshop.utm" I put the ResRef as "janitorshop"

http://i1010.photobucket.com/albums/af221/ViridianBandit/resrefchange.jpg)

LocName:
Set this to name of the store... normally it is the name of NPC who runs/owns the store... but you could set it to whatever...

http://i1010.photobucket.com/albums/af221/ViridianBandit/locnamechange.jpg)

Tag:
An identifier that scripts can use to gain access to your custom store... probably you should rename it to what you named your ResRef, unless you really don't want to or you have a reason to do otherwise...

http://i1010.photobucket.com/albums/af221/ViridianBandit/tagchange.jpg)

Buy/Sell Flag:
Obviously, this is what you can set to make it to where the merchant will only buy, only sell, or buy and sell. Just click the arrow and then change it to whichever one you want.

http://i1010.photobucket.com/albums/af221/ViridianBandit/buysell.jpg)

Mark Up:
This will set the store's price to sell their goods. 100 is the base price of the item... 125 is 25% more than the base price, 130 is 30% more than the base price and so forth and so forth.

http://i1010.photobucket.com/albums/af221/ViridianBandit/markupchange.jpg)

Mark Down:
Is the exact opposite of Mark Up, it sets the percentage at which the store will buy from you. Once again 100 is the base price, though normally it will be set to below 100, it's usually at about 40-60. 40 is 40% of the base price that they will use to buy from you... 50 is set to half of the base price and so forth and so forth.

http://i1010.photobucket.com/albums/af221/ViridianBandit/markdownchange.jpg)

OnOpenScript:
Just a ResRef to a script that will fire when the store is open... unless you want something a little different to happen, just leave it blank.

http://i1010.photobucket.com/albums/af221/ViridianBandit/OnOpenScript.jpg)

ID:
The ID is always set to 5 for stores... so don't change anything.

http://i1010.photobucket.com/albums/af221/ViridianBandit/ID.jpg)

INVENTORY:
Obviously this is what the store contains... you can add or destroy items within the store. To destroy an item from the inventory, just set the quantity to 0. To add them, click the + symbol on whatever type of thing you want to add and then drag one of the items over onto the grey inventory box. (As far as I can tell, you can't set any item as infinite in Kotor Tool, to do that, you'll need to download K-GFF by tk102 (http://www.starwarsknights.com/mtools/kgff_131.zip) and you'll need to look at this thread (http://www.lucasforums.com/showthread.php?t=147231).

http://i1010.photobucket.com/albums/af221/ViridianBandit/iventore.jpg)

http://i1010.photobucket.com/albums/af221/ViridianBandit/iventory.jpg)

Now then, resave your Merchant's store and over write the file, that you had it renamed as...


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");
object oSpeaker = GetPCSpeaker();

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

if (GetIsObjectValid(oStore))
DelayCommand(0.5, OpenStore(oStore, oSpeaker));
}

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.
 Bane's Heart
07-15-2010, 5:12 AM
#2
The only part I'm not getting is the script part. How on earth do you compile it?
 Canaan Sadow
07-15-2010, 5:34 AM
#3
In Kotor Tool, there is this thing called Text Editor... you copy the script and then go to edit, paste and then save it... and then script button and put it for K1 or K2, depending and then script button again and hit compile. (:
 Bane's Heart
07-15-2010, 5:46 AM
#4
Ah I found that out in the scripting tutorials section, and brilliant tutorial. Although I would be interested in creating a new npc who likes to hang around the Ebon Hawk on tatooine, or around it at least.
 Canaan Sadow
07-15-2010, 6:15 AM
#5
In the Scripting tutorial section, there's a frequently used script thread. You'll find scripts that'll help you to spawn custom made NPCs (: And thanks. Haha.
 Bane's Heart
07-15-2010, 7:16 PM
#6
Yeah in the scripting tutorial that's where I found out how to compile a script :X.

I've already had a skim through of that though and there's sadly no specification on the script to place a new NPC.
 Dak Drexl
04-17-2011, 10:54 PM
#7
Thanks a lot for this tut, but I just want to point out that in the script there is a problem:

// ST: st_startstore.nss

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

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

if (GetIsObjectValid(oStore))
DelayCommand(0.5, OpenStore(oStore, oSpeaker));
}

That exclamation point needs to come out if you want the script to work. It will still compile with it in, but it won't work unless you take it out; just a future warning to anyone!

But thanks again for this :D very helpful.
 stoffe
04-18-2011, 1:22 AM
#8
Thanks a lot for this tut, but I just want to point out that in the script there is a problem:

// ST: st_startstore.nss

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

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

if (GetIsObjectValid(oStore))
DelayCommand(0.5, OpenStore(oStore, oSpeaker));
}

That exclamation point needs to come out if you want the script to work. It will still compile with it in, but it won't work unless you take it out; just a future warning to anyone!

But thanks again for this :D very helpful.

Uh, no. The exclamation point is a negation operator. It makes the script create the store object if it does not already exist. If you remove the negation operator you'll spawn a new instance of the store object every time you talk to the merchant, instead of using the one that you already spawned the first time you talked to them. You'd flood the samegame with store object instances if it's a frequently visited merchant.

If you remove the negation operator you'd spawn the store object when an object with that tag already exists. So if your variant "works" it would mean that you've specified the tag of another non-store object within that area that already exists (and your store likely has the same tag as such an object). Change the tag of your store to something unique and it should work. :)
 Canaan Sadow
04-18-2011, 4:22 AM
#9
^^^ Ahhh! The Master has spoken! :lol:

But thanks again for this :D very helpful.

Haha. No problem. I use KotOR Tool more often than I do KGFF editor (I only use KGFF editor if I'm wanting a custom appearance of an NPC, other than that it confuses the heck out of me :xp: ) and I figured there might be others (such as Bane's Heart) and so yeah haha.

As for the script I take stoffe's word for it, seeing as I always use that script and it functioned fine for me. :p (as stoffe just said :) )
 newbiemodder
04-18-2011, 8:29 AM
#10
This should accompany the already existing tutorial on merchants under general modding nicely
 Dak Drexl
04-18-2011, 5:42 PM
#11
Uh, no. The exclamation point is a negation operator. It makes the script create the store object if it does not already exist. If you remove the negation operator you'll spawn a new instance of the store object every time you talk to the merchant, instead of using the one that you already spawned the first time you talked to them. You'd flood the samegame with store object instances if it's a frequently visited merchant.

If you remove the negation operator you'd spawn the store object when an object with that tag already exists. So if your variant "works" it would mean that you've specified the tag of another non-store object within that area that already exists (and your store likely has the same tag as such an object). Change the tag of your store to something unique and it should work. :)

I'm sorry, I just don't get it :confused: I'm scripting retarded and I just observed that the store wouldn't open when I had the exclamation point in there. When I took it out, it opens.

In this mod I have the merchant greet the player by name after he is met for the first time. Is it then when I want to have the ! a part of the script ("then" being the second time)? I hope I'm being clear, you'll have to forgive my ignorance here!
 Qui-Gon Glenn
04-18-2011, 6:34 PM
#12
Hey Dak!

So, when are you spawning the store? Is it spawned before or after the conversation takes place with the merchant? Or, as I re-read your post, is it that you are trying to spawn the store a second time while the Merchant now addressed the PC by name? If it was spawned already, the store should still be there, and there is no need to spawn the store again. You just need to edit the Merchant's dialog to lock off the part of the dialog where the merchant did not know the PC's name. This would be accomplished via a Dialog Conditional Script, which TB12 did an excellent tut on :)

The only reason why the script wouldn't work with the "!" is if you had already spawned the store earlier, perhaps in an OnEnter script via script injection. In that case, it would not create a second shop of the same tag, as that is what the !GetIs... does... it makes sure that such a thing is NOT already in existence.

EDIT: Nice tut KS :D
 Canaan Sadow
04-18-2011, 6:45 PM
#13
Hey Dak!

So, when are you spawning the store? Is it spawned before or after the conversation takes place with the merchant? Or, as I re-read your post, is it that you are trying to spawn the store a second time while the Merchant now addressed the PC by name? If it was spawned already, the store should still be there, and there is no need to spawn the store again. You just need to edit the Merchant's dialog to lock off the part of the dialog where the merchant did not know the PC's name. This would be accomplished via a Dialog Conditional Script, which TB12 did an excellent tut on :)

The only reason why the script wouldn't work with the "!" is if you had already spawned the store earlier, perhaps in an OnEnter script via script injection. In that case, it would not create a second shop of the same tag, as that is what the !GetIs... does... it makes sure that such a thing is NOT already in existence.

EDIT: Nice tut KS :D

Thanks :evil5: (sorry about the evil smiley, it's the only one that I saw that does the peace sign. xD )

And also thanks for answering his question, I was just about to start doing that, cuz I finally finished the rough draft of my paper, but now I don't have to. :p (Thankfully, cuz I'm not sure my brain could handle it right now, massive migrane and all xD )
 stoffe
04-20-2011, 2:04 AM
#14
I'm sorry, I just don't get it :confused: I'm scripting retarded and I just observed that the store wouldn't open when I had the exclamation point in there. When I took it out, it opens.



The only reason why the script wouldn't work with the "!" is if you had already spawned the store earlier, perhaps in an OnEnter script via script injection. In that case, it would not create a second shop of the same tag, as that is what the !GetIs... does... it makes sure that such a thing is NOT already in existence.


Pretty much. The only situation I can think of off the top of my head where it would work as DD described would be if there is another non-store object in the area already with the same tag as the store. In that case the script would find an existing object and not spawn a new store instance, but since the existing object isn't a store it would be unable to open it, and thus nothing would happen.

In preudo-code, the script essentially does:

void main()
{
object oStore = Get existing store object identified by its Tag value
object oSpeaker = Get the object (player, usually) that I'm in dialog with

if (there is no object in the area matching the specified Tag)
oStore = Create a new store object at my location from the UTM template with the Resref set here

if (there is now a oStore object, either previously existing or just created)
open the store with the person I'm in dialog with after 0.5 seconds.
}
 Qui-Gon Glenn
04-23-2011, 3:55 PM
#15
^^^ Good clarification :)

PM coming your way stoffe.
 redindianman13
01-13-2013, 2:16 PM
#16
Ok, I got to the scripting part and have done as instructed. But I want to make my new merchant into a Wookiee, and I want to place him somewhere on Onderon. Also I want him to have some interesting dialogue that I have thought up. Can anyone be of assistance to me? :)
 Hassat Hunter
01-13-2013, 9:51 PM
#17
UTC for making it a wookie, the GIT file for placing it on Onderon. A DLG-file for dialogue.
And then of course the store files (actual store, script to launch, script to stock if desired).

What do you need assistance with?
 redindianman13
01-13-2013, 11:17 PM
#18
UTC for making it a wookie, the GIT file for placing it on Onderon. A DLG-file for dialogue.
And then of course the store files (actual store, script to launch, script to stock if desired).

What do you need assistance with?
Well I followed the tut above so I have everything based off of Gegorran on Onderon. So I think I have the actual store files down pat but I need help into making him a Wookiee, placing him on Onderon, and then making the dialogue. :)
 redindianman13
01-16-2013, 5:22 PM
#19
Can anyone help me please, ^^^
 CaptainPike
09-03-2014, 2:47 AM
#20
I can't change the numbers on anything, anywhere. When I try to change the amount of the store (by hitting enter, tab, whatever), it goes back to the original value. I also can not change the mark up/mark down amount. I enter what I want, press >enter<, leave the field, save, and reopen to find the same numbers there as when I first opened the store. Quite frustrating. Is there a way to script markup/markdown when calling on the store?
 Fair Strides 2
09-03-2014, 3:15 AM
#21
I can't change the numbers on anything, anywhere. When I try to change the amount of the store (by hitting enter, tab, whatever), it goes back to the original value. I also can not change the mark up/mark down amount. I enter what I want, press >enter<, leave the field, save, and reopen to find the same numbers there as when I first opened the store. Quite frustrating. Is there a way to script markup/markdown when calling on the store?

Send me the file via PM(upload somewhere and send a link) and I'll check it out.

As to scripting the markup and markdown, you can do so in the OpenStore function I showed you. Also, note that it is often frowned upon for resurrecting threads older than 2 months...
Page: 1 of 1