Add enum for icreateinfo

This commit is contained in:
qndel
2020-07-29 03:30:16 +02:00
committed by Anders Jenbo
parent 166029c95b
commit 2cc494581f
4 changed files with 78 additions and 39 deletions

6
.gitignore vendored
View File

@@ -374,3 +374,9 @@ ASALocalRun/
# End of https://www.gitignore.io/api/visualstudio
/docs/html/
# MPQ files
*.mpq
# ddraw wrapper configuration file
ddraw_settings.ini

View File

@@ -1514,7 +1514,7 @@ void InvGetItem(int pnum, int ii)
if (dItem[item[ii]._ix][item[ii]._iy] != 0) {
if (myplr == pnum && pcurs >= CURSOR_FIRSTITEM)
NetSendCmdPItem(TRUE, CMD_SYNCPUTITEM, plr[myplr]._px, plr[myplr]._py);
item[ii]._iCreateInfo &= ~0x8000;
item[ii]._iCreateInfo &= ~CF_PREGEN;
plr[pnum].HoldItem = item[ii];
CheckQuestItem(pnum);
CheckBookLevel(pnum);
@@ -1550,7 +1550,7 @@ void AutoGetItem(int pnum, int ii)
return;
}
item[ii]._iCreateInfo &= 0x7FFF;
item[ii]._iCreateInfo &= ~CF_PREGEN;
plr[pnum].HoldItem = item[ii]; /// BUGFIX: overwrites cursor item, allowing for belt dupe bug
CheckQuestItem(pnum);
CheckBookLevel(pnum);

View File

