@ -999,14 +999,14 @@ void CalcPlrBookVals(PlayerStruct &player)
for ( int i = 0 ; i < player . _pNumInv ; i + + ) {
if ( player . InvList [ i ] . _itype = = ITYPE_MISC & & player . InvList [ i ] . _iMiscId = = IMISC_BOOK ) {
player . InvList [ i ] . _iMinMag = spelldata [ player . InvList [ i ] . _iSpell ] . sMinInt ;
int slvl = player . _pSplLvl [ player . InvList [ i ] . _iSpell ] ;
int8_t spel lLe ve l = player . _pSplLvl [ player . InvList [ i ] . _iSpell ] ;
while ( slvl ! = 0 ) {
while ( spel lLe ve l ! = 0 ) {
player . InvList [ i ] . _iMinMag + = 20 * player . InvList [ i ] . _iMinMag / 100 ;
slvl - - ;
spel lLe ve l - - ;
if ( player . InvList [ i ] . _iMinMag + 20 * player . InvList [ i ] . _iMinMag / 100 > 255 ) {
player . InvList [ i ] . _iMinMag = 255 ;
slvl = 0 ;
spel lLe ve l = 0 ;
}
}
player . InvList [ i ] . _iStatFlag = ItemMinStats ( player , & player . InvList [ i ] ) ;
@ -1569,7 +1569,7 @@ void GetStaffSpell(int i, int lvl, bool onlygood)
void GetOilType ( int i , int maxLvl )
{
int cnt = 2 ;
char rnd [ 32 ] = { 5 , 6 } ;
int8_t rnd [ 32 ] = { 5 , 6 } ;
if ( ! gbIsMultiplayer ) {
if ( maxLvl = = 0 )
@ -1584,7 +1584,7 @@ void GetOilType(int i, int maxLvl)
}
}
int t = rnd [ GenerateRnd ( cnt ) ] ;
int8_t t = rnd [ GenerateRnd ( cnt ) ] ;
strcpy ( items [ i ] . _iName , _ ( OilNames [ t ] ) ) ;
strcpy ( items [ i ] . _iIName , _ ( OilNames [ t ] ) ) ;
@ -2524,7 +2524,7 @@ void SpawnItem(int m, Point position, bool sendmsg)
GetSuperItemSpace ( position , ii ) ;
int uper = monster [ m ] . _uniqtype ! = 0 ? 15 : 1 ;
int mLevel = monster [ m ] . MData - > mLevel ;
int8_t mLevel = monster [ m ] . MData - > mLevel ;
if ( ! gbIsHellfire & & monster [ m ] . MType - > mtype = = MT_DIABLO )
mLevel - = 15 ;
@ -3161,7 +3161,7 @@ static bool OilItem(ItemStruct *x, PlayerStruct &player)
}
break ;
case IMISC_OILFORT :
if ( x - > _iMaxDur ! = 255 & & x - > _iMaxDur < 200 ) {
if ( x - > _iMaxDur ! = DUR_INDESTRUCTIBLE & & x - > _iMaxDur < 200 ) {
r = GenerateRnd ( 41 ) + 10 ;
x - > _iMaxDur + = r ;
x - > _iDurability + = r ;
@ -3266,9 +3266,6 @@ void PrintItemOil(char iDidx)
AddPanelString ( tempstr ) ;
break ;
case IMISC_RUNEL :
strcpy ( tempstr , _ ( " sets lightning trap " ) ) ;
AddPanelString ( tempstr ) ;
break ;
case IMISC_GR_RUNEL :
strcpy ( tempstr , _ ( " sets lightning trap " ) ) ;
AddPanelString ( tempstr ) ;
@ -3322,9 +3319,6 @@ void PrintItemOil(char iDidx)
AddPanelString ( tempstr ) ;
break ;
case IMISC_ELIXWEAK :
strcpy ( tempstr , _ ( " decrease strength " ) ) ;
AddPanelString ( tempstr ) ;
break ;
case IMISC_ELIXDIS :
strcpy ( tempstr , _ ( " decrease strength " ) ) ;
AddPanelString ( tempstr ) ;
@ -3368,11 +3362,9 @@ void PrintItemPower(char plidx, ItemStruct *x)
strcpy ( tempstr , fmt : : format ( _ ( " {:+d}% armor " ) , x - > _iPLAC ) . c_str ( ) ) ;
break ;
case IPL_SETAC :
strcpy ( tempstr , fmt : : format ( _ ( " armor class: {:d} " ) , x - > _iAC ) . c_str ( ) ) ;
break ;
case IPL_AC_CURSE :
strcpy ( tempstr , fmt : : format ( _ ( " armor class: {:d} " ) , x - > _iAC ) . c_str ( ) ) ;
break ;
break ;
case IPL_FIRERES :
case IPL_FIRERES_CURSE :
if ( x - > _iPLFR < 75 )
@ -4124,17 +4116,17 @@ int RndSmithItem(int lvl)
return RndVendorItem < SmithItemOk , true > ( 0 , lvl ) ;
}
void SortVendor ( ItemStruct * items )
void SortVendor ( ItemStruct * itemLi st )
{
int count = 1 ;
while ( ! items [ count ] . isEmpty ( ) )
while ( ! itemLi st [ count ] . isEmpty ( ) )
count + + ;
auto cmp = [ ] ( const ItemStruct & a , const ItemStruct & b ) {
return a . IDidx < b . IDidx ;
} ;
std : : sort ( items , items + count , cmp ) ;
std : : sort ( itemLi st , itemLi st + count , cmp ) ;
}
void SpawnSmith ( int lvl )
@ -4197,17 +4189,17 @@ int RndPremiumItem(int minlvl, int maxlvl)
return RndVendorItem < PremiumItemOk > ( minlvl , maxlvl ) ;
}
static void SpawnOnePremium ( int i , int plvl , int my plr)
static void SpawnOnePremium ( int i , int plvl , int playe rId )
{
int iv alue = 0 ;
bool keepg oing = false ;
ItemStruct holdi tem = items [ 0 ] ;
int itemV alue = 0 ;
bool keepG oing = false ;
ItemStruct tempI tem = items [ 0 ] ;
auto & myP layer = plr [ my plr] ;
auto & p layer = plr [ playe rId ] ;
int strength = std : : max ( myP layer. GetMaximumAttributeValue ( CharacterAttribute : : Strength ) , myP layer. _pStrength ) ;
int dexterity = std : : max ( myP layer. GetMaximumAttributeValue ( CharacterAttribute : : Dexterity ) , myP layer. _pDexterity ) ;
int magic = std : : max ( myP layer. GetMaximumAttributeValue ( CharacterAttribute : : Magic ) , myP layer. _pMagic ) ;
int strength = std : : max ( p layer. GetMaximumAttributeValue ( CharacterAttribute : : Strength ) , p layer. _pStrength ) ;
int dexterity = std : : max ( p layer. GetMaximumAttributeValue ( CharacterAttribute : : Dexterity ) , p layer. _pDexterity ) ;
int magic = std : : max ( p layer. GetMaximumAttributeValue ( CharacterAttribute : : Magic ) , p layer. _pMagic ) ;
strength + = strength / 5 ;
dexterity + = dexterity / 5 ;
magic + = magic / 5 ;
@ -4217,16 +4209,16 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
int count = 0 ;
do {
keepg oing = false ;
keepG oing = false ;
memset ( & items [ 0 ] , 0 , sizeof ( * items ) ) ;
items [ 0 ] . _iSeed = AdvanceRndSeed ( ) ;
int itype = RndPremiumItem ( plvl / 4 , plvl ) - 1 ;
GetItemAttrs ( 0 , itype , plvl ) ;
int itemT ype = RndPremiumItem ( plvl / 4 , plvl ) - 1 ;
GetItemAttrs ( 0 , itemT ype , plvl ) ;
GetItemBonus ( 0 , plvl / 2 , plvl , true , ! gbIsHellfire ) ;
if ( ! gbIsHellfire ) {
if ( items [ 0 ] . _iIvalue > 140000 ) {
keepg oing = true ; // prevent breaking the do/while loop too early by failing hellfire's condition in while
keepG oing = true ; // prevent breaking the do/while loop too early by failing hellfire's condition in while
continue ;
}
break ;
@ -4236,14 +4228,14 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
case ITYPE_LARMOR :
case ITYPE_MARMOR :
case ITYPE_HARMOR : {
const auto * const mostValuablePlayerArmor = myP layer. GetMostValuableItem (
const auto * const mostValuablePlayerArmor = p layer. GetMostValuableItem (
[ ] ( const ItemStruct & item ) {
return item . _itype = = ITYPE_LARMOR
| | item . _itype = = ITYPE_MARMOR
| | item . _itype = = ITYPE_HARMOR ;
} ) ;
iv alue = mostValuablePlayerArmor = = nullptr ? 0 : mostValuablePlayerArmor - > _iIvalue ;
itemV alue = mostValuablePlayerArmor = = nullptr ? 0 : mostValuablePlayerArmor - > _iIvalue ;
break ;
}
case ITYPE_SHIELD :
@ -4255,37 +4247,37 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
case ITYPE_STAFF :
case ITYPE_RING :
case ITYPE_AMULET : {
const auto * const mostValuablePlayerItem = myP layer. GetMostValuableItem (
const auto * const mostValuablePlayerItem = p layer. GetMostValuableItem (
[ ] ( const ItemStruct & item ) { return item . _itype = = items [ 0 ] . _itype ; } ) ;
iv alue = mostValuablePlayerItem = = nullptr ? 0 : mostValuablePlayerItem - > _iIvalue ;
itemV alue = mostValuablePlayerItem = = nullptr ? 0 : mostValuablePlayerItem - > _iIvalue ;
break ;
}
default :
iv alue = 0 ;
itemV alue = 0 ;
break ;
}
iv alue * = 0.8 ;
itemV alue * = 0.8 ;
count + + ;
} while ( keepg oing
| | ( (
} while ( keepG oing
| | ( (
items [ 0 ] . _iIvalue > 200000
| | items [ 0 ] . _iMinStr > strength
| | items [ 0 ] . _iMinMag > magic
| | items [ 0 ] . _iMinDex > dexterity
| | items [ 0 ] . _iIvalue < iv alue )
| | items [ 0 ] . _iIvalue < itemV alue )
& & count < 150 ) ) ;
premiumitems [ i ] = items [ 0 ] ;
premiumitems [ i ] . _iCreateInfo = plvl | CF_SMITHPREMIUM ;
premiumitems [ i ] . _iIdentified = true ;
premiumitems [ i ] . _iStatFlag = StoreStatOk ( & premiumitems [ i ] ) ;
items [ 0 ] = holdi tem;
items [ 0 ] = tempI tem;
}
void SpawnPremium ( int pnum )
{
int lvl = plr [ pnum ] . _pLevel ;
int8_t lvl = plr [ pnum ] . _pLevel ;
int maxItems = gbIsHellfire ? SMITH_PREMIUM_ITEMS : 6 ;
if ( numpremium < maxItems ) {
for ( int i = 0 ; i < maxItems ; i + + ) {
@ -4350,13 +4342,13 @@ void WitchBookLevel(int ii)
if ( witchitem [ ii ] . _iMiscId ! = IMISC_BOOK )
return ;
witchitem [ ii ] . _iMinMag = spelldata [ witchitem [ ii ] . _iSpell ] . sMinInt ;
int slvl = plr [ myplr ] . _pSplLvl [ witchitem [ ii ] . _iSpell ] ;
while ( slvl > 0 ) {
int8_t spel lLe ve l = plr [ myplr ] . _pSplLvl [ witchitem [ ii ] . _iSpell ] ;
while ( spel lLe ve l > 0 ) {
witchitem [ ii ] . _iMinMag + = 20 * witchitem [ ii ] . _iMinMag / 100 ;
slvl - - ;
spel lLe ve l - - ;
if ( witchitem [ ii ] . _iMinMag + 20 * witchitem [ ii ] . _iMinMag / 100 > 255 ) {
witchitem [ ii ] . _iMinMag = 255 ;
slvl = 0 ;
spel lLe ve l = 0 ;
}
}
}