@ -189,7 +189,7 @@ void ItemInfo::InitializeItems(){
enhancementStats . SetAttribute ( enhancementLevel , attr , dat . GetReal ( attrIndex ) ) ;
attrIndex + + ;
}
std : : vector < std : : pair < IT , int > > itemsRequired ;
std : : vector < ItemPair > itemsRequired ;
uint32_t goldCost = 0 ;
if ( enhancementLevel ! = 0 ) { //The first level does not require any crafting, skip this level.
while ( data [ key ] [ " Crafting " ] [ std : : format ( " Level[{}] " , enhancementLevel ) ] . HasProperty ( std : : format ( " Item[{}] " , itemsRequired . size ( ) ) ) ) {
@ -222,7 +222,7 @@ void ItemInfo::InitializeItems(){
}
if ( data [ key ] . HasProperty ( " Crafting " ) & & ! data [ key ] [ " Crafting " ] . HasProperty ( " Level[1] " ) ) {
std : : vector < std : : pair < IT , int > > itemsRequired ;
std : : vector < ItemPair > itemsRequired ;
uint32_t goldCost = 0 ;
uint8_t availableChapter = 1 ;
//If the item has a key called "Crafting" but did not specify a level number, then we assume this item just has one base level for normal crafting and thus we will add the requirements to craft this item under enhancement level 1.
@ -357,7 +357,7 @@ std::string ItemProps::GetStringProp(const std::string&prop,size_t index)const{
const uint32_t ItemProps : : PropCount ( const std : : string & prop ) const {
if ( customProps - > HasProperty ( prop ) ) return ( * customProps ) [ prop ] . GetValueCount ( ) ;
else return ( * scriptProps ) [ prop ] . GetValueCount ( ) ;
else return uint32_t ( ( * scriptProps ) [ prop ] . GetValueCount ( ) ) ;
}
void ItemInfo : : InitializeScripts ( ) {
@ -367,7 +367,7 @@ void ItemInfo::InitializeScripts(){
int restoreAmt = props . GetIntProp ( propName ) ;
action ( game , restoreAmt ) ;
if ( restoreAmt > 0 & & props . PropCount ( propName ) = = 3 ) {
game - > GetPlayer ( ) - > AddBuff ( RESTORATION , props . GetFloatProp ( propName , 2 ) , restoreAmt , props . GetFloatProp ( propName , 1 ) , action ) ;
game - > GetPlayer ( ) - > AddBuff ( RESTORATION , props . GetFloatProp ( propName , 2 ) , float ( restoreAmt ) , props . GetFloatProp ( propName , 1 ) , action ) ;
}
} ;
ParseItemScriptData ( " HP Restore " , [ & ] ( AiL * game , int restoreAmt ) {
@ -404,7 +404,7 @@ void ItemInfo::InitializeScripts(){
int restoreAmt = props . GetIntProp ( propName ) ;
action ( game , restoreAmt ) ;
if ( restoreAmt > 0 & & props . PropCount ( propName ) = = 3 ) {
game - > GetPlayer ( ) - > AddBuff ( RESTORATION_DURING_CAST , props . GetFloatProp ( propName , 2 ) , restoreAmt , props . GetFloatProp ( propName , 1 ) , action ) ;
game - > GetPlayer ( ) - > AddBuff ( RESTORATION_DURING_CAST , props . GetFloatProp ( propName , 2 ) , float ( restoreAmt ) , props . GetFloatProp ( propName , 1 ) , action ) ;
}
} ;
ParseItemScriptData ( " HP Restore " , [ & ] ( AiL * game , int restoreAmt ) {
@ -658,8 +658,11 @@ const std::string Item::Description(CompactText compact)const{
}
description + = ' \n ' ;
description + = GetStats ( ) . GetStatsString ( Stats : : NO_MAX_HIGHLIGHT , compact ) ;
if ( ItemSet ( ) ) {
const : : ItemSet * const set = ItemSet ( ) . value ( ) ;
std : : optional < const : : ItemSet * const > setOpt = ItemSet ( ) ;
if ( setOpt ) {
const : : ItemSet * const set = setOpt . value ( ) ;
if ( compact = = COMPACT ) {
description + = " \n " + set - > GetSetName ( ) + " Set - " ;
} else {
@ -688,7 +691,7 @@ const std::string Item::Description(CompactText compact)const{
size_t enhanceIndex = std : : min ( EnhancementLevel ( ) + 1 , " Item.Item Max Enhancement Level " _I ) ;
if ( IsEquippable ( ) & & Inventory : : GetItemCount ( ActualName ( ) ) = = 0 ) enhanceIndex = 0 ;
const EnhancementLevelInfo & info = GetEnhancementInfo ( ) [ enhanceIndex ] ;
const EnhancementLevelInfo & info = GetEnhancementInfo ( ) [ int ( enhanceIndex ) ] ;
for ( const auto & [ name , amt ] : info . craftingRequirement . GetItems ( ) ) {
description + = std : : format ( " {}{} x{} ({}) \n " ,
Inventory : : GetItemCount ( name ) < amt ? " #FF0000 " : " #FFFFFF " ,
@ -818,14 +821,14 @@ const std::optional<const ItemSet *const>ItemInfo::ItemSet()const{
} ;
const Stats & ItemSet : : operator [ ] ( int setPieces ) const {
if ( setPieces < = 0 | | setPieces > = 9 ) ERR ( " Piece count is invalid! Expecting a value (1-8) but got " < < setPieces ) ;
return setBonuses [ setPieces ] ;
if ( setPieces - 1 < = - 1 | | setPieces - 1 > = setBonuses . size ( ) ) ERR ( " Piece count is invalid! Expecting a value (1-8) but got " < < setPieces ) ;
return setBonuses [ setPieces - 1 ] ;
} ;
void ItemSet : : AddSetBonus ( std : : string setName , int pieceCount , Stats & bonuses ) {
if ( pieceCount < = 0 | | pieceCount > = 9 ) ERR ( " Piece count is invalid! Expecting a value (1-8) but got " < < pieceCount ) ;
if ( pieceCount - 1 < = - 1 | | pieceCount - 1 > = sets [ setName ] . setBonuses . size ( ) ) ERR ( " Piece count is invalid! Expecting a value (1-8) but got " < < pieceCount ) ;
sets [ setName ] . name = setName ;
for ( int i = pieceCount ; i < sets [ setName ] . setBonuses . size ( ) ; i + + ) {
for ( int i = pieceCount - 1 ; i < sets [ setName ] . setBonuses . size ( ) ; i + + ) {
sets [ setName ] . setBonuses [ i ] + = bonuses ;
}
sets [ setName ] . setBonusBreakpoints . push_back ( { pieceCount , bonuses } ) ;
@ -1078,7 +1081,7 @@ void Stats::InitializeDamageReductionTable(){
}
}
void EnhancementInfo : : SetCraftingRequirements ( const int enhanceLevel , const std : : vector < std : : pair < IT , int > > & requiredItems , const uint32_t goldCost , const uint8_t availableChapter ) {
void EnhancementInfo : : SetCraftingRequirements ( const int enhanceLevel , const std : : vector < ItemPair > & requiredItems , const uint32_t goldCost , const uint8_t availableChapter ) {
while ( craftingRequirements . size ( ) < = enhanceLevel ) {
craftingRequirements . push_back ( CraftingRequirement ( { } , 0 , availableChapter ) ) ;
}