@@ -251,7 +251,7 @@ void AddInitItems()
GetItemAttrs(i, IDI_HEAL, currlevel);
else
GetItemAttrs(i, IDI_MANA, currlevel);
item[i]._iCreateInfo = currlevel - 0x8000;
item[i]._iCreateInfo = currlevel - CF_PREGEN;
SetupItem(i);
item[i]._iAnimFrame = item[i]._iAnimLen;
item[i]._iAnimFlag = FALSE;
@@ -2007,7 +2007,7 @@ void GetUniqueItem(int i, int uid)
item[i]._iUid = uid;
item[i]._iMagical = ITEM_QUALITY_UNIQUE;
item[i]._iCreateInfo |= 0x0200;
item[i]._iCreateInfo |= CF_UNIQUE;
}
void SpawnUnique(int uid, int x, int y)
@@ -2049,14 +2049,14 @@ void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood,
item[ii]._iCreateInfo = lvl;
if (pregen)
item[ii]._iCreateInfo = lvl | 0x8000;
item[ii]._iCreateInfo = lvl | CF_PREGEN;
if (onlygood)
item[ii]._iCreateInfo |= 0x40;
item[ii]._iCreateInfo |= CF_ONLYGOOD;
if (uper == 15)
item[ii]._iCreateInfo |= 0x80;
item[ii]._iCreateInfo |= CF_UPER15;
else if (uper == 1)
item[ii]._iCreateInfo |= 0x0100;
item[ii]._iCreateInfo |= CF_UPER1;
if (item[ii]._iMiscId != IMISC_UNIQUE) {
iblvl = -1;
@@ -2082,7 +2082,7 @@ void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood,
GetItemBonus(ii, idx, iblvl >> 1, iblvl, onlygood);
} else {
GetUniqueItem(ii, uid);
item[ii]._iCreateInfo |= 0x0200;
item[ii]._iCreateInfo |= CF_UNIQUE;
}
}
if (item[ii]._iMagical != ITEM_QUALITY_UNIQUE)
@@ -2204,7 +2204,7 @@ void SetupAllUseful(int ii, int iseed, int lvl)
idx = IDI_PORTAL;
GetItemAttrs(ii, idx, lvl);
item[ii]._iCreateInfo = lvl + 384;
item[ii]._iCreateInfo = lvl + CF_USEFUL;
SetupItem(ii);
}
@@ -2271,26 +2271,26 @@ void RecreateItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue)
SetPlrHandItem(&item[ii], idx);
SetPlrHandSeed(&item[ii], iseed);
} else {
if (icreateinfo & 0x7C00) {
if (icreateinfo & CF_TOWN) {
RecreateTownItem(ii, idx, icreateinfo, iseed, ivalue);
} else if ((icreateinfo & 0x0180) == 0x0180) {
SetupAllUseful(ii, iseed, icreateinfo & 0x3F);
} else if ((icreateinfo & CF_USEFUL) == CF_USEFUL) {
SetupAllUseful(ii, iseed, icreateinfo & CF_LEVEL);
} else {
uper = 0;
onlygood = 0;
recreate = 0;
pregen = FALSE;
if (icreateinfo & 0x0100)
if (icreateinfo & CF_UPER1)
uper = 1;
if (icreateinfo & 0x80)
if (icreateinfo & CF_UPER15)
uper = 15;
if (icreateinfo & 0x40)
if (icreateinfo & CF_ONLYGOOD)
onlygood = 1;
if (icreateinfo & 0x0200)
if (icreateinfo & CF_UNIQUE)
recreate = 1;
if (icreateinfo & 0x8000)
if (icreateinfo & CF_PREGEN)
pregen = TRUE;
SetupAllItems(ii, idx, iseed, icreateinfo & 0x3F, uper, onlygood, recreate, pregen);
SetupAllItems(ii, idx, iseed, icreateinfo & CF_LEVEL, uper, onlygood, recreate, pregen);
}
}
}
@@ -3421,7 +3421,7 @@ void SpawnSmith(int lvl)
GetItemAttrs(0, idata, lvl);
} while (item[0]._iIvalue > SMITH_MAX_VALUE);
smithitem[i] = item[0];
smithitem[i]._iCreateInfo = lvl | 0x400;
smithitem[i]._iCreateInfo = lvl | CF_SMITH;
smithitem[i]._iIdentified = TRUE;
smithitem[i]._iStatFlag = StoreStatOk(&smithitem[i]);
}
@@ -3493,7 +3493,7 @@ void SpawnOnePremium(int i, int plvl)
GetItemBonus(0, itype, plvl >> 1, plvl, TRUE);
} while (item[0]._iIvalue > SMITH_MAX_PREMIUM_VALUE);
premiumitem[i] = item[0];
premiumitem[i]._iCreateInfo = plvl | 0x800;
premiumitem[i]._iCreateInfo = plvl | CF_SMITHPREMIUM;
premiumitem[i]._iIdentified = TRUE;
premiumitem[i]._iStatFlag = StoreStatOk(&premiumitem[i]);
item[0] = holditem;
@@ -3639,7 +3639,7 @@ void SpawnWitch(int lvl)
GetItemBonus(0, idata, maxlvl >> 1, maxlvl, TRUE);
} while (item[0]._iIvalue > 140000);
witchitem[i] = item[0];
witchitem[i]._iCreateInfo = lvl | 0x2000;
witchitem[i]._iCreateInfo = lvl | CF_WITCH;
witchitem[i]._iIdentified = TRUE;
WitchBookLevel(i);
witchitem[i]._iStatFlag = StoreStatOk(&witchitem[i]);
@@ -3680,7 +3680,7 @@ void SpawnBoy(int lvl)
GetItemBonus(0, itype, lvl, 2 * lvl, TRUE);
} while (item[0]._iIvalue > 90000);
boyitem = item[0];
boyitem._iCreateInfo = lvl | 0x1000;
boyitem._iCreateInfo = lvl | CF_BOY;
boyitem._iIdentified = TRUE;
boyitem._iStatFlag = StoreStatOk(&boyitem);
boylevel = lvl >> 1;
@@ -3802,7 +3802,7 @@ void SpawnHealer(int lvl)
itype = RndHealerItem(lvl) - 1;
GetItemAttrs(0, itype, lvl);
healitem[i] = item[0];
healitem[i]._iCreateInfo = lvl | 0x4000;
healitem[i]._iCreateInfo = lvl | CF_HEALER;
healitem[i]._iIdentified = TRUE;
healitem[i]._iStatFlag = StoreStatOk(&healitem[i]);
}
@@ -3828,7 +3828,7 @@ void RecreateSmithItem(int ii, int idx, int lvl, int iseed)
GetItemAttrs(ii, itype, lvl);
item[ii]._iSeed = iseed;
item[ii]._iCreateInfo = lvl | 0x400;
item[ii]._iCreateInfo = lvl | CF_SMITH;
item[ii]._iIdentified = TRUE;
}
@@ -3842,7 +3842,7 @@ void RecreatePremiumItem(int ii, int idx, int plvl, int iseed)
GetItemBonus(ii, itype, plvl >> 1, plvl, TRUE);
item[ii]._iSeed = iseed;
item[ii]._iCreateInfo = plvl | 0x800;
item[ii]._iCreateInfo = plvl | CF_SMITHPREMIUM;
item[ii]._iIdentified = TRUE;
}
@@ -3855,7 +3855,7 @@ void RecreateBoyItem(int ii, int idx, int lvl, int iseed)
GetItemAttrs(ii, itype, lvl);
GetItemBonus(ii, itype, lvl, 2 * lvl, TRUE);
item[ii]._iSeed = iseed;
item[ii]._iCreateInfo = lvl | 0x1000;
item[ii]._iCreateInfo = lvl | CF_BOY;
item[ii]._iIdentified = TRUE;
}
@@ -3879,7 +3879,7 @@ void RecreateWitchItem(int ii, int idx, int lvl, int iseed)
}
item[ii]._iSeed = iseed;
item[ii]._iCreateInfo = lvl | 0x2000;
item[ii]._iCreateInfo = lvl | CF_WITCH;
item[ii]._iIdentified = TRUE;
}
@@ -3896,22 +3896,22 @@ void RecreateHealerItem(int ii, int idx, int lvl, int iseed)
}
item[ii]._iSeed = iseed;
item[ii]._iCreateInfo = lvl | 0x4000;
item[ii]._iCreateInfo = lvl | CF_HEALER;
item[ii]._iIdentified = TRUE;
}
void RecreateTownItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue)
{
if (icreateinfo & 0x400)
RecreateSmithItem(ii, idx, icreateinfo & 0x3F, iseed);
else if (icreateinfo & 0x800)
RecreatePremiumItem(ii, idx, icreateinfo & 0x3F, iseed);
else if (icreateinfo & 0x1000)
RecreateBoyItem(ii, idx, icreateinfo & 0x3F, iseed);
else if (icreateinfo & 0x2000)
RecreateWitchItem(ii, idx, icreateinfo & 0x3F, iseed);
else if (icreateinfo & 0x4000)
RecreateHealerItem(ii, idx, icreateinfo & 0x3F, iseed);
if (icreateinfo & CF_SMITH)
RecreateSmithItem(ii, idx, icreateinfo & CF_LEVEL, iseed);
else if (icreateinfo & CF_SMITHPREMIUM)
RecreatePremiumItem(ii, idx, icreateinfo & CF_LEVEL, iseed);
else if (icreateinfo & CF_BOY)
RecreateBoyItem(ii, idx, icreateinfo & CF_LEVEL, iseed);
else if (icreateinfo & CF_WITCH)
RecreateWitchItem(ii, idx, icreateinfo & CF_LEVEL, iseed);
else if (icreateinfo & CF_HEALER)
RecreateHealerItem(ii, idx, icreateinfo & CF_LEVEL, iseed);
}
void RecalcStoreStats()

