From 8bc995e68190691f6309b8ee6359a5f16a407fc2 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 1 May 2019 15:24:20 +0300 Subject: [PATCH] Add _uniq_monsterid enum for indexes in UniqMonst for special unique monsters. Apply it where necessary. --- Source/monster.cpp | 66 +++++++++++++++++++++++----------------------- Source/objects.cpp | 2 +- Source/quests.cpp | 10 +++---- enums.h | 14 ++++++++++ 4 files changed, 53 insertions(+), 39 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index ca823a442..be95d2698 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -198,15 +198,15 @@ void GetLevelMTypes() if (QuestStatus(QTYPE_BUTCH)) AddMonsterType(MT_CLEAVER, 2); if (QuestStatus(QTYPE_GARB)) - AddMonsterType(UniqMonst[0].mtype, 4); + AddMonsterType(UniqMonst[UMT_GARBUD].mtype, 4); if (QuestStatus(QTYPE_ZHAR)) - AddMonsterType(UniqMonst[2].mtype, 4); + AddMonsterType(UniqMonst[UMT_ZHAR].mtype, 4); if (QuestStatus(QTYPE_BOL)) - AddMonsterType(UniqMonst[3].mtype, 4); + AddMonsterType(UniqMonst[UMT_SNOTSPIL].mtype, 4); if (QuestStatus(QTYPE_VEIL)) - AddMonsterType(UniqMonst[7].mtype, 4); + AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 4); if (QuestStatus(QTYPE_WARLRD)) - AddMonsterType(UniqMonst[8].mtype, 4); + AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 4); if (gbMaxPlayers != 1 && currlevel == quests[QTYPE_KING]._qlevel) { @@ -771,7 +771,7 @@ void PlaceQuestMonsters() if (!setlevel) { if (QuestStatus(QTYPE_BUTCH)) { - PlaceUniqueMonst(9, 0, 0); + PlaceUniqueMonst(UMT_BUTCHER, 0, 0); } if (currlevel == quests[QTYPE_KING]._qlevel && gbMaxPlayers != 1) { @@ -783,7 +783,7 @@ void PlaceQuestMonsters() } } - PlaceUniqueMonst(1, skeltype, 30); + PlaceUniqueMonst(UMT_SKELKING, skeltype, 30); } if (QuestStatus(QTYPE_BOL)) { @@ -810,28 +810,28 @@ void PlaceQuestMonsters() setp = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); - AddMonsterType(UniqMonst[8].mtype, 1); + AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 1); } if (QuestStatus(QTYPE_VEIL)) { - AddMonsterType(UniqMonst[7].mtype, 1); + AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 1); } if (QuestStatus(QTYPE_ZHAR) && zharlib == -1) { quests[QTYPE_ZHAR]._qactive = 0; } if (currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { - AddMonsterType(UniqMonst[4].mtype, 4); - AddMonsterType(UniqMonst[5].mtype, 4); - PlaceUniqueMonst(4, 0, 0); - PlaceUniqueMonst(5, 0, 0); - PlaceUniqueMonst(6, 0, 0); + AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, 4); + AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, 4); + PlaceUniqueMonst(UMT_LAZURUS, 0, 0); + PlaceUniqueMonst(UMT_RED_VEX, 0, 0); + PlaceUniqueMonst(UMT_BLACKJADE, 0, 0); setp = LoadFileInMem("Levels\\L4Data\\Vile1.DUN", 0); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } } else { if (setlvlnum == SL_SKELKING) { - PlaceUniqueMonst(1, 0, 0); + PlaceUniqueMonst(UMT_SKELKING, 0, 0); } } } @@ -1020,15 +1020,15 @@ void PlaceUniques() done = (Monsters[mt].mtype == UniqMonst[u].mtype); } mt--; - if (u == 0 && quests[QTYPE_GARB]._qactive == 0) + if (u == UMT_GARBUD && quests[QTYPE_GARB]._qactive == 0) done = FALSE; - if (u == 2 && quests[QTYPE_ZHAR]._qactive == 0) + if (u == UMT_ZHAR && quests[QTYPE_ZHAR]._qactive == 0) done = FALSE; - if (u == 3 && quests[QTYPE_BOL]._qactive == 0) + if (u == UMT_SNOTSPIL && quests[QTYPE_BOL]._qactive == 0) done = FALSE; - if (u == 7 && quests[QTYPE_VEIL]._qactive == 0) + if (u == UMT_LACHDAN && quests[QTYPE_VEIL]._qactive == 0) done = FALSE; - if (u == 8 && quests[QTYPE_WARLRD]._qactive == 0) + if (u == UMT_WARLORD && quests[QTYPE_WARLRD]._qactive == 0) done = FALSE; if (done) PlaceUniqueMonst(u, mt, 8); @@ -1048,12 +1048,12 @@ void SetMapMonsters(unsigned char *pMap, int startx, int starty) AddMonster(1, 0, 0, 0, FALSE); AddMonster(1, 0, 0, 0, FALSE); if (setlevel && setlvlnum == SL_VILEBETRAYER) { - AddMonsterType(UniqMonst[4].mtype, 4); - AddMonsterType(UniqMonst[5].mtype, 4); - AddMonsterType(UniqMonst[6].mtype, 4); - PlaceUniqueMonst(4, 0, 0); - PlaceUniqueMonst(5, 0, 0); - PlaceUniqueMonst(6, 0, 0); + AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, 4); + AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, 4); + AddMonsterType(UniqMonst[UMT_BLACKJADE].mtype, 4); + PlaceUniqueMonst(UMT_LAZURUS, 0, 0); + PlaceUniqueMonst(UMT_RED_VEX, 0, 0); + PlaceUniqueMonst(UMT_BLACKJADE, 0, 0); } lm = (WORD*)pMap; rw = *lm; @@ -1717,7 +1717,7 @@ void MonstStartKill(int i, int pnum, BOOL sendmsg) monstkills[monster[i].MType->mtype]++; monster[i]._mhitpoints = 0; SetRndSeed(monster[i]._mRndSeed); - if (QuestStatus(QTYPE_GARB) && monster[i].mName == UniqMonst[0].mName) { + if (QuestStatus(QTYPE_GARB) && monster[i].mName == UniqMonst[UMT_GARBUD].mName) { CreateTypeItem(monster[i]._mx + 1, monster[i]._my + 1, TRUE, 4, FALSE, TRUE, FALSE); } else if (i > 3) { SpawnItem(i, monster[i]._mx, monster[i]._my, sendmsg); @@ -2529,7 +2529,7 @@ int M_DoTalk(int i) //_LOBYTE(v3) = effect_is_playing(alltext[monster[v1].mtalkmsg].sfxnr); if (!effect_is_playing(alltext[monster[v1].mtalkmsg].sfxnr)) { InitQTextMsg(monster[v2].mtalkmsg); - if (monster[v2].mName == UniqMonst[0].mName) { + if (monster[v2].mName == UniqMonst[UMT_GARBUD].mName) { v4 = monster[v2].mtalkmsg; if (v4 == QUEST_GARBUD1) quests[QTYPE_GARB]._qactive = 2; @@ -2539,7 +2539,7 @@ int M_DoTalk(int i) monster[v2]._mFlags |= MFLAG_QUEST_COMPLETE; } } - if (monster[v2].mName == UniqMonst[2].mName + if (monster[v2].mName == UniqMonst[UMT_ZHAR].mName && monster[v2].mtalkmsg == QUEST_ZHAR1 && !(monster[v2]._mFlags & MFLAG_QUEST_COMPLETE)) { v5 = monster[v2]._my + 1; @@ -2549,7 +2549,7 @@ int M_DoTalk(int i) CreateTypeItem(v6, v5, 0, 0, 24, 1, 0); monster[v2]._mFlags |= MFLAG_QUEST_COMPLETE; } - if (monster[v2].mName == UniqMonst[3].mName) { + if (monster[v2].mName == UniqMonst[UMT_SNOTSPIL].mName) { if (monster[v2].mtalkmsg == QUEST_BANNER10 && !(monster[v2]._mFlags & MFLAG_QUEST_COMPLETE)) { ObjChangeMap(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 2, (setpc_h >> 1) + setpc_y - 2); v7 = TransVal; @@ -2566,7 +2566,7 @@ int M_DoTalk(int i) app_fatal(tempstr); } } - if (monster[v2].mName == UniqMonst[7].mName) { + if (monster[v2].mName == UniqMonst[UMT_LACHDAN].mName) { v8 = monster[v2].mtalkmsg; if (v8 == QUEST_VEIL9) { quests[QTYPE_VEIL]._qactive = 2; @@ -2578,9 +2578,9 @@ int M_DoTalk(int i) } } v9 = monster[v2].mName; - if (v9 == UniqMonst[8].mName) + if (v9 == UniqMonst[UMT_WARLORD].mName) quests[QTYPE_WARLRD]._qvar1 = 2; - if (v9 == UniqMonst[4].mName && gbMaxPlayers != 1) { + if (v9 == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers != 1) { monster[v2]._msquelch = -1; monster[v2].mtalkmsg = 0; quests[QTYPE_VB]._qvar1 = 6; diff --git a/Source/objects.cpp b/Source/objects.cpp index 6d93e38ab..e1f0e0018 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -3539,7 +3539,7 @@ void OperateBookCase(int pnum, int i, BOOL sendmsg) SetRndSeed(object[i]._oRndSeed); CreateTypeItem(object[i]._ox, object[i]._oy, 0, ITYPE_MISC, IMISC_BOOK, sendmsg, 0); if (QuestStatus(QTYPE_ZHAR) - && monster[4].mName == UniqMonst[2].mName + && monster[4].mName == UniqMonst[UMT_ZHAR].mName && monster[4]._msquelch == -1 && monster[4]._mhitpoints) { monster[4].mtalkmsg = QUEST_ZHAR2; diff --git a/Source/quests.cpp b/Source/quests.cpp index 7e14534d3..d3471045f 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -275,7 +275,7 @@ void CheckQuestKill(int m, BOOL sendmsg) } if (sendmsg) NetSendCmdQuest(TRUE, 6); - } else if (monster[m].mName == UniqMonst[0].mName) { //"Gharbad the Weak" + } else if (monster[m].mName == UniqMonst[UMT_GARBUD].mName) { //"Gharbad the Weak" quests[QTYPE_GARB]._qactive = 3; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { @@ -285,7 +285,7 @@ void CheckQuestKill(int m, BOOL sendmsg) } else if (plr[myplr]._pClass == PC_SORCERER) { sfxdnum = PS_MAGE61; } - } else if (monster[m].mName == UniqMonst[2].mName) { //"Zhar the Mad" + } else if (monster[m].mName == UniqMonst[UMT_ZHAR].mName) { //"Zhar the Mad" quests[QTYPE_ZHAR]._qactive = 3; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { @@ -295,7 +295,7 @@ void CheckQuestKill(int m, BOOL sendmsg) } else if (plr[myplr]._pClass == PC_SORCERER) { sfxdnum = PS_MAGE62; } - } else if (monster[m].mName == UniqMonst[4].mName && gbMaxPlayers != 1) { //"Arch-Bishop Lazarus" + } else if (monster[m].mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers != 1) { //"Arch-Bishop Lazarus" quests[QTYPE_VB]._qactive = 3; quests[QTYPE_VB]._qvar1 = 7; sfxdelay = 30; @@ -322,7 +322,7 @@ void CheckQuestKill(int m, BOOL sendmsg) NetSendCmdQuest(TRUE, 15); NetSendCmdQuest(TRUE, 5); } - } else if (monster[m].mName == UniqMonst[4].mName && gbMaxPlayers == 1) { //"Arch-Bishop Lazarus" + } else if (monster[m].mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers == 1) { //"Arch-Bishop Lazarus" quests[QTYPE_VB]._qactive = 3; sfxdelay = 30; InitVPTriggers(); @@ -337,7 +337,7 @@ void CheckQuestKill(int m, BOOL sendmsg) } else if (plr[myplr]._pClass == PC_SORCERER) { sfxdnum = PS_MAGE83; } - } else if (monster[m].mName == UniqMonst[8].mName) { //"Warlord of Blood" + } else if (monster[m].mName == UniqMonst[UMT_WARLORD].mName) { //"Warlord of Blood" quests[QTYPE_WARLRD]._qactive = 3; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { diff --git a/enums.h b/enums.h index 9e4fc0351..e45c9d23c 100644 --- a/enums.h +++ b/enums.h @@ -1451,6 +1451,20 @@ typedef enum _monster_id { NUM_MTYPES } _monster_id; +// this enum contains indexes from UniqMonst array for special unique monsters (usually quest related) +typedef enum { + UMT_GARBUD = 0, + UMT_SKELKING = 1, + UMT_ZHAR = 2, + UMT_SNOTSPIL = 3, + UMT_LAZURUS = 4, + UMT_RED_VEX = 5, + UMT_BLACKJADE = 6, + UMT_LACHDAN = 7, + UMT_WARLORD = 8, + UMT_BUTCHER = 9, +} _uniq_monsterid; + typedef enum monster_flag { MFLAG_HIDDEN = 0x01, MFLAG_LOCK_ANIMATION = 0x02,