LucasForums

LucasForums (http://www.lucasforums.com/index.php)
-   Holowan Laboratories (http://www.lucasforums.com/forumdisplay.php?f=324)
-   -   [Tutorial] Creating Merchants (with Kotor Tool) (http://www.lucasforums.com/showthread.php?t=204745)

Canaan Sadow 07-14-2010 03:48 AM

Creating Merchants (with Kotor Tool)
 
First off, I would suggest that you create a new folder for your mod to go in...

Show spoiler


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.

Show spoiler


Show spoiler


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"

Show spoiler


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...

Show spoiler


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...

Show spoiler


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.

Show spoiler


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.

Show spoiler


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.

Show spoiler


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.

Show spoiler


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

Show spoiler


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 and you'll need to look at this thread.

Show spoiler


Show spoiler


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


Quote:

Originally Posted by stoffe
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:

Code:

// 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 05:12 AM

The only part I'm not getting is the script part. How on earth do you compile it?

Canaan Sadow 07-15-2010 05:34 AM

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 05:46 AM

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 06:15 AM

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 07:16 PM

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

Thanks a lot for this tut, but I just want to point out that in the script there is a problem:

Code:

// 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 01:22 AM

Quote:

Originally Posted by Dak Drexl (Post 2774631)
Thanks a lot for this tut, but I just want to point out that in the script there is a problem:

Code:

// 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 04:22 AM

^^^ Ahhh! The Master has spoken! :lol:

Quote:

Originally Posted by Dak Drexl (Post 2774631)
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 08:29 AM

This should accompany the already existing tutorial on merchants under general modding nicely

Dak Drexl 04-18-2011 05:42 PM

Quote:

Originally Posted by stoffe (Post 2774649)
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 06:34 PM

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 06:45 PM

Quote:

Originally Posted by Qui-Gon Glenn (Post 2774781)
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 02:04 AM

Quote:

Originally Posted by Dak Drexl (Post 2774771)
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.

Quote:

Originally Posted by Qui-Gon Glenn (Post 2774781)
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:
Code:

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 03:55 PM

^^^ Good clarification :)

PM coming your way stoffe.

redindianman13 01-13-2013 02:16 PM

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 09:51 PM

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

Quote:

Originally Posted by Hassat Hunter (Post 2826617)
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 05:22 PM

?
 
Can anyone help me please, ^^^


All times are GMT -4. The time now is 05:50 PM.

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