33
enums.h
View File

@@ -1884,6 +1884,39 @@ typedef enum dflag {
BFLAG_EXPLORED = 0x80,
} dflag;
/*
First 5 bits store level
6th bit stores onlygood flag
7th bit stores uper15 flag - uper means unique percent, this flag is true for unique monsters and loot from them has 15% to become unique
8th bit stores uper1 flag - this is loot from normal monsters, which has 1% to become unique
9th bit stores info if item is unique
10th bit stores info if item is a basic one from griswold
11th bit stores info if item is a premium one from griswold
12th bit stores info if item is from wirt
13th bit stores info if item is from adria
14th bit stores info if item is from pepin
15th bit stores pregen flag
combining CF_UPER15 and CF_UPER1 flags (CF_USEFUL) is used to mark potions and town portal scrolls created on the ground
CF_TOWN is combining all store flags and indicates if item has been bought from a NPC
*/
typedef enum icreateinfo_flag {
CF_LEVEL = (1 << 6) - 1,
CF_ONLYGOOD = 1 << 6,
CF_UPER15 = 1 << 7,
CF_UPER1 = 1 << 8,
CF_UNIQUE = 1 << 9,
CF_SMITH = 1 << 10,
CF_SMITHPREMIUM = 1 << 11,
CF_BOY = 1 << 12,
CF_WITCH = 1 << 13,
CF_HEALER = 1 << 14,
CF_PREGEN = 1 << 15,
CF_USEFUL = CF_UPER15 | CF_UPER1,
CF_TOWN = CF_SMITH | CF_SMITHPREMIUM | CF_BOY | CF_WITCH | CF_HEALER,
} icreateinfo_flag;
typedef enum dungeon_message {
DMSG_CATHEDRAL = 1 << 0,
DMSG_CATACOMBS = 1 << 1,