• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Item Trading overhaul

Thanks. :]
Correct. Then it'll show.

I also rewrote characters_init to only do the blood massive init'ing when starting a new game, not just when launching POTC (i.e. launch POTC -> load game escapes the ~57 second wait). It now loads to main menu _quite_ fast, at least for me.

OK, it's finally normal speed. While it takes ~4 seconds to "create" a trader, it takes only a few milliseconds to update one.
However, if the trader (or the town) changes quality, it's another `4-second` wait to update the trader.

File same as before.

Alan, Blacksmith is now supported both on the trader side _and_ on the item side (I edited scheffnow's funcs to set item type, and quality is `auto-set` based on price). Just add the itemtrade node to the dialog (copy the link to it and the node itself over).
You can check in itemsitems_utilite.c if I set the various multipliers correctly; just edit->find "blacksmith".

I also gave swords and pistols each a nationality (except dagger). This means that, for instance, Badelaires are ~1.25 more available (and 0.9x price) by French traders.

Yes, you (once more) need to start a new game; but I think this is finally in testable condition.
 
NOTES:
All functions are at the bottom of Items_utilite.c
Don't worry; traders will be automatically assigned everything if you add nothing to their ch defines; you can add as many or as few extra attributes as you like and the functions will do the rest (see trader flags, below, for ways to control this).
You should, however, set ch.itemtrade.tradetype to one of the IT_TYPE defines in BS.h; right now only storekeepers and item traders are automatically detected, and only they, blacksmiths, and GENERAL (a `catch-all` default) have `auto-assign` support. But I provided a ton of IT_TYPE choices, and you can easily write your own cases in IT_AssignTypesToTrader(), using BLACKSMITH as an example.

Traders and towns both share the same structure.
thing.itemtrade is the parent.
Then itemtrade.qty and .price for global scalars.
Traders also have itemtrade.quality. Note that items have itm.quality, not itm.itemtrade.quality!
itemtrade.types is the list of types (t0 through tX for types, i0 through iX for item IDs).

Items have a shortened structure. itm.types, and each type is set to true. (if not of a type, leave the type out, don't set it to false). They do _not_ have an itm.itemtrade.* tree!

Structure
thing.itemtrade.types.tqty = X, where X is the number of type attributes (they will be t0 through t(`X-1`). iqty is for item IDs.
thing.itemtrade.types.iX or tX: (where X is the number)
*.qty = mult for qty
*.price = mult for price
*.quality = change in quality for that type (i.e. -1 means `trader_quality-1` is the quality to use for this item type)

Qty of 0 means not traded (if you want the trader not to stock the item but still _buy_ them, set qty to 0.000001 or something).
Qty of < 0 means contraband.

Traders also have ch.itemtrade.size, a multiplier of storesize. This is in addition to qty, and works independently of rarity.
I think I probably should have made rarity and qty separate at the beginning...

Each time you trade with a trader (not just windowshop but buy/sell) a counter gets incremented. Once the counter reaches 10 x (trader's current quality), the trader's quality increments by 1 (to a max of 10), and the trader's item stats are then recalculated.

Traders that have been talked to and given items have their IDs placed on an update list { ShipLookupTable.itemtraders.(ch.id) } and this tells the game whom to update each day.
If you remove a trader, make sure you also DeleteAttribute(&ShipLookupTable,"itemtraders."+ch.id);
If you only want the trader to not update for a while, do: string tmpstr = ch.id; ShipLookupTable.(tmpstr) = false;
And set back to true when you want updates to resume.

Item quality of 0 (itm.quality == 0) means ignore quality for rareness/qty calcs.

Instead of setting a type for general and qty -1, use itm.skipgeneral = true (for items) or ch.itemtrade.skiptype.general (for traders, see below) to skip general type

For a trader to obey a town's `not-trade`-items list, the trader must _not_ be set to skip town mults!

Traders may have the following flags:
ch.itemtrade.skiptown will skip changing qty, price, and qual by town.
{Note that this will skip both town size based effects but also town itemtype based effects}
.skiptype.town will skip adding the Town item type (for items that are sold more or less in certain towns--CCC suggested restricting artifacts this way).
.skiptype.island ditto
.skiptype.nat ditto, for nations
{Note, otherwise town, item, and nation types will be added, with the stats defined by their respective IT_AssignXXXType() functions.}
skiptype.general means trader will not sell items of general type.

Almost everything is tweakable by the IT_ defines in BuildSettings.h

New item property: skipsell. If true, trader will only buy item, not sell, and item will be put in ch.itemtrade.itemlist.buyonly.(id) rather than *.items.(id).
If skipsell, item _may_ have property itm.replacewith, and when trader buys a skipsell item, it will be replaced the next day with the replacewith item.

New item property: replacewith. Does not default to anything. Used in the case where an item is set skipsell = true (or is otherwise not carried by the trader); on getting such an item it is replaced with an item of id olditem.replacewith (assuming olditem.replacewith exists).
This is done right now for `less-than`-average weapons.
 
Alan, I just changed it (again). <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
But for you! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />

Now you can be selective with your smiths.

All you need do is, for your smiths:
Set
ch.itemtrade.tradetype = IT_TYPE_BLACKSMITH;

if they do everything smithlike, or (pick one) BLADE_ITEM_TYPE, or GUN_ or ARMOR_ if they only do one of those. (that is to say, ch.itemtrade.tradetype = BLADE_ITEM_TYPE; not IT_TYPE_BLADE!, and so with gun and armor).

For the apothecary, I'll need to create a new case; but you do him via dialog, right? (or at least manually assign the items).

Oh, and find the file items_utilite.c on the FTP and grab it, or just regrab the whole itemtrade.zip archive, for these changes.
 
Nathan, this will be added to the B12 update, yes?

Which means my sneaky trader will be able to take advantage of this?

Because I need him to have items no other merchant will carry - I'd like them to be exclusive to him; and be a random selection like the merchants, so you'll never know which items you'll find when you talk to the guy... Will that work, with this? I haven't had much time to follow this, but I think that's what you're saying, right? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" />
 
Are we forcing a restart or not for 12.2?
I think we should go with a relatively minimal update (just bugfixes and maybe a bit of content / new code), and do the restart and new stuff for 13.
But also release a "early adopters edition" of 12.2 plus the `restart-requiring` parts of 13 _real soon_, so people who restart now will not have to then.

I _think_ I've oversized all the arrays...

Yes, it will, sneakytrader is one of the things this was designed around (that is, for).
You assign him, in his ch define, ch.itemtrade.tradetype = IT_TYPE_SNEAKY.
I wrote the `auto-assign` code in IT_AssignTypes to recognize that type automatically.
You probably also want to set the ch.itemtrade.skiptown = true; so that the trader(s)'s rarity and price calcs are not affected by town size.

Um. Here's the full rundown of stuff I think you want:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->ch.itemtrade.tradetype = IT_TYPE_SNEAKY;

ch.itemtrade.quality = 10;

//Note that if an item has quality of 0 relative qual will be ignored for rarity calcs.

//The `auto-detection` will set these flag true, but just to be sure...

ch.itemtrade.skiptype.town = true; // Will not add selling of type (trader's town).

ch.itemtrade.skiptype.island = true; // ditto

ch.itemtrade.skiptype.nat = true; // ditto

ch.itemtrade.skiptype.general = true; // ditto

// **** multipliers:

ch.itemtrade.qty = 1.0; // 1.0 means rarity * 1.0 = chance for item to appear.

// Up this to increase that chance.



ch.itemtrade.size = 1.0; // if size < 1.0, then we will only add item if

// frnd() < size. This is a way to simulate smaller stores, irrespective of rarity.



ch.itemtrade.price = 1.0; // price multiplier.

ch.itemtrade.pricebuyratio = 0.1; // or whatever you want the ratio to be for buying back items.



ch.itemtrade.pricenoskill = true; // this is to prevent pchar skill and perks from having an

// effect on price.If you _do_ want them to have an effect (at 1 comm and no skill it's

// circa 1.5/0.5, right?) leave this flag unset.<!--c2--></div><!--ec2-->

Also, for every sneakytrade item, set:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->itm.skiptrade = false;

itm.skipsell = false;

itm.skipgeneral = true;

itm.types.(IT_TYPE_SNEAKY) = true;

itm.maxquantity = 1;

itm.quality = 0;<!--c2--></div><!--ec2-->

And that's it! Set the rarity as you like.
 
Heh, my writing that reply is making me realize I forgot some stuff (notably the pricebuyratio and pricenoskill flags...and some other stuff). So it'll be a bit before I `re-up` the archive.
 
No, we should go as you suggest for 12.2.

THANK YOU, Nathan! This is just what I've needed... You de MAN! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/bow.gif" style="vertical-align:middle" emoid=":bow" border="0" alt="bow.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />
 
NK: aha, now I've smoked it. Splendid; I'd just asked about variable smith repair skills in a different thread before reading this.
 
Cat: Aw, shucks. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/oops3.gif" style="vertical-align:middle" emoid=":eek:ops2" border="0" alt="oops3.gif" />
Thankee. :]

Re: 12.2--I have a 12.2 base sitting around--Fred Bob helped me through figuring out branching on the server--so I'll try and plop in all the fixes I can remember adding.

Alan: Looked at the blacksmith dialog(s), noticed they're all the same except for for the H side, and the specified can'`t-repair` thing.
So I had a thought. Why not make only 1 c file and 6 H files? I'll add some code to handle that (a second dialog.filename attribute for the H) and a hook in the C file to see which level he can't repair to (or see below, you may not want that any more).
Then you assign just one C file.

<!--`QuoteBegin-alan_smithee`+--><div class='quotetop'>QUOTE(alan_smithee)</div><div class='quotemain'><!--QuoteEBegin-->NK: If the new system is flexible enough, and I suspect it is, I'd like the blacksmiths to have different strengths and weaknesses... they'd all do swords, but only a few could do armour* or pistols or both.

* is armour gonna stay the way it is, with only the visibly armoured soldier characters, or will it be an item again (worn, ehm, under the clothes) like in previous builds?[/quote]

I added it back as invisible* for now, so I could use armorers. (But there's a toggle for it, like everything else...).
*in addition to the visible kinds.
Actually, the armor stats were inverted; the TYPEfrac stats are lower = better, not higher=better, and somewhere along the line they got reversed. Fixed now.

In fact, we probably should add `quality-based` armor too.

Sure you can do that; What we could do is, in the dialog, check for which types the trader has. Then allow only the repair options for the types. Plus I can add a hook for "maxrepairlevel"--or maybe do it based on quality?*
And also the skiprepairlevel if you still want that.

*Qual is `1-10` inclusive. So how about maxrepairlevel = bladequal *2 - 3, so qual 1 can repair to worn, 3 to average, then 5, 7. 9.
And this should not be dependent on town quality, but it _should_ be on itemtype quality (i.e. a smith with a +1 quality bonus for swords (or +2 for swords of his/her nation) should get that bonus on maxrepairlevel check).
Also, right now, traders have a kind of XP system for quality. +1XP per trade, and when they reach (current quality) * 10 XP they "level up" and the counter gets reset to 0.
Do you want smiths to do this too?
 
NK: one c file sounds good. And yes to a better way to vary their repair skills... it's sort of a clumsy way I did that, just as an afterthought, and I know it's caused a few people a few problems. (All the code is RobC's, don't forget, so I've little idea how it works... I only `half-assedly` adapted it to my own purposes.)

I also like the idea of them leveling up... would they do it depending on how much buisiness you give them? That's good because it would also prevent them from being able to fix you up a perfect sword right away, but that'd come later with time when you're at a higher level.
 
"would they do it depending on how much buisiness you give them?"
Yep, the trade count would increase one per trade*, but also 1 per repair (well, +whatever you want, not necessarily +1).

*Well, 1 per trading _session_. No +10 if you buy 10 items, it's still +1; and if you windowshop, no increase.

I've added the itemtrade section to the Dialogs, but haven't got off Oxbay yet to test. I'll make sure that works, then add the rest.
Would you like a simple "Show me your wares" and bingo itemtrade, or do you want the smith to say a response and the pchar a response, before opening itemtrade?
(Right now you go straight to trade from choosing the "Show me" link).
 
Since it's done in dialog, we have multiple options at the same time... Though they should greet you at first like the other shopkeeps, maybe get your name; then the second time, sure, you can launch right into business after they greet you.*
(And so, you're giving blacksmiths a sword/gun/armour selling ability, in addition to repair? [= second dialog option at first response on subsequent meetings])

*kind of odd I think sometimes how all the dialogs are initiated by NPCs and never the player...
 
Ah, I wasn't clear. What I mean is launch straight into _the IT interface_ on choosing the "show me your wares" option.
Or do you want the Blacksmith to say something when you ask to see their wares, and then you respond? And only _then_ launch the interface?
{I.e. "Sure, let me put down my hammer and tongs and I'll show you what I have."}

As distinct from the upgrade interface, which yes is in dialog.
 
Ah, I see. Nope, not necessary. He'd just say, "Right, lemme just set down my hammer and tongs," and I'd be all, "Yeah just be quick about it bub," and anyway there's enough dialog to scroll through already.

Still and all, will it be blacksmiths selling weapons or a different sort of weapon-seller, whom I feel like installing in only a few key locations, pirate and smugler, and even then kind of hidden behind some doors? I think what I picture here is maybe the stores can sell a few basic cheap-ass weapons, and the blacksmiths maybe a few more, and then it's the weapons sellers you can get muskets, musketoons, powerful swords and etc. from. And anyway that sounds do-able with different trader-specific item commands.
 
1. OK, great.
2. Yup, that's quite doable. Either create the type by hand in his/their character define(s), or set to a type and add a case in IT_AssignTypes.
 
Few things I noticed on item trading while just beginning the tutorial:
- I can't buy the spyglass I have to buy for the tutorial from the traders (the common spyglass)
- When scrolling through all available items, the scrolling staggers as if the computer's really busy with something
- The traders have a lot of really good items; I reckon they should sell almost nothing but crap in the beginning of the game. Or make sure you can't afford it yet in the very beginning.
- Gregor Samsa has a ridiculous amount of top-notch items for ridiculous prices (35000 for a musketoon, anyone?)

Hope something can be done about this. Otherwise: Seems like we're getting quite an improvement here! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" />
 
Looks like there are still some major bugs with the item trading:
- Some traders don't have anything at all for sale (and have an amount of 0 gold with which they can buy your stuff)
- Some traders have ridiculous amounts of the best stuff available in the 10000-50000 price range (happened to me with the Redmond blacksmith)
- Almost all traders have a big lot of stuff available. Even though there are no (badly) worn items for sale anymore, it's even more to scroll through
- Seems like all the amounts of money have greatly increased. In the beginning of the game, I already have 10000's of money. Prices have also greatly increased
- Somehow, I have not yet encountered any enemies in towns; would've expected these to show up already. Haven't paid attention to CCC-type citizens being there. Normal citizens are there and also talk (which I had managed to disable by attempting to install CCC's most recent modding).
 
Great catches, Pieter! Thanks! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />
------------------
- I can't buy the spyglass I have to buy for the tutorial from the traders (the common spyglass)
Huh. You mean, it's not showing up in their list of stuff?
Ah, wait. I know why. I've given it to them, but it doesn't show in the interface because it's probably not the right quality level. Let me fix that.

- When scrolling through all available items, the scrolling staggers as if the computer's really busy with something
That's odd, it shouldn't have to do so much then (it pre-calculates most everything). Well, it checks item price against a town multiplier, so maybe that's it...Ah, I can rewrite that so it only gets it once, on loading the interface...
- The traders have a lot of really good items; I reckon they should sell almost nothing but crap in the beginning of the game. Or make sure you can't afford it yet in the very beginning.
Yeah, I basically threw out the minlevel attribute and replaced it with trader quality--i.e. if a trader has the item for sale and you can pay for it, fine. Minlevel's still used for randitems though IIRC.

But that's not a decision to take lightly, and we ought to discuss & decide...

- Gregor Samsa has a ridiculous amount of top-notch items for ridiculous prices (35000 for a musketoon, anyone?)
He's set to quality 10, is why, I think. Again, D&D time--I think he needs more flavor than as just a walking merchant, but giving him super-quality stuff is probably not the answer.
Maybe we can make him some special type of high quality but _very_ limited qty and chance for an _individual_ item? I.e. sure it's qual10, but he'll only ever have _1_ qual10 item at a time...?

- Some traders don't have anything at all for sale (and have an amount of 0 gold with which they can buy your stuff)
Do you know where this happened? Do you have a save nearby?

- Some traders have ridiculous amounts of the best stuff available in the 10000-50000 price range (happened to me with the Redmond blacksmith)
Qual10, right? So we should make quality a curve rather than a linear rand() probably...

- Almost all traders have a big lot of stuff available. Even though there are no (badly) worn items for sale anymore, it's even more to scroll through
Yeah. We can try decreasing itemtrade.size all 'round--or maybe use a better algorithm than I used...

- Seems like all the amounts of money have greatly increased. In the beginning of the game, I already have 10000's of money. Prices have also greatly increased
Speaking of D&D...we really do need to go over everything and rationalize prices (goods vs. ships. vs. items, and the differences in each category between individual things. And payscales.)

- Somehow, I have not yet encountered any enemies in towns; would've expected these to show up already. Haven't paid attention to CCC-type citizens being there. Normal citizens are there and also talk (which I had managed to disable by attempting to install CCC's most recent modding).
Hmm. Because I know I have, so they're not completely off...Maybe I tweaked a VC setting by mistake, and uploaded that in my BS.h?
 
Back
Top