diff --git a/Source/items.cpp b/Source/items.cpp index ac5ea0c97..5f67b5b52 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -332,7 +332,7 @@ int premiumlvladd[SMITH_PREMIUM_ITEMS] = { }; #ifdef HELLFIRE -int items_4231CA(int i) +int get_ring_max_value(int i) { int j, res; @@ -349,7 +349,7 @@ int items_4231CA(int i) return res; } -int items_423230(int i) +int get_bow_max_value(int i) { int j, res; @@ -366,7 +366,7 @@ int items_423230(int i) return res; } -int items_423296(int i) +int get_staff_max_value(int i) { int j, res; @@ -383,7 +383,7 @@ int items_423296(int i) return res; } -int items_4232FC(int i) +int get_sword_max_value(int i) { int j, res; @@ -400,7 +400,7 @@ int items_4232FC(int i) return res; } -int items_423362(int i) +int get_helm_max_value(int i) { int j, res; @@ -417,7 +417,7 @@ int items_423362(int i) return res; } -int items_4233C8(int i) +int get_shield_max_value(int i) { int j, res; @@ -434,7 +434,7 @@ int items_4233C8(int i) return res; } -int items_42342E(int i) +int get_armor_max_value(int i) { int j, res; @@ -455,7 +455,7 @@ int items_42342E(int i) return res; } -int items_4234B2(int i) +int get_mace_max_value(int i) { int j, res; @@ -472,7 +472,7 @@ int items_4234B2(int i) return res; } -int items_423518(int i) +int get_amulet_max_value(int i) { int j, res; @@ -489,7 +489,7 @@ int items_423518(int i) return res; } -int items_42357E(int i) +int get_axe_max_value(int i) { int j, res; @@ -726,9 +726,9 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) ItemStruct *itm = &plr[p].InvBody[i]; if (itm->_itype != ITYPE_NONE && itm->_iStatFlag) { - tac += itm->_iAC; mind += itm->_iMinDam; maxd += itm->_iMaxDam; + tac += itm->_iAC; if (itm->_iSpell != SPL_NULL) { spl |= SPELLBIT(itm->_iSpell); @@ -738,14 +738,16 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) bdam += itm->_iPLDam; btohit += itm->_iPLToHit; if (itm->_iPLAC) { - int tmpac = itm->_iPLAC * itm->_iAC / 100; + int tmpac = itm->_iAC; + tmpac *= itm->_iPLAC; + tmpac /= 100; if (tmpac == 0) tmpac = 1; bac += tmpac; } iflgs |= itm->_iFlags; #ifdef HELLFIRE - pDamAcFlags |= plr[p].pDamAcFlags; + pDamAcFlags |= itm->_iDamAcFlags; #endif sadd += itm->_iPLStr; madd += itm->_iPLMag; @@ -783,10 +785,8 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) #ifdef HELLFIRE if (plr[p]._pClass == PC_MONK) { - if (plr[p]._pLevel >> 1 >= 1) - mind = plr[p]._pLevel >> 1; - if (maxd <= plr[p]._pLevel) - maxd = plr[p]._pLevel; + mind = max(mind, plr[p]._pLevel >> 1); + maxd = max(maxd, plr[p]._pLevel); } #endif } @@ -827,11 +827,10 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) if (plr[p]._pLightRad != lrad && p == myplr) { ChangeLightRadius(plr[p]._plid, lrad); - pvid = plr[p]._pvid; - if (lrad >= 10) { - ChangeVisionRadius(pvid, lrad); + if (lrad < 10) { + ChangeVisionRadius(plr[p]._pvid, 10); } else { - ChangeVisionRadius(pvid, 10); + ChangeVisionRadius(plr[p]._pvid, lrad); } plr[p]._pLightRad = lrad; @@ -936,24 +935,36 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) if (mr > MAXRESIST) mr = MAXRESIST; +#ifdef HELLFIRE + else if (mr < 0) + mr = 0; +#endif plr[p]._pMagResist = mr; if (fr > MAXRESIST) fr = MAXRESIST; +#ifdef HELLFIRE + else if (fr < 0) + fr = 0; +#endif plr[p]._pFireResist = fr; if (lr > MAXRESIST) lr = MAXRESIST; +#ifdef HELLFIRE + else if (lr < 0) + lr = 0; +#endif plr[p]._pLghtResist = lr; if (plr[p]._pClass == PC_WARRIOR) { - vadd *= 2; + vadd <<= 1; } #ifdef HELLFIRE - if (plr[p]._pClass == PC_BARBARIAN) { - vadd *= 3; - } - if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK || plr[p]._pClass == PC_BARD) { + else if (plr[p]._pClass == PC_BARBARIAN) { + vadd += vadd; + vadd += (vadd >> 2); + } else if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK || plr[p]._pClass == PC_BARD) { #else if (plr[p]._pClass == PC_ROGUE) { #endif @@ -962,7 +973,7 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) ihp += (vadd << 6); if (plr[p]._pClass == PC_SORCERER) { - madd *= 2; + madd <<= 1; } #ifdef HELLFIRE if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK) { @@ -973,7 +984,7 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) } #ifdef HELLFIRE else if (plr[p]._pClass == PC_BARD) { - madd += madd >> 2 + madd >> 1; + madd += (madd >> 2) + (madd >> 1); } #endif imana += (madd << 6); @@ -3770,7 +3781,7 @@ void PrintItemOil(char IDidx) switch (IDidx) { #ifdef HELLFIRE case IMISC_OILACC: - strcpy(tempstr, "increases a weapon\'s"); + strcpy(tempstr, "increases a weapon's"); AddPanelString(tempstr, TRUE); strcpy(tempstr, "chance to hit"); AddPanelString(tempstr, TRUE); @@ -3778,17 +3789,17 @@ void PrintItemOil(char IDidx) case IMISC_OILMAST: strcpy(tempstr, "greatly increases a"); AddPanelString(tempstr, TRUE); - strcpy(tempstr, "weapon\'s chance to hit"); + strcpy(tempstr, "weapon's chance to hit"); AddPanelString(tempstr, TRUE); break; case IMISC_OILSHARP: - strcpy(tempstr, "increases a weapon\'s"); + strcpy(tempstr, "increases a weapon's"); AddPanelString(tempstr, TRUE); strcpy(tempstr, "damage potential"); AddPanelString(tempstr, TRUE); break; case IMISC_OILDEATH: - strcpy(tempstr, "greatly increases a weapon\'s"); + strcpy(tempstr, "greatly increases a weapon's"); AddPanelString(tempstr, TRUE); strcpy(tempstr, "damage potential - not bows"); AddPanelString(tempstr, TRUE); @@ -3802,11 +3813,11 @@ void PrintItemOil(char IDidx) case IMISC_OILBSMTH: strcpy(tempstr, "restores 20% of an"); AddPanelString(tempstr, TRUE); - strcpy(tempstr, "item\'s durability"); + strcpy(tempstr, "item's durability"); AddPanelString(tempstr, TRUE); break; case IMISC_OILFORT: - strcpy(tempstr, "increases an item\'s"); + strcpy(tempstr, "increases an item's"); AddPanelString(tempstr, TRUE); strcpy(tempstr, "current and max durability"); AddPanelString(tempstr, TRUE); @@ -3928,9 +3939,6 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_TOHIT_DAMP: case IPL_TOHIT_DAMP_CURSE: -#ifdef HELLFIRE - case IPL_DOPPELGANGER: -#endif sprintf(tempstr, "to hit: %+i%%, %+i%% damage", x->_iPLToHit, x->_iPLDam); break; case IPL_ACP: @@ -3949,7 +3957,11 @@ void PrintItemPower(char plidx, ItemStruct *x) #endif if (x->_iPLFR < 75) sprintf(tempstr, "Resist Fire : %+i%%", x->_iPLFR); +#ifdef HELLFIRE + else +#else if (x->_iPLFR >= 75) +#endif sprintf(tempstr, "Resist Fire : 75%% MAX"); break; case IPL_LIGHTRES: @@ -3958,7 +3970,11 @@ void PrintItemPower(char plidx, ItemStruct *x) #endif if (x->_iPLLR < 75) sprintf(tempstr, "Resist Lightning : %+i%%", x->_iPLLR); +#ifdef HELLFIRE + else +#else if (x->_iPLLR >= 75) +#endif sprintf(tempstr, "Resist Lightning : 75%% MAX"); break; case IPL_MAGICRES: @@ -3967,7 +3983,11 @@ void PrintItemPower(char plidx, ItemStruct *x) #endif if (x->_iPLMR < 75) sprintf(tempstr, "Resist Magic : %+i%%", x->_iPLMR); +#ifdef HELLFIRE + else +#else if (x->_iPLMR >= 75) +#endif sprintf(tempstr, "Resist Magic : 75%% MAX"); break; case IPL_ALLRES: @@ -3983,18 +4003,19 @@ void PrintItemPower(char plidx, ItemStruct *x) if (x->_iSplLvlAdd == 1) strcpy(tempstr, "spells are increased 1 level"); #ifdef HELLFIRE - if (x->_iSplLvlAdd > 1) + else if (x->_iSplLvlAdd > 1) sprintf(tempstr, "spells are increased %i levels", x->_iSplLvlAdd); + else if (x->_iSplLvlAdd == -1) #else if (x->_iSplLvlAdd == 2) strcpy(tempstr, "spells are increased 2 levels"); -#endif if (x->_iSplLvlAdd < 1) +#endif strcpy(tempstr, "spells are decreased 1 level"); #ifdef HELLFIRE - if (x->_iSplLvlAdd < -1) - sprintf(tempstr, "spells are decreased %i levels", x->_iSplLvlAdd); - if (x->_iSplLvlAdd == 0) + else if (x->_iSplLvlAdd < -1) + sprintf(tempstr, "spells are decreased %i levels", -x->_iSplLvlAdd); + else if (x->_iSplLvlAdd == 0) strcpy(tempstr, "spell levels unchanged (?)"); #endif break; @@ -4069,7 +4090,7 @@ void PrintItemPower(char plidx, ItemStruct *x) break; #ifdef HELLFIRE case IPL_MULT_ARROWS: - strcpy(tempstr, "multiple arrows per shot"); + sprintf(tempstr, "multiple arrows per shot"); break; #endif case IPL_FIRE_ARROWS: @@ -4088,6 +4109,14 @@ void PrintItemPower(char plidx, ItemStruct *x) #endif sprintf(tempstr, "lightning arrows damage %i-%i", x->_iLMinDam, x->_iLMaxDam); break; +#ifdef HELLFIRE + case IPL_FIREBALL: + if (x->_iFMinDam == x->_iFMaxDam) + sprintf(tempstr, "fireball damage: %i", x->_iFMinDam); + else + sprintf(tempstr, "fireball damage: %i-%i", x->_iFMinDam, x->_iFMaxDam); + break; +#endif case IPL_THORNS: strcpy(tempstr, "attacker takes 1-3 damage"); break; @@ -4097,14 +4126,6 @@ void PrintItemPower(char plidx, ItemStruct *x) case IPL_NOHEALPLR: strcpy(tempstr, "you can't heal"); break; -#ifdef HELLFIRE - case IPL_FIREBALL: - if (x->_iFMinDam != x->_iFMaxDam) - sprintf(tempstr, "fireball damage: %i-%i", x->_iFMinDam, x->_iFMaxDam); - else - sprintf(tempstr, "fireball damage: %i", x->_iFMinDam); - break; -#endif case IPL_ABSHALFTRAP: strcpy(tempstr, "absorbs half of trap damage"); break; @@ -4134,7 +4155,7 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_TARGAC: #ifdef HELLFIRE - strcpy(tempstr, "penetrates target\'s armor"); + strcpy(tempstr, "penetrates target's armor"); #else strcpy(tempstr, "damages target's armor"); #endif @@ -4195,11 +4216,10 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_ADDACLIFE: #ifdef HELLFIRE - if (x->_iFMinDam != x->_iFMaxDam) { - sprintf(tempstr, "lightning: %i-%i", x->_iFMinDam, x->_iFMaxDam); - break; - } - sprintf(tempstr, "lightning damage: %i", x->_iFMinDam); + if (x->_iFMinDam == x->_iFMaxDam) + sprintf(tempstr, "lightning damage: %i", x->_iFMinDam); + else + sprintf(tempstr, "lightning damage: %i-%i", x->_iFMinDam, x->_iFMaxDam); #else strcpy(tempstr, "Armor class added to life"); #endif @@ -4233,17 +4253,20 @@ void PrintItemPower(char plidx, ItemStruct *x) case IPL_CRYSTALLINE: sprintf(tempstr, "low dur, %+i%% damage", x->_iPLDam); break; + case IPL_DOPPELGANGER: + sprintf(tempstr, "to hit: %+i%%, %+i%% damage", x->_iPLToHit, x->_iPLDam); + break; case IPL_ACDEMON: - strcpy(tempstr, "extra AC vs demons"); + sprintf(tempstr, "extra AC vs demons"); break; case IPL_ACUNDEAD: - strcpy(tempstr, "extra AC vs undead"); + sprintf(tempstr, "extra AC vs undead"); break; case IPL_MANATOLIFE: - strcpy(tempstr, "50%% Mana moved to Health"); + sprintf(tempstr, "50%% Mana moved to Health"); break; case IPL_LIFETOMANA: - strcpy(tempstr, "40%% Health moved to Mana"); + sprintf(tempstr, "40%% Health moved to Mana"); break; #endif default: @@ -4524,9 +4547,17 @@ void UseItem(int p, int Mid, int spl) case IMISC_MEAT: j = plr[p]._pMaxHP >> 8; l = ((j >> 1) + random_(39, j)) << 6; +#ifdef HELLFIRE + if (plr[p]._pClass == PC_WARRIOR || plr[p]._pClass == PC_BARBARIAN) +#else if (plr[p]._pClass == PC_WARRIOR) - l *= 2; +#endif + l <<= 1; +#ifdef HELLFIRE + if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK || plr[p]._pClass == PC_BARD) +#else if (plr[p]._pClass == PC_ROGUE) +#endif l += l >> 1; plr[p]._pHitPoints += l; if (plr[p]._pHitPoints > plr[p]._pMaxHP) @@ -4545,8 +4576,12 @@ void UseItem(int p, int Mid, int spl) j = plr[p]._pMaxMana >> 8; l = ((j >> 1) + random_(40, j)) << 6; if (plr[p]._pClass == PC_SORCERER) - l *= 2; + l <<= 1; +#ifdef HELLFIRE + if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK || plr[p]._pClass == PC_BARD) +#else if (plr[p]._pClass == PC_ROGUE) +#endif l += l >> 1; if (!(plr[p]._pIFlags & ISPL_NOMANA)) { plr[p]._pMana += l; @@ -4570,18 +4605,32 @@ void UseItem(int p, int Mid, int spl) break; case IMISC_ELIXMAG: ModifyPlrMag(p, 1); +#ifdef HELLFIRE + plr[p]._pMana = plr[p]._pMaxMana; + plr[p]._pManaBase = plr[p]._pMaxManaBase; + drawmanaflag = TRUE; +#endif break; case IMISC_ELIXDEX: ModifyPlrDex(p, 1); break; case IMISC_ELIXVIT: ModifyPlrVit(p, 1); +#ifdef HELLFIRE + plr[p]._pHitPoints = plr[p]._pMaxHP; + plr[p]._pHPBase = plr[p]._pMaxHPBase; + drawhpflag = TRUE; +#endif break; case IMISC_REJUV: j = plr[p]._pMaxHP >> 8; l = ((j >> 1) + random_(39, j)) << 6; +#ifdef HELLFIRE + if (plr[p]._pClass == PC_WARRIOR || plr[p]._pClass == PC_BARBARIAN) +#else if (plr[p]._pClass == PC_WARRIOR) - l *= 2; +#endif + l <<= 1; if (plr[p]._pClass == PC_ROGUE) l += l >> 1; plr[p]._pHitPoints += l; @@ -4594,7 +4643,7 @@ void UseItem(int p, int Mid, int spl) j = plr[p]._pMaxMana >> 8; l = ((j >> 1) + random_(40, j)) << 6; if (plr[p]._pClass == PC_SORCERER) - l *= 2; + l <<= 1; if (plr[p]._pClass == PC_ROGUE) l += l >> 1; if (!(plr[p]._pIFlags & ISPL_NOMANA)) { @@ -4691,7 +4740,7 @@ void UseItem(int p, int Mid, int spl) if (!invflag) { invflag = TRUE; } - SetCursor_(CURSOR_OIL); + NewCursor(CURSOR_OIL); break; #endif case IMISC_SPECELIX: @@ -4705,31 +4754,31 @@ void UseItem(int p, int Mid, int spl) plr[p]._pTSpell = SPL_RUNEFIRE; plr[p]._pTSplType = RSPLTYPE_INVALID; if (p == myplr) - SetCursor_(CURSOR_TELEPORT); + NewCursor(CURSOR_TELEPORT); break; case IMISC_RUNEL: plr[p]._pTSpell = SPL_RUNELIGHT; plr[p]._pTSplType = RSPLTYPE_INVALID; if (p == myplr) - SetCursor_(CURSOR_TELEPORT); + NewCursor(CURSOR_TELEPORT); break; case IMISC_GR_RUNEL: plr[p]._pTSpell = SPL_RUNENOVA; plr[p]._pTSplType = RSPLTYPE_INVALID; if (p == myplr) - SetCursor_(CURSOR_TELEPORT); + NewCursor(CURSOR_TELEPORT); break; case IMISC_GR_RUNEF: plr[p]._pTSpell = SPL_RUNEIMMOLAT; plr[p]._pTSplType = RSPLTYPE_INVALID; if (p == myplr) - SetCursor_(CURSOR_TELEPORT); + NewCursor(CURSOR_TELEPORT); break; case IMISC_RUNES: plr[p]._pTSpell = SPL_RUNESTONE; plr[p]._pTSplType = RSPLTYPE_INVALID; if (p == myplr) - SetCursor_(CURSOR_TELEPORT); + NewCursor(CURSOR_TELEPORT); break; #endif } @@ -4933,6 +4982,31 @@ static void SpawnOnePremium(int i, int plvl) ItemStruct holditem; holditem = item[0]; + +#ifdef HELLFIRE + int ivalue; + int count = 0; + + int strength = get_max_strength(plr[myplr]._pClass); + int dexterity = get_max_dexterity(plr[myplr]._pClass); + int magic = get_max_magic(plr[myplr]._pClass); + + if (strength < plr[myplr]._pStrength) { + strength = plr[myplr]._pStrength; + } + strength *= 1.2; + + if (dexterity < plr[myplr]._pDexterity) { + dexterity = plr[myplr]._pDexterity; + } + dexterity *= 1.2; + + if (magic < plr[myplr]._pMagic) { + magic = plr[myplr]._pMagic; + } + magic *= 1.2; +#endif + if (plvl > 30) plvl = 30; if (plvl < 1) @@ -4943,11 +5017,59 @@ static void SpawnOnePremium(int i, int plvl) itype = RndPremiumItem(plvl >> 2, plvl) - 1; GetItemAttrs(0, itype, plvl); #ifdef HELLFIRE - GetItemBonus(0, itype, plvl >> 1, plvl, TRUE, FALSE); + GetItemBonus(0, itype, plvl >> 1, plvl, TRUE, noSpells); #else GetItemBonus(0, itype, plvl >> 1, plvl, TRUE); #endif + +#ifdef HELLFIRE + ivalue = 0; + switch (item[0]._itype) { + case ITYPE_LARMOR: + case ITYPE_MARMOR: + case ITYPE_HARMOR: + ivalue = get_armor_max_value(myplr); + break; + case ITYPE_SHIELD: + ivalue = get_shield_max_value(myplr); + break; + case ITYPE_AXE: + ivalue = get_axe_max_value(myplr); + break; + case ITYPE_BOW: + ivalue = get_bow_max_value(myplr); + break; + case ITYPE_MACE: + ivalue = get_mace_max_value(myplr); + break; + case ITYPE_SWORD: + ivalue = get_sword_max_value(myplr); + break; + case ITYPE_HELM: + ivalue = get_helm_max_value(myplr); + break; + case ITYPE_STAFF: + ivalue = get_staff_max_value(myplr); + break; + case ITYPE_RING: + ivalue = get_ring_max_value(myplr); + break; + case ITYPE_AMULET: + ivalue = get_amulet_max_value(myplr); + break; + } + ivalue *= 0.8; + + count++; + } while ((item[0]._iIvalue > SMITH_MAX_PREMIUM_VALUE + || item[0]._iMinStr > strength + || item[0]._iMinMag > magic + || item[0]._iMinDex > dexterity + || item[0]._iIvalue < ivalue) + && count < 150); +#else } while (item[0]._iIvalue > SMITH_MAX_PREMIUM_VALUE); +#endif premiumitem[i] = item[0]; premiumitem[i]._iCreateInfo = plvl | CF_SMITHPREMIUM; premiumitem[i]._iIdentified = TRUE; @@ -5112,9 +5234,15 @@ void WitchBookLevel(int ii) void SpawnWitch(int lvl) { - int i, iCnt; + int i, j, iCnt; int idata, maxlvl; + j = 3; +#ifdef HELLFIRE + iCnt = random_(51, 15) + 10; + int books = random_(3, 4); +#endif + GetItemAttrs(0, IDI_MANA, 1); witchitem[0] = item[0]; witchitem[0]._iCreateInfo = lvl; @@ -5127,9 +5255,31 @@ void SpawnWitch(int lvl) witchitem[2] = item[0]; witchitem[2]._iCreateInfo = lvl; witchitem[2]._iStatFlag = TRUE; + +#ifdef HELLFIRE + int bCnt; + for (i = 114, bCnt = 0; i <= 117 && bCnt < books; ++i) { + if (WitchItemOk(i) + && lvl >= AllItemsList[i].iMinMLvl) { + item[0]._iSeed = GetRndSeed(); + SetRndSeed(item[0]._iSeed); + volatile int junk = random_(0, 1); + + GetItemAttrs(0, i, lvl); + witchitem[j] = item[0]; + witchitem[j]._iCreateInfo = lvl | CF_WITCH; + witchitem[j]._iIdentified = TRUE; + WitchBookLevel(j); + witchitem[j]._iStatFlag = StoreStatOk(&witchitem[j]); + j++; + bCnt++; + } + } +#else iCnt = random_(51, 8) + 10; +#endif - for (i = 3; i < iCnt; i++) { + for (i = j; i < iCnt; i++) { do { item[0]._iSeed = GetRndSeed(); SetRndSeed(item[0]._iSeed); @@ -5146,7 +5296,7 @@ void SpawnWitch(int lvl) #else GetItemBonus(0, idata, maxlvl >> 1, maxlvl, TRUE); #endif - } while (item[0]._iIvalue > 140000); + } while (item[0]._iIvalue > WITCH_MAX_VALUE); witchitem[i] = item[0]; witchitem[i]._iCreateInfo = lvl | CF_WITCH; witchitem[i]._iIdentified = TRUE; @@ -5154,7 +5304,7 @@ void SpawnWitch(int lvl) witchitem[i]._iStatFlag = StoreStatOk(&witchitem[i]); } - for (i = iCnt; i < 20; i++) + for (i = iCnt; i < WITCH_ITEMS; i++) witchitem[i]._itype = ITYPE_NONE; SortWitch(); @@ -5184,6 +5334,31 @@ void SpawnBoy(int lvl) { int itype; +#ifdef HELLFIRE + int ivalue; + int count = 0; + + int strength = get_max_strength(plr[myplr]._pClass); + int dexterity = get_max_dexterity(plr[myplr]._pClass); + int magic = get_max_magic(plr[myplr]._pClass); + int pc = plr[myplr]._pClass; + + if (strength < plr[myplr]._pStrength) { + strength = plr[myplr]._pStrength; + } + strength *= 1.2; + + if (dexterity < plr[myplr]._pDexterity) { + dexterity = plr[myplr]._pDexterity; + } + dexterity *= 1.2; + + if (magic < plr[myplr]._pMagic) { + magic = plr[myplr]._pMagic; + } + magic *= 1.2; +#endif + if (boylevel < (lvl >> 1) || boyitem._itype == ITYPE_NONE) { do { item[0]._iSeed = GetRndSeed(); @@ -5192,10 +5367,87 @@ void SpawnBoy(int lvl) GetItemAttrs(0, itype, lvl); #ifdef HELLFIRE GetItemBonus(0, itype, lvl, 2 * lvl, TRUE, TRUE); + + ivalue = 0; + + int itemType = item[0]._itype; + + switch (itemType) { + case ITYPE_LARMOR: + case ITYPE_MARMOR: + case ITYPE_HARMOR: + ivalue = get_armor_max_value(myplr); + break; + case ITYPE_SHIELD: + ivalue = get_shield_max_value(myplr); + break; + case ITYPE_AXE: + ivalue = get_axe_max_value(myplr); + break; + case ITYPE_BOW: + ivalue = get_bow_max_value(myplr); + break; + case ITYPE_MACE: + ivalue = get_mace_max_value(myplr); + break; + case ITYPE_SWORD: + ivalue = get_sword_max_value(myplr); + break; + case ITYPE_HELM: + ivalue = get_helm_max_value(myplr); + break; + case ITYPE_STAFF: + ivalue = get_staff_max_value(myplr); + break; + case ITYPE_RING: + ivalue = get_ring_max_value(myplr); + break; + case ITYPE_AMULET: + ivalue = get_amulet_max_value(myplr); + break; + } + ivalue *= 0.8; + + count++; + + if (count < 200) { + switch (pc) { + case PC_WARRIOR: + if (itemType == ITYPE_BOW || itemType == ITYPE_STAFF) + ivalue = INT_MAX; + break; + case PC_ROGUE: + if (itemType == ITYPE_SWORD || itemType == ITYPE_STAFF || itemType == ITYPE_AXE || itemType == ITYPE_MACE || itemType == ITYPE_SHIELD) + ivalue = INT_MAX; + break; + case PC_SORCERER: + if (itemType == ITYPE_STAFF || itemType == ITYPE_AXE || itemType == ITYPE_BOW || itemType == ITYPE_MACE) + ivalue = INT_MAX; + break; + case PC_MONK: + if (itemType == ITYPE_BOW || itemType == ITYPE_MARMOR || itemType == ITYPE_SHIELD || itemType == ITYPE_MACE) + ivalue = INT_MAX; + break; + case PC_BARD: + if (itemType == ITYPE_AXE || itemType == ITYPE_MACE || itemType == ITYPE_STAFF) + ivalue = INT_MAX; + break; + case PC_BARBARIAN: + if (itemType == ITYPE_BOW || itemType == ITYPE_STAFF) + ivalue = INT_MAX; + break; + } + } + } while ((item[0]._iIvalue > BOY_MAX_VALUE + || item[0]._iMinStr > strength + || item[0]._iMinMag > magic + || item[0]._iMinDex > dexterity + || item[0]._iIvalue < ivalue) + && count < 250); #else GetItemBonus(0, itype, lvl, 2 * lvl, TRUE); + } while (item[0]._iIvalue > BOY_MAX_VALUE); #endif - } while (item[0]._iIvalue > 90000); boyitem = item[0]; boyitem._iCreateInfo = lvl | CF_BOY; boyitem._iIdentified = TRUE; diff --git a/Source/items.h b/Source/items.h index 7f8d4ba04..597a76be2 100644 --- a/Source/items.h +++ b/Source/items.h @@ -27,16 +27,16 @@ extern int auricGold; extern int numitems; #ifdef HELLFIRE -int items_4231CA(int i); -int items_423230(int i); -int items_423296(int i); -int items_4232FC(int i); -int items_423362(int i); -int items_4233C8(int i); -int items_42342E(int i); -int items_4234B2(int i); -int items_423518(int i); -int items_42357E(int i); +int get_ring_max_value(int i); +int get_bow_max_value(int i); +int get_staff_max_value(int i); +int get_sword_max_value(int i); +int get_helm_max_value(int i); +int get_shield_max_value(int i); +int get_armor_max_value(int i); +int get_mace_max_value(int i); +int get_amulet_max_value(int i); +int get_axe_max_value(int i); #endif void InitItemGFX(); void InitItems(); diff --git a/Source/player.cpp b/Source/player.cpp index f2810eac6..18fe81383 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1450,7 +1450,8 @@ void StartWalk(int pnum, int xvel, int yvel, int xadd, int yadd, int EndDir, int #if defined(__clang__) || defined(__GNUC__) __attribute__((no_sanitize("shift-base"))) #endif -void StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int EndDir, int sdir) +void +StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int EndDir, int sdir) { int px, py; @@ -1526,7 +1527,8 @@ void StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int #if defined(__clang__) || defined(__GNUC__) __attribute__((no_sanitize("shift-base"))) #endif -void StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, int EndDir, int sdir) +void +StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, int EndDir, int sdir) { int px, py, x, y; @@ -1868,7 +1870,8 @@ static void PlrDeadItem(int pnum, ItemStruct *itm, int xx, int yy) #if defined(__clang__) || defined(__GNUC__) __attribute__((no_sanitize("shift-base"))) #endif -void StartPlayerKill(int pnum, int earflag) +void +StartPlayerKill(int pnum, int earflag) { BOOL diablolevel; int i, pdd; @@ -2231,7 +2234,8 @@ void InitLevelChange(int pnum) #if defined(__clang__) || defined(__GNUC__) __attribute__((no_sanitize("shift-base"))) #endif -void StartNewLvl(int pnum, int fom, int lvl) +void +StartNewLvl(int pnum, int fom, int lvl) { InitLevelChange(pnum); @@ -4611,17 +4615,17 @@ void PlayDungMsgs() } #ifdef HELLFIRE -int player_45EFA1(int i) +int get_max_strength(int i) { return MaxStats[i][ATTRIB_STR]; } -int player_45EFAB(int i) +int get_max_magic(int i) { return MaxStats[i][ATTRIB_MAG]; } -int player_45EFB5(int i) +int get_max_dexterity(int i) { return MaxStats[i][ATTRIB_DEX]; } diff --git a/Source/player.h b/Source/player.h index df4086834..d260fed2d 100644 --- a/Source/player.h +++ b/Source/player.h @@ -74,9 +74,9 @@ void SetPlrVit(int p, int v); void InitDungMsgs(int pnum); void PlayDungMsgs(); #ifdef HELLFIRE -int player_45EFA1(int i); -int player_45EFAB(int i); -int player_45EFB5(int i); +int get_max_strength(int i); +int get_max_magic(int i); +int get_max_dexterity(int i); #endif /* data */ diff --git a/Source/stores.cpp b/Source/stores.cpp index a3c9eb18e..cf9b9d57a 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -129,20 +129,20 @@ void DrawSTextBack() void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int val) { - int xx, yy; int len, width, sx, sy, i, k, s; + int xx, yy; BYTE c; char valstr[32]; s = y * 12 + stext[y]._syoff; - if (stextsize) + if (stextsize != 0) xx = PANEL_X + 32; else xx = PANEL_X + 352; sx = xx + x; sy = s + 44 + SCREEN_Y + UI_OFFSET_Y; len = strlen(str); - if (stextsize) + if (stextsize != 0) yy = 577; else yy = 257; @@ -161,7 +161,7 @@ void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int v for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; - if (c && k <= yy) { + if (c != 0 && k <= yy) { PrintChar(sx, sy, c, col); } sx += fontkern[c] + 1; @@ -169,10 +169,11 @@ void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int v if (!cjustflag && val >= 0) { sprintf(valstr, "%i", val); sx = PANEL_X + 592 - x; - for (i = strlen(valstr) - 1; i >= 0; i--) { + len = strlen(valstr); + for (i = len - 1; i >= 0; i--) { c = fontframe[gbFontTransTbl[(BYTE)valstr[i]]]; sx -= fontkern[c] + 1; - if (c) { + if (c != 0) { PrintChar(sx, sy, c, col); } } @@ -926,7 +927,15 @@ BOOL WitchSellOk(int i) if (pI->_itype == ITYPE_MISC) rv = TRUE; +#ifdef HELLFIRE + if (pI->_iMiscId > 29 && pI->_iMiscId < 41) + rv = FALSE; + if (pI->_iClass == ICLASS_QUEST) + rv = FALSE; + if (pI->_itype == ITYPE_STAFF && pI->_iSpell != SPL_NULL) +#else if (pI->_itype == ITYPE_STAFF) +#endif rv = TRUE; if (pI->IDidx >= IDI_FIRSTQUEST && pI->IDidx <= IDI_LASTQUEST) rv = FALSE; @@ -1018,6 +1027,12 @@ BOOL WitchRechargeOk(int i) && plr[myplr].InvList[i]._iCharges != plr[myplr].InvList[i]._iMaxCharges) { rv = TRUE; } +#ifdef HELLFIRE + if ((plr[myplr].InvList[i]._iMiscId == IMISC_UNIQUE || plr[myplr].InvList[i]._iMiscId == IMISC_STAFF) + && plr[myplr].InvList[i]._iCharges < plr[myplr].InvList[i]._iMaxCharges) { + rv = TRUE; + } +#endif return rv; } diff --git a/defs.h b/defs.h index 469a8979c..39a0eaf7a 100644 --- a/defs.h +++ b/defs.h @@ -98,7 +98,9 @@ // todo: enums #ifdef HELLFIRE #define NUMLEVELS 25 +#define BOY_MAX_VALUE 200000 #define WITCH_ITEMS 25 +#define WITCH_MAX_VALUE 200000 #define SMITH_ITEMS 25 #define SMITH_PREMIUM_ITEMS 15 #define SMITH_MAX_VALUE 200000 @@ -106,7 +108,9 @@ #define STORE_LINES 104 #else #define NUMLEVELS 17 +#define BOY_MAX_VALUE 90000 #define WITCH_ITEMS 20 +#define WITCH_MAX_VALUE 140000 #define SMITH_ITEMS 20 #define SMITH_PREMIUM_ITEMS 6 #define SMITH_MAX_VALUE 140000