@ -380,16 +380,19 @@ Item::Item(uint32_t amt,IT item,uint8_t enhancementLevel)
void Inventory : : AddItem ( IT it , uint32_t amt , bool monsterDrop ) {
if ( ! ITEM_DATA . count ( it ) ) ERR ( " Item " < < std : : quoted ( it ) < < " does not exist in Item Database! " ) ;
std : : shared_ptr < Item > newItem = ( * _inventory . insert ( { it , std : : make_shared < Item > ( amt , it ) } ) ) . second ;
newItem - > RandomizeStats ( ) ;
if ( ITEM_DATA [ it ] . IsEquippable ( ) ) { //Do not stack equips!
for ( uint32_t i = 0 ; i < amt ; i + + ) {
InsertIntoSortedInv ( ( * _inventory . insert ( { it , std : : make_shared < Item > ( amt , it ) } ) ) . second ) ;
InsertIntoSortedInv ( newItem ) ;
}
goto SkipAddingStackableItem ;
}
else
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
if ( ! _inventory . count ( it ) ) {
InsertIntoSortedInv ( ( * _inventory . insert ( { it , std : : make_shared < Item > ( amt , it ) } ) ) . second ) ;
InsertIntoSortedInv ( newItem ) ;
} else {
auto inventory = _inventory . equal_range ( it ) ;
if ( std : : accumulate ( inventory . first , inventory . second , 0 ,
@ -1050,8 +1053,8 @@ const uint8_t EnhancementInfo::AvailableChapter()const{
const Stats & Item : : RandomStats ( ) const {
return randomizedStats ;
} ;
void Item : : Set RandomStat( const ItemAttribute attr , const float val ) {
randomizedStats . A ( attr ) = val ;
void Item : : Randomize Stats ( ) {
randomizedStats = it - > RandomizeStats ( ) ;
} ;
const Stats ItemInfo : : GetMinStats ( ) const {
@ -1064,7 +1067,11 @@ Stats ItemInfo::RandomizeStats(){
Stats randomRolls ;
for ( auto & [ attr , minVal ] : minStats ) {
float diff = maxStats . A ( attr ) - minVal ;
randomRolls . A ( attr ) = util : : random ( diff ) + minVal ;
if ( attr . ShowAsDecimal ( ) ) {
randomRolls . A ( attr ) = util : : random ( diff ) + minVal ;
} else {
randomRolls . A ( attr ) = floor ( util : : random ( diff + 1 ) + minVal ) ; //We must add 1 because we are going to floor the value to prevent the edges from having half as likely probability as all other numbers.
}
}
return randomRolls ;
}