Scripting Merchant Gold Amount?

Post » Tue Jun 19, 2012 9:14 am

I've already created a merchant, but I want my merchant to always have a large amount of gold available. I first tried adding a large amount of gold (60000) to the merchant container, but this only seemed to "break" the merchant. If I tried to buy or sell something, no money would change hands. Reducing the gold amount to 30000 fixed this problem. However, a one-time total of 30000 gold is not high enough for my purposes...

So my next idea is to try and fix the amount of gold in the merchant container through scripting. Essentially I would like the merchant to always have 30000 gold in their container. The only problem is I need help with the scripting. What's an example of a script I might try using for this?
User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Tue Jun 19, 2012 4:47 am

Adding more than one vendercash thingie to the chest doesn't work?
User avatar
Tamika Jett
 
Posts: 3301
Joined: Wed Jun 06, 2007 3:44 am

Post » Tue Jun 19, 2012 3:05 am

Adding more than one vendercash thingie to the chest doesn't work?

I also tried that... assuming you mean gold by "vendercash thingie". You can increase the amount of gold as high as you want by adding multiple gold items and setting the item count (there is a limit on the item count... 60,000 or so) for each entry very high. However, it doesn't matter since merchants seem to stop working after their gold count exceeds 40-50 thousand.... I haven't figured out the exact number. Its strange... I noticed similar behavior with the Fallout series merchants back when I was modding that game. Scripting appears to be the only way to give a merchant large/infinite gold reserves.

Any help with a possible script would be great. Should be simple for those who know how to script... just re-set the amount of gold in the merchant container each time the merchant's cell loads or something like that I'm thinking.
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Tue Jun 19, 2012 2:01 am

Might not work since I didn't test this, but here's a starting point:

Spoiler

Scriptname aaaMerchGold extends ObjectReferenceForm Property Gold001	  Auto ; Property storing Gold form.int  Property gold_amount Auto ; Amount of gold this reference should have; Whenever something is removed.Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)	  ; Check if akBaseItem is gold.  If ( akBaseItem == Gold001 )    modGold()  EndIf	EndEvent; Whenever something is added.Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)  ; Check if akBaseItem is gold.  If ( akBaseItem == Gold001 )    modGold()  EndIf	EndEvent; //; // Function: modGold(); //; // Add or remove gold based on amound required. To maintain "gold_amount" gold; // in this reference's inventory.; //Function modGold()  int diff = GetItemCount(Gold001) - gold_amount	  If (diff < 0) ; Negative difference --> reference has less gold than required.    AddItem(Gold001, ( Math.abs(diff) as int ), true)	  ElseIf (diff > 0) ; Positive difference --> reference has too much gold.    RemoveItem(Gold001, diff, true)		  Else    ; Do nothing. Reference has proper amount of gold.  EndIfEndFunction

Edit: Bethesda really needs to give us Papyrus-specific syntax-highlighting. It looks kinda funny with the default setting.
User avatar
Carolyne Bolt
 
Posts: 3401
Joined: Mon Jul 10, 2006 4:56 am

Post » Tue Jun 19, 2012 7:39 am

Thank you so much for the reply!

I have very limited understanding of scripts though, and I have some questions about the one you posted:

-Where in the script do I specify how much gold I want the merchant to maintain? Or am I not supposed to... does it just work based on how much is already in the container?

-Do I need to change any reference names so it points to a specific container?

-Is the script supposed to be attached to the merchant's container?

I went ahead and attached the script to my merchant's container... but I did not observe any changes in game. It didn't seem like the gold amount was being controlled or altered in any way. I'm not suggesting your script doesn't work... its likely I'm doing something wrong or don't understand the script too well.
User avatar
Fiori Pra
 
Posts: 3446
Joined: Thu Mar 15, 2007 12:30 pm

Post » Tue Jun 19, 2012 4:09 am

Thank you so much for the reply!

I have very limited understanding of scripts though, and I have some questions about the one you posted:

-Where in the script do I specify how much gold I want the merchant to maintain? Or am I not supposed to... does it just work based on how much is already in the container?

-Do I need to change any reference names so it points to a specific container?

-Is the script supposed to be attached to the merchant's container?

I went ahead and attached the script to my merchant's container... but I did not observe any changes in game. It didn't seem like the gold amount was being controlled or altered in any way. I'm not suggesting your script doesn't work... its likely I'm doing something wrong or don't understand the script too well.
If you attached the script directly to the container, it should be on every reference of that container as well.

Where you attach the scripts, there should be a button called "Properties". Click on it (make sure you selected the script first). Near the bottom of the new window, there'll be a button labelled "Auto-fill All", click on that as well. You should get a prompt telling you 1 property was auto filled. There'll still be one property that wasn't filled: gold_amount. That's the amount of gold your container should hold, click on "Edit Value" and enter an integer value.

Hopefully that made sense, I'm not very good with directions.
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm


Return to V - Skyrim