From 783e4a70b15c29dc569a03a917bfcefb368c2c56 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 6 Mar 2021 08:10:44 +0100 Subject: [PATCH] :recycle: Strongly type items structures --- Source/itemdat.h | 527 ++++++++++++++++++++++++++++++++++++++++++++ Source/items.cpp | 71 +++--- Source/items.h | 192 +++++++++------- Source/loadsave.cpp | 4 +- Source/objects.cpp | 4 +- Source/objects.h | 2 +- enums.h | 494 ----------------------------------------- structs.h | 82 ------- 8 files changed, 686 insertions(+), 690 deletions(-) diff --git a/Source/itemdat.h b/Source/itemdat.h index f67e826fa..f03a0319e 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -12,6 +12,533 @@ DEVILUTION_BEGIN_NAMESPACE extern "C" { #endif +typedef enum item_drop_rate { + IDROP_NEVER, + IDROP_REGULAR, + IDROP_DOUBLE, +} item_drop_rate; + +typedef enum item_class { + ICLASS_NONE, + ICLASS_WEAPON, + ICLASS_ARMOR, + ICLASS_MISC, + ICLASS_GOLD, + ICLASS_QUEST, +} item_class; + +typedef enum item_equip_type { + ILOC_NONE, + ILOC_ONEHAND, + ILOC_TWOHAND, + ILOC_ARMOR, + ILOC_HELM, + ILOC_RING, + ILOC_AMULET, + ILOC_UNEQUIPABLE, + ILOC_BELT, + ILOC_INVALID = -1, +} item_equip_type; + +/// Item graphic IDs; frame_num-11 of objcurs.cel. +typedef enum item_cursor_graphic { + // clang-format off + ICURS_POTION_OF_FULL_MANA = 0, + ICURS_SCROLL_OF = 1, + ICURS_GOLD_SMALL = 4, + ICURS_GOLD_MEDIUM = 5, + ICURS_GOLD_LARGE = 6, + ICURS_RING_OF_TRUTH = 10, + ICURS_RING = 12, + ICURS_SPECTRAL_ELIXIR = 15, + ICURS_GOLDEN_ELIXIR = 17, + ICURS_EMPYREAN_BAND = 18, + ICURS_EAR_SORCEROR = 19, + ICURS_EAR_WARRIOR = 20, + ICURS_EAR_ROGUE = 21, + ICURS_BLOOD_STONE = 25, + ICURS_OIL = 30, + ICURS_ELIXIR_OF_VITALITY = 31, + ICURS_POTION_OF_HEALING = 32, + ICURS_POTION_OF_FULL_REJUVENATION = 33, + ICURS_ELIXIR_OF_MAGIC = 34, + ICURS_POTION_OF_FULL_HEALING = 35, + ICURS_ELIXIR_OF_DEXTERITY = 36, + ICURS_POTION_OF_REJUVENATION = 37, + ICURS_ELIXIR_OF_STRENGTH = 38, + ICURS_POTION_OF_MANA = 39, + ICURS_BRAIN = 40, + ICURS_OPTIC_AMULET = 44, + ICURS_AMULET = 45, + ICURS_DAGGER = 51, + ICURS_BLADE = 56, + ICURS_BASTARD_SWORD = 57, + ICURS_MACE = 59, + ICURS_LONG_SWORD = 60, + ICURS_BROAD_SWORD = 61, + ICURS_FALCHION = 62, + ICURS_MORNING_STAR = 63, + ICURS_SHORT_SWORD = 64, + ICURS_CLAYMORE = 65, + ICURS_CLUB = 66, + ICURS_SABRE = 67, + ICURS_SPIKED_CLUB = 70, + ICURS_SCIMITAR = 72, + ICURS_FULL_HELM = 75, + ICURS_MAGIC_ROCK = 76, + ICURS_THE_UNDEAD_CROWN = 78, + ICURS_HELM = 82, + ICURS_BUCKLER = 83, + ICURS_VIEL_OF_STEEL = 85, + ICURS_BOOK_GREY = 86, + ICURS_BOOK_RED = 87, + ICURS_BOOK_BLUE = 88, + ICURS_BLACK_MUSHROOM = 89, + ICURS_SKULL_CAP = 90, + ICURS_CAP = 91, + ICURS_HARLEQUIN_CREST = 93, + ICURS_CROWN = 95, + ICURS_MAP_OF_THE_STARS = 96, + ICURS_FUNGAL_TOME = 97, + ICURS_GREAT_HELM = 98, + ICURS_BATTLE_AXE = 101, + ICURS_HUNTERS_BOW = 102, + ICURS_FIELD_PLATE = 103, + ICURS_SMALL_SHIELD = 105, + ICURS_CLEAVER = 106, + ICURS_STUDDED_LEATHER_ARMOR = 107, + ICURS_SHORT_STAFF = 109, + ICURS_TWO_HANDED_SWORD = 110, + ICURS_CHAIN_MAIL = 111, + ICURS_SMALL_AXE = 112, + ICURS_KITE_SHIELD = 113, + ICURS_SCALE_MAIL = 114, + ICURS_SHORT_BOW = 118, + ICURS_LONG_WAR_BOW = 119, + ICURS_WAR_HAMMER = 121, + ICURS_MAUL = 122, + ICURS_LONG_STAFF = 123, + ICURS_WAR_STAFF = 124, + ICURS_TAVERN_SIGN = 126, + ICURS_HARD_LEATHER_ARMOR = 127, + ICURS_RAGS = 128, + ICURS_QUILTED_ARMOR = 129, + ICURS_FLAIL = 131, + ICURS_TOWER_SHIELD = 132, + ICURS_COMPOSITE_BOW = 133, + ICURS_GREAT_SWORD = 134, + ICURS_LEATHER_ARMOR = 135, + ICURS_SPLINT_MAIL = 136, + ICURS_ROBE = 137, + ICURS_ANVIL_OF_FURY = 140, + ICURS_BROAD_AXE = 141, + ICURS_LARGE_AXE = 142, + ICURS_GREAT_AXE = 143, + ICURS_AXE = 144, + ICURS_LARGE_SHIELD = 147, + ICURS_GOTHIC_SHIELD = 148, + ICURS_CLOAK = 149, + ICURS_CAPE = 150, + ICURS_FULL_PLATE_MAIL = 151, + ICURS_GOTHIC_PLATE = 152, + ICURS_BREAST_PLATE = 153, + ICURS_RING_MAIL = 154, + ICURS_STAFF_OF_LAZARUS = 155, + ICURS_ARKAINES_VALOR = 157, + ICURS_SHORT_WAR_BOW = 165, + ICURS_COMPOSITE_STAFF = 166, + ICURS_SHORT_BATTLE_BOW = 167, + ICURS_GOLD = 168, + ICURS_AURIC_AMULET = 180, + ICURS_RUNE_BOMB = 187, + ICURS_THEODORE = 188, + ICURS_TORN_NOTE_1 = 189, + ICURS_TORN_NOTE_2 = 190, + ICURS_TORN_NOTE_3 = 191, + ICURS_RECONSTRUCTED_NOTE = 192, + ICURS_RUNE_OF_FIRE = 193, + ICURS_GREATER_RUNE_OF_FIRE = 194, + ICURS_RUNE_OF_LIGHTNING = 195, + ICURS_GREATER_RUNE_OF_LIGHTNING = 196, + ICURS_RUNE_OF_STONE = 197, + ICURS_GREY_SUIT = 198, + ICURS_BROWN_SUIT = 199, + ICURS_BOVINE = 226, + // clang-format on +} item_cursor_graphic; + +typedef enum item_type { + ITYPE_MISC, + ITYPE_SWORD, + ITYPE_AXE, + ITYPE_BOW, + ITYPE_MACE, + ITYPE_SHIELD, + ITYPE_LARMOR, + ITYPE_HELM, + ITYPE_MARMOR, + ITYPE_HARMOR, + ITYPE_STAFF, + ITYPE_GOLD, + ITYPE_RING, + ITYPE_AMULET, + ITYPE_FOOD, /* used in demo */ + ITYPE_NONE = -1, +} item_type; + +typedef enum unique_base_item { + UITYPE_NONE, + UITYPE_SHORTBOW, + UITYPE_LONGBOW, + UITYPE_HUNTBOW, + UITYPE_COMPBOW, + UITYPE_WARBOW, + UITYPE_BATTLEBOW, + UITYPE_DAGGER, + UITYPE_FALCHION, + UITYPE_CLAYMORE, + UITYPE_BROADSWR, + UITYPE_SABRE, + UITYPE_SCIMITAR, + UITYPE_LONGSWR, + UITYPE_BASTARDSWR, + UITYPE_TWOHANDSWR, + UITYPE_GREATSWR, + UITYPE_CLEAVER, + UITYPE_LARGEAXE, + UITYPE_BROADAXE, + UITYPE_SMALLAXE, + UITYPE_BATTLEAXE, + UITYPE_GREATAXE, + UITYPE_MACE, + UITYPE_MORNSTAR, + UITYPE_SPIKCLUB, + UITYPE_MAUL, + UITYPE_WARHAMMER, + UITYPE_FLAIL, + UITYPE_LONGSTAFF, + UITYPE_SHORTSTAFF, + UITYPE_COMPSTAFF, + UITYPE_QUARSTAFF, + UITYPE_WARSTAFF, + UITYPE_SKULLCAP, + UITYPE_HELM, + UITYPE_GREATHELM, + UITYPE_CROWN, + UITYPE_38, + UITYPE_RAGS, + UITYPE_STUDARMOR, + UITYPE_CLOAK, + UITYPE_ROBE, + UITYPE_CHAINMAIL, + UITYPE_LEATHARMOR, + UITYPE_BREASTPLATE, + UITYPE_CAPE, + UITYPE_PLATEMAIL, + UITYPE_FULLPLATE, + UITYPE_BUCKLER, + UITYPE_SMALLSHIELD, + UITYPE_LARGESHIELD, + UITYPE_KITESHIELD, + UITYPE_GOTHSHIELD, + UITYPE_RING, + UITYPE_55, + UITYPE_AMULET, + UITYPE_SKCROWN, + UITYPE_INFRARING, + UITYPE_OPTAMULET, + UITYPE_TRING, + UITYPE_HARCREST, + UITYPE_MAPOFDOOM, + UITYPE_ELIXIR, + UITYPE_ARMOFVAL, + UITYPE_STEELVEIL, + UITYPE_GRISWOLD, + UITYPE_LGTFORGE, + UITYPE_LAZSTAFF, + UITYPE_BOVINE, + UITYPE_INVALID = -1, +} unique_base_item; + +typedef enum item_special_effect { + // clang-format off + ISPL_NONE = 0x00000000, + ISPL_INFRAVISION = 0x00000001, + ISPL_RNDSTEALLIFE = 0x00000002, + ISPL_RNDARROWVEL = 0x00000004, + ISPL_FIRE_ARROWS = 0x00000008, + ISPL_FIREDAM = 0x00000010, + ISPL_LIGHTDAM = 0x00000020, + ISPL_DRAINLIFE = 0x00000040, + ISPL_UNKNOWN_1 = 0x00000080, + ISPL_NOHEALPLR = 0x00000100, + ISPL_MULT_ARROWS = 0x00000200, + ISPL_UNKNOWN_3 = 0x00000400, + ISPL_KNOCKBACK = 0x00000800, + ISPL_NOHEALMON = 0x00001000, + ISPL_STEALMANA_3 = 0x00002000, + ISPL_STEALMANA_5 = 0x00004000, + ISPL_STEALLIFE_3 = 0x00008000, + ISPL_STEALLIFE_5 = 0x00010000, + ISPL_QUICKATTACK = 0x00020000, + ISPL_FASTATTACK = 0x00040000, + ISPL_FASTERATTACK = 0x00080000, + ISPL_FASTESTATTACK = 0x00100000, + ISPL_FASTRECOVER = 0x00200000, + ISPL_FASTERRECOVER = 0x00400000, + ISPL_FASTESTRECOVER = 0x00800000, + ISPL_FASTBLOCK = 0x01000000, + ISPL_LIGHT_ARROWS = 0x02000000, + ISPL_THORNS = 0x04000000, + ISPL_NOMANA = 0x08000000, + ISPL_ABSHALFTRAP = 0x10000000, + ISPL_UNKNOWN_4 = 0x20000000, + ISPL_3XDAMVDEM = 0x40000000, + ISPL_ALLRESZERO = 0x80000000, + // clang-format on +} item_special_effect; + +typedef enum item_misc_id { + IMISC_NONE, + IMISC_USEFIRST, + IMISC_FULLHEAL, + IMISC_HEAL, + IMISC_OLDHEAL, + IMISC_DEADHEAL, + IMISC_MANA, + IMISC_FULLMANA, + IMISC_POTEXP, /* add experience */ + IMISC_POTFORG, /* remove experience */ + IMISC_ELIXSTR, + IMISC_ELIXMAG, + IMISC_ELIXDEX, + IMISC_ELIXVIT, + IMISC_ELIXWEAK, /* double check with alpha */ + IMISC_ELIXDIS, + IMISC_ELIXCLUM, + IMISC_ELIXSICK, + IMISC_REJUV, + IMISC_FULLREJUV, + IMISC_USELAST, + IMISC_SCROLL, + IMISC_SCROLLT, + IMISC_STAFF, + IMISC_BOOK, + IMISC_RING, + IMISC_AMULET, + IMISC_UNIQUE, + IMISC_FOOD, /* from demo/PSX */ + IMISC_OILFIRST, + IMISC_OILOF, /* oils are beta or hellfire only */ + IMISC_OILACC, + IMISC_OILMAST, + IMISC_OILSHARP, + IMISC_OILDEATH, + IMISC_OILSKILL, + IMISC_OILBSMTH, + IMISC_OILFORT, + IMISC_OILPERM, + IMISC_OILHARD, + IMISC_OILIMP, + IMISC_OILLAST, + IMISC_MAPOFDOOM, + IMISC_EAR, + IMISC_SPECELIX, + IMISC_0xD, + IMISC_RUNEFIRST, + IMISC_RUNEF, + IMISC_RUNEL, + IMISC_GR_RUNEL, + IMISC_GR_RUNEF, + IMISC_RUNES, + IMISC_RUNELAST, + IMISC_AURIC, + IMISC_NOTE, + IMISC_INVALID = -1, +} item_misc_id; + +typedef struct ItemDataStruct { + enum item_drop_rate iRnd; + enum item_class iClass; + enum item_equip_type iLoc; + enum item_cursor_graphic iCurs; + enum item_type itype; + enum unique_base_item iItemId; + const char *iName; + const char *iSName; + Sint8 iMinMLvl; + Sint32 iDurability; + Sint32 iMinDam; + Sint32 iMaxDam; + Sint32 iMinAC; + Sint32 iMaxAC; + Sint8 iMinStr; + Sint8 iMinMag; + Sint8 iMinDex; + Sint32 iFlags; // item_special_effect as bit flags + enum item_misc_id iMiscId; + enum spell_id iSpell; + BOOL iUsable; + Sint32 iValue; + Sint32 iMaxValue; +} ItemDataStruct; + +typedef enum item_effect_type { + IPL_TOHIT, + IPL_TOHIT_CURSE, + IPL_DAMP, + IPL_DAMP_CURSE, + IPL_TOHIT_DAMP, + IPL_TOHIT_DAMP_CURSE, + IPL_ACP, + IPL_ACP_CURSE, + IPL_FIRERES, + IPL_LIGHTRES, + IPL_MAGICRES, + IPL_ALLRES, + IPL_SPLCOST, /* only used in beta */ + IPL_SPLDUR, /* only used in beta */ + IPL_SPLLVLADD, + IPL_CHARGES, + IPL_FIREDAM, + IPL_LIGHTDAM, + IPL_0x12, + IPL_STR, + IPL_STR_CURSE, + IPL_MAG, + IPL_MAG_CURSE, + IPL_DEX, + IPL_DEX_CURSE, + IPL_VIT, + IPL_VIT_CURSE, + IPL_ATTRIBS, + IPL_ATTRIBS_CURSE, + IPL_GETHIT_CURSE, + IPL_GETHIT, + IPL_LIFE, + IPL_LIFE_CURSE, + IPL_MANA, + IPL_MANA_CURSE, + IPL_DUR, + IPL_DUR_CURSE, + IPL_INDESTRUCTIBLE, + IPL_LIGHT, + IPL_LIGHT_CURSE, + IPL_0x28, + IPL_MULT_ARROWS, /* only used in hellfire */ + IPL_FIRE_ARROWS, + IPL_LIGHT_ARROWS, + IPL_INVCURS, + IPL_THORNS, + IPL_NOMANA, + IPL_NOHEALPLR, + IPL_0x30, + IPL_0x31, + IPL_FIREBALL, /* only used in hellfire */ + IPL_0x33, + IPL_ABSHALFTRAP, + IPL_KNOCKBACK, + IPL_NOHEALMON, + IPL_STEALMANA, + IPL_STEALLIFE, + IPL_TARGAC, + IPL_FASTATTACK, + IPL_FASTRECOVER, + IPL_FASTBLOCK, + IPL_DAMMOD, + IPL_RNDARROWVEL, + IPL_SETDAM, + IPL_SETDUR, + IPL_NOMINSTR, + IPL_SPELL, + IPL_FASTSWING, + IPL_ONEHAND, + IPL_3XDAMVDEM, + IPL_ALLRESZERO, + IPL_0x47, + IPL_DRAINLIFE, + IPL_RNDSTEALLIFE, + IPL_INFRAVISION, + IPL_SETAC, + IPL_ADDACLIFE, + IPL_ADDMANAAC, + IPL_FIRERESCLVL, + IPL_AC_CURSE, + IPL_FIRERES_CURSE, + IPL_LIGHTRES_CURSE, + IPL_MAGICRES_CURSE, + IPL_ALLRES_CURSE, + IPL_DEVASTATION, + IPL_DECAY, + IPL_PERIL, + IPL_JESTERS, + IPL_CRYSTALLINE, + IPL_DOPPELGANGER, + IPL_ACDEMON, + IPL_ACUNDEAD, + IPL_MANATOLIFE, + IPL_LIFETOMANA, + IPL_INVALID = -1, +} item_effect_type; + +typedef enum goodorevil { + GOE_ANY, + GOE_EVIL, + GOE_GOOD, +} goodorevil; + +typedef enum affix_item_type { + // clang-format off + PLT_MISC = 0x000001, + PLT_BOW = 0x000010, + PLT_STAFF = 0x000100, + PLT_WEAP = 0x001000, + PLT_SHLD = 0x010000, + PLT_ARMO = 0x100000, + // clang-format on +} affix_item_type; + +typedef struct PLStruct { + const char *PLName; + enum item_effect_type PLPower; + Sint32 PLParam1; + Sint32 PLParam2; + Sint8 PLMinLvl; + Sint32 PLIType; // affix_item_type as bit flags + enum goodorevil PLGOE; + bool PLDouble; + bool PLOk; + Sint32 PLMinVal; + Sint32 PLMaxVal; + Sint32 PLMultVal; +} PLStruct; + +typedef struct UItemStruct { + const char *UIName; + enum unique_base_item UIItemId; + Sint8 UIMinLvl; + Sint8 UINumPL; + Sint32 UIValue; + enum item_effect_type UIPower1; + Sint32 UIParam1; + Sint32 UIParam2; + enum item_effect_type UIPower2; + Sint32 UIParam3; + Sint32 UIParam4; + enum item_effect_type UIPower3; + Sint32 UIParam5; + Sint32 UIParam6; + enum item_effect_type UIPower4; + Sint32 UIParam7; + Sint32 UIParam8; + enum item_effect_type UIPower5; + Sint32 UIParam9; + Sint32 UIParam10; + enum item_effect_type UIPower6; + Sint32 UIParam11; + Sint32 UIParam12; +} UItemStruct; + extern ItemDataStruct AllItemsList[]; extern const PLStruct PL_Prefix[]; extern const PLStruct PL_Suffix[]; diff --git a/Source/items.cpp b/Source/items.cpp index 02ee6ae6f..007083ba2 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -28,7 +28,7 @@ int gnNumGetRecords; int OilLevels[] = { 1, 10, 1, 10, 4, 1, 5, 17, 1, 10 }; int OilValues[] = { 500, 2500, 500, 2500, 1500, 100, 2500, 15000, 500, 2500 }; -int OilMagic[] = { +enum item_misc_id OilMagic[] = { IMISC_OILACC, IMISC_OILMAST, IMISC_OILSHARP, @@ -348,11 +348,11 @@ int get_ring_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_RING && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_RING && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_RING && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_RING && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -365,11 +365,11 @@ int get_bow_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_BOW && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_BOW && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_BOW && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_BOW && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -382,11 +382,11 @@ int get_staff_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_STAFF && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_STAFF && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_STAFF && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_STAFF && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -399,11 +399,11 @@ int get_sword_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_SWORD && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_SWORD && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_SWORD && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_SWORD && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -416,11 +416,11 @@ int get_helm_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_HELM && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_HELM && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_HELM && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_HELM && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -433,11 +433,11 @@ int get_shield_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_SHIELD && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_SHIELD && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_SHIELD && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_SHIELD && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -450,13 +450,13 @@ int get_armor_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && (plr[i].InvBody[j]._itype == ITYPE_LARMOR || plr[i].InvBody[j]._itype == ITYPE_MARMOR || plr[i].InvBody[j]._itype == ITYPE_HARMOR) && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE + if (plr[i].InvList[j]._iClass != ICLASS_NONE && (plr[i].InvList[j]._itype == ITYPE_LARMOR || plr[i].InvList[j]._itype == ITYPE_MARMOR || plr[i].InvList[j]._itype == ITYPE_HARMOR) && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; @@ -471,11 +471,11 @@ int get_mace_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_MACE && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_MACE && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_MACE && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_MACE && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -488,11 +488,11 @@ int get_amulet_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_AMULET && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_AMULET && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_AMULET && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_AMULET && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -505,11 +505,11 @@ int get_axe_max_value(int i) res = 0; for (j = 0; j < NUM_INVLOC; j++) { - if (plr[i].InvBody[j]._iClass != ITYPE_NONE && plr[i].InvBody[j]._itype == ITYPE_AXE && res < plr[i].InvBody[j]._iIvalue) + if (plr[i].InvBody[j]._iClass != ICLASS_NONE && plr[i].InvBody[j]._itype == ITYPE_AXE && res < plr[i].InvBody[j]._iIvalue) res = plr[i].InvBody[j]._iIvalue; } for (j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[i].InvList[j]._iClass != ITYPE_NONE && plr[i].InvList[j]._itype == ITYPE_AXE && res < plr[i].InvList[j]._iIvalue) + if (plr[i].InvList[j]._iClass != ICLASS_NONE && plr[i].InvList[j]._itype == ITYPE_AXE && res < plr[i].InvList[j]._iIvalue) res = plr[i].InvList[j]._iIvalue; } @@ -1281,8 +1281,8 @@ void SetPlrHandItem(ItemStruct *h, int idata) h->_iMinDex = pAllItem->iMinDex; h->_ivalue = pAllItem->iValue; h->_iIvalue = pAllItem->iValue; - h->_iPrePower = -1; - h->_iSufPower = -1; + h->_iPrePower = IPL_INVALID; + h->_iSufPower = IPL_INVALID; h->_iMagical = ITEM_QUALITY_NORMAL; h->IDidx = idata; } @@ -1637,7 +1637,7 @@ void CalcItemValue(int i) void GetBookSpell(int i, int lvl) { - int rv, s, bs; + int rv; if (lvl == 0) lvl = 1; @@ -1649,13 +1649,13 @@ void GetBookSpell(int i, int lvl) if (gbIsSpawn && lvl > 5) lvl = 5; - s = SPL_FIREBOLT; - bs = SPL_FIREBOLT; + int s = SPL_FIREBOLT; + enum spell_id bs = SPL_FIREBOLT; while (rv > 0) { int sLevel = GetSpellBookLevel(s); if (sLevel != -1 && lvl >= sLevel) { rv--; - bs = s; + bs = static_cast(s); } s++; if (!gbIsMultiplayer) { @@ -1744,7 +1744,7 @@ void GetStaffPower(int i, int lvl, int bs, BOOL onlygood) void GetStaffSpell(int i, int lvl, BOOL onlygood) { - int l, rv, s, minc, maxc, v, bs; + int l, rv, minc, maxc, v; char istr[68]; if (!gbIsHellfire && random_(17, 4) == 0) { @@ -1759,12 +1759,13 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood) if (gbIsSpawn && lvl > 10) lvl = 10; - s = SPL_FIREBOLT; + int s = SPL_FIREBOLT; + enum spell_id bs = SPL_NULL; while (rv > 0) { int sLevel = GetSpellStaffLevel(s); if (sLevel != -1 && l >= sLevel) { rv--; - bs = s; + bs = static_cast(s); } s++; if (!gbIsMultiplayer && s == SPL_RESURRECT) @@ -1846,8 +1847,8 @@ void GetItemAttrs(int i, int idata, int lvl) item[i]._iMinMag = AllItemsList[idata].iMinMag; item[i]._iMinDex = AllItemsList[idata].iMinDex; item[i].IDidx = idata; - item[i]._iPrePower = -1; - item[i]._iSufPower = -1; + item[i]._iPrePower = IPL_INVALID; + item[i]._iSufPower = IPL_INVALID; if (item[i]._iMiscId == IMISC_BOOK) GetBookSpell(i, lvl); @@ -1981,7 +1982,7 @@ void SaveItemPower(int i, int power, int param1, int param2, int minval, int max item[i]._iMaxCharges = item[i]._iCharges; break; case IPL_SPELL: - item[i]._iSpell = param1; + item[i]._iSpell = static_cast(param1); item[i]._iCharges = param2; item[i]._iMaxCharges = param2; break; @@ -2307,7 +2308,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood) int pre, post, nt, nl, j, preidx, sufidx; int l[256]; char istr[128]; - BYTE goe; + goodorevil goe; pre = random_(23, 4); post = random_(23, 3); @@ -2362,7 +2363,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood) break; if (IsSuffixValidForItemType(j, flgs) && PL_Suffix[j].PLMinLvl >= minlvl && PL_Suffix[j].PLMinLvl <= maxlvl - && (goe | PL_Suffix[j].PLGOE) != (GOE_GOOD | GOE_EVIL) + && !((goe == GOE_GOOD && PL_Suffix[j].PLGOE == GOE_EVIL) || (goe == GOE_EVIL && PL_Suffix[j].PLGOE == GOE_GOOD)) && (!onlygood || PL_Suffix[j].PLOk)) { l[nl] = j; nl++; diff --git a/Source/items.h b/Source/items.h index 767e22cde..d345d6a6a 100644 --- a/Source/items.h +++ b/Source/items.h @@ -6,100 +6,144 @@ #ifndef __ITEMS_H__ #define __ITEMS_H__ +#include "itemdat.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus extern "C" { #endif +typedef enum item_quality { + ITEM_QUALITY_NORMAL, + ITEM_QUALITY_MAGIC, + ITEM_QUALITY_UNIQUE, +} item_quality; + +/* + 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 struct ItemStruct { - int _iSeed; - WORD _iCreateInfo; - int _itype; - int _ix; - int _iy; - BOOL _iAnimFlag; - unsigned char *_iAnimData; // PSX name -> ItemFrame - int _iAnimLen; // Number of frames in current animation - int _iAnimFrame; // Current frame of animation. - int _iAnimWidth; - int _iAnimWidth2; // width 2? - BOOL _iDelFlag; // set when item is flagged for deletion, deprecated in 1.02 - char _iSelFlag; - BOOL _iPostDraw; - BOOL _iIdentified; - char _iMagical; + Sint32 _iSeed; + Uint16 _iCreateInfo; + enum item_type _itype; + Sint32 _ix; + Sint32 _iy; + bool _iAnimFlag; + Uint8 *_iAnimData; // PSX name -> ItemFrame + Sint32 _iAnimLen; // Number of frames in current animation + Sint32 _iAnimFrame; // Current frame of animation. + Sint32 _iAnimWidth; + Sint32 _iAnimWidth2; // width 2? + bool _iDelFlag; // set when item is flagged for deletion, deprecated in 1.02 + Sint8 _iSelFlag; + bool _iPostDraw; + bool _iIdentified; + Sint8 _iMagical; char _iName[64]; char _iIName[64]; - char _iLoc; - // item_class enum - char _iClass; - int _iCurs; - int _ivalue; - int _iIvalue; - int _iMinDam; - int _iMaxDam; - int _iAC; - // item_special_effect - int _iFlags; - // item_misc_id - int _iMiscId; - // spell_id - int _iSpell; - int _iCharges; - int _iMaxCharges; - int _iDurability; - int _iMaxDur; - int _iPLDam; - int _iPLToHit; - int _iPLAC; - int _iPLStr; - int _iPLMag; - int _iPLDex; - int _iPLVit; - int _iPLFR; - int _iPLLR; - int _iPLMR; - int _iPLMana; - int _iPLHP; - int _iPLDamMod; - int _iPLGetHit; - int _iPLLight; - char _iSplLvlAdd; - char _iRequest; - int _iUid; - int _iFMinDam; - int _iFMaxDam; - int _iLMinDam; - int _iLMaxDam; - int _iPLEnAc; - char _iPrePower; - char _iSufPower; - int _iVAdd1; - int _iVMult1; - int _iVAdd2; - int _iVMult2; - char _iMinStr; - unsigned char _iMinMag; - char _iMinDex; - BOOL _iStatFlag; - int IDidx; - int offs016C; // _oldlight or _iInvalid - int _iDamAcFlags; + enum item_equip_type _iLoc; + enum item_class _iClass; + Sint32 _iCurs; + Sint32 _ivalue; + Sint32 _iIvalue; + Sint32 _iMinDam; + Sint32 _iMaxDam; + Sint32 _iAC; + Sint32 _iFlags; // item_special_effect + enum item_misc_id _iMiscId; + enum spell_id _iSpell; + Sint32 _iCharges; + Sint32 _iMaxCharges; + Sint32 _iDurability; + Sint32 _iMaxDur; + Sint32 _iPLDam; + Sint32 _iPLToHit; + Sint32 _iPLAC; + Sint32 _iPLStr; + Sint32 _iPLMag; + Sint32 _iPLDex; + Sint32 _iPLVit; + Sint32 _iPLFR; + Sint32 _iPLLR; + Sint32 _iPLMR; + Sint32 _iPLMana; + Sint32 _iPLHP; + Sint32 _iPLDamMod; + Sint32 _iPLGetHit; + Sint32 _iPLLight; + Sint8 _iSplLvlAdd; + Sint8 _iRequest; + Sint32 _iUid; + Sint32 _iFMinDam; + Sint32 _iFMaxDam; + Sint32 _iLMinDam; + Sint32 _iLMaxDam; + Sint32 _iPLEnAc; + enum item_effect_type _iPrePower; + enum item_effect_type _iSufPower; + Sint32 _iVAdd1; + Sint32 _iVMult1; + Sint32 _iVAdd2; + Sint32 _iVMult2; + Sint8 _iMinStr; + Uint8 _iMinMag; + Sint8 _iMinDex; + bool _iStatFlag; + Sint32 IDidx; + Sint32 _iDamAcFlags; /** * @brief Checks whether this item is empty or not. * @return 'True' in case the item is empty and 'False' otherwise. */ - bool isEmpty() const { + bool isEmpty() const + { return this->_itype == ITYPE_NONE; } } ItemStruct; +typedef struct ItemGetRecordStruct { + Sint32 nSeed; + Uint16 wCI; + Sint32 nIndex; + Uint32 dwTimestamp; +} ItemGetRecordStruct; + typedef struct CornerStoneStruct { - int x; - int y; + Sint32 x; + Sint32 y; bool activated; ItemStruct item; } CornerStoneStruct; diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 395d7c4f3..fcd4c50f6 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -186,7 +186,7 @@ static void LoadItemData(ItemStruct *pItem) if (!gbIsHellfireSaveGame) { pItem->IDidx = RemapItemIdxFromDiablo(pItem->IDidx); } - CopyInt(tbuff, &pItem->offs016C); + tbuff += 4; // Unused if (gbIsHellfireSaveGame) CopyInt(tbuff, &pItem->_iDamAcFlags); else @@ -1140,7 +1140,7 @@ static void SaveItem(ItemStruct *pItem) tbuff += 1; // Alignment CopyInt(&pItem->_iStatFlag, tbuff); CopyInt(&idx, tbuff); - CopyInt(&pItem->offs016C, tbuff); + tbuff += 4; // Unused if (gbIsHellfire) CopyInt(&pItem->_iDamAcFlags, tbuff); } diff --git a/Source/objects.cpp b/Source/objects.cpp index fc544a4b1..d20574873 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -3319,11 +3319,11 @@ void TryDisarm(int pnum, int i) } } -int ItemMiscIdIdx(int imiscid) +int ItemMiscIdIdx(item_misc_id imiscid) { int i; - i = 0; + i = IDI_GOLD; while (AllItemsList[i].iRnd == IDROP_NEVER || AllItemsList[i].iMiscId != imiscid) { i++; } diff --git a/Source/objects.h b/Source/objects.h index 85b9d471b..eaf4a93cc 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -42,7 +42,7 @@ void MonstCheckDoors(int m); void ObjChangeMap(int x1, int y1, int x2, int y2); void ObjChangeMapResync(int x1, int y1, int x2, int y2); void TryDisarm(int pnum, int i); -int ItemMiscIdIdx(int imiscid); +int ItemMiscIdIdx(item_misc_id imiscid); void OperateObject(int pnum, int i, BOOL TeleFlag); void SyncOpObject(int pnum, int cmd, int i); void BreakObject(int pnum, int oi); diff --git a/enums.h b/enums.h index aa9eadcf0..328bc228a 100644 --- a/enums.h +++ b/enums.h @@ -6,312 +6,6 @@ DEVILUTION_BEGIN_NAMESPACE -typedef enum item_quality { - ITEM_QUALITY_NORMAL = 0, - ITEM_QUALITY_MAGIC = 1, - ITEM_QUALITY_UNIQUE = 2, -} item_quality; - -typedef enum unique_base_item { - UITYPE_NONE = 0x0, - UITYPE_SHORTBOW = 0x1, - UITYPE_LONGBOW = 0x2, - UITYPE_HUNTBOW = 0x3, - UITYPE_COMPBOW = 0x4, - UITYPE_WARBOW = 0x5, - UITYPE_BATTLEBOW = 0x6, - UITYPE_DAGGER = 0x7, - UITYPE_FALCHION = 0x8, - UITYPE_CLAYMORE = 0x9, - UITYPE_BROADSWR = 0xA, - UITYPE_SABRE = 0xB, - UITYPE_SCIMITAR = 0xC, - UITYPE_LONGSWR = 0xD, - UITYPE_BASTARDSWR = 0xE, - UITYPE_TWOHANDSWR = 0xF, - UITYPE_GREATSWR = 0x10, - UITYPE_CLEAVER = 0x11, - UITYPE_LARGEAXE = 0x12, - UITYPE_BROADAXE = 0x13, - UITYPE_SMALLAXE = 0x14, - UITYPE_BATTLEAXE = 0x15, - UITYPE_GREATAXE = 0x16, - UITYPE_MACE = 0x17, - UITYPE_MORNSTAR = 0x18, - UITYPE_SPIKCLUB = 0x19, - UITYPE_MAUL = 0x1A, - UITYPE_WARHAMMER = 0x1B, - UITYPE_FLAIL = 0x1C, - UITYPE_LONGSTAFF = 0x1D, - UITYPE_SHORTSTAFF = 0x1E, - UITYPE_COMPSTAFF = 0x1F, - UITYPE_QUARSTAFF = 0x20, - UITYPE_WARSTAFF = 0x21, - UITYPE_SKULLCAP = 0x22, - UITYPE_HELM = 0x23, - UITYPE_GREATHELM = 0x24, - UITYPE_CROWN = 0x25, - UITYPE_38 = 0x26, - UITYPE_RAGS = 0x27, - UITYPE_STUDARMOR = 0x28, - UITYPE_CLOAK = 0x29, - UITYPE_ROBE = 0x2A, - UITYPE_CHAINMAIL = 0x2B, - UITYPE_LEATHARMOR = 0x2C, - UITYPE_BREASTPLATE = 0x2D, - UITYPE_CAPE = 0x2E, - UITYPE_PLATEMAIL = 0x2F, - UITYPE_FULLPLATE = 0x30, - UITYPE_BUCKLER = 0x31, - UITYPE_SMALLSHIELD = 0x32, - UITYPE_LARGESHIELD = 0x33, - UITYPE_KITESHIELD = 0x34, - UITYPE_GOTHSHIELD = 0x35, - UITYPE_RING = 0x36, - UITYPE_55 = 0x37, - UITYPE_AMULET = 0x38, - UITYPE_SKCROWN = 0x39, - UITYPE_INFRARING = 0x3A, - UITYPE_OPTAMULET = 0x3B, - UITYPE_TRING = 0x3C, - UITYPE_HARCREST = 0x3D, - UITYPE_MAPOFDOOM = 0x3E, - UITYPE_ELIXIR = 0x3F, - UITYPE_ARMOFVAL = 0x40, - UITYPE_STEELVEIL = 0x41, - UITYPE_GRISWOLD = 0x42, - UITYPE_LGTFORGE = 0x43, - UITYPE_LAZSTAFF = 0x44, - UITYPE_BOVINE = 0x45, - UITYPE_INVALID = -1, -} unique_base_item; - -typedef enum item_effect_type { - IPL_TOHIT = 0x0, - IPL_TOHIT_CURSE = 0x1, - IPL_DAMP = 0x2, - IPL_DAMP_CURSE = 0x3, - IPL_TOHIT_DAMP = 0x4, - IPL_TOHIT_DAMP_CURSE = 0x5, - IPL_ACP = 0x6, - IPL_ACP_CURSE = 0x7, - IPL_FIRERES = 0x8, - IPL_LIGHTRES = 0x9, - IPL_MAGICRES = 0xA, - IPL_ALLRES = 0xB, - IPL_SPLCOST = 0xC, /* only used in beta */ - IPL_SPLDUR = 0xD, /* only used in beta */ - IPL_SPLLVLADD = 0xE, - IPL_CHARGES = 0xF, - IPL_FIREDAM = 0x10, - IPL_LIGHTDAM = 0x11, - IPL_STR = 0x13, - IPL_STR_CURSE = 0x14, - IPL_MAG = 0x15, - IPL_MAG_CURSE = 0x16, - IPL_DEX = 0x17, - IPL_DEX_CURSE = 0x18, - IPL_VIT = 0x19, - IPL_VIT_CURSE = 0x1A, - IPL_ATTRIBS = 0x1B, - IPL_ATTRIBS_CURSE = 0x1C, - IPL_GETHIT_CURSE = 0x1D, - IPL_GETHIT = 0x1E, - IPL_LIFE = 0x1F, - IPL_LIFE_CURSE = 0x20, - IPL_MANA = 0x21, - IPL_MANA_CURSE = 0x22, - IPL_DUR = 0x23, - IPL_DUR_CURSE = 0x24, - IPL_INDESTRUCTIBLE = 0x25, - IPL_LIGHT = 0x26, - IPL_LIGHT_CURSE = 0x27, - IPL_MULT_ARROWS = 0x29, /* only used in hellfire */ - IPL_FIRE_ARROWS = 0x2A, - IPL_LIGHT_ARROWS = 0x2B, - IPL_INVCURS = 0x2C, - IPL_THORNS = 0x2D, - IPL_NOMANA = 0x2E, - IPL_NOHEALPLR = 0x2F, - IPL_FIREBALL = 0x32, /* only used in hellfire */ - IPL_ABSHALFTRAP = 0x34, - IPL_KNOCKBACK = 0x35, - IPL_NOHEALMON = 0x36, - IPL_STEALMANA = 0x37, - IPL_STEALLIFE = 0x38, - IPL_TARGAC = 0x39, - IPL_FASTATTACK = 0x3A, - IPL_FASTRECOVER = 0x3B, - IPL_FASTBLOCK = 0x3C, - IPL_DAMMOD = 0x3D, - IPL_RNDARROWVEL = 0x3E, - IPL_SETDAM = 0x3F, - IPL_SETDUR = 0x40, - IPL_NOMINSTR = 0x41, - IPL_SPELL = 0x42, - IPL_FASTSWING = 0x43, - IPL_ONEHAND = 0x44, - IPL_3XDAMVDEM = 0x45, - IPL_ALLRESZERO = 0x46, - IPL_DRAINLIFE = 0x48, - IPL_RNDSTEALLIFE = 0x49, - IPL_INFRAVISION = 0x4A, - IPL_SETAC = 0x4B, - IPL_ADDACLIFE = 0x4C, - IPL_ADDMANAAC = 0x4D, - IPL_FIRERESCLVL = 0x4E, - IPL_AC_CURSE = 0x4F, - IPL_FIRERES_CURSE = 0x50, - IPL_LIGHTRES_CURSE = 0x51, - IPL_MAGICRES_CURSE = 0x52, - IPL_ALLRES_CURSE = 0x53, - IPL_DEVASTATION = 0x54, - IPL_DECAY = 0x55, - IPL_PERIL = 0x56, - IPL_JESTERS = 0x57, - IPL_CRYSTALLINE = 0x58, - IPL_DOPPELGANGER = 0x59, - IPL_ACDEMON = 0x5A, - IPL_ACUNDEAD = 0x5B, - IPL_MANATOLIFE = 0x5C, - IPL_LIFETOMANA = 0x5D, - IPL_INVALID = -1, -} item_effect_type; - -typedef enum affix_item_type { - PLT_MISC = 0x1, - PLT_BOW = 0x10, - PLT_STAFF = 0x100, - PLT_WEAP = 0x1000, - PLT_SHLD = 0x10000, - PLT_ARMO = 0x100000, -} affix_item_type; - -/// Item graphic IDs; frame_num-11 of objcurs.cel. -typedef enum item_cursor_graphic { - ICURS_POTION_OF_FULL_MANA = 0, - ICURS_SCROLL_OF = 1, - ICURS_GOLD_SMALL = 4, - ICURS_GOLD_MEDIUM = 5, - ICURS_GOLD_LARGE = 6, - ICURS_RING_OF_TRUTH = 10, - ICURS_RING = 12, - ICURS_SPECTRAL_ELIXIR = 15, - ICURS_GOLDEN_ELIXIR = 17, - ICURS_EMPYREAN_BAND = 18, - ICURS_EAR_SORCEROR = 19, - ICURS_EAR_WARRIOR = 20, - ICURS_EAR_ROGUE = 21, - ICURS_BLOOD_STONE = 25, - ICURS_OIL = 30, - ICURS_ELIXIR_OF_VITALITY = 31, - ICURS_POTION_OF_HEALING = 32, - ICURS_POTION_OF_FULL_REJUVENATION = 33, - ICURS_ELIXIR_OF_MAGIC = 34, - ICURS_POTION_OF_FULL_HEALING = 35, - ICURS_ELIXIR_OF_DEXTERITY = 36, - ICURS_POTION_OF_REJUVENATION = 37, - ICURS_ELIXIR_OF_STRENGTH = 38, - ICURS_POTION_OF_MANA = 39, - ICURS_BRAIN = 40, - ICURS_OPTIC_AMULET = 44, - ICURS_AMULET = 45, - ICURS_DAGGER = 51, - ICURS_BLADE = 56, - ICURS_BASTARD_SWORD = 57, - ICURS_MACE = 59, - ICURS_LONG_SWORD = 60, - ICURS_BROAD_SWORD = 61, - ICURS_FALCHION = 62, - ICURS_MORNING_STAR = 63, - ICURS_SHORT_SWORD = 64, - ICURS_CLAYMORE = 65, - ICURS_CLUB = 66, - ICURS_SABRE = 67, - ICURS_SPIKED_CLUB = 70, - ICURS_SCIMITAR = 72, - ICURS_FULL_HELM = 75, - ICURS_MAGIC_ROCK = 76, - ICURS_THE_UNDEAD_CROWN = 78, - ICURS_HELM = 82, - ICURS_BUCKLER = 83, - ICURS_VIEL_OF_STEEL = 85, - ICURS_BOOK_GREY = 86, - ICURS_BOOK_RED = 87, - ICURS_BOOK_BLUE = 88, - ICURS_BLACK_MUSHROOM = 89, - ICURS_SKULL_CAP = 90, - ICURS_CAP = 91, - ICURS_HARLEQUIN_CREST = 93, - ICURS_CROWN = 95, - ICURS_MAP_OF_THE_STARS = 96, - ICURS_FUNGAL_TOME = 97, - ICURS_GREAT_HELM = 98, - ICURS_BATTLE_AXE = 101, - ICURS_HUNTERS_BOW = 102, - ICURS_FIELD_PLATE = 103, - ICURS_SMALL_SHIELD = 105, - ICURS_CLEAVER = 106, - ICURS_STUDDED_LEATHER_ARMOR = 107, - ICURS_SHORT_STAFF = 109, - ICURS_TWO_HANDED_SWORD = 110, - ICURS_CHAIN_MAIL = 111, - ICURS_SMALL_AXE = 112, - ICURS_KITE_SHIELD = 113, - ICURS_SCALE_MAIL = 114, - ICURS_SHORT_BOW = 118, - ICURS_LONG_WAR_BOW = 119, - ICURS_WAR_HAMMER = 121, - ICURS_MAUL = 122, - ICURS_LONG_STAFF = 123, - ICURS_WAR_STAFF = 124, - ICURS_TAVERN_SIGN = 126, - ICURS_HARD_LEATHER_ARMOR = 127, - ICURS_RAGS = 128, - ICURS_QUILTED_ARMOR = 129, - ICURS_FLAIL = 131, - ICURS_TOWER_SHIELD = 132, - ICURS_COMPOSITE_BOW = 133, - ICURS_GREAT_SWORD = 134, - ICURS_LEATHER_ARMOR = 135, - ICURS_SPLINT_MAIL = 136, - ICURS_ROBE = 137, - ICURS_ANVIL_OF_FURY = 140, - ICURS_BROAD_AXE = 141, - ICURS_LARGE_AXE = 142, - ICURS_GREAT_AXE = 143, - ICURS_AXE = 144, - ICURS_LARGE_SHIELD = 147, - ICURS_GOTHIC_SHIELD = 148, - ICURS_CLOAK = 149, - ICURS_CAPE = 150, - ICURS_FULL_PLATE_MAIL = 151, - ICURS_GOTHIC_PLATE = 152, - ICURS_BREAST_PLATE = 153, - ICURS_RING_MAIL = 154, - ICURS_STAFF_OF_LAZARUS = 155, - ICURS_ARKAINES_VALOR = 157, - ICURS_SHORT_WAR_BOW = 165, - ICURS_COMPOSITE_STAFF = 166, - ICURS_SHORT_BATTLE_BOW = 167, - ICURS_GOLD = 168, - ICURS_AURIC_AMULET = 180, - ICURS_RUNE_BOMB = 187, - ICURS_THEODORE = 188, - ICURS_TORN_NOTE_1 = 189, - ICURS_TORN_NOTE_2 = 190, - ICURS_TORN_NOTE_3 = 191, - ICURS_RECONSTRUCTED_NOTE = 192, - ICURS_RUNE_OF_FIRE = 193, - ICURS_GREATER_RUNE_OF_FIRE = 194, - ICURS_RUNE_OF_LIGHTNING = 195, - ICURS_GREATER_RUNE_OF_LIGHTNING = 196, - ICURS_RUNE_OF_STONE = 197, - ICURS_GREY_SUIT = 198, - ICURS_BROWN_SUIT = 199, - ICURS_BOVINE = 226, -} item_cursor_graphic; - typedef enum _sfx_id { PS_WALK1, PS_WALK2, @@ -1348,19 +1042,6 @@ typedef enum sfx_flag { sfx_HELLFIRE = 0x80, } sfx_flag; -typedef enum item_equip_type { - ILOC_NONE = 0x0, - ILOC_ONEHAND = 0x1, - ILOC_TWOHAND = 0x2, - ILOC_ARMOR = 0x3, - ILOC_HELM = 0x4, - ILOC_RING = 0x5, - ILOC_AMULET = 0x6, - ILOC_UNEQUIPABLE = 0x7, - ILOC_BELT = 0x8, - ILOC_INVALID = -1, -} item_equip_type; - typedef enum missile_id { MIS_ARROW = 0x0, MIS_FIREBOLT = 0x1, @@ -2244,48 +1925,6 @@ typedef enum mienemy_type { TARGET_BOTH = 2, } mienemy_type; -/* -Looks like someone treated hex values as binary, so 0x10 came after 0x01, that's why we have 1 and 16, they did the same thing with affix_item_type -*/ -typedef enum goodorevil { - GOE_ANY = 0x00, - GOE_EVIL = 0x01, - GOE_GOOD = 0x10, -} goodorevil; - -/* - 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, @@ -2397,11 +2036,6 @@ typedef enum event_type { EVENT_TYPE_15 = 15, } event_type; -typedef enum _copyprot_results { - COPYPROT_OK = 1, - COPYPROT_CANCEL = 2, -} _copyprot_results; - typedef enum text_color { COL_WHITE = 0x0, COL_BLUE = 0x1, @@ -2884,83 +2518,6 @@ typedef enum _object_id { OBJ_BOOKSHELFR = 0x62, } _object_id; -typedef enum item_misc_id { - IMISC_NONE = 0x0, - IMISC_USEFIRST = 0x1, - IMISC_FULLHEAL = 0x2, - IMISC_HEAL = 0x3, - IMISC_OLDHEAL = 0x4, - IMISC_DEADHEAL = 0x5, - IMISC_MANA = 0x6, - IMISC_FULLMANA = 0x7, - IMISC_POTEXP = 0x8, /* add experience */ - IMISC_POTFORG = 0x9, /* remove experience */ - IMISC_ELIXSTR = 0xA, - IMISC_ELIXMAG = 0xB, - IMISC_ELIXDEX = 0xC, - IMISC_ELIXVIT = 0xD, - IMISC_ELIXWEAK = 0xE, /* double check with alpha */ - IMISC_ELIXDIS = 0xF, - IMISC_ELIXCLUM = 0x10, - IMISC_ELIXSICK = 0x11, - IMISC_REJUV = 0x12, - IMISC_FULLREJUV = 0x13, - IMISC_USELAST = 0x14, - IMISC_SCROLL = 0x15, - IMISC_SCROLLT = 0x16, - IMISC_STAFF = 0x17, - IMISC_BOOK = 0x18, - IMISC_RING = 0x19, - IMISC_AMULET = 0x1A, - IMISC_UNIQUE = 0x1B, - IMISC_FOOD = 0x1C, /* from demo/PSX */ - IMISC_OILFIRST = 0x1D, - IMISC_OILOF = 0x1E, /* oils are beta or hellfire only */ - IMISC_OILACC = 0x1F, - IMISC_OILMAST = 0x20, - IMISC_OILSHARP = 0x21, - IMISC_OILDEATH = 0x22, - IMISC_OILSKILL = 0x23, - IMISC_OILBSMTH = 0x24, - IMISC_OILFORT = 0x25, - IMISC_OILPERM = 0x26, - IMISC_OILHARD = 0x27, - IMISC_OILIMP = 0x28, - IMISC_OILLAST = 0x29, - IMISC_MAPOFDOOM = 0x2A, - IMISC_EAR = 0x2B, - IMISC_SPECELIX = 0x2C, - IMISC_RUNEFIRST = 0x2E, - IMISC_RUNEF = 0x2F, - IMISC_RUNEL = 0x30, - IMISC_GR_RUNEL = 0x31, - IMISC_GR_RUNEF = 0x32, - IMISC_RUNES = 0x33, - IMISC_RUNELAST = 0x34, - IMISC_AURIC = 0x35, - IMISC_NOTE = 0x36, - IMISC_INVALID = -1, -} item_misc_id; - -typedef enum item_type { - ITYPE_MISC = 0x0, - ITYPE_SWORD = 0x1, - ITYPE_AXE = 0x2, - ITYPE_BOW = 0x3, - ITYPE_MACE = 0x4, - ITYPE_SHIELD = 0x5, - ITYPE_LARMOR = 0x6, - ITYPE_HELM = 0x7, - ITYPE_MARMOR = 0x8, - ITYPE_HARMOR = 0x9, - ITYPE_STAFF = 0xA, - ITYPE_GOLD = 0xB, - ITYPE_RING = 0xC, - ITYPE_AMULET = 0xD, - ITYPE_FOOD = 0xE, /* used in demo */ - ITYPE_NONE = -1, -} item_type; - typedef enum _item_indexes { IDI_GOLD, IDI_WARRIOR, @@ -3223,57 +2780,6 @@ typedef enum player_weapon_type { WT_RANGED = 1, } player_weapon_type; -typedef enum item_class { - ICLASS_NONE = 0, - ICLASS_WEAPON = 1, - ICLASS_ARMOR = 2, - ICLASS_MISC = 3, - ICLASS_GOLD = 4, - ICLASS_QUEST = 5, -} item_class; - -typedef enum item_drop_rate { - IDROP_NEVER = 0, - IDROP_REGULAR = 1, - IDROP_DOUBLE = 2, -} item_drop_rate; - -typedef enum item_special_effect { - ISPL_NONE = 0x00000000, - ISPL_INFRAVISION = 0x00000001, - ISPL_RNDSTEALLIFE = 0x00000002, - ISPL_RNDARROWVEL = 0x00000004, - ISPL_FIRE_ARROWS = 0x00000008, - ISPL_FIREDAM = 0x00000010, - ISPL_LIGHTDAM = 0x00000020, - ISPL_DRAINLIFE = 0x00000040, - ISPL_UNKNOWN_1 = 0x00000080, - ISPL_NOHEALPLR = 0x00000100, - ISPL_MULT_ARROWS = 0x00000200, - ISPL_UNKNOWN_3 = 0x00000400, - ISPL_KNOCKBACK = 0x00000800, - ISPL_NOHEALMON = 0x00001000, - ISPL_STEALMANA_3 = 0x00002000, - ISPL_STEALMANA_5 = 0x00004000, - ISPL_STEALLIFE_3 = 0x00008000, - ISPL_STEALLIFE_5 = 0x00010000, - ISPL_QUICKATTACK = 0x00020000, - ISPL_FASTATTACK = 0x00040000, - ISPL_FASTERATTACK = 0x00080000, - ISPL_FASTESTATTACK = 0x00100000, - ISPL_FASTRECOVER = 0x00200000, - ISPL_FASTERRECOVER = 0x00400000, - ISPL_FASTESTRECOVER = 0x00800000, - ISPL_FASTBLOCK = 0x01000000, - ISPL_LIGHT_ARROWS = 0x02000000, - ISPL_THORNS = 0x04000000, - ISPL_NOMANA = 0x08000000, - ISPL_ABSHALFTRAP = 0x10000000, - ISPL_UNKNOWN_4 = 0x20000000, - ISPL_3XDAMVDEM = 0x40000000, - ISPL_ALLRESZERO = 0x80000000, -} item_special_effect; - // Logical equipment locations typedef enum inv_body_loc { INVLOC_HEAD = 0, diff --git a/structs.h b/structs.h index ed3ff1501..6c3d82ab6 100644 --- a/structs.h +++ b/structs.h @@ -6,88 +6,6 @@ DEVILUTION_BEGIN_NAMESPACE -////////////////////////////////////////////////// -// items -////////////////////////////////////////////////// - -typedef struct PLStruct { - const char *PLName; - int PLPower; - int PLParam1; - int PLParam2; - char PLMinLvl; - int PLIType; - BYTE PLGOE; - BOOL PLDouble; - BOOL PLOk; - int PLMinVal; - int PLMaxVal; - int PLMultVal; -} PLStruct; - -typedef struct UItemStruct { - const char *UIName; - char UIItemId; - char UIMinLvl; - char UINumPL; - int UIValue; - char UIPower1; - int UIParam1; - int UIParam2; - char UIPower2; - int UIParam3; - int UIParam4; - char UIPower3; - int UIParam5; - int UIParam6; - char UIPower4; - int UIParam7; - int UIParam8; - char UIPower5; - int UIParam9; - int UIParam10; - char UIPower6; - int UIParam11; - int UIParam12; -} UItemStruct; - -typedef struct ItemDataStruct { - int iRnd; - char iClass; - char iLoc; - int iCurs; - char itype; - char iItemId; - const char *iName; - const char *iSName; - char iMinMLvl; - int iDurability; - int iMinDam; - int iMaxDam; - int iMinAC; - int iMaxAC; - char iMinStr; - char iMinMag; - char iMinDex; - // item_special_effect - int iFlags; - // item_misc_id - int iMiscId; - // spell_id - int iSpell; - BOOL iUsable; - int iValue; - int iMaxValue; -} ItemDataStruct; - -typedef struct ItemGetRecordStruct { - int nSeed; - unsigned short wCI; - int nIndex; - unsigned int dwTimestamp; -} ItemGetRecordStruct; - - ////////////////////////////////////////////////// // textdat //////////////////////////////////////////////////