Jump to content

Automatical restocking mod help


Graesholt

Recommended Posts

Hey.

I like to buy in bulk, and for that I would like to make a mod that automatically restocks a merchant with appropriate goods when their supply gets low.

Say that I was to apply this to Arcadia in Whiterun (the potions/ingrediants dealer).
I have gotten as far as deciding that the script should be attached to her merchant container.
The script would ensure that if her supply of ingredients (not wares; ingredients) dropped below X, she would recieve a new item from a leveled list, Y. Then it would recheck to see if the number was X or above and then end or repeat accordingly.

Does anyone have any idea how that script would look?
I have seen toturials, but nothing have worked so far...

I just need the first working script, and then I can do the rest of the mod on my own.
Whatever help I recieve will of course have their names credited as script-assistance in the final credits.

Thank you.

Link to comment
Share on other sites

First I wouldn't put the script directly on the merchant container. I would set up a quest that has aliases filled with the merchant containers. This would prevent issues with the script being left behind should the mod be uninstalled.

 

Anyway simple script segment -- event plus required properties only

 

 

 

Property Int MinAmount Auto
Property Int RestockAmount Auto
 
Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
  If akBaseItem.GetItemCount() <= MinAmount
    ObjectReference Cont = Self.GetReference()
    Cont.AddItem(akBaseItem,RestockAmount)
  EndIf
EndEvent

If you want to limit what items, that would require a little bit more.

 

For example to limit to only ingredients...

 

 

Property Int MinAmount Auto
Property Int RestockAmount Auto
 
Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
  If akBaseItem as Ingredient
    If akBaseItem.GetItemCount() <= MinAmount
      ObjectReference Cont = Self.GetReference()
      Cont.AddItem(akBaseItem,RestockAmount)
    EndIf
  EndIf
EndEvent

But where you get into tricky situations is with those items you want to restock that are in categories that have items you do not want to restock.
Link to comment
Share on other sites

 

But where you get into tricky situations is with those items you want to restock that are in categories that have items you do not want to restock.

 

I see what you mean, but is it possible to have it simply restock a random item from a leveled list?

That way, no item put in the inventory would be out of the vendor's regular repetoire.

Link to comment
Share on other sites

I guess it is possible but I've never added items from a leveled list before or even worked with leveled lists.

 

But the vendor's regular stock is comprised of leveled lists... The types of items you would most likely want to restock are probably already on their leveled lists. Besides no matter what you put in their chest, it will be gone in 2 days time. The chest respawns independent of visiting the merchant.

Link to comment
Share on other sites

Hey,

For what purpose do you use the Properties in the suggestions you gave me?
(I really want to understand, but reading up on the internet made them seem completely nonsensical for the purposes of the script)

I am really grateful that you take the time to help me out :)

Link to comment
Share on other sites

In this case I used properties so that you could set the numerical values you wanted to use for the minimum stock to be left behind before restocking and for the quantity to restock with. As properties you could reuse the script on a different container with different values.

 

The main purpose of properties, however, is to let the script know exactly what objects you are referring to and want to work with.

 

For example, let us say that the merchant was a seller of soul gems. Since there is already an existing soul gem form list (not a leveled list) we could use that along with a random number to restock a random soul gem.

 

 

Int Property MinAmount Auto
Int Property RestockAmount Auto
FormList Property SoulGemList Auto 
 
Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
  If akBaseitem as SoulGem
    If akBaseItem.GetItemCount() <= MinAmount
      ObjectReference Cont = Self.GetReference()
      Int Total = SoulGemList.GetSize()
      Int EntryIndex = RandomInt(0,Total)
      Form Entry = SoulGemList.GetAt(EntryIndex)
      Cont.AddItem(Entry,RestockAmount)
  EndIf
EndEvent

Hopefully that did not confuse you too much.

 

 

***Just noticed in the initial scripts I flipped the positions of Int & Property... It happens (a lot) when my mind switches tasks.

Link to comment
Share on other sites

Okay,
Thank you so much for your patience, but after looking and searching on the internet, I must admit that this project was ambitious at best from the beginning.
As I said, I came into it completely green, so this was probably too big a mouthful for me.

I have decided to settle for a mod that increases the inventory of the merchants in different holds, as I always found it nonsensical for one to be able to outbuy them with the change in one's pocket (especially the guys in Whiterun, which is supposed to be the capital).
(And let's be perfectly honest: Their supply magically replenishing while being bought was even more senseless. Stupid idea on my part, I admit.)

When I eventually release the new mod, I would like to list you, IsharaMeradin, as a help in the idea development process, but if you would rather that I didn’t, I completely understand.
Again, thank you for all your help. I’ve really appreciated it.
Even this short-lived experience has taught me a couple of new tricks for my basket.

Thank you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...