Skip to content

Commit

Permalink
some cleanup (diasurgical#2146)
Browse files Browse the repository at this point in the history
  • Loading branch information
qndel authored Nov 4, 2020
1 parent f2f4de8 commit c94c04d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 48 deletions.
74 changes: 37 additions & 37 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,46 +224,46 @@ void GetLevelMTypes()
mamask = 3; // monster availability mask
#endif

AddMonsterType(MT_GOLEM, 2);
AddMonsterType(MT_GOLEM, PLACE_SPECIAL);
if (currlevel == 16) {
AddMonsterType(MT_ADVOCATE, 1);
AddMonsterType(MT_RBLACK, 1);
AddMonsterType(MT_DIABLO, 2);
AddMonsterType(MT_ADVOCATE, PLACE_SCATTER);
AddMonsterType(MT_RBLACK, PLACE_SCATTER);
AddMonsterType(MT_DIABLO, PLACE_SPECIAL);
return;
}

#ifdef HELLFIRE
if (currlevel == 18)
AddMonsterType(117, 1);
AddMonsterType(MT_HORKSPWN, PLACE_SCATTER);
if (currlevel == 19) {
AddMonsterType(117, 1);
AddMonsterType(123, 4);
AddMonsterType(MT_HORKSPWN, PLACE_SCATTER);
AddMonsterType(MT_HORKDMN, PLACE_UNIQUE);
}
if (currlevel == 20)
AddMonsterType(124, 4);
AddMonsterType(MT_DEFILER, PLACE_UNIQUE);
if (currlevel == 24) {
AddMonsterType(133, 1);
AddMonsterType(137, 2);
AddMonsterType(MT_ARCHLICH, PLACE_SCATTER);
AddMonsterType(MT_NAKRUL, PLACE_SPECIAL);
}
#endif

if (!setlevel) {
if (QuestStatus(Q_BUTCHER))
AddMonsterType(MT_CLEAVER, 2);
AddMonsterType(MT_CLEAVER, PLACE_SPECIAL);
if (QuestStatus(Q_GARBUD))
AddMonsterType(UniqMonst[UMT_GARBUD].mtype, 4);
AddMonsterType(UniqMonst[UMT_GARBUD].mtype, PLACE_UNIQUE);
if (QuestStatus(Q_ZHAR))
AddMonsterType(UniqMonst[UMT_ZHAR].mtype, 4);
AddMonsterType(UniqMonst[UMT_ZHAR].mtype, PLACE_UNIQUE);
if (QuestStatus(Q_LTBANNER))
AddMonsterType(UniqMonst[UMT_SNOTSPIL].mtype, 4);
AddMonsterType(UniqMonst[UMT_SNOTSPIL].mtype, PLACE_UNIQUE);
if (QuestStatus(Q_VEIL))
AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 4);
AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, PLACE_UNIQUE);
if (QuestStatus(Q_WARLORD))
AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 4);
AddMonsterType(UniqMonst[UMT_WARLORD].mtype, PLACE_UNIQUE);

if (gbMaxPlayers != 1 && currlevel == quests[Q_SKELKING]._qlevel) {

AddMonsterType(MT_SKING, 4);
AddMonsterType(MT_SKING, PLACE_UNIQUE);

nt = 0;
for (i = MT_WSKELAX; i <= MT_WSKELAX + numskeltypes; i++) {
Expand All @@ -278,7 +278,7 @@ void GetLevelMTypes()
}
}
}
AddMonsterType(skeltypes[random_(88, nt)], 1);
AddMonsterType(skeltypes[random_(88, nt)], PLACE_SCATTER);
}

nt = 0;
Expand All @@ -295,7 +295,7 @@ void GetLevelMTypes()

