Difference between revisions of "Merchants"

From Caves of Qud Wiki
Jump to: navigation, search
(Created page with "{{As Of Patch|2.0.185.1}} Merchants are NPCs that sell their goods and restock on a semi random basis. ==Restocking== Merchants restock randomly according to their Chance and...")
 
 
(14 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{As Of Patch|2.0.185.1}}
+
{{As Of Patch|2.0.200.89}}
Merchants are NPCs that sell their goods and restock on a semi random basis.
+
Merchants are NPCs that sell their goods and restock on a semi random basis. The first one the player will see (if the player chooses to start in {{favilink|Joppa}}) will be {{favilink|Tam}}. For other villages with procedurally generated [[village merchant]]s, they will be {{qud text|&Wyellow}} and have a bonus +3 to [[Ego]].
  +
==Restocking==
+
== Restocking ==
Merchants restock randomly according to their Chance and Restock Frequency. LastRestockTick is the last ingameTick that they have refreshed their wares. Currently, Chance is specified as 71, and RestockFrequency is 5 ingame days, or 6,000 ticks. It calls [[Modding: Random Functions|Stat.Random()]] to find a random integer between half the restock frequency and the restock frequency:<ref>XRL.World.Parts.GenericInventoryRestocker</ref>
 
  +
  +
