MCPcopy Create free account
hub / github.com/TurningWheel/Barony / createCustomInventory

Function createCustomInventory

src/items.cpp:6289–6403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6287}
6288
6289void createCustomInventory(Stat* const stats, const int itemLimit, BaronyRNG& rng)
6290{
6291 int itemSlots[6] = { ITEM_SLOT_INV_1, ITEM_SLOT_INV_2, ITEM_SLOT_INV_3, ITEM_SLOT_INV_4, ITEM_SLOT_INV_5, ITEM_SLOT_INV_6 };
6292 int i = 0;
6293 Sint32 itemId = -1;
6294 int itemAppearance = rng.rand();
6295 int category = 0;
6296 bool itemIdentified;
6297 int itemsGenerated = 0;
6298 int chance = 1;
6299
6300 if ( stats != nullptr )
6301 {
6302 for ( i = 0; i < 6 && itemsGenerated <= itemLimit; ++i )
6303 {
6304 category = stats->EDITOR_ITEMS[itemSlots[i] + ITEM_SLOT_CATEGORY];
6305 if ( category > 0 && stats->EDITOR_ITEMS[itemSlots[i]] == 1 )
6306 {
6307 if ( category > 0 && category <= 13 )
6308 {
6309 itemId = itemLevelCurve(static_cast<Category>(category - 1), 0, currentlevel, rng);
6310 }
6311 else
6312 {
6313 int randType = 0;
6314 if ( category == 14 )
6315 {
6316 // equipment
6317 randType = rng.rand() % 2;
6318 if ( randType == 0 )
6319 {
6320 itemId = itemLevelCurve(static_cast<Category>(WEAPON), 0, currentlevel, rng);
6321 }
6322 else if ( randType == 1 )
6323 {
6324 itemId = itemLevelCurve(static_cast<Category>(ARMOR), 0, currentlevel, rng);
6325 }
6326 }
6327 else if ( category == 15 )
6328 {
6329 // jewelry
6330 randType = rng.rand() % 2;
6331 if ( randType == 0 )
6332 {
6333 itemId = itemLevelCurve(static_cast<Category>(AMULET), 0, currentlevel, rng);
6334 }
6335 else
6336 {
6337 itemId = itemLevelCurve(static_cast<Category>(RING), 0, currentlevel, rng);
6338 }
6339 }
6340 else if ( category == 16 )
6341 {
6342 // magical
6343 randType = rng.rand() % 3;
6344 if ( randType == 0 )
6345 {
6346 itemId = itemLevelCurve(static_cast<Category>(SCROLL), 0, currentlevel, rng);

Callers 15

initMonsterSFunction · 0.85
initMonsterMFunction · 0.85
initMonsterGFunction · 0.85
initGoblinFunction · 0.85
initImpFunction · 0.85
initMinotaurFunction · 0.85
initVampireFunction · 0.85
initSentryBotFunction · 0.85
initGyroBotFunction · 0.85
initDummyBotFunction · 0.85
initScorpionFunction · 0.85
initAutomatonFunction · 0.85

Calls 3

itemLevelCurveFunction · 0.85
randMethod · 0.80
newItemFunction · 0.70

Tested by

no test coverage detected