Browse Source

IsPrefixValidForItemType/IsSuffixValidForItemType doesn't rely on gbIsHellfire

pull/5745/head^2
obligaron 3 years ago committed by Anders Jenbo
parent
commit
f154bad1bd
  1. 22
      Source/items.cpp

22
Source/items.cpp

@ -351,11 +351,11 @@ int premiumLvlAddHellfire[] = {
// clang-format on
};
bool IsPrefixValidForItemType(int i, AffixItemType flgs)
bool IsPrefixValidForItemType(int i, AffixItemType flgs, bool hellfireItem)
{
AffixItemType itemTypes = ItemPrefixes[i].PLIType;
if (!gbIsHellfire) {
if (!hellfireItem) {
if (i > 82)
return false;
@ -366,11 +366,11 @@ bool IsPrefixValidForItemType(int i, AffixItemType flgs)
return HasAnyOf(flgs, itemTypes);
}
bool IsSuffixValidForItemType(int i, AffixItemType flgs)
bool IsSuffixValidForItemType(int i, AffixItemType flgs, bool hellfireItem)
{
AffixItemType itemTypes = ItemSuffixes[i].PLIType;
if (!gbIsHellfire) {
if (!hellfireItem) {
if (i > 94)
return false;
@ -1078,14 +1078,14 @@ void SaveItemAffix(const Player &player, Item &item, const PLStruct &affix)
}
}
int GetStaffPrefixId(int lvl, bool onlygood)
int GetStaffPrefixId(int lvl, bool onlygood, bool hellfireItem)
{
int preidx = -1;
if (FlipCoin(10) || onlygood) {
int nl = 0;
int l[256];
for (int j = 0; ItemPrefixes[j].power.type != IPL_INVALID; j++) {
if (!IsPrefixValidForItemType(j, AffixItemType::Staff) || ItemPrefixes[j].PLMinLvl > lvl)
if (!IsPrefixValidForItemType(j, AffixItemType::Staff, hellfireItem) || ItemPrefixes[j].PLMinLvl > lvl)
continue;
if (onlygood && !ItemPrefixes[j].PLOk)
continue;
@ -1105,7 +1105,7 @@ int GetStaffPrefixId(int lvl, bool onlygood)
void GetStaffPower(const Player &player, Item &item, int lvl, SpellID bs, bool onlygood)
{
int preidx = GetStaffPrefixId(lvl, onlygood);
int preidx = GetStaffPrefixId(lvl, onlygood, gbIsHellfire);
if (preidx != -1) {
item._iMagical = ITEM_QUALITY_MAGIC;
SaveItemAffix(player, item, ItemPrefixes[preidx]);
@ -1152,7 +1152,7 @@ std::string GenerateMagicItemName(const string_view &baseNamel, const PLStruct *
return std::string(baseNamel);
}
void GetItemPowerPrefixAndSuffix(int minlvl, int maxlvl, AffixItemType flgs, bool onlygood, tl::function_ref<void(const PLStruct &prefix)> prefixFound, tl::function_ref<void(const PLStruct &suffix)> suffixFound)
void GetItemPowerPrefixAndSuffix(int minlvl, int maxlvl, AffixItemType flgs, bool onlygood, bool hellfireItem, tl::function_ref<void(const PLStruct &prefix)> prefixFound, tl::function_ref<void(const PLStruct &suffix)> suffixFound)
{
int preidx = -1;
int sufidx = -1;
@ -1175,7 +1175,7 @@ void GetItemPowerPrefixAndSuffix(int minlvl, int maxlvl, AffixItemType flgs, boo
if (allocatePrefix) {
int nt = 0;
for (int j = 0; ItemPrefixes[j].power.type != IPL_INVALID; j++) {
if (!IsPrefixValidForItemType(j, flgs))
if (!IsPrefixValidForItemType(j, flgs, hellfireItem))
continue;
if (ItemPrefixes[j].PLMinLvl < minlvl || ItemPrefixes[j].PLMinLvl > maxlvl)
continue;
@ -1199,7 +1199,7 @@ void GetItemPowerPrefixAndSuffix(int minlvl, int maxlvl, AffixItemType flgs, boo
if (allocateSuffix) {
int nl = 0;
for (int j = 0; ItemSuffixes[j].power.type != IPL_INVALID; j++) {
if (IsSuffixValidForItemType(j, flgs)
if (IsSuffixValidForItemType(j, flgs, hellfireItem)
&& ItemSuffixes[j].PLMinLvl >= minlvl && ItemSuffixes[j].PLMinLvl <= maxlvl
&& !((goe == GOE_GOOD && ItemSuffixes[j].PLGOE == GOE_EVIL) || (goe == GOE_EVIL && ItemSuffixes[j].PLGOE == GOE_GOOD))
&& (!onlygood || ItemSuffixes[j].PLOk)) {
@ -1219,7 +1219,7 @@ void GetItemPower(const Player &player, Item &item, int minlvl, int maxlvl, Affi
const PLStruct *pPrefix = nullptr;
const PLStruct *pSufix = nullptr;
GetItemPowerPrefixAndSuffix(
minlvl, maxlvl, flgs, onlygood,
minlvl, maxlvl, flgs, onlygood, gbIsHellfire,
[&item, &player, &pPrefix](const PLStruct &prefix) {
item._iMagical = ITEM_QUALITY_MAGIC;
SaveItemAffix(player, item, prefix);

Loading…
Cancel
Save