Merchants do not keep their wares: they rotate their stock around every 5 to 8 in game days(for more detailed math, view [[#In depth restocking formula]]). When a merchant restocks, their trading inventory is refreshed and new items will repopulate the inventory. These items will generally be of similar tier and type as the initial stock.
  +
  +
For how the trading system works, check [[Commerce]].
  +
 
== Legendary Merchants ==
  +
 
Merchants have a chance of spawning Legendary Merchants, loyal to the [[Merchants' Guild]]. They live in their own lairs, and are always guarded by two random hired guards. All stock will contain the Maker's Mark of the Merchant, which is a random [[Modding: Code page 437|Code page 437]] character from 1-254 (in decimal) excluding all alphanumerics, &, ^, and white space.{{Code Reference | namespace = XRL.World.ZoneBuilders | class = HeroMaker | method = MakeHero}}
  +
  +
== In-depth Restocking Formula ==
  +
 
Merchants restock randomly according to their Chance and Restock Frequency. LastRestockTick is the last ingameTick that they have refreshed their wares. Currently, Chance is specified as 71, and RestockFrequency is 5 ingame days, or 6,000 ticks. It calls [[Modding:Random Functions|<code>Stat.Random()</code>]] to find a random integer between half the restock frequency and the restock frequency:{{Code Reference | class = GenericInventoryRestocker}}
   
 
When the merchant is first created, LastRestock tick is set to
 
When the merchant is first created, LastRestock tick is set to
   
<math>\text{LastRestockTick} = \text{TickOnCreation} + \text{RandomInt}(\frac{RestockFrequency}{2}, RestockFrequency)</math>
+
<math>\text{LastRestockTick} = \text{TickOnCreation} + \text{Random}( \frac{RestockFrequency}{2}, RestockFrequency)</math>
   
 
which substitutes to
 
which substitutes to
   
<math>\text{LastRestockTick} = \text{TickOnCreation} + \text{RandomInt}(3000, 6000)</math>
+
<math>\text{LastRestockTick} = \text{TickOnCreation} + \text{Random}(3000, 6000)</math>
   
  +
Every EndTurn, this is called:
If the current in game turn count-LastRestockTick is greater than RestockFrequency, LastRestockTick is set to equal the current GameTick.
 
  +
 
If the current in game turn count-LastRestockTick is greater than RestockFrequency, LastRestockTick is set to equal the current GameTick.
   
 
<math>\text{num1} = \text{InGameTurn} - \text{LastRestockTick} \ge 6000</math> <math>\rightarrow</math>
 
<math>\text{num1} = \text{InGameTurn} - \text{LastRestockTick} \ge 6000</math> <math>\rightarrow</math>
Line 19: Line 33:
 
<math>\rightarrow</math>
 
<math>\rightarrow</math>
   
If <math>\text{RestockCheck} \ge 100</math> or <math>\text{RestockCheck} \ge \text{RandomInt}(1,100)</math>,
+
If <math>\text{RestockCheck} \ge 100</math> or <math>\text{RestockCheck} \ge \text{Random}(1,100)</math>,
   
 
the merchant will restock. This means that about 8450-8451 turns (a little more over an ingame week) after the last restock must pass in order to guarantee a restock. The earliest that a merchant can restock is 6,000 turns, with a 71% chance of restocking, or 9,000 turns at a 100% restock if this is the first time the merchant restocks.
 
the merchant will restock. This means that about 8450-8451 turns (a little more over an ingame week) after the last restock must pass in order to guarantee a restock. The earliest that a merchant can restock is 6,000 turns, with a 71% chance of restocking, or 9,000 turns at a 100% restock if this is the first time the merchant restocks.
Line 25: Line 39:
 
If a merchant is holding a quest item, they will not destroy the quest item during restock. any other item that contains the tag <code>norestock</code> will also not be restocked. Merchants that are following the player do not restock, and if the player is also a merchant via [[Domination]], they will not restock.
 
If a merchant is holding a quest item, they will not destroy the quest item during restock. any other item that contains the tag <code>norestock</code> will also not be restocked. Merchants that are following the player do not restock, and if the player is also a merchant via [[Domination]], they will not restock.
   
  +
== Trade Prices ==
==Legendary Merchants==
 
  +
Trade prices in {{gamename}} are variable, and depend on a number of factors, including the player's [[Modifier|Ego modifier]] and their [[reputation]] with the merchant.
Merchants have a chance of spawning Legendary Merchants, loyal to the [[Merchants' guild]]. They live in their own lairs, and are always guarded by two random hired guards. All stock will contain the Maker's Mark of the Merchant, which is a random [[Modding: Code page 437|Code page 437]] character from 1-254 (in decimal) excluding all alphanumerics, &, ^, and white space.<ref>XRL.World.ZoneBuilders.HeroMaker.MakeHero()</ref>
 
  +
  +
For more details about trade prices, refer to the [[commerce]] page.
   
[[Category:NPCs]]
+
[[Category:Mechanics]]
 
==References==
 
==References==

Latest revision as of 20:37, 18 December 2020

This information is reliable as of patch 2.0.200.89. If this is no longer the current patch, you can help by updating it.
As of Patch This information is reliable as of patch 2.0.200.89.

Merchants are NPCs that sell their goods and restock on a semi random basis. The first one the player will see (if the player chooses to start in Ovw joppa.pngJoppa) will be Tam dromad merchant.pngTam, dromad merchant. For other villages with procedurally generated village merchants, they will be yellow and have a bonus +3 to Ego.

Restocking[edit | edit source]

Merchants do not keep their wares: they rotate their stock around every 5 to 8 in game days(for more detailed math, view #In depth restocking formula). When a merchant restocks, their trading inventory is refreshed and new items will repopulate the inventory. These items will generally be of similar tier and type as the initial stock.

For how the trading system works, check Commerce.

Legendary Merchants[edit | edit source]

Merchants have a chance of spawning Legendary Merchants, loyal to the Merchants' Guild. They live in their own lairs, and are always guarded by two random hired guards. All stock will contain the Maker's Mark of the Merchant, which is a random Code page 437 character from 1-254 (in decimal) excluding all alphanumerics, &, ^, and white space.[1]

In-depth Restocking Formula[edit | edit source]

Merchants restock randomly according to their Chance and Restock Frequency. LastRestockTick is the last ingameTick that they have refreshed their wares. Currently, Chance is specified as 71, and RestockFrequency is 5 ingame days, or 6,000 ticks. It calls Stat.Random() to find a random integer between half the restock frequency and the restock frequency:[2]

When the merchant is first created, LastRestock tick is set to

which substitutes to

Every EndTurn, this is called:

If the current in game turn count-LastRestockTick is greater than RestockFrequency, LastRestockTick is set to equal the current GameTick.

If or ,

the merchant will restock. This means that about 8450-8451 turns (a little more over an ingame week) after the last restock must pass in order to guarantee a restock. The earliest that a merchant can restock is 6,000 turns, with a 71% chance of restocking, or 9,000 turns at a 100% restock if this is the first time the merchant restocks.

If a merchant is holding a quest item, they will not destroy the quest item during restock. any other item that contains the tag norestock will also not be restocked. Merchants that are following the player do not restock, and if the player is also a merchant via Domination, they will not restock.

Trade Prices[edit | edit source]

Trade prices in Caves of Qud are variable, and depend on a number of factors, including the player's Ego modifier and their reputation with the merchant.

For more details about trade prices, refer to the commerce page.

References[edit | edit source]

  1. XRL.World.ZoneBuilders.HeroMaker, method MakeHero
  2. XRL.World.Parts.GenericInventoryRestocker