|
| 1 | +# Treasure Sets |
| 2 | + |
| 3 | +Treasure Sets are templates (located in `Templates/Treasure`) that are used to define NPC weapon loadouts, NPC plunder/pickpocket/trade inventories, and the contents of chests. |
| 4 | +Up to five treasure sets can be assigned to an NPC via the `TreasureSet1` to `TreasureSet5` properties of its `gCInventory_PS` property set. |
| 5 | + |
| 6 | +## Plunder Inventory |
| 7 | + |
| 8 | +### gETreasureDistribution_Plunder |
| 9 | +```text |
| 10 | +TransferStacks = Random selection from the interval [MinTransferStacks, MaxTransferStacks] |
| 11 | +
|
| 12 | +If TransferStacks < 1: |
| 13 | + TransferStacks = 1 |
| 14 | +
|
| 15 | +Repeat TransferStacks times: |
| 16 | + Stack = Select a random stack from the TreasureSet |
| 17 | +
|
| 18 | + If Stack.Amount > 1: |
| 19 | + Amount = Random selection from the interval [Stack.Amount / 2, Stack.Amount] |
| 20 | + Otherwise: |
| 21 | + Amount = Stack.Amount |
| 22 | +
|
| 23 | + Inventory.Add(Stack.Template, Amount, GetCombinedQuality(Stack), gEStackType_Treasure) |
| 24 | +``` |
| 25 | + |
| 26 | +### gETreasureDistribution_Unique |
| 27 | +```text |
| 28 | +Stack = Stack with the lowest gold value among all stacks of the TreasureSet that are not yet marked as already generated |
| 29 | +
|
| 30 | +If all stacks are already marked as generated: |
| 31 | + Stack = Random stack from the TreasureSet |
| 32 | +
|
| 33 | +If Stack.Amount > 1: |
| 34 | + Amount = Random selection from the interval [Stack.Amount / 2, Stack.Amount] |
| 35 | +Otherwise: |
| 36 | + Amount = Stack.Amount |
| 37 | +
|
| 38 | +Inventory.Add(Stack.Template, Amount, GetCombinedQuality(Stack), gEStackType_Treasure) |
| 39 | +
|
| 40 | +Mark Stack as generated |
| 41 | +``` |
| 42 | + |
| 43 | +### gETreasureDistribution_Trophy |
| 44 | +```text |
| 45 | +Repeat for each stack: |
| 46 | + If Stack.UseType == gEUseType_TrophyTeeth and the player has NOT learned Perk_TrophyTeeth: |
| 47 | + Skip stack |
| 48 | +
|
| 49 | + If Stack.UseType == gEUseType_TrophyFur and the player has NOT learned Perk_TrophyFur: |
| 50 | + Skip stack |
| 51 | +
|
| 52 | + If Stack.UseType == gEUseType_TrophySkin and the player has NOT learned Perk_TrophySkin: |
| 53 | + Skip stack |
| 54 | +
|
| 55 | + Inventory.Add(Stack.Template, Stack.Amount, GetCombinedQuality(Stack), gEStackType_Treasure) |
| 56 | +``` |
| 57 | + |
| 58 | +### gETreasureDistribution_Mining |
| 59 | +```text |
| 60 | +Repeat for each stack: |
| 61 | + If the player has learned Perk_Mining: |
| 62 | + Amount = 2 * Stack.Amount |
| 63 | + Otherwise: |
| 64 | + Amount = Stack.Amount |
| 65 | +
|
| 66 | + Inventory.Add(Stack.Template, Amount, Stack.Quality, gEStackType_Treasure) |
| 67 | +``` |
| 68 | + |
| 69 | +## Trade Inventory |
| 70 | + |
| 71 | +### gETreasureDistribution_Trade_Generate |
| 72 | +```text |
| 73 | +TransferStacks = Random selection from the interval [MinTransferStacks, MaxTransferStacks] |
| 74 | +
|
| 75 | +Repeat TransferStacks times: |
| 76 | + Stack = Select a random stack from the TreasureSet |
| 77 | +
|
| 78 | + If Stack.Amount > 1: |
| 79 | + Amount = Random selection from the interval [Stack.Amount / 2, Stack.Amount] |
| 80 | + Otherwise: |
| 81 | + Amount = Stack.Amount |
| 82 | +
|
| 83 | + Inventory.Add(Stack.Template, Amount, GetCombinedQuality(Stack), gEStackType_Merchandise) |
| 84 | +``` |
| 85 | + |
| 86 | +### gETreasureDistribution_Trade_Refresh |
| 87 | +```text |
| 88 | +Repeat for each stack: |
| 89 | + If Stack.Amount > 1: |
| 90 | + Amount = Random selection from the interval [Stack.Amount / 2, Stack.Amount] |
| 91 | + Otherwise: |
| 92 | + Amount = Stack.Amount |
| 93 | +
|
| 94 | + Inventory.Add(Stack.Template, Amount, GetCombinedQuality(Stack), gEStackType_Merchandise) |
| 95 | +``` |
| 96 | + |
| 97 | +### gETreasureDistribution_Trade_NotRandom |
| 98 | +Each stack is generated into the trade inventory in exactly the specified amount. (see also Modder Handbook 1.7.6) |
| 99 | +```text |
| 100 | +Repeat for each stack: |
| 101 | + Inventory.Add(Stack.Template, Stack.Amount, Stack.Quality, gEStackType_Merchandise) |
| 102 | +``` |
| 103 | +## Pickpocket Inventory |
| 104 | + |
| 105 | +### gETreasureDistribution_Pickpocket |
| 106 | +```text |
| 107 | +Stack = Select a random stack |
| 108 | +
|
| 109 | +Inventory.AddAndEquip(Stack.Template, Stack.Amount, Stack.Quality, gEStackType_Normal) |
| 110 | +``` |
| 111 | + |
| 112 | +## Weaponry |
| 113 | + |
| 114 | +### gETreasureDistribution_Weaponry |
| 115 | +```text |
| 116 | +Repeat for each stack: |
| 117 | + Quality = Stack.Quality |
| 118 | + if ( Stack.UseType != gEUseType_Arrow and Stack.UseType != gEUseType_Bolt ) |
| 119 | + Quality |= gEItemQuality_Worn; |
| 120 | + Inventory.AddAndEquip(Stack.Template, Stack.Amount, Quality, gEStackType_Normal) |
| 121 | +``` |
| 122 | + |
| 123 | +Min/MaxTransferStacks do not matter for Weaponry treasure sets. The engine simply processes the full list of stacks contained in the TreasureSet. Also note, that only the first Weaponry treasure set is considered. |
| 124 | + |
| 125 | +If alternative balancing is enabled, once an NPC has been defeated by the hero (`PSNpc::DefeatedByPlayer == true`), that NPC's weaponry is no longer derived from its TreasureSets, but instead the NPC receives a standard weapon that depends on its species (Orc or Human) and political alignment. |
| 126 | + |
| 127 | + |
0 commit comments