Stormie97

Adding a custom item to a merchants inventory (TSL)

Recommended Posts

Hey folks,

I've picked my WIP Luke robe from ROTJ  up where I leftyesterday and it's almost done, I just have to insert it somewhere for the player to acquire it. I want to put it in Dendis Dobo's merchant inventory, the Duros merchant on Telos. But I can't get to work for some reason. Here's what I have tried so far:

  • I followed this tutorial and added my robse item to his inventory by moddifying m_202_001.utm which appears to be the corresponding merchant utm file. However, putting it in my override folder seems to have no effect on his inventory IG whatsoever.
  • I used TSLPatcher to inject the modifications into the appropriate RIM file (202TEL_s.rim). What I have done seems to have worked since I can now see my custom item when I open m_202_001.utm in KoTORTool:
Spoiler

Problem2.PNG

Yet, his inventory IG still remains unchanged.

Even adding existing jedi robes from the vanilla game doesn't seem to work so surely there is something I'm missing here.

Any ideas on what I'm doing wrong here?

 

 

 

Share this post


Link to post
Share on other sites

If you are loading a save in the module it won't work, as the save will have a copy already stored in it (inside the specific module's GIT). You'll have to load a save from before entering the area for the first time to see the changes.

Share this post


Link to post
Share on other sites
Just now, DarthParametric said:

If you are loading a save in the module it won't work, as the save will have a copy already stored in it (inside the specific module's GIT). You'll have to load a save from before entering the area for the first time to see the changes.

I loaded an earlier save. That solved it.

However, since this area is entered pretty early on in the game, this would make it impossible to get the item without cheating for those who have already made further progress in the game. What are my options then, besides putting the robes in another merchant's inventory on one of the later planets?

Share this post


Link to post
Share on other sites

You could spawn it via script, either adding it to the store or a container. There would be a couple of ways to go about it. Hijack the module's OnEnter script and have it spawn it (and use a local boolean to make sure it only spawns once). Or edit the merchant's DLG and add a spawn script on a repeated node (like the generic greeting they always do, etc.) that does a similar check/spawn.

Share this post


Link to post
Share on other sites
6 minutes ago, DarthParametric said:

You could spawn it via script, either adding it to the store or a container. There would be a couple of ways to go about it. Hijack the module's OnEnter script and have it spawn it (and use a local boolean to make sure it only spawns once). Or edit the merchant's DLG and add a spawn script on a repeated node (like the generic greeting they always do, etc.) that does a similar check/spawn.

Never done scripting before, so I'll look into it. Editing the merchant's DLG seems to be most doable of those options for a beginner.

Share this post


Link to post
Share on other sites
2 hours ago, Stormie97 said:

I used TSLPatcher to inject the modifications into the appropriate RIM file

You don't want to do that by the way. You want to create a MOD and inject your changes into that.

Edit: Try this @Stormie97 and see if it works (you'll need to add your item's template name and compile it):

void main() {
	
	object oStore = GetObjectByTag("m_202_001", 0);
	
	// To make sure the item only spawns once, check Dendis for the presence of
	// a custom local boolean we'll create. If it returns false, spawn the item.
	// Since the DLG we are firing the script from is owned by Dendis, we can use
	// OBJECT_SELF for any call that requires a target object, like the boolean set/get.
	if (!GetLocalBoolean(OBJECT_SELF, 66))
		{
			// The check returned false, so set the boolean to true so that the
			// item won't spawn a second time on future triggers of this script.
			SetLocalBoolean(OBJECT_SELF, 66, TRUE);
			
			// Create the item in the store's inventory. The values are of the form:
			// Item template resref (string) / target (object) / item stack size (int)
			CreateItemOnObject("item_template_here", oStore, 1);
		}
}

After compiling it, you'll also need to edit Dendis's DLG and add the script name to one of the nodes. I would put it in the Script #2 slot on Reply 9 ("Just let me shop"). Just make sure not to replace any existing script.

  • Like 1
  • Thanks 2
  • Light Side Points 1

Share this post


Link to post
Share on other sites
7 hours ago, DarthParametric said:

You don't want to do that by the way. You want to create a MOD and inject your changes into that.

Edit: Try this @Stormie97 and see if it works (you'll need to add your item's template name and compile it):


void main() {
	
	object oStore = GetObjectByTag("m_202_001", 0);
	
	// To make sure the item only spawns once, check Dendis for the presence of
	// a custom local boolean we'll create. If it returns false, spawn the item.
	// Since the DLG we are firing the script from is owned by Dendis, we can use
	// OBJECT_SELF for any call that requires a target object, like the boolean set/get.
	if (!GetLocalBoolean(OBJECT_SELF, 66))
		{
			// The check returned false, so set the boolean to true so that the
			// item won't spawn a second time on future triggers of this script.
			SetLocalBoolean(OBJECT_SELF, 66, TRUE);
			
			// Create the item in the store's inventory. The values are of the form:
			// Item template resref (string) / target (object) / item stack size (int)
			CreateItemOnObject("item_template_here", oStore, 1);
		}
}

After compiling it, you'll also need to edit Dendis's DLG and add the script name to one of the nodes. I would put it in the Script #2 slot on Reply 9 ("Just let me shop"). Just make sure not to replace any existing script.

It works perfectly, thank you so much for your help!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.