Skip to content

Commit ce516e2

Browse files
authored
[G3] Document inventory and treasure sets (#164)
1 parent 7221acc commit ce516e2

2 files changed

Lines changed: 156 additions & 0 deletions

File tree

docs/genome/inventory/index.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Inventory
2+
3+
The `gCInventory_PS` property set manages the inventory of an entity (such as NPC, Hero or chest).
4+
The inventory is a list of inventory stacks (`gCInventoryStack`).
5+
Each inventory stack references a `Template` that is the blueprint for the item contained in the stack.
6+
The `Quality` and `Amount` of the item is also stored as part of the stack.
7+
When an item gets equipped to a slot, a physical object with a 3D mesh, physics, and location is spawned in the world and attached to the holding entity (see `Slot` and `Item`).
8+
The inventory can contain multiple stacks referencing the same template, but with a different quality, equip status or stack type.
9+
10+
Both the category of an item (`gCItem.Category`) and the stack type with which the item gets inserted into the inventory (see also [Treasure Sets](treasure_sets.md)) control in which contexts an inventory stack is visible and usable:
11+
12+
- Regular inventory
13+
- Trade inventory
14+
- Plunder inventory
15+
- Skills
16+
- Spellbook
17+
- ...
18+
19+
## Skills and Spells
20+
The skills and spells that the hero can learn are represented by items in his inventory with the category `gEItemCategory_Spellbook` respectively `gEItemCategory_Skill`.
21+
22+
The `ActivationCount` of a stack is only relevant for stacks containing skills or spells. Its content is related to the `Learned` flag of the stack, because if `ActivationCount` has a value > 0, the skill or spell is activated for the hero.
23+
24+
The difference between the two is important:
25+
26+
- If `Learned` is set to `true`, the hero has permanently learned the skill or spell and can no longer unlearn it.
27+
- The `ActivationCount`, on the other hand, is always increased by 1 when the hero equips an item that grants this skill or spell as a bonus. When the item is unequipped, the counter is decreased by 1 again. If all items are unequipped, the skills are no longer active for the hero.
28+
29+
Since the hero receives his skills, spells, etc. via code at the start of the game, setting the `ActivationCount` or `Learned` flag for a stack is of no practical use.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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

Comments
 (0)