if (monstdebug) {
for (i = 0; i < debugmonsttypes; i++)
AddMonsterType(DebugMonsters[i], 1);
AddMonsterType(DebugMonsters[i], PLACE_SCATTER);
} else {

while (nt > 0 && nummtypes < MAX_LVLMTYPES && monstimgtot < 4000) {
Expand All @@ -310,15 +310,15 @@ void GetLevelMTypes()

if (nt != 0) {
i = random_(88, nt);
AddMonsterType(typelist[i], 1);
AddMonsterType(typelist[i], PLACE_SCATTER);
typelist[i] = typelist[--nt];
}
}
}

} else {
if (setlvlnum == SL_SKELKING) {
AddMonsterType(MT_SKING, 4);
AddMonsterType(MT_SKING, PLACE_UNIQUE);
}
}
}
Expand Down Expand Up @@ -689,7 +689,7 @@ void PlaceMonster(int i, int mtype, int x, int y)
}

#ifndef SPAWN
void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize)
void PlaceUniqueMonst(int uniqindex, int miniontype, int bosspacksize)
{
int xp, yp, x, y, i;
int uniqtype;
Expand Down Expand Up @@ -913,7 +913,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize)
nummonsters++;

if (Uniq->mUnqAttr & 1) {
PlaceGroup(miniontype, unpackfilesize, Uniq->mUnqAttr, nummonsters - 1);
PlaceGroup(miniontype, bosspacksize, Uniq->mUnqAttr, nummonsters - 1);
}

if (Monst->_mAi != AI_GARG) {
Expand Down Expand Up @@ -1000,18 +1000,18 @@ void PlaceQuestMonsters()
setp = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL);
SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y);
mem_free_dbg(setp);
AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 1);
AddMonsterType(UniqMonst[UMT_WARLORD].mtype, PLACE_SCATTER);
}
if (QuestStatus(Q_VEIL)) {
AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 1);
AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, PLACE_SCATTER);
}
if (QuestStatus(Q_ZHAR) && zharlib == -1) {
quests[Q_ZHAR]._qactive = QUEST_NOTAVAIL;
}

