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

Function itemLevelCurvePostProcess

src/items.cpp:350–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350bool itemLevelCurvePostProcess(Entity* my, Item* item, BaronyRNG& rng, int itemLevel, int* lastItemType, int* lastItemSpellType)
351{
352 if ( !((my && my->behavior == &actItem) || item) )
353 {
354 return false;
355 }
356
357 bool modified = false;
358 itemLevelCurveType = ITEM_LEVEL_CURVE_TYPE_DEFAULT;
359 if ( my )
360 {
361 if ( my->behavior == &actMonster && (my->getMonsterTypeFromSprite() == SHOPKEEPER || my->monsterCanTradeWith(-1)) )
362 {
363 itemLevelCurveType = ITEM_LEVEL_CURVE_TYPE_SHOP;
364 itemLevelCurveShop = my->monsterStoreType;
365 }
366 else if ( my->behavior == &actChest )
367 {
368 itemLevelCurveType = ITEM_LEVEL_CURVE_TYPE_CHEST;
369 }
370 }
371
372 int itemType = (my && my->behavior == &actItem) ? my->skill[10] : item->type;
373 int itemStatus = (my && my->behavior == &actItem) ? my->skill[11] : item->type;
374 if ( itemType >= BRONZE_TOMAHAWK && itemType <= CRYSTAL_SHURIKEN )
375 {
376 // thrown weapons always fixed status. (tomahawk = decrepit, shuriken = excellent)
377 itemStatus = std::min(static_cast<Status>(DECREPIT + (itemType - BRONZE_TOMAHAWK)), EXCELLENT);
378 if ( my && my->behavior == &actItem )
379 {
380 my->skill[11] = itemStatus;
381 }
382 else
383 {
384 item->status = static_cast<Status>(itemStatus);
385 }
386 }
387 if ( itemType == BOLAS )
388 {
389 itemStatus = SERVICABLE;
390 if ( my && my->behavior == &actItem )
391 {
392 my->skill[11] = itemStatus;
393 }
394 else
395 {
396 item->status = static_cast<Status>(itemStatus);
397 }
398 }
399 if ( itemType >= 0 && itemType < NUMITEMS )
400 {
401 if ( items[itemType].category == SPELLBOOK )
402 {
403 //if ( itemLevelCurveType == ITEM_LEVEL_CURVE_TYPE_DEFAULT )
404 {
405 std::vector<std::pair<int, int>> chances;
406 chances.reserve(NUM_SPELLS);
407 std::vector<unsigned int> chanceWeights;

Callers 4

createChestInventoryFunction · 0.85
initShopkeeperFunction · 0.85
assignActionsFunction · 0.85
consolecommand.cppFile · 0.85

Calls 9

getSpellIDFromSpellbookFunction · 0.85
getSpellFromIDFunction · 0.85
getSpellbookFromSpellIDFunction · 0.85
monsterCanTradeWithMethod · 0.80
reserveMethod · 0.80
discreteMethod · 0.80
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected