Grateful merchant

Post » Thu Jan 27, 2011 2:21 pm

I'd like to add a reward to a quest set by a merchant that allows the player to buy special items at less than base price. The idea is that they are made by the vendor specially for the player, and sold at cost - other vendors would evaluate their worth and set a higher price. This gives the player a reason to go visit that NPC at intervals after the quest ends, just like the Master's chest does for the Fighter's Guild questline.

These would be items unique to the mod, which gives me some extra flexibility in how they're set up. The rest of the vendor's inventory is to behave normally, with prices set by the usual markup rules. I'd put a separate merchant container in place for these special items, and use a leveled list that gives zero items most of the time, so the special stuff is only a infrequent addition to what's offered.

The problem I have is finding a way that price markup can be different for these items than that for the regular inventory. Setting their price low in the form means that they sell at a low price to everyone else, and I don't believe I have control over the "value" of any enchantments. Item-swapping may be possible, so that the vendor's inventory shows a lower-valued item than the one that goes into the player's, but I'm not sure how I'd achieve that. Any other ideas?
User avatar
Tiff Clark
 
Posts: 3297
Joined: Wed Aug 09, 2006 2:23 am

Post » Thu Jan 27, 2011 8:32 pm

Maybe you could set the value of the items (setitemvalue or the set/modgoldvalue OBSE functions) when the player activates the merchant who sells them and set them back to their original value once the player is back in gamemode. That way you also can't buy the items from the merchant and sell them back to him for a higher price directly, which would be pretty silly. Since both functions modifiy the base object it would also work for non-unique items that can be bought more than once (like potions etc).
User avatar
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm

Post » Thu Jan 27, 2011 7:17 pm

Would I need to attach the script that does that to the item or the NPC?

This looks like a generically useful mechanism if it can be made independent of the items and tied only to the extra merchant container, but I haven't figured out how that gets handled by the game engine. In effect, when you activate a merchant's barter menu, you open a combination of inventories, of the merchant and the containers he/she owns all merged together, but I have no idea if OnActivate would be triggered on a merchant container at that point, which would be the ideal situation.
User avatar
Nick Swan
 
Posts: 3511
Joined: Sat Dec 01, 2007 1:34 pm

Post » Thu Jan 27, 2011 4:20 pm

Would I need to attach the script that does that to the item or the NPC?

This looks like a generically useful mechanism if it can be made independent of the items and tied only to the extra merchant container, but I haven't figured out how that gets handled by the game engine. In effect, when you activate a merchant's barter menu, you open a combination of inventories, of the merchant and the containers he/she owns all merged together, but I have no idea if OnActivate would be triggered on a merchant container at that point, which would be the ideal situation.


Don't think onactivate will trigger on a merchant container, but never tried. I put this script on Rohssan in 'A Fighting Chance' and it worked pretty well:

short switchbegin gamemodeif switch == 1setgoldvalue 100 RepairHammer set switch to 0endifendbegin onactivatesetgoldvalue 1 RepairHammerset switch to 1activate playerend


The hammer had a base value of 1 when I bought it from her and after exiting the dialogue and looking in my inventory it had a value of 100.
User avatar
Enie van Bied
 
Posts: 3350
Joined: Sun Apr 22, 2007 11:47 pm

Post » Thu Jan 27, 2011 9:03 am

Would I need to attach the script that does that to the item or the NPC?
The furniture contracts you buy as part of the vanilla house quests do something similar, only that they get their price set to 0 as soon as you buy them. This is handled by adding a script to the contracts, with an "OnAdd" block which gets triggered when the player buys it (and they get added to the player's inventory). So you could look at them too.
User avatar
Aman Bhattal
 
Posts: 3424
Joined: Sun Dec 17, 2006 12:01 am

Post » Thu Jan 27, 2011 7:49 pm

Attaching a script to the items could be the better option. If the script can get the base value, mark it down a percentage for the sale and restore afterward, I can use the same script on all of them, which makes it much easier to add more of the same. It looks like a script on the merchant would need to know all the item references in advance.

I have a number of instances where I may try variations of this. Since the object script can check a quest variable, it could be set to work once only, so all the prices go back to normal when you close the dialog, or a fixed number of times, or until another quest event happens, or ...
User avatar
Bird
 
Posts: 3492
Joined: Fri Nov 30, 2007 12:45 am


Return to IV - Oblivion