if (currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) {
AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, 4);
AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, 4);
AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, PLACE_UNIQUE);
AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, PLACE_UNIQUE);
PlaceUniqueMonst(UMT_LAZURUS, 0, 0);
PlaceUniqueMonst(UMT_RED_VEX, 0, 0);
PlaceUniqueMonst(UMT_BLACKJADE, 0, 0);
Expand Down Expand Up @@ -1185,11 +1185,11 @@ void InitMonsters()
numplacemonsters = na / 30;
if (gbMaxPlayers != 1)
numplacemonsters += numplacemonsters >> 1;
if (nummonsters + numplacemonsters > 190)
numplacemonsters = 190 - nummonsters;
if (nummonsters + numplacemonsters > MAXMONSTERS - 10)
numplacemonsters = MAXMONSTERS - 10 - nummonsters;
totalmonsters = nummonsters + numplacemonsters;
for (i = 0; i < nummtypes; i++) {
if (Monsters[i].mPlaceFlags & 1) {
if (Monsters[i].mPlaceFlags & PLACE_SCATTER) {
scattertypes[numscattypes] = i;
numscattypes++;
}
Expand Down Expand Up @@ -1225,15 +1225,15 @@ void SetMapMonsters(BYTE *pMap, int startx, int starty)
int i, j;
int mtype;

AddMonsterType(MT_GOLEM, 2);
AddMonsterType(MT_GOLEM, PLACE_SPECIAL);
AddMonster(1, 0, 0, 0, FALSE);
AddMonster(1, 0, 0, 0, FALSE);
AddMonster(1, 0, 0, 0, FALSE);
AddMonster(1, 0, 0, 0, FALSE);
if (setlevel && setlvlnum == SL_VILEBETRAYER) {
AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, 4);
AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, 4);
AddMonsterType(UniqMonst[UMT_BLACKJADE].mtype, 4);
AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, PLACE_UNIQUE);
AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, PLACE_UNIQUE);
AddMonsterType(UniqMonst[UMT_BLACKJADE].mtype, PLACE_UNIQUE);
PlaceUniqueMonst(UMT_LAZURUS, 0, 0);
PlaceUniqueMonst(UMT_RED_VEX, 0, 0);
PlaceUniqueMonst(UMT_BLACKJADE, 0, 0);
Expand All @@ -1250,7 +1250,7 @@ void SetMapMonsters(BYTE *pMap, int startx, int starty)
for (j = 0; j < rh; j++) {
for (i = 0; i < rw; i++) {
if (*lm) {
mtype = AddMonsterType(MonstConvTbl[(*lm) - 1], 2);
mtype = AddMonsterType(MonstConvTbl[(*lm) - 1], PLACE_SPECIAL);
PlaceMonster(nummonsters++, mtype, i + startx + 16, j + starty + 16);
}
lm++;
Expand Down Expand Up @@ -3118,7 +3118,7 @@ void GroupUnity(int i)
if ((DWORD)i >= MAXMONSTERS)
app_fatal("GroupUnity: Invalid monster %d", i);

if (monster[i].leaderflag) {
if (monster[i].leaderflag != 0) {
leader = monster[i].leader;
clear = LineClearF(CheckNoSolid, monster[i]._mx, monster[i]._my, monster[leader]._mfutx, monster[leader]._mfuty);
if (clear || monster[i].leaderflag != 1) {
Expand Down Expand Up @@ -4037,7 +4037,7 @@ void MAI_Scav(int i)
if (monster[i]._mmode != MM_STAND)
return;
if (Monst->_mhitpoints < (Monst->_mmaxhp >> 1) && Monst->_mgoal != MGOAL_HEALING) {
if (Monst->leaderflag) {
if (Monst->leaderflag != 0) {
monster[Monst->leader].packsize--;
Monst->leaderflag = 0;
}
Expand Down
16 changes: 8 additions & 8 deletions Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ void objects_44D8C5(int ot, int v2, int ox, int oy)
return;

oi = objectavail[0];
objectavail[0] = objectavail[126 - nobjects];
objectavail[0] = objectavail[MAXOBJECTS - 1 - nobjects];
objectactive[nobjects] = oi;
dObject[ox][oy] = oi + 1;
SetupObject(oi, ox, oy, ot);
Expand Down Expand Up @@ -1741,7 +1741,7 @@ void AddObject(int ot, int ox, int oy)
return;

oi = objectavail[0];
objectavail[0] = objectavail[126 - nobjects];
objectavail[0] = objectavail[MAXOBJECTS - 1 - nobjects];
objectactive[nobjects] = oi;
dObject[ox][oy] = oi + 1;
SetupObject(oi, ox, oy, ot);
Expand Down Expand Up @@ -3096,12 +3096,12 @@ void OperateBookLever(int pnum, int i)
x = 2 * setpc_x + 16;
y = 2 * setpc_y + 16;
if (object[i]._oSelFlag != 0 && !qtextflag) {
if (object[i]._otype == OBJ_BLINDBOOK && !quests[Q_BLIND]._qvar1) {
if (object[i]._otype == OBJ_BLINDBOOK && quests[Q_BLIND]._qvar1 == 0) {
quests[Q_BLIND]._qactive = QUEST_ACTIVE;
quests[Q_BLIND]._qlog = TRUE;
quests[Q_BLIND]._qvar1 = 1;
}
if (object[i]._otype == OBJ_BLOODBOOK && !quests[Q_BLOOD]._qvar1) {
if (object[i]._otype == OBJ_BLOODBOOK && quests[Q_BLOOD]._qvar1 == 0) {
quests[Q_BLOOD]._qactive = QUEST_ACTIVE;
quests[Q_BLOOD]._qlog = TRUE;
quests[Q_BLOOD]._qvar1 = 1;
Expand All @@ -3110,7 +3110,7 @@ void OperateBookLever(int pnum, int i)
SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 25, 2 * setpc_y + 33, 0, 1);
}
object[i]._otype = object[i]._otype;
if (object[i]._otype == OBJ_STEELTOME && !quests[Q_WARLORD]._qvar1) {
if (object[i]._otype == OBJ_STEELTOME && quests[Q_WARLORD]._qvar1 == 0) {
quests[Q_WARLORD]._qactive = QUEST_ACTIVE;
quests[Q_WARLORD]._qlog = TRUE;
quests[Q_WARLORD]._qvar1 = 1;
Expand All @@ -3119,7 +3119,7 @@ void OperateBookLever(int pnum, int i)
if (object[i]._otype != OBJ_BLOODBOOK)
ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4);
if (object[i]._otype == OBJ_BLINDBOOK) {
CreateItem(3, x + 5, y + 5);
CreateItem(UITEM_OPTAMULET, x + 5, y + 5);
tren = TransVal;
TransVal = 9;
DRLG_MRectTrans(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4);
Expand Down Expand Up @@ -3450,7 +3450,7 @@ void OperatePedistal(int pnum, int i)
mem = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", NULL);
LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y);
mem_free_dbg(mem);
CreateItem(7, 2 * setpc_x + 25, 2 * setpc_y + 19);
CreateItem(UITEM_ARMOFVAL, 2 * setpc_x + 25, 2 * setpc_y + 19);
object[i]._oSelFlag = 0;
}
}
Expand Down Expand Up @@ -4574,7 +4574,7 @@ void OperateStoryBook(int pnum, int i)
object[i]._oAnimFrame = object[i]._oVar4;
PlaySfxLoc(IS_ISCROL, object[i]._ox, object[i]._oy);
#ifdef HELLFIRE
if (object[i]._oVar8 && currlevel == 24) {
if (object[i]._oVar8 != 0 && currlevel == 24) {
if (IsUberLeverActivated != 1 && quests[Q_NAKRUL]._qactive != 3 && objects_lv_24_454B04(object[i]._oVar8)) {
NetSendCmd(FALSE, CMD_NAKRUL);
return;
Expand Down
4 changes: 2 additions & 2 deletions Source/quests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ void ResyncQuests()
}
}
if (currlevel == quests[Q_MUSHROOM]._qlevel) {
if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && !quests[Q_MUSHROOM]._qvar1) {
if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && quests[Q_MUSHROOM]._qvar1 == 0) {
SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1);
quests[Q_MUSHROOM]._qvar1 = QS_TOMESPAWNED;
} else {
Expand All @@ -800,7 +800,7 @@ void ResyncQuests()
}
}
}
if (currlevel == quests[Q_VEIL]._qlevel + 1 && quests[Q_VEIL]._qactive == QUEST_ACTIVE && !quests[Q_VEIL]._qvar1) {
if (currlevel == quests[Q_VEIL]._qlevel + 1 && quests[Q_VEIL]._qactive == QUEST_ACTIVE && quests[Q_VEIL]._qvar1 == 0) {
quests[Q_VEIL]._qvar1 = 1;
SpawnQuestItem(IDI_GLDNELIX, 0, 0, 5, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void PlaceThemeMonsts(int t, int f)

numscattypes = 0;
for (i = 0; i < nummtypes; i++) {
if (Monsters[i].mPlaceFlags & 1) {
if (Monsters[i].mPlaceFlags & PLACE_SCATTER) {
scattertypes[numscattypes] = i;
numscattypes++;
}
Expand Down
6 changes: 6 additions & 0 deletions enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -2297,6 +2297,12 @@ typedef enum clicktype {
CLICK_RIGHT = 2,
} clicktype;

typedef enum placeflag {
PLACE_SCATTER = 1,
PLACE_SPECIAL = 2,
PLACE_UNIQUE = 4,
} placeflag;

/*
First 5 bits store level
6th bit stores onlygood flag
Expand Down

0 comments on commit c94c04d

Please sign in to comment.