diff --git a/Source/control.cpp b/Source/control.cpp index 9800febdb..1400c4624 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -905,9 +905,9 @@ void DrawInfoBox(const Surface &out) if (leveltype != DTYPE_TOWN) { const auto &monster = Monsters[pcursmonst]; InfoColor = UiFlags::ColorWhite; - InfoString = string_view(monster.mName); + InfoString = string_view(monster.name); ClearPanel(); - if (monster._uniqtype != 0) { + if (monster.uniqType != 0) { InfoColor = UiFlags::ColorWhitegold; PrintUniqueHistory(); } else { diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 4cdbcdffc..97ce3318a 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -226,9 +226,9 @@ bool HasRangedSpell() bool CanTargetMonster(const Monster &monster) { - if ((monster._mFlags & (MFLAG_HIDDEN | MFLAG_GOLEM)) != 0) + if ((monster.flags & (MFLAG_HIDDEN | MFLAG_GOLEM)) != 0) return false; - if (monster._mhitpoints >> 6 <= 0) // dead + if (monster.hitPoints >> 6 <= 0) // dead return false; if (!IsTileLit(monster.position.tile)) // not visible diff --git a/Source/controls/touch/renderers.cpp b/Source/controls/touch/renderers.cpp index 3e0a8e8f5..0ee4d9976 100644 --- a/Source/controls/touch/renderers.cpp +++ b/Source/controls/touch/renderers.cpp @@ -421,7 +421,7 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetDungeonButtonType() { if (pcursmonst != -1) { const auto &monster = Monsters[pcursmonst]; - if (M_Talker(monster) || monster.mtalkmsg != TEXT_NONE) + if (M_Talker(monster) || monster.talkMsg != TEXT_NONE) return GetTalkButtonType(virtualPadButton->isHeld); } return GetAttackButtonType(virtualPadButton->isHeld); diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 01c6c39ea..5950f6e4b 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -404,58 +404,58 @@ void CheckCursMove() if (pcurstemp != -1) { if (!flipflag && mx + 2 < MAXDUNX && my + 1 < MAXDUNY && dMonster[mx + 2][my + 1] != 0 && IsTileLit({ mx + 2, my + 1 })) { int mi = abs(dMonster[mx + 2][my + 1]) - 1; - if (mi == pcurstemp && Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { + if (mi == pcurstemp && Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { cursPosition = Point { mx, my } + Displacement { 2, 1 }; pcursmonst = mi; } } if (flipflag && mx + 1 < MAXDUNX && my + 2 < MAXDUNY && dMonster[mx + 1][my + 2] != 0 && IsTileLit({ mx + 1, my + 2 })) { int mi = abs(dMonster[mx + 1][my + 2]) - 1; - if (mi == pcurstemp && Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { + if (mi == pcurstemp && Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { cursPosition = Point { mx, my } + Displacement { 1, 2 }; pcursmonst = mi; } } if (mx + 2 < MAXDUNX && my + 2 < MAXDUNY && dMonster[mx + 2][my + 2] != 0 && IsTileLit({ mx + 2, my + 2 })) { int mi = abs(dMonster[mx + 2][my + 2]) - 1; - if (mi == pcurstemp && Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { + if (mi == pcurstemp && Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { cursPosition = Point { mx, my } + Displacement { 2, 2 }; pcursmonst = mi; } } if (mx + 1 < MAXDUNX && !flipflag && dMonster[mx + 1][my] != 0 && IsTileLit({ mx + 1, my })) { int mi = abs(dMonster[mx + 1][my]) - 1; - if (mi == pcurstemp && Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { + if (mi == pcurstemp && Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { cursPosition = Point { mx, my } + Displacement { 1, 0 }; pcursmonst = mi; } } if (my + 1 < MAXDUNY && flipflag && dMonster[mx][my + 1] != 0 && IsTileLit({ mx, my + 1 })) { int mi = abs(dMonster[mx][my + 1]) - 1; - if (mi == pcurstemp && Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { + if (mi == pcurstemp && Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { cursPosition = Point { mx, my } + Displacement { 0, 1 }; pcursmonst = mi; } } if (dMonster[mx][my] != 0 && IsTileLit({ mx, my })) { int mi = abs(dMonster[mx][my]) - 1; - if (mi == pcurstemp && Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 1) != 0) { + if (mi == pcurstemp && Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 1) != 0) { cursPosition = { mx, my }; pcursmonst = mi; } } if (mx + 1 < MAXDUNX && my + 1 < MAXDUNY && dMonster[mx + 1][my + 1] != 0 && IsTileLit({ mx + 1, my + 1 })) { int mi = abs(dMonster[mx + 1][my + 1]) - 1; - if (mi == pcurstemp && Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { + if (mi == pcurstemp && Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { cursPosition = Point { mx, my } + Displacement { 1, 1 }; pcursmonst = mi; } } - if (pcursmonst != -1 && (Monsters[pcursmonst]._mFlags & MFLAG_HIDDEN) != 0) { + if (pcursmonst != -1 && (Monsters[pcursmonst].flags & MFLAG_HIDDEN) != 0) { pcursmonst = -1; cursPosition = { mx, my }; } - if (pcursmonst != -1 && (Monsters[pcursmonst]._mFlags & MFLAG_GOLEM) != 0 && (Monsters[pcursmonst]._mFlags & MFLAG_BERSERK) == 0) { + if (pcursmonst != -1 && (Monsters[pcursmonst].flags & MFLAG_GOLEM) != 0 && (Monsters[pcursmonst].flags & MFLAG_BERSERK) == 0) { pcursmonst = -1; } if (pcursmonst != -1) { @@ -464,58 +464,58 @@ void CheckCursMove() } if (!flipflag && mx + 2 < MAXDUNX && my + 1 < MAXDUNY && dMonster[mx + 2][my + 1] != 0 && IsTileLit({ mx + 2, my + 1 })) { int mi = abs(dMonster[mx + 2][my + 1]) - 1; - if (Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { + if (Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { cursPosition = Point { mx, my } + Displacement { 2, 1 }; pcursmonst = mi; } } if (flipflag && mx + 1 < MAXDUNX && my + 2 < MAXDUNY && dMonster[mx + 1][my + 2] != 0 && IsTileLit({ mx + 1, my + 2 })) { int mi = abs(dMonster[mx + 1][my + 2]) - 1; - if (Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { + if (Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { cursPosition = Point { mx, my } + Displacement { 1, 2 }; pcursmonst = mi; } } if (mx + 2 < MAXDUNX && my + 2 < MAXDUNY && dMonster[mx + 2][my + 2] != 0 && IsTileLit({ mx + 2, my + 2 })) { int mi = abs(dMonster[mx + 2][my + 2]) - 1; - if (Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { + if (Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 4) != 0) { cursPosition = Point { mx, my } + Displacement { 2, 2 }; pcursmonst = mi; } } if (!flipflag && mx + 1 < MAXDUNX && dMonster[mx + 1][my] != 0 && IsTileLit({ mx + 1, my })) { int mi = abs(dMonster[mx + 1][my]) - 1; - if (Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { + if (Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { cursPosition = Point { mx, my } + Displacement { 1, 0 }; pcursmonst = mi; } } if (flipflag && my + 1 < MAXDUNY && dMonster[mx][my + 1] != 0 && IsTileLit({ mx, my + 1 })) { int mi = abs(dMonster[mx][my + 1]) - 1; - if (Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { + if (Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { cursPosition = Point { mx, my } + Displacement { 0, 1 }; pcursmonst = mi; } } if (dMonster[mx][my] != 0 && IsTileLit({ mx, my })) { int mi = abs(dMonster[mx][my]) - 1; - if (Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 1) != 0) { + if (Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 1) != 0) { cursPosition = { mx, my }; pcursmonst = mi; } } if (mx + 1 < MAXDUNX && my + 1 < MAXDUNY && dMonster[mx + 1][my + 1] != 0 && IsTileLit({ mx + 1, my + 1 })) { int mi = abs(dMonster[mx + 1][my + 1]) - 1; - if (Monsters[mi]._mhitpoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { + if (Monsters[mi].hitPoints >> 6 > 0 && (Monsters[mi].data().mSelFlag & 2) != 0) { cursPosition = Point { mx, my } + Displacement { 1, 1 }; pcursmonst = mi; } } - if (pcursmonst != -1 && (Monsters[pcursmonst]._mFlags & MFLAG_HIDDEN) != 0) { + if (pcursmonst != -1 && (Monsters[pcursmonst].flags & MFLAG_HIDDEN) != 0) { pcursmonst = -1; cursPosition = { mx, my }; } - if (pcursmonst != -1 && (Monsters[pcursmonst]._mFlags & MFLAG_GOLEM) != 0 && (Monsters[pcursmonst]._mFlags & MFLAG_BERSERK) == 0) { + if (pcursmonst != -1 && (Monsters[pcursmonst].flags & MFLAG_GOLEM) != 0 && (Monsters[pcursmonst].flags & MFLAG_BERSERK) == 0) { pcursmonst = -1; } } else { @@ -661,7 +661,7 @@ void CheckCursMove() pcursitem = -1; cursPosition = { mx, my }; } - if (pcursmonst != -1 && (Monsters[pcursmonst]._mFlags & MFLAG_GOLEM) != 0 && (Monsters[pcursmonst]._mFlags & MFLAG_BERSERK) == 0) { + if (pcursmonst != -1 && (Monsters[pcursmonst].flags & MFLAG_GOLEM) != 0 && (Monsters[pcursmonst].flags & MFLAG_BERSERK) == 0) { pcursmonst = -1; } } diff --git a/Source/dead.cpp b/Source/dead.cpp index d15359e5e..5beeb93b8 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -57,12 +57,12 @@ void InitCorpses() for (int i = 0; i < ActiveMonsterCount; i++) { auto &monster = Monsters[ActiveMonsters[i]]; - if (monster._uniqtype != 0) { + if (monster.uniqType != 0) { InitDeadAnimationFromMonster(Corpses[nd], monster.type()); Corpses[nd].translationPaletteIndex = ActiveMonsters[i] + 1; nd++; - monster._udeadval = nd; + monster.corpseId = nd; } } @@ -78,12 +78,12 @@ void SyncUniqDead() { for (int i = 0; i < ActiveMonsterCount; i++) { auto &monster = Monsters[ActiveMonsters[i]]; - if (monster._uniqtype == 0) + if (monster.uniqType == 0) continue; for (int dx = 0; dx < MAXDUNX; dx++) { for (int dy = 0; dy < MAXDUNY; dy++) { - if ((dCorpse[dx][dy] & 0x1F) == monster._udeadval) - ChangeLightXY(monster.mlid, { dx, dy }); + if ((dCorpse[dx][dy] & 0x1F) == monster.corpseId) + ChangeLightXY(monster.lightId, { dx, dy }); } } } diff --git a/Source/debug.cpp b/Source/debug.cpp index 0e9ad434a..ec37b46c9 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -100,13 +100,13 @@ void PrintDebugMonster(int m) EventPlrMsg(fmt::format( "Monster {:d} = {:s}\nX = {:d}, Y = {:d}\nEnemy = {:d}, HP = {:d}\nMode = {:d}, Var1 = {:d}", m, - monster.mName, + monster.name, monster.position.tile.x, monster.position.tile.y, - monster._menemy, - monster._mhitpoints, - static_cast(monster._mmode), - monster._mVar1), + monster.enemy, + monster.hitPoints, + static_cast(monster.mode), + monster.var1), UiFlags::ColorWhite); bool bActive = false; @@ -116,7 +116,7 @@ void PrintDebugMonster(int m) bActive = true; } - EventPlrMsg(fmt::format("Active List = {:d}, Squelch = {:d}", bActive ? 1 : 0, monster._msquelch), UiFlags::ColorWhite); + EventPlrMsg(fmt::format("Active List = {:d}, Squelch = {:d}", bActive ? 1 : 0, monster.activeForTicks), UiFlags::ColorWhite); } void ProcessMessages() @@ -736,7 +736,7 @@ std::string DebugCmdSpawnUniqueMonster(const string_view parameter) return fmt::format("I could only summon {} Monsters. The rest strike for shorter working hours.", spawnedMonster); PrepareUniqueMonst(*monster, uniqueIndex, 0, 0, UniqueMonstersData[uniqueIndex]); ActiveMonsterCount--; - monster->_udeadval = 1; + monster->corpseId = 1; spawnedMonster += 1; if (spawnedMonster >= count) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 4fef776fb..e18bdc175 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1219,8 +1219,8 @@ void UnstuckChargers() } for (int i = 0; i < ActiveMonsterCount; i++) { auto &monster = Monsters[ActiveMonsters[i]]; - if (monster._mmode == MonsterMode::Charge) - monster._mmode = MonsterMode::Stand; + if (monster.mode == MonsterMode::Charge) + monster.mode = MonsterMode::Stand; } } @@ -1229,20 +1229,20 @@ void UpdateMonsterLights() for (int i = 0; i < ActiveMonsterCount; i++) { auto &monster = Monsters[ActiveMonsters[i]]; - if ((monster._mFlags & MFLAG_BERSERK) != 0) { + if ((monster.flags & MFLAG_BERSERK) != 0) { int lightRadius = leveltype == DTYPE_NEST ? 9 : 3; - monster.mlid = AddLight(monster.position.tile, lightRadius); + monster.lightId = AddLight(monster.position.tile, lightRadius); } - if (monster.mlid != NO_LIGHT) { - if (monster.mlid == MyPlayer->_plid) { // Fix old saves where some monsters had 0 instead of NO_LIGHT - monster.mlid = NO_LIGHT; + if (monster.lightId != NO_LIGHT) { + if (monster.lightId == MyPlayer->_plid) { // Fix old saves where some monsters had 0 instead of NO_LIGHT + monster.lightId = NO_LIGHT; continue; } - Light &light = Lights[monster.mlid]; + Light &light = Lights[monster.lightId]; if (monster.position.tile != light.position.tile) { - ChangeLightXY(monster.mlid, monster.position.tile); + ChangeLightXY(monster.lightId, monster.position.tile); } } } diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 22cdd2368..926d0de07 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -332,7 +332,7 @@ void DrawMissilePrivate(const Surface &out, const Missile &missile, Point target const Point missileRenderPosition { targetBufferPosition + missile.position.offsetForRendering - Displacement { missile._miAnimWidth2, 0 } }; CelSprite cel { missile._miAnimData, missile._miAnimWidth }; if (missile._miUniqTrans != 0) - Cl2DrawTRN(out, missileRenderPosition.x, missileRenderPosition.y, cel, nCel, Monsters[missile._misource].uniqueTRN.get()); + Cl2DrawTRN(out, missileRenderPosition.x, missileRenderPosition.y, cel, nCel, Monsters[missile._misource].uniqueMonsterTRN.get()); else if (missile._miLightFlag) Cl2DrawLight(out, missileRenderPosition.x, missileRenderPosition.y, cel, nCel); else @@ -363,8 +363,8 @@ void DrawMissile(const Surface &out, Point tilePosition, Point targetBufferPosit */ void DrawMonster(const Surface &out, Point tilePosition, Point targetBufferPosition, const Monster &monster) { - if (!monster.AnimInfo.celSprite) { - Log("Draw Monster \"{}\": NULL Cel Buffer", monster.mName); + if (!monster.animInfo.celSprite) { + Log("Draw Monster \"{}\": NULL Cel Buffer", monster.name); return; } @@ -429,29 +429,29 @@ void DrawMonster(const Surface &out, Point tilePosition, Point targetBufferPosit } }; - int nCel = monster.AnimInfo.getFrameToUseForRendering(); - const uint32_t frames = LoadLE32(monster.AnimInfo.celSprite->Data()); + int nCel = monster.animInfo.getFrameToUseForRendering(); + const uint32_t frames = LoadLE32(monster.animInfo.celSprite->Data()); if (nCel < 0 || frames > 50 || nCel >= static_cast(frames)) { Log( "Draw Monster \"{}\" {}: facing {}, frame {} of {}", - monster.mName, - getMonsterModeDisplayName(monster._mmode), - DirectionToString(monster._mdir), + monster.name, + getMonsterModeDisplayName(monster.mode), + DirectionToString(monster.direction), nCel, frames); return; } - const auto &cel = *monster.AnimInfo.celSprite; + const auto &cel = *monster.animInfo.celSprite; if (!IsTileLit(tilePosition)) { Cl2DrawTRN(out, targetBufferPosition.x, targetBufferPosition.y, cel, nCel, GetInfravisionTRN()); return; } uint8_t *trn = nullptr; - if (monster._uniqtype != 0) - trn = monster.uniqueTRN.get(); - if (monster._mmode == MonsterMode::Petrified) + if (monster.uniqType != 0) + trn = monster.uniqueMonsterTRN.get(); + if (monster.mode == MonsterMode::Petrified) trn = GetStoneTRN(); if (MyPlayer->_pInfraFlag && LightTableIndex > 8) trn = GetInfravisionTRN(); @@ -768,20 +768,20 @@ void DrawMonsterHelper(const Surface &out, Point tilePosition, Point targetBuffe } const auto &monster = Monsters[mi]; - if ((monster._mFlags & MFLAG_HIDDEN) != 0) { + if ((monster.flags & MFLAG_HIDDEN) != 0) { return; } - CelSprite cel = *monster.AnimInfo.celSprite; + CelSprite cel = *monster.animInfo.celSprite; Displacement offset = monster.position.offset; - if (monster.IsWalking()) { - offset = GetOffsetForWalking(monster.AnimInfo, monster._mdir); + if (monster.isWalking()) { + offset = GetOffsetForWalking(monster.animInfo, monster.direction); } const Point monsterRenderPosition { targetBufferPosition + offset - Displacement { CalculateWidth2(cel.Width()), 0 } }; if (mi == pcursmonst) { - Cl2DrawOutline(out, 233, monsterRenderPosition.x, monsterRenderPosition.y, cel, monster.AnimInfo.getFrameToUseForRendering()); + Cl2DrawOutline(out, 233, monsterRenderPosition.x, monsterRenderPosition.y, cel, monster.animInfo.getFrameToUseForRendering()); } DrawMonster(out, tilePosition, monsterRenderPosition, monster); } @@ -848,7 +848,7 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit break; } if (pDeadGuy->translationPaletteIndex != 0) { - uint8_t *trn = Monsters[pDeadGuy->translationPaletteIndex - 1].uniqueTRN.get(); + uint8_t *trn = Monsters[pDeadGuy->translationPaletteIndex - 1].uniqueMonsterTRN.get(); Cl2DrawTRN(out, px, targetBufferPosition.y, CelSprite(pCelBuff, pDeadGuy->width), nCel, trn); } else { Cl2DrawLight(out, px, targetBufferPosition.y, CelSprite(pCelBuff, pDeadGuy->width), nCel); diff --git a/Source/inv.cpp b/Source/inv.cpp index 00ed84deb..f44a8e9ad 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -2090,7 +2090,7 @@ void DoTelekinesis() NetSendCmdGItem(true, CMD_REQUESTAGITEM, MyPlayerId, MyPlayerId, pcursitem); if (pcursmonst != -1) { auto &monter = Monsters[pcursmonst]; - if (!M_Talker(monter) && monter.mtalkmsg == TEXT_NONE) + if (!M_Talker(monter) && monter.talkMsg == TEXT_NONE) NetSendCmdParam1(true, CMD_KNOCKBACK, pcursmonst); } NewCursor(CURSOR_HAND); diff --git a/Source/items.cpp b/Source/items.cpp index da0698719..5f969c4e7 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1349,7 +1349,7 @@ int RndUItem(Monster *monster) if (AllItemsList[i].iRnd == IDROP_NEVER) okflag = false; if (monster != nullptr) { - if (monster->mLevel < AllItemsList[i].iMinMLvl) + if (monster->level < AllItemsList[i].iMinMLvl) okflag = false; } else { if (2 * curlv < AllItemsList[i].iMinMLvl) @@ -3026,12 +3026,12 @@ int RndItem(const Monster &monster) if (!IsItemAvailable(i)) continue; - if (AllItemsList[i].iRnd == IDROP_DOUBLE && monster.mLevel >= AllItemsList[i].iMinMLvl + if (AllItemsList[i].iRnd == IDROP_DOUBLE && monster.level >= AllItemsList[i].iMinMLvl && ri < 512) { ril[ri] = i; ri++; } - if (AllItemsList[i].iRnd != IDROP_NEVER && monster.mLevel >= AllItemsList[i].iMinMLvl + if (AllItemsList[i].iRnd != IDROP_NEVER && monster.level >= AllItemsList[i].iMinMLvl && ri < 512) { ril[ri] = i; ri++; @@ -3070,7 +3070,7 @@ void SpawnItem(Monster &monster, Point position, bool sendmsg) int idx; bool onlygood = true; - if (monster._uniqtype != 0 || ((monster.data().mTreasure & T_UNIQ) != 0 && gbIsMultiplayer)) { + if (monster.uniqType != 0 || ((monster.data().mTreasure & T_UNIQ) != 0 && gbIsMultiplayer)) { idx = RndUItem(&monster); if (idx < 0) { SpawnUnique((_unique_items) - (idx + 1), position); @@ -3099,7 +3099,7 @@ void SpawnItem(Monster &monster, Point position, bool sendmsg) int ii = AllocateItem(); auto &item = Items[ii]; GetSuperItemSpace(position, ii); - int uper = monster._uniqtype != 0 ? 15 : 1; + int uper = monster.uniqType != 0 ? 15 : 1; int8_t mLevel = monster.data().mLevel; if (!gbIsHellfire && monster.type().type == MT_DIABLO) @@ -4462,8 +4462,8 @@ std::string DebugSpawnItem(std::string itemName) uint32_t begin = SDL_GetTicks(); Monster fake_m; - fake_m._mMTidx = 0; - fake_m._uniqtype = 0; + fake_m.levelType = 0; + fake_m.uniqType = 0; int i = 0; for (;; i++) { @@ -4476,7 +4476,7 @@ std::string DebugSpawnItem(std::string itemName) if (i > max_iter) return fmt::format("Item not found in {:d} tries!", max_iter); - fake_m.mLevel = dist(BetterRng) % CF_LEVEL + 1; + fake_m.level = dist(BetterRng) % CF_LEVEL + 1; int idx = RndItem(fake_m); if (idx > 1) { @@ -4487,7 +4487,7 @@ std::string DebugSpawnItem(std::string itemName) Point bkp = item.position; item = {}; item.position = bkp; - SetupAllItems(item, idx, AdvanceRndSeed(), fake_m.mLevel, 1, false, false, false); + SetupAllItems(item, idx, AdvanceRndSeed(), fake_m.level, 1, false, false, false); std::string tmp(item._iIName); std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](unsigned char c) { return std::tolower(c); }); diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index fd1b5ef8a..339187765 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -564,15 +564,15 @@ bool gbSkipSync = false; void LoadMonster(LoadHelper *file, Monster &monster) { - monster._mMTidx = file->NextLE(); - monster._mmode = static_cast(file->NextLE()); - monster._mgoal = static_cast(file->NextLE()); + monster.levelType = file->NextLE(); + monster.mode = static_cast(file->NextLE()); + monster.goal = static_cast(file->NextLE()); file->Skip(3); // Alignment - monster._mgoalvar1 = file->NextLE(); - monster._mgoalvar2 = file->NextLE(); - monster._mgoalvar3 = file->NextLE(); + monster.goalVar1 = file->NextLE(); + monster.goalVar2 = file->NextLE(); + monster.goalVar3 = file->NextLE(); file->Skip(4); // Unused - monster._pathcount = file->NextLE(); + monster.pathCount = file->NextLE(); file->Skip(3); // Alignment monster.position.tile.x = file->NextLE(); monster.position.tile.y = file->NextLE(); @@ -584,77 +584,77 @@ void LoadMonster(LoadHelper *file, Monster &monster) monster.position.offset.deltaY = file->NextLE(); monster.position.velocity.deltaX = file->NextLE(); monster.position.velocity.deltaY = file->NextLE(); - monster._mdir = static_cast(file->NextLE()); - monster._menemy = file->NextLE(); + monster.direction = static_cast(file->NextLE()); + monster.enemy = file->NextLE(); monster.enemyPosition.x = file->NextLE(); monster.enemyPosition.y = file->NextLE(); file->Skip(2); // Unused file->Skip(4); // Skip pointer _mAnimData - monster.AnimInfo = {}; - monster.AnimInfo.ticksPerFrame = file->NextLENarrow(); + monster.animInfo = {}; + monster.animInfo.ticksPerFrame = file->NextLENarrow(); // Ensure that we can increase the tickCounterOfCurrentFrame at least once without overflow (needed for backwards compatibility for sitting gargoyles) - monster.AnimInfo.tickCounterOfCurrentFrame = file->NextLENarrow(1) - 1; - monster.AnimInfo.numberOfFrames = file->NextLENarrow(); - monster.AnimInfo.currentFrame = file->NextLENarrow(-1); + monster.animInfo.tickCounterOfCurrentFrame = file->NextLENarrow(1) - 1; + monster.animInfo.numberOfFrames = file->NextLENarrow(); + monster.animInfo.currentFrame = file->NextLENarrow(-1); file->Skip(4); // Skip _meflag - monster._mDelFlag = file->NextBool32(); - monster._mVar1 = file->NextLE(); - monster._mVar2 = file->NextLE(); - monster._mVar3 = file->NextLE(); + monster.isInvalid = file->NextBool32(); + monster.var1 = file->NextLE(); + monster.var2 = file->NextLE(); + monster.var3 = file->NextLE(); monster.position.temp.x = file->NextLE(); monster.position.temp.y = file->NextLE(); monster.position.offset2.deltaX = file->NextLE(); monster.position.offset2.deltaY = file->NextLE(); file->Skip(4); // Skip actionFrame - monster._mmaxhp = file->NextLE(); - monster._mhitpoints = file->NextLE(); + monster.maxHitPoints = file->NextLE(); + monster.hitPoints = file->NextLE(); - monster._mAi = static_cast<_mai_id>(file->NextLE()); - monster._mint = file->NextLE(); + monster.ai = static_cast<_mai_id>(file->NextLE()); + monster.intelligence = file->NextLE(); file->Skip(2); // Alignment - monster._mFlags = file->NextLE(); - monster._msquelch = file->NextLE(); + monster.flags = file->NextLE(); + monster.activeForTicks = file->NextLE(); file->Skip(3); // Alignment file->Skip(4); // Unused monster.position.last.x = file->NextLE(); monster.position.last.y = file->NextLE(); - monster._mRndSeed = file->NextLE(); - monster._mAISeed = file->NextLE(); + monster.rndItemSeed = file->NextLE(); + monster.aiSeed = file->NextLE(); file->Skip(4); // Unused - monster._uniqtype = file->NextLE(); - monster._uniqtrans = file->NextLE(); - monster._udeadval = file->NextLE(); + monster.uniqType = file->NextLE(); + monster.uniqTrans = file->NextLE(); + monster.corpseId = file->NextLE(); - monster.mWhoHit = file->NextLE(); - monster.mLevel = file->NextLE(); + monster.whoHit = file->NextLE(); + monster.level = file->NextLE(); file->Skip(1); // Alignment - monster.mExp = file->NextLE(); + monster.exp = file->NextLE(); - if ((monster._mFlags & MFLAG_GOLEM) != 0) // Don't skip for golems - monster.mHit = file->NextLE(); + if ((monster.flags & MFLAG_GOLEM) != 0) // Don't skip for golems + monster.hit = file->NextLE(); else - file->Skip(1); // Skip mHit as it's already initialized - monster.mMinDamage = file->NextLE(); - monster.mMaxDamage = file->NextLE(); - file->Skip(1); // Skip mHit2 as it's already initialized - monster.mMinDamage2 = file->NextLE(); - monster.mMaxDamage2 = file->NextLE(); - monster.mArmorClass = file->NextLE(); + file->Skip(1); // Skip hit as it's already initialized + monster.minDamage = file->NextLE(); + monster.maxDamage = file->NextLE(); + file->Skip(1); // Skip hit2 as it's already initialized + monster.minDamage2 = file->NextLE(); + monster.maxDamage2 = file->NextLE(); + monster.armorClass = file->NextLE(); file->Skip(1); // Alignment - monster.mMagicRes = file->NextLE(); + monster.magicResistance = file->NextLE(); file->Skip(2); // Alignment - monster.mtalkmsg = static_cast<_speech_id>(file->NextLE()); - if (monster.mtalkmsg == TEXT_KING1) // Fix original bad mapping of NONE for monsters - monster.mtalkmsg = TEXT_NONE; + monster.talkMsg = static_cast<_speech_id>(file->NextLE()); + if (monster.talkMsg == TEXT_KING1) // Fix original bad mapping of NONE for monsters + monster.talkMsg = TEXT_NONE; monster.leader = file->NextLE(); monster.leaderRelation = static_cast(file->NextLE()); - monster.packsize = file->NextLE(); - monster.mlid = file->NextLE(); - if (monster.mlid == 0) - monster.mlid = NO_LIGHT; // Correct incorect values in old saves + monster.packSize = file->NextLE(); + monster.lightId = file->NextLE(); + if (monster.lightId == 0) + monster.lightId = NO_LIGHT; // Correct incorect values in old saves // Omit pointer mName; @@ -669,17 +669,17 @@ void LoadMonster(LoadHelper *file, Monster &monster) */ void SyncPackSize(Monster &leader) { - if (leader._uniqtype == 0) + if (leader.uniqType == 0) return; - if (leader._mAi != AI_SCAV) + if (leader.ai != AI_SCAV) return; - leader.packsize = 0; + leader.packSize = 0; for (int i = 0; i < ActiveMonsterCount; i++) { auto &minion = Monsters[ActiveMonsters[i]]; if (minion.leaderRelation == LeaderRelation::Leashed && &Monsters[minion.leader] == &leader) - leader.packsize++; + leader.packSize++; } } @@ -1306,15 +1306,15 @@ void SavePlayer(SaveHelper &file, const Player &player) void SaveMonster(SaveHelper *file, Monster &monster) { - file->WriteLE(monster._mMTidx); - file->WriteLE(static_cast(monster._mmode)); - file->WriteLE(monster._mgoal); + file->WriteLE(monster.levelType); + file->WriteLE(static_cast(monster.mode)); + file->WriteLE(monster.goal); file->Skip(3); // Alignment - file->WriteLE(monster._mgoalvar1); - file->WriteLE(monster._mgoalvar2); - file->WriteLE(monster._mgoalvar3); + file->WriteLE(monster.goalVar1); + file->WriteLE(monster.goalVar2); + file->WriteLE(monster.goalVar3); file->Skip(4); // Unused - file->WriteLE(monster._pathcount); + file->WriteLE(monster.pathCount); file->Skip(3); // Alignment file->WriteLE(monster.position.tile.x); file->WriteLE(monster.position.tile.y); @@ -1326,72 +1326,72 @@ void SaveMonster(SaveHelper *file, Monster &monster) file->WriteLE(monster.position.offset.deltaY); file->WriteLE(monster.position.velocity.deltaX); file->WriteLE(monster.position.velocity.deltaY); - file->WriteLE(static_cast(monster._mdir)); - file->WriteLE(monster._menemy); + file->WriteLE(static_cast(monster.direction)); + file->WriteLE(monster.enemy); file->WriteLE(monster.enemyPosition.x); file->WriteLE(monster.enemyPosition.y); file->Skip(2); // Unused file->Skip(4); // Skip pointer _mAnimData - file->WriteLE(monster.AnimInfo.ticksPerFrame); - file->WriteLE(monster.AnimInfo.tickCounterOfCurrentFrame); - file->WriteLE(monster.AnimInfo.numberOfFrames); - file->WriteLE(monster.AnimInfo.currentFrame + 1); + file->WriteLE(monster.animInfo.ticksPerFrame); + file->WriteLE(monster.animInfo.tickCounterOfCurrentFrame); + file->WriteLE(monster.animInfo.numberOfFrames); + file->WriteLE(monster.animInfo.currentFrame + 1); file->Skip(); // Skip _meflag - file->WriteLE(monster._mDelFlag ? 1 : 0); - file->WriteLE(monster._mVar1); - file->WriteLE(monster._mVar2); - file->WriteLE(monster._mVar3); + file->WriteLE(monster.isInvalid ? 1 : 0); + file->WriteLE(monster.var1); + file->WriteLE(monster.var2); + file->WriteLE(monster.var3); file->WriteLE(monster.position.temp.x); file->WriteLE(monster.position.temp.y); file->WriteLE(monster.position.offset2.deltaX); file->WriteLE(monster.position.offset2.deltaY); file->Skip(); // Skip _mVar8 - file->WriteLE(monster._mmaxhp); - file->WriteLE(monster._mhitpoints); + file->WriteLE(monster.maxHitPoints); + file->WriteLE(monster.hitPoints); - file->WriteLE(monster._mAi); - file->WriteLE(monster._mint); + file->WriteLE(monster.ai); + file->WriteLE(monster.intelligence); file->Skip(2); // Alignment - file->WriteLE(monster._mFlags); - file->WriteLE(monster._msquelch); + file->WriteLE(monster.flags); + file->WriteLE(monster.activeForTicks); file->Skip(3); // Alignment file->Skip(4); // Unused file->WriteLE(monster.position.last.x); file->WriteLE(monster.position.last.y); - file->WriteLE(monster._mRndSeed); - file->WriteLE(monster._mAISeed); + file->WriteLE(monster.rndItemSeed); + file->WriteLE(monster.aiSeed); file->Skip(4); // Unused - file->WriteLE(monster._uniqtype); - file->WriteLE(monster._uniqtrans); - file->WriteLE(monster._udeadval); + file->WriteLE(monster.uniqType); + file->WriteLE(monster.uniqTrans); + file->WriteLE(monster.corpseId); - file->WriteLE(monster.mWhoHit); - file->WriteLE(monster.mLevel); + file->WriteLE(monster.whoHit); + file->WriteLE(monster.level); file->Skip(1); // Alignment - file->WriteLE(monster.mExp); - - file->WriteLE(static_cast(std::min(monster.mHit, std::numeric_limits::max()))); // For backwards compatibility - file->WriteLE(monster.mMinDamage); - file->WriteLE(monster.mMaxDamage); - file->WriteLE(static_cast(std::min(monster.mHit2, std::numeric_limits::max()))); // For backwards compatibility - file->WriteLE(monster.mMinDamage2); - file->WriteLE(monster.mMaxDamage2); - file->WriteLE(monster.mArmorClass); + file->WriteLE(monster.exp); + + file->WriteLE(static_cast(std::min(monster.hit, std::numeric_limits::max()))); // For backwards compatibility + file->WriteLE(monster.minDamage); + file->WriteLE(monster.maxDamage); + file->WriteLE(static_cast(std::min(monster.hit2, std::numeric_limits::max()))); // For backwards compatibility + file->WriteLE(monster.minDamage2); + file->WriteLE(monster.maxDamage2); + file->WriteLE(monster.armorClass); file->Skip(1); // Alignment - file->WriteLE(monster.mMagicRes); + file->WriteLE(monster.magicResistance); file->Skip(2); // Alignment - file->WriteLE(monster.mtalkmsg == TEXT_NONE ? 0 : monster.mtalkmsg); // Replicate original bad mapping of none for monsters + file->WriteLE(monster.talkMsg == TEXT_NONE ? 0 : monster.talkMsg); // Replicate original bad mapping of none for monsters file->WriteLE(monster.leader); file->WriteLE(static_cast(monster.leaderRelation)); - file->WriteLE(monster.packsize); + file->WriteLE(monster.packSize); // vanilla compatibility - if (monster.mlid == NO_LIGHT) + if (monster.lightId == NO_LIGHT) file->WriteLE(0); else - file->WriteLE(monster.mlid); + file->WriteLE(monster.lightId); // Omit pointer mName; } diff --git a/Source/misdat.cpp b/Source/misdat.cpp index f821eddba..12d4e13ae 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -15,7 +15,7 @@ namespace devilution { /** Data related to each missile ID. */ MissileData MissilesData[] = { // clang-format off - // mAddProc, mProc, mName, mDraw, mType, mResist, mFileNum, mlSFX, miSFX, MovementDistribution; + // mAddProc, mProc, name, mDraw, mType, mResist, mFileNum, mlSFX, miSFX, MovementDistribution; { &AddArrow, &MI_Arrow, MIS_ARROW, true, 0, MISR_NONE, MFILE_ARROWS, SFX_NONE, SFX_NONE, MissileMovementDistrubution::Blockable }, { &AddFirebolt, &MI_Firebolt, MIS_FIREBOLT, true, 1, MISR_FIRE, MFILE_FIREBA, LS_FBOLT1, LS_FIRIMP2, MissileMovementDistrubution::Blockable }, { &AddGuardian, &MI_Guardian, MIS_GUARDIAN, true, 1, MISR_NONE, MFILE_GUARD, LS_GUARD, LS_GUARDLAN, MissileMovementDistrubution::Disabled }, diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 5373de87b..8e6aa6c78 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -186,7 +186,7 @@ bool MonsterMHit(int pnum, int monsterId, int mindam, int maxdam, int dist, miss { auto &monster = Monsters[monsterId]; - if (!monster.IsPossibleToHit() || monster.IsImmune(t)) + if (!monster.isPossibleToHit() || monster.isImmune(t)) return false; int hit = GenerateRnd(100); @@ -194,18 +194,18 @@ bool MonsterMHit(int pnum, int monsterId, int mindam, int maxdam, int dist, miss const Player &player = Players[pnum]; if (MissilesData[t].mType == 0) { hper = player.GetRangedPiercingToHit(); - hper -= player.CalculateArmorPierce(monster.mArmorClass, false); + hper -= player.CalculateArmorPierce(monster.armorClass, false); hper -= (dist * dist) / 2; } else { - hper = player.GetMagicToHit() - (monster.mLevel * 2) - dist; + hper = player.GetMagicToHit() - (monster.level * 2) - dist; } hper = clamp(hper, 5, 95); - if (monster._mmode == MonsterMode::Petrified) + if (monster.mode == MonsterMode::Petrified) hit = 0; - if (monster.TryLiftGargoyle()) + if (monster.tryLiftGargoyle()) return true; if (hit >= hper) { @@ -217,7 +217,7 @@ bool MonsterMHit(int pnum, int monsterId, int mindam, int maxdam, int dist, miss int dam; if (t == MIS_BONESPIRIT) { - dam = monster._mhitpoints / 3 >> 6; + dam = monster.hitPoints / 3 >> 6; } else { dam = mindam + GenerateRnd(maxdam - mindam + 1); } @@ -231,31 +231,31 @@ bool MonsterMHit(int pnum, int monsterId, int mindam, int maxdam, int dist, miss if (monster.data().mMonstClass == MonsterClass::Demon && HasAnyOf(player._pIFlags, ItemSpecialEffect::TripleDemonDamage)) dam *= 3; } - bool resist = monster.IsResistant(t); + bool resist = monster.isResistant(t); if (!shift) dam <<= 6; if (resist) dam >>= 2; if (pnum == MyPlayerId) - monster._mhitpoints -= dam; + monster.hitPoints -= dam; if ((gbIsHellfire && HasAnyOf(player._pIFlags, ItemSpecialEffect::NoHealOnMonsters)) || (!gbIsHellfire && HasAnyOf(player._pIFlags, ItemSpecialEffect::FireArrows))) - monster._mFlags |= MFLAG_NOHEAL; + monster.flags |= MFLAG_NOHEAL; - if (monster._mhitpoints >> 6 <= 0) { + if (monster.hitPoints >> 6 <= 0) { M_StartKill(monsterId, pnum); } else if (resist) { PlayEffect(monster, 1); } else { - if (monster._mmode != MonsterMode::Petrified && MissilesData[t].mType == 0 && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback)) + if (monster.mode != MonsterMode::Petrified && MissilesData[t].mType == 0 && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback)) M_GetKnockback(monster); if (monster.type().type != MT_GOLEM) M_StartHit(monster, pnum, dam); } - if (monster._msquelch == 0) { - monster._msquelch = UINT8_MAX; + if (monster.activeForTicks == 0) { + monster.activeForTicks = UINT8_MAX; monster.position.last = player.position.tile; } @@ -389,12 +389,12 @@ void CheckMissileCol(Missile &missile, int minDamage, int maxDamage, bool isDama bool isMonsterHit = false; int mid = dMonster[mx][my]; - if (mid > 0 || (mid != 0 && Monsters[abs(mid) - 1]._mmode == MonsterMode::Petrified)) { + if (mid > 0 || (mid != 0 && Monsters[abs(mid) - 1].mode == MonsterMode::Petrified)) { mid = abs(mid) - 1; if (missile.IsTrap() || (missile._micaster == TARGET_PLAYERS - && (Monsters[missile._misource]._mFlags & MFLAG_TARGETS_MONSTER) != 0 - && ((Monsters[mid]._mFlags & MFLAG_GOLEM) != 0 || (Monsters[missile._misource]._mFlags & MFLAG_BERSERK) != 0))) { + && (Monsters[missile._misource].flags & MFLAG_TARGETS_MONSTER) != 0 + && ((Monsters[mid].flags & MFLAG_GOLEM) != 0 || (Monsters[missile._misource].flags & MFLAG_BERSERK) != 0))) { isMonsterHit = MonsterTrapHit(mid, minDamage, maxDamage, missile._midist, missile._mitype, isDamageShifted); } else if (IsAnyOf(missile._micaster, TARGET_BOTH, TARGET_MONSTERS)) { isMonsterHit = MonsterMHit(missile._misource, mid, minDamage, maxDamage, missile._midist, missile._mitype, isDamageShifted); @@ -596,7 +596,7 @@ bool GuardianTryFireAt(Missile &missile, Point target) const Monster &monster = Monsters[mid]; if (monster.type().type == MT_GOLEM) return false; - if (monster._mhitpoints >> 6 <= 0) + if (monster.hitPoints >> 6 <= 0) return false; Direction dir = GetDirection(position, target); @@ -844,34 +844,34 @@ bool MonsterTrapHit(int monsterId, int mindam, int maxdam, int dist, missile_id { auto &monster = Monsters[monsterId]; - if (!monster.IsPossibleToHit() || monster.IsImmune(t)) + if (!monster.isPossibleToHit() || monster.isImmune(t)) return false; int hit = GenerateRnd(100); - int hper = 90 - (BYTE)monster.mArmorClass - dist; + int hper = 90 - (BYTE)monster.armorClass - dist; hper = clamp(hper, 5, 95); - if (monster.TryLiftGargoyle()) + if (monster.tryLiftGargoyle()) return true; - if (hit >= hper && monster._mmode != MonsterMode::Petrified) { + if (hit >= hper && monster.mode != MonsterMode::Petrified) { #ifdef _DEBUG if (!DebugGodMode) #endif return false; } - bool resist = monster.IsResistant(t); + bool resist = monster.isResistant(t); int dam = mindam + GenerateRnd(maxdam - mindam + 1); if (!shift) dam <<= 6; if (resist) - monster._mhitpoints -= dam / 4; + monster.hitPoints -= dam / 4; else - monster._mhitpoints -= dam; + monster.hitPoints -= dam; #ifdef _DEBUG if (DebugGodMode) - monster._mhitpoints = 0; + monster.hitPoints = 0; #endif - if (monster._mhitpoints >> 6 <= 0) { + if (monster.hitPoints >> 6 <= 0) { StartMonsterDeath(monster, -1, true); } else if (resist) { PlayEffect(monster, 1); @@ -909,15 +909,15 @@ bool PlayerMHit(int pnum, Monster *monster, int dist, int mind, int maxd, missil if (MissilesData[mtype].mType == 0) { int tac = player.GetArmor(); if (monster != nullptr) { - hper = monster->mHit - + ((monster->mLevel - player._pLevel) * 2) + hper = monster->hit + + ((monster->level - player._pLevel) * 2) + 30 - (dist * 2) - tac; } else { hper = 100 - (tac / 2) - (dist * 2); } } else if (monster != nullptr) { - hper += (monster->mLevel * 2) - (player._pLevel * 2) - (dist * 2); + hper += (monster->level * 2) - (player._pLevel * 2) - (dist * 2); } int minhit = 10; @@ -941,7 +941,7 @@ bool PlayerMHit(int pnum, Monster *monster, int dist, int mind, int maxd, missil int blkper = player.GetBlockChance(false); if (monster != nullptr) - blkper -= (monster->mLevel - player._pLevel) * 2; + blkper -= (monster->level - player._pLevel) * 2; blkper = clamp(blkper, 0, 100); int8_t resper; @@ -1140,15 +1140,15 @@ void AddBerserk(Missile &missile, const AddMissileParameter ¶meter) const Monster &monster = Monsters[monsterId]; if (monster.type().type == MT_GOLEM) return false; - if ((monster._mFlags & MFLAG_BERSERK) != 0) + if ((monster.flags & MFLAG_BERSERK) != 0) return false; - if (monster._uniqtype != 0 || monster._mAi == AI_DIABLO) + if (monster.uniqType != 0 || monster.ai == AI_DIABLO) return false; - if (IsAnyOf(monster._mmode, MonsterMode::FadeIn, MonsterMode::FadeOut, MonsterMode::Charge)) + if (IsAnyOf(monster.mode, MonsterMode::FadeIn, MonsterMode::FadeOut, MonsterMode::Charge)) return false; - if ((monster.mMagicRes & IMMUNE_MAGIC) != 0) + if ((monster.magicResistance & IMMUNE_MAGIC) != 0) return false; - if ((monster.mMagicRes & RESIST_MAGIC) != 0 && ((monster.mMagicRes & RESIST_MAGIC) != 1 || GenerateRnd(2) != 0)) + if ((monster.magicResistance & RESIST_MAGIC) != 0 && ((monster.magicResistance & RESIST_MAGIC) != 1 || GenerateRnd(2) != 0)) return false; return true; @@ -1159,13 +1159,13 @@ void AddBerserk(Missile &missile, const AddMissileParameter ¶meter) auto &monster = Monsters[abs(dMonster[targetMonsterPosition->x][targetMonsterPosition->y]) - 1]; Player &player = Players[missile._misource]; const int slvl = player.GetSpellLevel(SPL_BERSERK); - monster._mFlags |= MFLAG_BERSERK | MFLAG_GOLEM; - monster.mMinDamage = (GenerateRnd(10) + 120) * monster.mMinDamage / 100 + slvl; - monster.mMaxDamage = (GenerateRnd(10) + 120) * monster.mMaxDamage / 100 + slvl; - monster.mMinDamage2 = (GenerateRnd(10) + 120) * monster.mMinDamage2 / 100 + slvl; - monster.mMaxDamage2 = (GenerateRnd(10) + 120) * monster.mMaxDamage2 / 100 + slvl; + monster.flags |= MFLAG_BERSERK | MFLAG_GOLEM; + monster.minDamage = (GenerateRnd(10) + 120) * monster.minDamage / 100 + slvl; + monster.maxDamage = (GenerateRnd(10) + 120) * monster.maxDamage / 100 + slvl; + monster.minDamage2 = (GenerateRnd(10) + 120) * monster.minDamage2 / 100 + slvl; + monster.maxDamage2 = (GenerateRnd(10) + 120) * monster.maxDamage2 / 100 + slvl; int lightRadius = leveltype == DTYPE_NEST ? 9 : 3; - monster.mlid = AddLight(monster.position.tile, lightRadius); + monster.lightId = AddLight(monster.position.tile, lightRadius); UseMana(player, SPL_BERSERK); } } @@ -1894,7 +1894,7 @@ void AddFlash(Missile &missile, const AddMissileParameter & /*parameter*/) missile._midam += missile._midam / 2; UseMana(player, SPL_FLASH); } else { - missile._midam = Monsters[missile._misource].mLevel * 2; + missile._midam = Monsters[missile._misource].level * 2; } } else { missile._midam = currlevel / 2; @@ -2041,8 +2041,8 @@ void AddRhino(Missile &missile, const AddMissileParameter ¶meter) InitMissileAnimationFromMonster(missile, parameter.midir, monster, graphic); if (IsAnyOf(monster.type().type, MT_NSNAKE, MT_RSNAKE, MT_BSNAKE, MT_GSNAKE)) missile._miAnimFrame = 7; - if (monster._uniqtype != 0) { - missile._mlid = monster.mlid; + if (monster.uniqType != 0) { + missile._mlid = monster.lightId; } PutMissile(missile); } @@ -2083,7 +2083,7 @@ void AddAcid(Missile &missile, const AddMissileParameter ¶meter) UpdateMissileVelocity(missile, parameter.dst, 16); SetMissDir(missile, GetDirection16(missile.position.start, parameter.dst)); if (!gbIsHellfire || (missile.position.velocity.deltaX & 0xFFFF0000) != 0 || (missile.position.velocity.deltaY & 0xFFFF0000) != 0) - missile._mirange = 5 * (Monsters[missile._misource]._mint + 4); + missile._mirange = 5 * (Monsters[missile._misource].intelligence + 4); else missile._mirange = 1; missile._mlid = NO_LIGHT; @@ -2096,7 +2096,7 @@ void AddAcidpud(Missile &missile, const AddMissileParameter & /*parameter*/) { missile._miLightFlag = true; int monst = missile._misource; - missile._mirange = GenerateRnd(15) + 40 * (Monsters[monst]._mint + 1); + missile._mirange = GenerateRnd(15) + 40 * (Monsters[monst].intelligence + 1); missile._miPreFlag = true; } @@ -2118,7 +2118,7 @@ void AddStone(Missile &missile, const AddMissileParameter ¶meter) if (IsAnyOf(monster.type().type, MT_GOLEM, MT_DIABLO, MT_NAKRUL)) { return false; } - if (IsAnyOf(monster._mmode, MonsterMode::FadeIn, MonsterMode::FadeOut, MonsterMode::Charge)) { + if (IsAnyOf(monster.mode, MonsterMode::FadeIn, MonsterMode::FadeOut, MonsterMode::Charge)) { return false; } @@ -2134,9 +2134,9 @@ void AddStone(Missile &missile, const AddMissileParameter ¶meter) // Petrify the targeted monster int monsterId = abs(dMonster[targetMonsterPosition->x][targetMonsterPosition->y]) - 1; auto &monster = Monsters[monsterId]; - missile.var1 = static_cast(monster._mmode); + missile.var1 = static_cast(monster.mode); missile.var2 = monsterId; - monster.Petrify(); + monster.petrify(); Player &player = Players[missile._misource]; @@ -2429,7 +2429,7 @@ void AddFlame(Missile &missile, const AddMissileParameter ¶meter) missile._midam = 8 * i + 16 + ((8 * i + 16) / 2); } else { auto &monster = Monsters[missile._misource]; - missile._midam = monster.mMinDamage + GenerateRnd(monster.mMaxDamage - monster.mMinDamage + 1); + missile._midam = monster.minDamage + GenerateRnd(monster.maxDamage - monster.minDamage + 1); } } @@ -2587,8 +2587,8 @@ Missile *AddMissile(Point src, Point dst, Direction midir, missile_id mitype, mi if (!missile.IsTrap() && micaster == TARGET_PLAYERS) { Monster &monster = Monsters[id]; - if (monster._uniqtype != 0) { - missile._miUniqTrans = monster._uniqtrans + 1; + if (monster.uniqType != 0) { + missile._miUniqTrans = monster.uniqTrans + 1; } } @@ -2624,8 +2624,8 @@ void MI_LArrow(Missile &missile) maxd = player._pIMaxDam; } else { Monster &monster = Monsters[p]; - mind = monster.mMinDamage; - maxd = monster.mMaxDamage; + mind = monster.minDamage; + maxd = monster.maxDamage; } } else { mind = GenerateRnd(10) + 1 + currlevel; @@ -2709,8 +2709,8 @@ void MI_Arrow(Missile &missile) maxd = player._pIMaxDam; } else { auto &monster = Monsters[p]; - mind = monster.mMinDamage; - maxd = monster.mMaxDamage; + mind = monster.minDamage; + maxd = monster.maxDamage; } } else { mind = currlevel; @@ -2747,7 +2747,7 @@ void MI_Firebolt(Missile &missile) } } else { auto &monster = Monsters[p]; - d = monster.mMinDamage + GenerateRnd(monster.mMaxDamage - monster.mMinDamage + 1); + d = monster.minDamage + GenerateRnd(monster.maxDamage - monster.minDamage + 1); } } else { d = currlevel + GenerateRnd(2 * currlevel); @@ -2894,8 +2894,8 @@ void MI_Fireball(Missile &missile) if (missile._micaster != TARGET_MONSTERS) { auto &monster = Monsters[missile._misource]; - minDam = monster.mMinDamage; - maxDam = monster.mMaxDamage; + minDam = monster.minDamage; + maxDam = monster.maxDamage; } MoveMissileAndCheckMissileCol(missile, minDam, maxDam, true, false); if (missile._mirange == 0) { @@ -3176,7 +3176,7 @@ void MI_Lightctrl(Missile &missile) dam = (GenerateRnd(2) + GenerateRnd(Players[missile._misource]._pLevel) + 2) << 6; } else { auto &monster = Monsters[missile._misource]; - dam = 2 * (monster.mMinDamage + GenerateRnd(monster.mMaxDamage - monster.mMinDamage + 1)); + dam = 2 * (monster.minDamage + GenerateRnd(monster.maxDamage - monster.minDamage + 1)); } SpawnLightning(missile, dam); @@ -3489,24 +3489,24 @@ void MI_Stone(Missile &missile) { missile._mirange--; auto &monster = Monsters[missile.var2]; - if (monster._mhitpoints == 0 && missile._miAnimType != MFILE_SHATTER1) { + if (monster.hitPoints == 0 && missile._miAnimType != MFILE_SHATTER1) { missile._mimfnum = 0; missile._miDrawFlag = true; SetMissAnim(missile, MFILE_SHATTER1); missile._mirange = 11; } - if (monster._mmode != MonsterMode::Petrified) { + if (monster.mode != MonsterMode::Petrified) { missile._miDelFlag = true; return; } if (missile._mirange == 0) { missile._miDelFlag = true; - if (monster._mhitpoints > 0) { - monster._mmode = static_cast(missile.var1); - monster.AnimInfo.isPetrified = false; + if (monster.hitPoints > 0) { + monster.mode = static_cast(missile.var1); + monster.animInfo.isPetrified = false; } else { - AddCorpse(monster.position.tile, stonendx, monster._mdir); + AddCorpse(monster.position.tile, stonendx, monster.direction); } } if (missile._miAnimType == MFILE_SHATTER1) @@ -3529,7 +3529,7 @@ void MI_Rhino(Missile &missile) { int monst = missile._misource; auto &monster = Monsters[monst]; - if (monster._mmode != MonsterMode::Charge) { + if (monster.mode != MonsterMode::Charge) { missile._miDelFlag = true; return; } @@ -3537,7 +3537,7 @@ void MI_Rhino(Missile &missile) Point prevPos = missile.position.tile; Point newPosSnake; dMonster[prevPos.x][prevPos.y] = 0; - if (monster._mAi == AI_SNAKE) { + if (monster.ai == AI_SNAKE) { missile.position.traveled += missile.position.velocity * 2; UpdateMissilePos(missile); newPosSnake = missile.position.tile; @@ -3547,7 +3547,7 @@ void MI_Rhino(Missile &missile) } UpdateMissilePos(missile); Point newPos = missile.position.tile; - if (!IsTileAvailable(monster, newPos) || (monster._mAi == AI_SNAKE && !IsTileAvailable(monster, newPosSnake))) { + if (!IsTileAvailable(monster, newPos) || (monster.ai == AI_SNAKE && !IsTileAvailable(monster, newPosSnake))) { MissToMonst(missile, prevPos); missile._miDelFlag = true; return; @@ -3556,7 +3556,7 @@ void MI_Rhino(Missile &missile) monster.position.old = newPos; monster.position.tile = newPos; dMonster[newPos.x][newPos.y] = -(monst + 1); - if (monster._uniqtype != 0) + if (monster.uniqType != 0) ChangeLightXY(missile._mlid, newPos); MoveMissilePos(missile); PutMissile(missile); @@ -3900,7 +3900,7 @@ void MI_Bonespirit(Missile &missile) missile._mirange = 255; auto *monster = FindClosest(c, 19); if (monster != nullptr) { - missile._midam = monster->_mhitpoints >> 7; + missile._midam = monster->hitPoints >> 7; SetMissDir(missile, GetDirection(c, monster->position.tile)); UpdateMissileVelocity(missile, monster->position.tile, 16); } else { diff --git a/Source/monstdat.cpp b/Source/monstdat.cpp index 62d96fb03..37077bb7f 100644 --- a/Source/monstdat.cpp +++ b/Source/monstdat.cpp @@ -25,7 +25,7 @@ constexpr uint16_t Uniq(_unique_items item) /** Contains the data related to each monster ID. */ const MonsterData MonstersData[] = { // clang-format off -//_monster_id mName, GraphicType, sndfile, TransFile, availability, width, mImage, has_special, snd_special, has_trans, Frames[6], rate[6], mMinDLvl, mMaxDLvl, mLevel, mMinHP, mMaxHP, mAi, mFlags , mInt, mHit, mAFNum, mMinDamage, mMaxDamage, mHit2, mAFNum2, mMinDamage2, mMaxDamage2, mArmorClass, mMonstClass , mMagicRes , mMagicRes2 , mSelFlag, mTreasure, mExp +//_monster_id name, GraphicType, sndfile, TransFile, availability, width, mImage, has_special, snd_special, has_trans, Frames[6], rate[6], mMinDLvl, mMaxDLvl, level, mMinHP, mMaxHP, mAi, mFlags , mInt, hit, mAFNum, minDamage, maxDamage, hit2, mAFNum2, minDamage2, maxDamage2, armorClass, mMonstClass , magicResistance , mMagicRes2 , mSelFlag, mTreasure, exp // TRANSLATORS: Monster Block start /* MT_NZOMBIE */ { P_("monster", "Zombie"), "Zombie\\Zombie", "Monsters\\Zombie\\Zombie", nullptr, MonsterAvailability::Always, 128, 799, false, false, false, { 11, 24, 12, 6, 16, 0 }, { 4, 1, 1, 1, 1, 1 }, 1, 2, 1, 4, 7, AI_ZOMBIE, 0 , 0, 10, 8, 2, 5, 0, 0, 0, 0, 5, MonsterClass::Undead, IMMUNE_MAGIC | IMMUNE_NULL_40 , IMMUNE_MAGIC | IMMUNE_NULL_40 , 3, 0, 54 }, @@ -336,7 +336,7 @@ const _monster_id MonstConvTbl[] = { /** Contains the data related to each unique monster ID. */ const UniqueMonsterData UniqueMonstersData[] = { // clang-format off - // type, mName, mTrnName, mlevel, mmaxhp, mAi, mint, mMinDamage, mMaxDamage, mMagicRes, monsterPack, customToHit, customArmorClass, mtalkmsg + // type, name, mTrnName, mlevel, mmaxhp, mAi, mint, minDamage, maxDamage, magicResistance, monsterPack, customToHit, customArmorClass, talkMsg // TRANSLATORS: Unique Monster Block start { MT_NGOATMC, P_("monster", "Gharbad the Weak"), "BSDB", 4, 120, AI_GARBUD, 3, 8, 16, IMMUNE_LIGHTNING | IMMUNE_NULL_40, UniqueMonsterPack::None, 0, 0, TEXT_GARBUD1 }, { MT_SKING, P_("monster", "Skeleton King"), "GENRL", 0, 240, AI_SKELKING, 3, 6, 16, IMMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMMUNE_NULL_40, UniqueMonsterPack::Independent, 0, 0, TEXT_NONE }, diff --git a/Source/monster.cpp b/Source/monster.cpp index 3dcb8d53a..ecc2d7177 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -190,98 +190,98 @@ void InitMonsterTRN(CMonster &monst) void InitMonster(Monster &monster, Direction rd, int mtype, Point position) { - monster._mdir = rd; + monster.direction = rd; monster.position.tile = position; monster.position.future = position; monster.position.old = position; - monster._mMTidx = mtype; - monster._mmode = MonsterMode::Stand; - monster.mName = pgettext("monster", monster.data().mName).data(); - monster.AnimInfo = {}; - monster.ChangeAnimationData(MonsterGraphic::Stand); - monster.AnimInfo.tickCounterOfCurrentFrame = GenerateRnd(monster.AnimInfo.ticksPerFrame - 1); - monster.AnimInfo.currentFrame = GenerateRnd(monster.AnimInfo.numberOfFrames - 1); - - monster.mLevel = monster.data().mLevel; + monster.levelType = mtype; + monster.mode = MonsterMode::Stand; + monster.name = pgettext("monster", monster.data().mName).data(); + monster.animInfo = {}; + monster.changeAnimationData(MonsterGraphic::Stand); + monster.animInfo.tickCounterOfCurrentFrame = GenerateRnd(monster.animInfo.ticksPerFrame - 1); + monster.animInfo.currentFrame = GenerateRnd(monster.animInfo.numberOfFrames - 1); + + monster.level = monster.data().mLevel; int maxhp = monster.data().mMinHP + GenerateRnd(monster.data().mMaxHP - monster.data().mMinHP + 1); if (monster.type().type == MT_DIABLO && !gbIsHellfire) { maxhp /= 2; - monster.mLevel -= 15; + monster.level -= 15; } - monster._mmaxhp = maxhp << 6; + monster.maxHitPoints = maxhp << 6; if (!gbIsMultiplayer) - monster._mmaxhp = std::max(monster._mmaxhp / 2, 64); - - monster._mhitpoints = monster._mmaxhp; - monster._mAi = monster.data().mAi; - monster._mint = monster.data().mInt; - monster._mgoal = MGOAL_NORMAL; - monster._mgoalvar1 = 0; - monster._mgoalvar2 = 0; - monster._mgoalvar3 = 0; - monster._pathcount = 0; - monster._mDelFlag = false; - monster._uniqtype = 0; - monster._msquelch = 0; - monster.mlid = NO_LIGHT; // BUGFIX monsters initial light id should be -1 (fixed) - monster._mRndSeed = AdvanceRndSeed(); - monster._mAISeed = AdvanceRndSeed(); - monster.mWhoHit = 0; - monster.mExp = monster.data().mExp; - monster.mHit = monster.data().mHit; - monster.mMinDamage = monster.data().mMinDamage; - monster.mMaxDamage = monster.data().mMaxDamage; - monster.mHit2 = monster.data().mHit2; - monster.mMinDamage2 = monster.data().mMinDamage2; - monster.mMaxDamage2 = monster.data().mMaxDamage2; - monster.mArmorClass = monster.data().mArmorClass; - monster.mMagicRes = monster.data().mMagicRes; + monster.maxHitPoints = std::max(monster.maxHitPoints / 2, 64); + + monster.hitPoints = monster.maxHitPoints; + monster.ai = monster.data().mAi; + monster.intelligence = monster.data().mInt; + monster.goal = MGOAL_NORMAL; + monster.goalVar1 = 0; + monster.goalVar2 = 0; + monster.goalVar3 = 0; + monster.pathCount = 0; + monster.isInvalid = false; + monster.uniqType = 0; + monster.activeForTicks = 0; + monster.lightId = NO_LIGHT; // BUGFIX monsters initial light id should be -1 (fixed) + monster.rndItemSeed = AdvanceRndSeed(); + monster.aiSeed = AdvanceRndSeed(); + monster.whoHit = 0; + monster.exp = monster.data().mExp; + monster.hit = monster.data().mHit; + monster.minDamage = monster.data().mMinDamage; + monster.maxDamage = monster.data().mMaxDamage; + monster.hit2 = monster.data().mHit2; + monster.minDamage2 = monster.data().mMinDamage2; + monster.maxDamage2 = monster.data().mMaxDamage2; + monster.armorClass = monster.data().mArmorClass; + monster.magicResistance = monster.data().mMagicRes; monster.leader = 0; monster.leaderRelation = LeaderRelation::None; - monster._mFlags = monster.data().mFlags; - monster.mtalkmsg = TEXT_NONE; + monster.flags = monster.data().mFlags; + monster.talkMsg = TEXT_NONE; - if (monster._mAi == AI_GARG) { - monster.ChangeAnimationData(MonsterGraphic::Special); - monster.AnimInfo.currentFrame = 0; - monster._mFlags |= MFLAG_ALLOW_SPECIAL; - monster._mmode = MonsterMode::SpecialMeleeAttack; + if (monster.ai == AI_GARG) { + monster.changeAnimationData(MonsterGraphic::Special); + monster.animInfo.currentFrame = 0; + monster.flags |= MFLAG_ALLOW_SPECIAL; + monster.mode = MonsterMode::SpecialMeleeAttack; } if (sgGameInitInfo.nDifficulty == DIFF_NIGHTMARE) { - monster._mmaxhp = 3 * monster._mmaxhp; + monster.maxHitPoints = 3 * monster.maxHitPoints; if (gbIsHellfire) - monster._mmaxhp += (gbIsMultiplayer ? 100 : 50) << 6; + monster.maxHitPoints += (gbIsMultiplayer ? 100 : 50) << 6; else - monster._mmaxhp += 64; - monster._mhitpoints = monster._mmaxhp; - monster.mLevel += 15; - monster.mExp = 2 * (monster.mExp + 1000); - monster.mHit += NightmareToHitBonus; - monster.mMinDamage = 2 * (monster.mMinDamage + 2); - monster.mMaxDamage = 2 * (monster.mMaxDamage + 2); - monster.mHit2 += NightmareToHitBonus; - monster.mMinDamage2 = 2 * (monster.mMinDamage2 + 2); - monster.mMaxDamage2 = 2 * (monster.mMaxDamage2 + 2); - monster.mArmorClass += NightmareAcBonus; + monster.maxHitPoints += 64; + monster.hitPoints = monster.maxHitPoints; + monster.level += 15; + monster.exp = 2 * (monster.exp + 1000); + monster.hit += NightmareToHitBonus; + monster.minDamage = 2 * (monster.minDamage + 2); + monster.maxDamage = 2 * (monster.maxDamage + 2); + monster.hit2 += NightmareToHitBonus; + monster.minDamage2 = 2 * (monster.minDamage2 + 2); + monster.maxDamage2 = 2 * (monster.maxDamage2 + 2); + monster.armorClass += NightmareAcBonus; } else if (sgGameInitInfo.nDifficulty == DIFF_HELL) { - monster._mmaxhp = 4 * monster._mmaxhp; + monster.maxHitPoints = 4 * monster.maxHitPoints; if (gbIsHellfire) - monster._mmaxhp += (gbIsMultiplayer ? 200 : 100) << 6; + monster.maxHitPoints += (gbIsMultiplayer ? 200 : 100) << 6; else - monster._mmaxhp += 192; - monster._mhitpoints = monster._mmaxhp; - monster.mLevel += 30; - monster.mExp = 4 * (monster.mExp + 1000); - monster.mHit += HellToHitBonus; - monster.mMinDamage = 4 * monster.mMinDamage + 6; - monster.mMaxDamage = 4 * monster.mMaxDamage + 6; - monster.mHit2 += HellToHitBonus; - monster.mMinDamage2 = 4 * monster.mMinDamage2 + 6; - monster.mMaxDamage2 = 4 * monster.mMaxDamage2 + 6; - monster.mArmorClass += HellAcBonus; - monster.mMagicRes = monster.data().mMagicRes2; + monster.maxHitPoints += 192; + monster.hitPoints = monster.maxHitPoints; + monster.level += 30; + monster.exp = 4 * (monster.exp + 1000); + monster.hit += HellToHitBonus; + monster.minDamage = 4 * monster.minDamage + 6; + monster.maxDamage = 4 * monster.maxDamage + 6; + monster.hit2 += HellToHitBonus; + monster.minDamage2 = 4 * monster.minDamage2 + 6; + monster.maxDamage2 = 4 * monster.maxDamage2 + 6; + monster.armorClass += HellAcBonus; + monster.magicResistance = monster.data().mMagicRes2; } } @@ -299,7 +299,7 @@ void PlaceMonster(int i, int mtype, Point position) { if (LevelMonsterTypes[mtype].type == MT_NAKRUL) { for (int j = 0; j < ActiveMonsterCount; j++) { - if (Monsters[j]._mMTidx == mtype) { + if (Monsters[j].levelType == mtype) { return; } if (Monsters[j].type().type == MT_NAKRUL) { @@ -359,21 +359,21 @@ void PlaceGroup(int mtype, int num, UniqueMonsterPack uniqueMonsterPack, int lea PlaceMonster(ActiveMonsterCount, mtype, { xp, yp }); if (uniqueMonsterPack != UniqueMonsterPack::None) { auto &minion = Monsters[ActiveMonsterCount]; - minion._mmaxhp *= 2; - minion._mhitpoints = minion._mmaxhp; - minion._mint = leader._mint; + minion.maxHitPoints *= 2; + minion.hitPoints = minion.maxHitPoints; + minion.intelligence = leader.intelligence; if (uniqueMonsterPack == UniqueMonsterPack::Leashed) { minion.leader = leaderId; minion.leaderRelation = LeaderRelation::Leashed; - minion._mAi = leader._mAi; + minion.ai = leader.ai; } - if (minion._mAi != AI_GARG) { - minion.ChangeAnimationData(MonsterGraphic::Stand); - minion.AnimInfo.currentFrame = GenerateRnd(minion.AnimInfo.numberOfFrames - 1); - minion._mFlags &= ~MFLAG_ALLOW_SPECIAL; - minion._mmode = MonsterMode::Stand; + if (minion.ai != AI_GARG) { + minion.changeAnimationData(MonsterGraphic::Stand); + minion.animInfo.currentFrame = GenerateRnd(minion.animInfo.numberOfFrames - 1); + minion.flags &= ~MFLAG_ALLOW_SPECIAL; + minion.mode = MonsterMode::Stand; } } ActiveMonsterCount++; @@ -387,7 +387,7 @@ void PlaceGroup(int mtype, int num, UniqueMonsterPack uniqueMonsterPack, int lea } if (uniqueMonsterPack == UniqueMonsterPack::Leashed) { - leader.packsize = placed; + leader.packSize = placed; } } @@ -509,9 +509,9 @@ int AddMonsterType(_monster_id type, placeflag placeflag) void ClearMVars(Monster &monster) { - monster._mVar1 = 0; - monster._mVar2 = 0; - monster._mVar3 = 0; + monster.var1 = 0; + monster.var2 = 0; + monster.var3 = 0; monster.position.temp = { 0, 0 }; monster.position.offset2 = { 0, 0 }; } @@ -520,21 +520,21 @@ void ClrAllMonsters() { for (auto &monster : Monsters) { ClearMVars(monster); - monster.mName = "Invalid Monster"; - monster._mgoal = MGOAL_NONE; - monster._mmode = MonsterMode::Stand; - monster._mVar1 = 0; - monster._mVar2 = 0; + monster.name = "Invalid Monster"; + monster.goal = MGOAL_NONE; + monster.mode = MonsterMode::Stand; + monster.var1 = 0; + monster.var2 = 0; monster.position.tile = { 0, 0 }; monster.position.future = { 0, 0 }; monster.position.old = { 0, 0 }; - monster._mdir = static_cast(GenerateRnd(8)); + monster.direction = static_cast(GenerateRnd(8)); monster.position.velocity = { 0, 0 }; - monster.AnimInfo = {}; - monster._mFlags = 0; - monster._mDelFlag = false; - monster._menemy = GenerateRnd(gbActivePlayers); - monster.enemyPosition = Players[monster._menemy].position.future; + monster.animInfo = {}; + monster.flags = 0; + monster.isInvalid = false; + monster.enemy = GenerateRnd(gbActivePlayers); + monster.enemyPosition = Players[monster.enemy].position.future; } } @@ -628,7 +628,7 @@ void PlaceQuestMonsters() if (i1 < LevelMonsterTypeCount) { for (int i2 = 0; i2 < ActiveMonsterCount; i2++) { auto &monster = Monsters[i2]; - if (monster._uniqtype != 0 || monster._mMTidx == i1) { + if (monster.uniqType != 0 || monster.levelType == i1) { UberDiabloMonsterIndex = i2; break; } @@ -665,8 +665,8 @@ void LoadDiabMonsts() void DeleteMonster(size_t activeIndex) { const auto &monster = Monsters[ActiveMonsters[activeIndex]]; - if ((monster._mFlags & MFLAG_BERSERK) != 0) { - AddUnLight(monster.mlid); + if ((monster.flags & MFLAG_BERSERK) != 0) { + AddUnLight(monster.lightId); } ActiveMonsterCount--; @@ -676,9 +676,9 @@ void DeleteMonster(size_t activeIndex) void NewMonsterAnim(Monster &monster, MonsterGraphic graphic, Direction md, AnimationDistributionFlags flags = AnimationDistributionFlags::None, int8_t numSkippedFrames = 0, int8_t distributeFramesBeforeFrame = 0) { const auto &animData = monster.type().getAnimData(graphic); - monster.AnimInfo.setNewAnimation(animData.getCelSpritesForDirection(md), animData.frames, animData.rate, flags, numSkippedFrames, distributeFramesBeforeFrame); - monster._mFlags &= ~(MFLAG_LOCK_ANIMATION | MFLAG_ALLOW_SPECIAL); - monster._mdir = md; + monster.animInfo.setNewAnimation(animData.getCelSpritesForDirection(md), animData.frames, animData.rate, flags, numSkippedFrames, distributeFramesBeforeFrame); + monster.flags &= ~(MFLAG_LOCK_ANIMATION | MFLAG_ALLOW_SPECIAL); + monster.direction = md; } void StartMonsterGotHit(Monster &monster) @@ -686,8 +686,8 @@ void StartMonsterGotHit(Monster &monster) if (monster.type().type != MT_GOLEM) { auto animationFlags = gGameLogicStep < GameLogicStep::ProcessMonsters ? AnimationDistributionFlags::ProcessAnimationPending : AnimationDistributionFlags::None; int8_t numSkippedFrames = (gbIsHellfire && monster.type().type == MT_DIABLO) ? 4 : 0; - NewMonsterAnim(monster, MonsterGraphic::GotHit, monster._mdir, animationFlags, numSkippedFrames); - monster._mmode = MonsterMode::HitRecovery; + NewMonsterAnim(monster, MonsterGraphic::GotHit, monster.direction, animationFlags, numSkippedFrames); + monster.mode = MonsterMode::HitRecovery; } monster.position.offset = { 0, 0 }; monster.position.tile = monster.position.old; @@ -698,7 +698,7 @@ void StartMonsterGotHit(Monster &monster) bool IsRanged(Monster &monster) { - return IsAnyOf(monster._mAi, AI_SKELBOW, AI_GOATBOW, AI_SUCC, AI_LAZHELP); + return IsAnyOf(monster.ai, AI_SKELBOW, AI_GOATBOW, AI_SUCC, AI_LAZHELP); } void UpdateEnemy(Monster &monster) @@ -708,7 +708,7 @@ void UpdateEnemy(Monster &monster) int bestDist = -1; bool bestsameroom = false; const auto &position = monster.position.tile; - if ((monster._mFlags & MFLAG_BERSERK) != 0 || (monster._mFlags & MFLAG_GOLEM) == 0) { + if ((monster.flags & MFLAG_BERSERK) != 0 || (monster.flags & MFLAG_GOLEM) == 0) { for (int pnum = 0; pnum < MAX_PLRS; pnum++) { Player &player = Players[pnum]; if (!player.plractive || !player.isOnActiveLevel() || player._pLvlChanging @@ -719,7 +719,7 @@ void UpdateEnemy(Monster &monster) if ((sameroom && !bestsameroom) || ((sameroom || !bestsameroom) && dist < bestDist) || (menemy == -1)) { - monster._mFlags &= ~MFLAG_TARGETS_MONSTER; + monster.flags &= ~MFLAG_TARGETS_MONSTER; menemy = pnum; target = player.position.future; bestDist = dist; @@ -732,31 +732,31 @@ void UpdateEnemy(Monster &monster) auto &otherMonster = Monsters[mi]; if (&otherMonster == &monster) continue; - if ((otherMonster._mhitpoints >> 6) <= 0) + if ((otherMonster.hitPoints >> 6) <= 0) continue; if (otherMonster.position.tile == GolemHoldingCell) continue; - if (M_Talker(otherMonster) && otherMonster.mtalkmsg != TEXT_NONE) + if (M_Talker(otherMonster) && otherMonster.talkMsg != TEXT_NONE) continue; - bool isBerserked = (monster._mFlags & MFLAG_BERSERK) != 0 || (otherMonster._mFlags & MFLAG_BERSERK) != 0; - if ((monster._mFlags & MFLAG_GOLEM) != 0 && (otherMonster._mFlags & MFLAG_GOLEM) != 0 && !isBerserked) // prevent golems from fighting each other + bool isBerserked = (monster.flags & MFLAG_BERSERK) != 0 || (otherMonster.flags & MFLAG_BERSERK) != 0; + if ((monster.flags & MFLAG_GOLEM) != 0 && (otherMonster.flags & MFLAG_GOLEM) != 0 && !isBerserked) // prevent golems from fighting each other continue; int dist = otherMonster.position.tile.WalkingDistance(position); - if (((monster._mFlags & MFLAG_GOLEM) == 0 - && (monster._mFlags & MFLAG_BERSERK) == 0 + if (((monster.flags & MFLAG_GOLEM) == 0 + && (monster.flags & MFLAG_BERSERK) == 0 && dist >= 2 && !IsRanged(monster)) - || ((monster._mFlags & MFLAG_GOLEM) == 0 - && (monster._mFlags & MFLAG_BERSERK) == 0 - && (otherMonster._mFlags & MFLAG_GOLEM) == 0)) { + || ((monster.flags & MFLAG_GOLEM) == 0 + && (monster.flags & MFLAG_BERSERK) == 0 + && (otherMonster.flags & MFLAG_GOLEM) == 0)) { continue; } bool sameroom = dTransVal[position.x][position.y] == dTransVal[otherMonster.position.tile.x][otherMonster.position.tile.y]; if ((sameroom && !bestsameroom) || ((sameroom || !bestsameroom) && dist < bestDist) || (menemy == -1)) { - monster._mFlags |= MFLAG_TARGETS_MONSTER; + monster.flags |= MFLAG_TARGETS_MONSTER; menemy = mi; target = otherMonster.position.future; bestDist = dist; @@ -764,11 +764,11 @@ void UpdateEnemy(Monster &monster) } } if (menemy != -1) { - monster._mFlags &= ~MFLAG_NO_ENEMY; - monster._menemy = menemy; + monster.flags &= ~MFLAG_NO_ENEMY; + monster.enemy = menemy; monster.enemyPosition = target; } else { - monster._mFlags |= MFLAG_NO_ENEMY; + monster.flags |= MFLAG_NO_ENEMY; } } @@ -782,12 +782,12 @@ void AiDelay(Monster &monster, int len) return; } - if (monster._mAi == AI_LAZARUS) { + if (monster.ai == AI_LAZARUS) { return; } - monster._mVar2 = len; - monster._mmode = MonsterMode::Delay; + monster.var2 = len; + monster.mode = MonsterMode::Delay; } /** @@ -801,7 +801,7 @@ Direction GetMonsterDirection(Monster &monster) void StartSpecialStand(Monster &monster, Direction md) { NewMonsterAnim(monster, MonsterGraphic::Special, md); - monster._mmode = MonsterMode::SpecialStand; + monster.mode = MonsterMode::SpecialStand; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; @@ -813,13 +813,13 @@ void WalkNorthwards(Monster &monster, int xvel, int yvel, int xadd, int yadd, Di const auto fy = static_cast(yadd + monster.position.tile.y); dMonster[fx][fy] = -(monster.getId() + 1); - monster._mmode = MonsterMode::MoveNorthwards; + monster.mode = MonsterMode::MoveNorthwards; monster.position.old = monster.position.tile; monster.position.future = { fx, fy }; monster.position.velocity = DisplacementOf { static_cast(xvel), static_cast(yvel) }; - monster._mVar1 = xadd; - monster._mVar2 = yadd; - monster._mVar3 = static_cast(endDir); + monster.var1 = xadd; + monster.var2 = yadd; + monster.var3 = static_cast(endDir); NewMonsterAnim(monster, MonsterGraphic::Walk, endDir, AnimationDistributionFlags::ProcessAnimationPending, -1); monster.position.offset2 = { 0, 0 }; } @@ -830,18 +830,18 @@ void WalkSouthwards(Monster &monster, int xvel, int yvel, int xoff, int yoff, in const auto fy = static_cast(yadd + monster.position.tile.y); dMonster[monster.position.tile.x][monster.position.tile.y] = -(monster.getId() + 1); - monster._mVar1 = monster.position.tile.x; - monster._mVar2 = monster.position.tile.y; + monster.var1 = monster.position.tile.x; + monster.var2 = monster.position.tile.y; monster.position.old = monster.position.tile; monster.position.tile = { fx, fy }; monster.position.future = { fx, fy }; dMonster[fx][fy] = monster.getId() + 1; - if (monster.mlid != NO_LIGHT) - ChangeLightXY(monster.mlid, monster.position.tile); + if (monster.lightId != NO_LIGHT) + ChangeLightXY(monster.lightId, monster.position.tile); monster.position.offset = DisplacementOf { static_cast(xoff), static_cast(yoff) }; - monster._mmode = MonsterMode::MoveSouthwards; + monster.mode = MonsterMode::MoveSouthwards; monster.position.velocity = DisplacementOf { static_cast(xvel), static_cast(yvel) }; - monster._mVar3 = static_cast(endDir); + monster.var3 = static_cast(endDir); NewMonsterAnim(monster, MonsterGraphic::Walk, endDir, AnimationDistributionFlags::ProcessAnimationPending, -1); monster.position.offset2 = DisplacementOf { static_cast(16 * xoff), static_cast(16 * yoff) }; } @@ -853,8 +853,8 @@ void WalkSideways(Monster &monster, int xvel, int yvel, int xoff, int yoff, int const auto x = static_cast(mapx + monster.position.tile.x); const auto y = static_cast(mapy + monster.position.tile.y); - if (monster.mlid != NO_LIGHT) - ChangeLightXY(monster.mlid, { x, y }); + if (monster.lightId != NO_LIGHT) + ChangeLightXY(monster.lightId, { x, y }); dMonster[monster.position.tile.x][monster.position.tile.y] = -(monster.getId() + 1); dMonster[fx][fy] = monster.getId() + 1; @@ -862,11 +862,11 @@ void WalkSideways(Monster &monster, int xvel, int yvel, int xoff, int yoff, int monster.position.old = monster.position.tile; monster.position.future = { fx, fy }; monster.position.offset = DisplacementOf { static_cast(xoff), static_cast(yoff) }; - monster._mmode = MonsterMode::MoveSideways; + monster.mode = MonsterMode::MoveSideways; monster.position.velocity = DisplacementOf { static_cast(xvel), static_cast(yvel) }; - monster._mVar1 = fx; - monster._mVar2 = fy; - monster._mVar3 = static_cast(endDir); + monster.var1 = fx; + monster.var2 = fy; + monster.var3 = static_cast(endDir); NewMonsterAnim(monster, MonsterGraphic::Walk, endDir, AnimationDistributionFlags::ProcessAnimationPending, -1); monster.position.offset2 = DisplacementOf { static_cast(16 * xoff), static_cast(16 * yoff) }; } @@ -875,7 +875,7 @@ void StartAttack(Monster &monster) { Direction md = GetMonsterDirection(monster); NewMonsterAnim(monster, MonsterGraphic::Attack, md, AnimationDistributionFlags::ProcessAnimationPending); - monster._mmode = MonsterMode::MeleeAttack; + monster.mode = MonsterMode::MeleeAttack; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; @@ -885,9 +885,9 @@ void StartRangedAttack(Monster &monster, missile_id missileType, int dam) { Direction md = GetMonsterDirection(monster); NewMonsterAnim(monster, MonsterGraphic::Attack, md, AnimationDistributionFlags::ProcessAnimationPending); - monster._mmode = MonsterMode::RangedAttack; - monster._mVar1 = missileType; - monster._mVar2 = dam; + monster.mode = MonsterMode::RangedAttack; + monster.var1 = missileType; + monster.var2 = dam; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; @@ -897,13 +897,13 @@ void StartRangedSpecialAttack(Monster &monster, missile_id missileType, int dam) { Direction md = GetMonsterDirection(monster); int8_t distributeFramesBeforeFrame = 0; - if (monster._mAi == AI_MEGA) + if (monster.ai == AI_MEGA) distributeFramesBeforeFrame = monster.data().mAFNum2; NewMonsterAnim(monster, MonsterGraphic::Special, md, AnimationDistributionFlags::ProcessAnimationPending, 0, distributeFramesBeforeFrame); - monster._mmode = MonsterMode::SpecialRangedAttack; - monster._mVar1 = missileType; - monster._mVar2 = 0; - monster._mVar3 = dam; + monster.mode = MonsterMode::SpecialRangedAttack; + monster.var1 = missileType; + monster.var2 = 0; + monster.var3 = dam; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; @@ -913,7 +913,7 @@ void StartSpecialAttack(Monster &monster) { Direction md = GetMonsterDirection(monster); NewMonsterAnim(monster, MonsterGraphic::Special, md); - monster._mmode = MonsterMode::SpecialMeleeAttack; + monster.mode = MonsterMode::SpecialMeleeAttack; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; @@ -921,8 +921,8 @@ void StartSpecialAttack(Monster &monster) void StartEating(Monster &monster) { - NewMonsterAnim(monster, MonsterGraphic::Special, monster._mdir); - monster._mmode = MonsterMode::SpecialMeleeAttack; + NewMonsterAnim(monster, MonsterGraphic::Special, monster.direction); + monster.mode = MonsterMode::SpecialMeleeAttack; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; @@ -940,13 +940,13 @@ void DiabloDeath(Monster &diablo, bool sendmsg) for (int j = 0; j < ActiveMonsterCount; j++) { int k = ActiveMonsters[j]; auto &monster = Monsters[k]; - if (monster.type().type == MT_DIABLO || diablo._msquelch == 0) + if (monster.type().type == MT_DIABLO || diablo.activeForTicks == 0) continue; - NewMonsterAnim(monster, MonsterGraphic::Death, monster._mdir); - monster._mmode = MonsterMode::Death; + NewMonsterAnim(monster, MonsterGraphic::Death, monster.direction); + monster.mode = MonsterMode::Death; monster.position.offset = { 0, 0 }; - monster._mVar1 = 0; + monster.var1 = 0; monster.position.tile = monster.position.old; monster.position.future = monster.position.tile; M_ClearSquares(monster); @@ -957,9 +957,9 @@ void DiabloDeath(Monster &diablo, bool sendmsg) int dist = diablo.position.tile.WalkingDistance(ViewPosition); if (dist > 20) dist = 20; - diablo._mVar3 = ViewPosition.x << 16; + diablo.var3 = ViewPosition.x << 16; diablo.position.temp.x = ViewPosition.y << 16; - diablo.position.temp.y = (int)((diablo._mVar3 - (diablo.position.tile.x << 16)) / (double)dist); + diablo.position.temp.y = (int)((diablo.var3 - (diablo.position.tile.x << 16)) / (double)dist); diablo.position.offset2.deltaX = (int)((diablo.position.temp.x - (diablo.position.tile.y << 16)) / (double)dist); } @@ -969,14 +969,14 @@ void SpawnLoot(Monster &monster, bool sendmsg) return; } - if (Quests[Q_GARBUD].IsAvailable() && monster._uniqtype - 1 == UMT_GARBUD) { + if (Quests[Q_GARBUD].IsAvailable() && monster.uniqType - 1 == UMT_GARBUD) { CreateTypeItem(monster.position.tile + Displacement { 1, 1 }, true, ItemType::Mace, IMISC_NONE, sendmsg, false); - } else if (monster._uniqtype - 1 == UMT_DEFILER) { + } else if (monster.uniqType - 1 == UMT_DEFILER) { if (effect_is_playing(USFX_DEFILER8)) stream_stop(); Quests[Q_DEFILER]._qlog = false; SpawnMapOfDoom(monster.position.tile, sendmsg); - } else if (monster._uniqtype - 1 == UMT_HORKDMN) { + } else if (monster.uniqType - 1 == UMT_HORKDMN) { if (sgGameInitInfo.bTheoQuest != 0) { SpawnTheodore(monster.position.tile, sendmsg); } else { @@ -1023,7 +1023,7 @@ std::optional GetTeleportTile(const Monster &monster) void Teleport(Monster &monster) { - if (monster._mmode == MonsterMode::Petrified) + if (monster.mode == MonsterMode::Petrified) return; std::optional position = GetTeleportTile(monster); @@ -1034,10 +1034,10 @@ void Teleport(Monster &monster) dMonster[monster.position.tile.x][monster.position.tile.y] = 0; dMonster[position->x][position->y] = monster.getId() + 1; monster.position.old = *position; - monster._mdir = GetMonsterDirection(monster); + monster.direction = GetMonsterDirection(monster); - if (monster.mlid != NO_LIGHT) { - ChangeLightXY(monster.mlid, *position); + if (monster.lightId != NO_LIGHT) { + ChangeLightXY(monster.lightId, *position); } } @@ -1050,16 +1050,16 @@ void HitMonster(int monsterId, int dam) NetSendCmdMonDmg(false, monsterId, dam); PlayEffect(monster, 1); - if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.mLevel + 3) { + if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.level + 3) { if (monster.type().type == MT_BLINK) { Teleport(monster); } else if (IsAnyOf(monster.type().type, MT_NSCAV, MT_BSCAV, MT_WSCAV, MT_YSCAV, MT_GRAVEDIG)) { - monster._mgoal = MGOAL_NORMAL; - monster._mgoalvar1 = 0; - monster._mgoalvar2 = 0; + monster.goalVar1 = MGOAL_NORMAL; + monster.goalVar2 = 0; + monster.goalVar3 = 0; } - if (monster._mmode != MonsterMode::Petrified) { + if (monster.mode != MonsterMode::Petrified) { StartMonsterGotHit(monster); } } @@ -1071,10 +1071,10 @@ void MonsterHitMonster(int monsterId, int i, int dam) auto &monster = Monsters[monsterId]; if (i < MAX_PLRS) - monster.mWhoHit |= 1 << i; + monster.whoHit |= 1 << i; - if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.mLevel + 3) { - monster._mdir = Opposite(Monsters[i]._mdir); + if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.level + 3) { + monster.direction = Opposite(Monsters[i].direction); } HitMonster(monsterId, dam); @@ -1084,14 +1084,14 @@ void MonsterDeath(Monster &monster, int pnum, Direction md, bool sendmsg) { if (pnum < MAX_PLRS) { if (pnum >= 0) - monster.mWhoHit |= 1 << pnum; + monster.whoHit |= 1 << pnum; if (monster.type().type != MT_GOLEM) - AddPlrMonstExper(monster.mLevel, monster.mExp, monster.mWhoHit); + AddPlrMonstExper(monster.level, monster.exp, monster.whoHit); } MonsterKillCounts[monster.type().type]++; - monster._mhitpoints = 0; - SetRndSeed(monster._mRndSeed); + monster.hitPoints = 0; + SetRndSeed(monster.rndItemSeed); SpawnLoot(monster, sendmsg); @@ -1100,14 +1100,14 @@ void MonsterDeath(Monster &monster, int pnum, Direction md, bool sendmsg) else PlayEffect(monster, 2); - if (monster._mmode != MonsterMode::Petrified) { + if (monster.mode != MonsterMode::Petrified) { if (monster.type().type == MT_GOLEM) md = Direction::South; NewMonsterAnim(monster, MonsterGraphic::Death, md, gGameLogicStep < GameLogicStep::ProcessMonsters ? AnimationDistributionFlags::ProcessAnimationPending : AnimationDistributionFlags::None); - monster._mmode = MonsterMode::Death; + monster.mode = MonsterMode::Death; } - monster._mgoal = MGOAL_NONE; - monster._mVar1 = 0; + monster.goal = MGOAL_NONE; + monster.var1 = 0; monster.position.offset = { 0, 0 }; monster.position.tile = monster.position.old; monster.position.future = monster.position.old; @@ -1116,7 +1116,7 @@ void MonsterDeath(Monster &monster, int pnum, Direction md, bool sendmsg) CheckQuestKill(monster, sendmsg); M_FallenFear(monster.position.tile); if (IsAnyOf(monster.type().type, MT_NACID, MT_RACID, MT_BACID, MT_XACID, MT_SPIDLORD)) - AddMissile(monster.position.tile, { 0, 0 }, Direction::South, MIS_ACIDPUD, TARGET_PLAYERS, monster.getId(), monster._mint + 1, 0); + AddMissile(monster.position.tile, { 0, 0 }, Direction::South, MIS_ACIDPUD, TARGET_PLAYERS, monster.getId(), monster.intelligence + 1, 0); } void StartDeathFromMonster(int i, int mid) @@ -1132,43 +1132,43 @@ void StartDeathFromMonster(int i, int mid) Direction md = GetDirection(monster.position.tile, killer.position.tile); MonsterDeath(monster, i, md, true); if (gbIsHellfire) - M_StartStand(killer, killer._mdir); + M_StartStand(killer, killer.direction); } void StartFadein(Monster &monster, Direction md, bool backwards) { NewMonsterAnim(monster, MonsterGraphic::Special, md); - monster._mmode = MonsterMode::FadeIn; + monster.mode = MonsterMode::FadeIn; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; - monster._mFlags &= ~MFLAG_HIDDEN; + monster.flags &= ~MFLAG_HIDDEN; if (backwards) { - monster._mFlags |= MFLAG_LOCK_ANIMATION; - monster.AnimInfo.currentFrame = monster.AnimInfo.numberOfFrames - 1; + monster.flags |= MFLAG_LOCK_ANIMATION; + monster.animInfo.currentFrame = monster.animInfo.numberOfFrames - 1; } } void StartFadeout(Monster &monster, Direction md, bool backwards) { NewMonsterAnim(monster, MonsterGraphic::Special, md); - monster._mmode = MonsterMode::FadeOut; + monster.mode = MonsterMode::FadeOut; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; if (backwards) { - monster._mFlags |= MFLAG_LOCK_ANIMATION; - monster.AnimInfo.currentFrame = monster.AnimInfo.numberOfFrames - 1; + monster.flags |= MFLAG_LOCK_ANIMATION; + monster.animInfo.currentFrame = monster.animInfo.numberOfFrames - 1; } } void StartHeal(Monster &monster) { - monster.ChangeAnimationData(MonsterGraphic::Special); - monster.AnimInfo.currentFrame = monster.type().getAnimData(MonsterGraphic::Special).frames - 1; - monster._mFlags |= MFLAG_LOCK_ANIMATION; - monster._mmode = MonsterMode::Heal; - monster._mVar1 = monster._mmaxhp / (16 * (GenerateRnd(5) + 4)); + monster.changeAnimationData(MonsterGraphic::Special); + monster.animInfo.currentFrame = monster.type().getAnimData(MonsterGraphic::Special).frames - 1; + monster.flags |= MFLAG_LOCK_ANIMATION; + monster.mode = MonsterMode::Heal; + monster.var1 = monster.maxHitPoints / (16 * (GenerateRnd(5) + 4)); } void SyncLightPosition(Monster &monster) @@ -1176,21 +1176,21 @@ void SyncLightPosition(Monster &monster) int lx = (monster.position.offset.deltaX + 2 * monster.position.offset.deltaY) / 8; int ly = (2 * monster.position.offset.deltaY - monster.position.offset.deltaX) / 8; - if (monster.mlid != NO_LIGHT) - ChangeLightOffset(monster.mlid, { lx, ly }); + if (monster.lightId != NO_LIGHT) + ChangeLightOffset(monster.lightId, { lx, ly }); } bool MonsterIdle(Monster &monster) { if (monster.type().type == MT_GOLEM) - monster.ChangeAnimationData(MonsterGraphic::Walk); + monster.changeAnimationData(MonsterGraphic::Walk); else - monster.ChangeAnimationData(MonsterGraphic::Stand); + monster.changeAnimationData(MonsterGraphic::Stand); - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) UpdateEnemy(monster); - monster._mVar2++; + monster.var2++; return false; } @@ -1201,33 +1201,33 @@ bool MonsterIdle(Monster &monster) bool MonsterWalk(Monster &monster, MonsterMode variant) { // Check if we reached new tile - const bool isAnimationEnd = monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1; + const bool isAnimationEnd = monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1; if (isAnimationEnd) { switch (variant) { case MonsterMode::MoveNorthwards: dMonster[monster.position.tile.x][monster.position.tile.y] = 0; - monster.position.tile.x += monster._mVar1; - monster.position.tile.y += monster._mVar2; + monster.position.tile.x += monster.var1; + monster.position.tile.y += monster.var2; dMonster[monster.position.tile.x][monster.position.tile.y] = monster.getId() + 1; break; case MonsterMode::MoveSouthwards: - dMonster[monster._mVar1][monster._mVar2] = 0; + dMonster[monster.var1][monster.var2] = 0; break; case MonsterMode::MoveSideways: dMonster[monster.position.tile.x][monster.position.tile.y] = 0; - monster.position.tile = WorldTilePosition { static_cast(monster._mVar1), static_cast(monster._mVar2) }; + monster.position.tile = WorldTilePosition { static_cast(monster.var1), static_cast(monster.var2) }; // dMonster is set here for backwards comparability, without it the monster would be invisible if loaded from a vanilla save. dMonster[monster.position.tile.x][monster.position.tile.y] = monster.getId() + 1; break; default: break; } - if (monster.mlid != NO_LIGHT) - ChangeLightXY(monster.mlid, monster.position.tile); - M_StartStand(monster, monster._mdir); + if (monster.lightId != NO_LIGHT) + ChangeLightXY(monster.lightId, monster.position.tile); + M_StartStand(monster, monster.direction); } else { // We didn't reach new tile so update monster's "sub-tile" position - if (monster.AnimInfo.tickCounterOfCurrentFrame == 0) { - if (monster.AnimInfo.currentFrame == 0 && monster.type().type == MT_FLESTHNG) + if (monster.animInfo.tickCounterOfCurrentFrame == 0) { + if (monster.animInfo.currentFrame == 0 && monster.type().type == MT_FLESTHNG) PlayEffect(monster, 3); monster.position.offset2 += monster.position.velocity; monster.position.offset.deltaX = monster.position.offset2.deltaX >> 4; @@ -1235,7 +1235,7 @@ bool MonsterWalk(Monster &monster, MonsterMode variant) } } - if (monster.mlid != NO_LIGHT) // BUGFIX: change uniqtype check to mlid check like it is in all other places (fixed) + if (monster.lightId != NO_LIGHT) // BUGFIX: change uniqtype check to lightId check like it is in all other places (fixed) SyncLightPosition(monster); return isAnimationEnd; @@ -1246,28 +1246,28 @@ void MonsterAttackMonster(int i, int mid, int hper, int mind, int maxd) assert(mid >= 0 && mid < MaxMonsters); auto &monster = Monsters[mid]; - if (!monster.IsPossibleToHit()) + if (!monster.isPossibleToHit()) return; int hit = GenerateRnd(100); - if (monster._mmode == MonsterMode::Petrified) + if (monster.mode == MonsterMode::Petrified) hit = 0; - if (monster.TryLiftGargoyle()) + if (monster.tryLiftGargoyle()) return; if (hit >= hper) return; int dam = (mind + GenerateRnd(maxd - mind + 1)) << 6; - monster._mhitpoints -= dam; - if (monster._mhitpoints >> 6 <= 0) { + monster.hitPoints -= dam; + if (monster.hitPoints >> 6 <= 0) { StartDeathFromMonster(i, mid); } else { MonsterHitMonster(mid, i, dam); } Monster &attackingMonster = Monsters[i]; - if (monster._msquelch == 0) { - monster._msquelch = UINT8_MAX; + if (monster.activeForTicks == 0) { + monster.activeForTicks = UINT8_MAX; monster.position.last = attackingMonster.position.tile; } } @@ -1282,9 +1282,9 @@ void CheckReflect(int monsterId, int pnum, int dam) NetSendCmdParam1(true, CMD_SETREFLECT, 0); // reflects 20-30% damage int mdam = dam * (GenerateRnd(10) + 20L) / 100; - monster._mhitpoints -= mdam; + monster.hitPoints -= mdam; dam = std::max(dam - mdam, 0); - if (monster._mhitpoints >> 6 <= 0) + if (monster.hitPoints >> 6 <= 0) M_StartKill(monsterId, pnum); else M_StartHit(monster, pnum, mdam); @@ -1295,7 +1295,7 @@ void MonsterAttackPlayer(int monsterId, int pnum, int hit, int minDam, int maxDa assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if ((monster._mFlags & MFLAG_TARGETS_MONSTER) != 0) { + if ((monster.flags & MFLAG_TARGETS_MONSTER) != 0) { MonsterAttackMonster(monsterId, pnum, hit, minDam, maxDam); return; } @@ -1317,7 +1317,7 @@ void MonsterAttackPlayer(int monsterId, int pnum, int hit, int minDam, int maxDa ac += 40; if (HasAnyOf(player.pDamAcFlags, ItemSpecialEffectHf::ACAgainstUndead) && monster.data().mMonstClass == MonsterClass::Undead) ac += 20; - hit += 2 * (monster.mLevel - player._pLevel) + hit += 2 * (monster.level - player._pLevel) + 30 - ac; int minhit = 15; @@ -1332,7 +1332,7 @@ void MonsterAttackPlayer(int monsterId, int pnum, int hit, int minDam, int maxDa if ((player._pmode == PM_STAND || player._pmode == PM_ATTACK) && player._pBlockFlag) { blkper = GenerateRnd(100); } - int blk = player.GetBlockChance() - (monster.mLevel * 2); + int blk = player.GetBlockChance() - (monster.level * 2); blk = clamp(blk, 0, 100); if (hper >= hit) return; @@ -1369,27 +1369,27 @@ void MonsterAttackPlayer(int monsterId, int pnum, int hit, int minDam, int maxDa } // Reflect can also kill a monster, so make sure the monster is still alive - if (HasAnyOf(player._pIFlags, ItemSpecialEffect::Thorns) && monster._mmode != MonsterMode::Death) { + if (HasAnyOf(player._pIFlags, ItemSpecialEffect::Thorns) && monster.mode != MonsterMode::Death) { int mdam = (GenerateRnd(3) + 1) << 6; - monster._mhitpoints -= mdam; - if (monster._mhitpoints >> 6 <= 0) + monster.hitPoints -= mdam; + if (monster.hitPoints >> 6 <= 0) M_StartKill(monsterId, pnum); else M_StartHit(monster, pnum, mdam); } - if ((monster._mFlags & MFLAG_NOLIFESTEAL) == 0 && monster.type().type == MT_SKING && gbIsMultiplayer) - monster._mhitpoints += dam; + if ((monster.flags & MFLAG_NOLIFESTEAL) == 0 && monster.type().type == MT_SKING && gbIsMultiplayer) + monster.hitPoints += dam; if (player._pHitPoints >> 6 <= 0) { if (gbIsHellfire) - M_StartStand(monster, monster._mdir); + M_StartStand(monster, monster.direction); return; } StartPlrHit(pnum, dam, false); - if ((monster._mFlags & MFLAG_KNOCKBACK) != 0) { + if ((monster.flags & MFLAG_KNOCKBACK) != 0) { if (player._pmode != PM_GOTHIT) StartPlrHit(pnum, 0, true); - Point newPosition = player.position.tile + monster._mdir; + Point newPosition = player.position.tile + monster.direction; if (PosOkPlayer(player, newPosition)) { player.position.tile = newPosition; FixPlayerLocation(player, player._pdir); @@ -1405,23 +1405,23 @@ bool MonsterAttack(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster.AnimInfo.currentFrame == monster.data().mAFNum - 1) { - MonsterAttackPlayer(monsterId, monster._menemy, monster.mHit, monster.mMinDamage, monster.mMaxDamage); - if (monster._mAi != AI_SNAKE) + if (monster.animInfo.currentFrame == monster.data().mAFNum - 1) { + MonsterAttackPlayer(monsterId, monster.enemy, monster.hit, monster.minDamage, monster.maxDamage); + if (monster.ai != AI_SNAKE) PlayEffect(monster, 0); } - if (IsAnyOf(monster.type().type, MT_NMAGMA, MT_YMAGMA, MT_BMAGMA, MT_WMAGMA) && monster.AnimInfo.currentFrame == 8) { - MonsterAttackPlayer(monsterId, monster._menemy, monster.mHit + 10, monster.mMinDamage - 2, monster.mMaxDamage - 2); + if (IsAnyOf(monster.type().type, MT_NMAGMA, MT_YMAGMA, MT_BMAGMA, MT_WMAGMA) && monster.animInfo.currentFrame == 8) { + MonsterAttackPlayer(monsterId, monster.enemy, monster.hit + 10, monster.minDamage - 2, monster.maxDamage - 2); PlayEffect(monster, 0); } - if (IsAnyOf(monster.type().type, MT_STORM, MT_RSTORM, MT_STORML, MT_MAEL) && monster.AnimInfo.currentFrame == 12) { - MonsterAttackPlayer(monsterId, monster._menemy, monster.mHit - 20, monster.mMinDamage + 4, monster.mMaxDamage + 4); + if (IsAnyOf(monster.type().type, MT_STORM, MT_RSTORM, MT_STORML, MT_MAEL) && monster.animInfo.currentFrame == 12) { + MonsterAttackPlayer(monsterId, monster.enemy, monster.hit - 20, monster.minDamage + 4, monster.maxDamage + 4); PlayEffect(monster, 0); } - if (monster._mAi == AI_SNAKE && monster.AnimInfo.currentFrame == 0) + if (monster.ai == AI_SNAKE && monster.animInfo.currentFrame == 0) PlayEffect(monster, 0); - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { - M_StartStand(monster, monster._mdir); + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { + M_StartStand(monster, monster.direction); return true; } @@ -1430,8 +1430,8 @@ bool MonsterAttack(int monsterId) bool MonsterRangedAttack(Monster &monster) { - if (monster.AnimInfo.currentFrame == monster.data().mAFNum - 1) { - const auto &missileType = static_cast(monster._mVar1); + if (monster.animInfo.currentFrame == monster.data().mAFNum - 1) { + const auto &missileType = static_cast(monster.var1); if (missileType != MIS_NULL) { int multimissiles = 1; if (missileType == MIS_CBOLT) @@ -1440,19 +1440,19 @@ bool MonsterRangedAttack(Monster &monster) AddMissile( monster.position.tile, monster.enemyPosition, - monster._mdir, + monster.direction, missileType, TARGET_PLAYERS, monster.getId(), - monster._mVar2, + monster.var2, 0); } } PlayEffect(monster, 0); } - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { - M_StartStand(monster, monster._mdir); + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { + M_StartStand(monster, monster.direction); return true; } @@ -1464,31 +1464,31 @@ bool MonsterRangedSpecialAttack(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster.AnimInfo.currentFrame == monster.data().mAFNum2 - 1 && monster.AnimInfo.tickCounterOfCurrentFrame == 0 && (monster._mAi != AI_MEGA || monster._mVar2 == 0)) { + if (monster.animInfo.currentFrame == monster.data().mAFNum2 - 1 && monster.animInfo.tickCounterOfCurrentFrame == 0 && (monster.ai != AI_MEGA || monster.var2 == 0)) { if (AddMissile( monster.position.tile, monster.enemyPosition, - monster._mdir, - static_cast(monster._mVar1), + monster.direction, + static_cast(monster.var1), TARGET_PLAYERS, monsterId, - monster._mVar3, + monster.var3, 0) != nullptr) { PlayEffect(monster, 3); } } - if (monster._mAi == AI_MEGA && monster.AnimInfo.currentFrame == monster.data().mAFNum2 - 1) { - if (monster._mVar2++ == 0) { - monster._mFlags |= MFLAG_ALLOW_SPECIAL; - } else if (monster._mVar2 == 15) { - monster._mFlags &= ~MFLAG_ALLOW_SPECIAL; + if (monster.ai == AI_MEGA && monster.animInfo.currentFrame == monster.data().mAFNum2 - 1) { + if (monster.var2++ == 0) { + monster.flags |= MFLAG_ALLOW_SPECIAL; + } else if (monster.var2 == 15) { + monster.flags &= ~MFLAG_ALLOW_SPECIAL; } } - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { - M_StartStand(monster, monster._mdir); + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { + M_StartStand(monster, monster.direction); return true; } @@ -1500,11 +1500,11 @@ bool MonsterSpecialAttack(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster.AnimInfo.currentFrame == monster.data().mAFNum2 - 1) - MonsterAttackPlayer(monsterId, monster._menemy, monster.mHit2, monster.mMinDamage2, monster.mMaxDamage2); + if (monster.animInfo.currentFrame == monster.data().mAFNum2 - 1) + MonsterAttackPlayer(monsterId, monster.enemy, monster.hit2, monster.minDamage2, monster.maxDamage2); - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { - M_StartStand(monster, monster._mdir); + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { + M_StartStand(monster, monster.direction); return true; } @@ -1513,49 +1513,49 @@ bool MonsterSpecialAttack(int monsterId) bool MonsterFadein(Monster &monster) { - if (((monster._mFlags & MFLAG_LOCK_ANIMATION) == 0 || monster.AnimInfo.currentFrame != 0) - && ((monster._mFlags & MFLAG_LOCK_ANIMATION) != 0 || monster.AnimInfo.currentFrame != monster.AnimInfo.numberOfFrames - 1)) { + if (((monster.flags & MFLAG_LOCK_ANIMATION) == 0 || monster.animInfo.currentFrame != 0) + && ((monster.flags & MFLAG_LOCK_ANIMATION) != 0 || monster.animInfo.currentFrame != monster.animInfo.numberOfFrames - 1)) { return false; } - M_StartStand(monster, monster._mdir); - monster._mFlags &= ~MFLAG_LOCK_ANIMATION; + M_StartStand(monster, monster.direction); + monster.flags &= ~MFLAG_LOCK_ANIMATION; return true; } bool MonsterFadeout(Monster &monster) { - if (((monster._mFlags & MFLAG_LOCK_ANIMATION) == 0 || monster.AnimInfo.currentFrame != 0) - && ((monster._mFlags & MFLAG_LOCK_ANIMATION) != 0 || monster.AnimInfo.currentFrame != monster.AnimInfo.numberOfFrames - 1)) { + if (((monster.flags & MFLAG_LOCK_ANIMATION) == 0 || monster.animInfo.currentFrame != 0) + && ((monster.flags & MFLAG_LOCK_ANIMATION) != 0 || monster.animInfo.currentFrame != monster.animInfo.numberOfFrames - 1)) { return false; } - monster._mFlags &= ~MFLAG_LOCK_ANIMATION; - monster._mFlags |= MFLAG_HIDDEN; + monster.flags &= ~MFLAG_LOCK_ANIMATION; + monster.flags |= MFLAG_HIDDEN; - M_StartStand(monster, monster._mdir); + M_StartStand(monster, monster.direction); return true; } bool MonsterHeal(Monster &monster) { - if ((monster._mFlags & MFLAG_NOHEAL) != 0) { - monster._mFlags &= ~MFLAG_ALLOW_SPECIAL; - monster._mmode = MonsterMode::SpecialMeleeAttack; + if ((monster.flags & MFLAG_NOHEAL) != 0) { + monster.flags &= ~MFLAG_ALLOW_SPECIAL; + monster.mode = MonsterMode::SpecialMeleeAttack; return false; } - if (monster.AnimInfo.currentFrame == 0) { - monster._mFlags &= ~MFLAG_LOCK_ANIMATION; - monster._mFlags |= MFLAG_ALLOW_SPECIAL; - if (monster._mVar1 + monster._mhitpoints < monster._mmaxhp) { - monster._mhitpoints = monster._mVar1 + monster._mhitpoints; + if (monster.animInfo.currentFrame == 0) { + monster.flags &= ~MFLAG_LOCK_ANIMATION; + monster.flags |= MFLAG_ALLOW_SPECIAL; + if (monster.var1 + monster.hitPoints < monster.maxHitPoints) { + monster.hitPoints = monster.var1 + monster.hitPoints; } else { - monster._mhitpoints = monster._mmaxhp; - monster._mFlags &= ~MFLAG_ALLOW_SPECIAL; - monster._mmode = MonsterMode::SpecialMeleeAttack; + monster.hitPoints = monster.maxHitPoints; + monster.flags &= ~MFLAG_ALLOW_SPECIAL; + monster.mode = MonsterMode::SpecialMeleeAttack; } } return false; @@ -1563,31 +1563,31 @@ bool MonsterHeal(Monster &monster) bool MonsterTalk(Monster &monster) { - M_StartStand(monster, monster._mdir); - monster._mgoal = MGOAL_TALKING; - if (effect_is_playing(Speeches[monster.mtalkmsg].sfxnr)) + M_StartStand(monster, monster.direction); + monster.goal = MGOAL_TALKING; + if (effect_is_playing(Speeches[monster.talkMsg].sfxnr)) return false; - InitQTextMsg(monster.mtalkmsg); - if (monster._uniqtype - 1 == UMT_GARBUD) { - if (monster.mtalkmsg == TEXT_GARBUD1) { + InitQTextMsg(monster.talkMsg); + if (monster.uniqType - 1 == UMT_GARBUD) { + if (monster.talkMsg == TEXT_GARBUD1) { Quests[Q_GARBUD]._qactive = QUEST_ACTIVE; Quests[Q_GARBUD]._qlog = true; // BUGFIX: (?) for other quests qactive and qlog go together, maybe this should actually go into the if above (fixed) } - if (monster.mtalkmsg == TEXT_GARBUD2 && (monster._mFlags & MFLAG_QUEST_COMPLETE) == 0) { + if (monster.talkMsg == TEXT_GARBUD2 && (monster.flags & MFLAG_QUEST_COMPLETE) == 0) { SpawnItem(monster, monster.position.tile + Displacement { 1, 1 }, true); - monster._mFlags |= MFLAG_QUEST_COMPLETE; + monster.flags |= MFLAG_QUEST_COMPLETE; } } - if (monster._uniqtype - 1 == UMT_ZHAR - && monster.mtalkmsg == TEXT_ZHAR1 - && (monster._mFlags & MFLAG_QUEST_COMPLETE) == 0) { + if (monster.uniqType - 1 == UMT_ZHAR + && monster.talkMsg == TEXT_ZHAR1 + && (monster.flags & MFLAG_QUEST_COMPLETE) == 0) { Quests[Q_ZHAR]._qactive = QUEST_ACTIVE; Quests[Q_ZHAR]._qlog = true; CreateTypeItem(monster.position.tile + Displacement { 1, 1 }, false, ItemType::Misc, IMISC_BOOK, true, false); - monster._mFlags |= MFLAG_QUEST_COMPLETE; + monster.flags |= MFLAG_QUEST_COMPLETE; } - if (monster._uniqtype - 1 == UMT_SNOTSPIL) { - if (monster.mtalkmsg == TEXT_BANNER10 && (monster._mFlags & MFLAG_QUEST_COMPLETE) == 0) { + if (monster.uniqType - 1 == UMT_SNOTSPIL) { + if (monster.talkMsg == TEXT_BANNER10 && (monster.flags & MFLAG_QUEST_COMPLETE) == 0) { ObjChangeMap(SetPiece.position.x, SetPiece.position.y, SetPiece.position.x + (SetPiece.size.width / 2) + 2, SetPiece.position.y + (SetPiece.size.height / 2) - 2); auto tren = TransVal; TransVal = 9; @@ -1596,37 +1596,37 @@ bool MonsterTalk(Monster &monster) Quests[Q_LTBANNER]._qvar1 = 2; if (Quests[Q_LTBANNER]._qactive == QUEST_INIT) Quests[Q_LTBANNER]._qactive = QUEST_ACTIVE; - monster._mFlags |= MFLAG_QUEST_COMPLETE; + monster.flags |= MFLAG_QUEST_COMPLETE; } if (Quests[Q_LTBANNER]._qvar1 < 2) { - app_fatal(fmt::format("SS Talk = {}, Flags = {}", monster.mtalkmsg, monster._mFlags)); + app_fatal(fmt::format("SS Talk = {}, Flags = {}", monster.talkMsg, monster.flags)); } } - if (monster._uniqtype - 1 == UMT_LACHDAN) { - if (monster.mtalkmsg == TEXT_VEIL9) { + if (monster.uniqType - 1 == UMT_LACHDAN) { + if (monster.talkMsg == TEXT_VEIL9) { Quests[Q_VEIL]._qactive = QUEST_ACTIVE; Quests[Q_VEIL]._qlog = true; } - if (monster.mtalkmsg == TEXT_VEIL11 && (monster._mFlags & MFLAG_QUEST_COMPLETE) == 0) { + if (monster.talkMsg == TEXT_VEIL11 && (monster.flags & MFLAG_QUEST_COMPLETE) == 0) { SpawnUnique(UITEM_STEELVEIL, monster.position.tile + Direction::South); - monster._mFlags |= MFLAG_QUEST_COMPLETE; + monster.flags |= MFLAG_QUEST_COMPLETE; } } - if (monster._uniqtype - 1 == UMT_WARLORD) + if (monster.uniqType - 1 == UMT_WARLORD) Quests[Q_WARLORD]._qvar1 = 2; - if (monster._uniqtype - 1 == UMT_LAZARUS && gbIsMultiplayer) { + if (monster.uniqType - 1 == UMT_LAZARUS && gbIsMultiplayer) { Quests[Q_BETRAYER]._qvar1 = 6; - monster._mgoal = MGOAL_NORMAL; - monster._msquelch = UINT8_MAX; - monster.mtalkmsg = TEXT_NONE; + monster.goal = MGOAL_NORMAL; + monster.activeForTicks = UINT8_MAX; + monster.talkMsg = TEXT_NONE; } return false; } bool MonsterGotHit(Monster &monster) { - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { - M_StartStand(monster, monster._mdir); + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { + M_StartStand(monster, monster.direction); return true; } @@ -1639,7 +1639,7 @@ bool MonsterDeath(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - monster._mVar1++; + monster.var1++; if (monster.type().type == MT_DIABLO) { if (monster.position.tile.x < ViewPosition.x) { ViewPosition.x--; @@ -1653,16 +1653,16 @@ bool MonsterDeath(int monsterId) ViewPosition.y++; } - if (monster._mVar1 == 140) + if (monster.var1 == 140) PrepDoEnding(); - } else if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { - if (monster._uniqtype == 0) - AddCorpse(monster.position.tile, monster.type().corpseId, monster._mdir); + } else if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { + if (monster.uniqType == 0) + AddCorpse(monster.position.tile, monster.type().corpseId, monster.direction); else - AddCorpse(monster.position.tile, monster._udeadval, monster._mdir); + AddCorpse(monster.position.tile, monster.corpseId, monster.direction); dMonster[monster.position.tile.x][monster.position.tile.y] = 0; - monster._mDelFlag = true; + monster.isInvalid = true; M_UpdateLeader(monsterId); } @@ -1671,11 +1671,11 @@ bool MonsterDeath(int monsterId) bool MonsterSpecialStand(Monster &monster) { - if (monster.AnimInfo.currentFrame == monster.data().mAFNum2 - 1) + if (monster.animInfo.currentFrame == monster.data().mAFNum2 - 1) PlayEffect(monster, 3); - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { - M_StartStand(monster, monster._mdir); + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { + M_StartStand(monster, monster.direction); return true; } @@ -1684,16 +1684,16 @@ bool MonsterSpecialStand(Monster &monster) bool MonsterDelay(Monster &monster) { - monster.ChangeAnimationData(MonsterGraphic::Stand, GetMonsterDirection(monster)); - if (monster._mAi == AI_LAZARUS) { - if (monster._mVar2 > 8 || monster._mVar2 < 0) - monster._mVar2 = 8; + monster.changeAnimationData(MonsterGraphic::Stand, GetMonsterDirection(monster)); + if (monster.ai == AI_LAZARUS) { + if (monster.var2 > 8 || monster.var2 < 0) + monster.var2 = 8; } - if (monster._mVar2-- == 0) { - int oFrame = monster.AnimInfo.currentFrame; - M_StartStand(monster, monster._mdir); - monster.AnimInfo.currentFrame = oFrame; + if (monster.var2-- == 0) { + int oFrame = monster.animInfo.currentFrame; + M_StartStand(monster, monster.direction); + monster.animInfo.currentFrame = oFrame; return true; } @@ -1702,9 +1702,9 @@ bool MonsterDelay(Monster &monster) bool MonsterPetrified(Monster &monster) { - if (monster._mhitpoints <= 0) { + if (monster.hitPoints <= 0) { dMonster[monster.position.tile.x][monster.position.tile.y] = 0; - monster._mDelFlag = true; + monster.isInvalid = true; } return false; @@ -1752,11 +1752,11 @@ void FollowTheLeader(Monster &monster) return; auto &leader = Monsters[monster.leader]; - if (monster._msquelch >= leader._msquelch) + if (monster.activeForTicks >= leader.activeForTicks) return; monster.position.last = leader.position.tile; - monster._msquelch = leader._msquelch - 1; + monster.activeForTicks = leader.activeForTicks - 1; } void GroupUnity(Monster &monster) @@ -1767,29 +1767,29 @@ void GroupUnity(Monster &monster) // Someone with a leaderRelation should have a leader ... assert(monster.leader >= 0); // And no unique monster would be a minion of someone else! - assert(monster._uniqtype == 0); + assert(monster.uniqType == 0); auto &leader = Monsters[monster.leader]; if (IsLineNotSolid(monster.position.tile, leader.position.future)) { if (monster.leaderRelation == LeaderRelation::Separated && monster.position.tile.WalkingDistance(leader.position.future) < 4) { // Reunite the separated monster with the pack - leader.packsize++; + leader.packSize++; monster.leaderRelation = LeaderRelation::Leashed; } } else if (monster.leaderRelation == LeaderRelation::Leashed) { - leader.packsize--; + leader.packSize--; monster.leaderRelation = LeaderRelation::Separated; } if (monster.leaderRelation == LeaderRelation::Leashed) { - if (monster._msquelch > leader._msquelch) { + if (monster.activeForTicks > leader.activeForTicks) { leader.position.last = monster.position.tile; - leader._msquelch = monster._msquelch - 1; + leader.activeForTicks = monster.activeForTicks - 1; } - if (leader._mAi == AI_GARG && (leader._mFlags & MFLAG_ALLOW_SPECIAL) != 0) { - leader._mFlags &= ~MFLAG_ALLOW_SPECIAL; - leader._mmode = MonsterMode::SpecialMeleeAttack; + if (leader.ai == AI_GARG && (leader.flags & MFLAG_ALLOW_SPECIAL) != 0) { + leader.flags &= ~MFLAG_ALLOW_SPECIAL; + leader.mode = MonsterMode::SpecialMeleeAttack; } } } @@ -1845,8 +1845,8 @@ bool IsTileSafe(const Monster &monster, Point position) return true; } - bool fearsFire = (monster.mMagicRes & IMMUNE_FIRE) == 0 || monster.type().type == MT_DIABLO; - bool fearsLightning = (monster.mMagicRes & IMMUNE_LIGHTNING) == 0 || monster.type().type == MT_DIABLO; + bool fearsFire = (monster.magicResistance & IMMUNE_FIRE) == 0 || monster.type().type == MT_DIABLO; + bool fearsLightning = (monster.magicResistance & IMMUNE_LIGHTNING) == 0 || monster.type().type == MT_DIABLO; for (auto &missile : Missiles) { if (missile.position.tile == position) { @@ -1884,7 +1884,7 @@ bool IsTileAccessible(const Monster &monster, Point position) if (dPlayer[position.x][position.y] != 0 || dMonster[position.x][position.y] != 0) return false; - if (!IsTileWalkable(position, (monster._mFlags & MFLAG_CAN_OPEN_DOOR) != 0)) + if (!IsTileWalkable(position, (monster.flags & MFLAG_CAN_OPEN_DOOR) != 0)) return false; return IsTileSafe(monster, position); @@ -1960,11 +1960,11 @@ bool AiPlanPath(int monsterId) auto &monster = Monsters[monsterId]; if (monster.type().type != MT_GOLEM) { - if (monster._msquelch == 0) + if (monster.activeForTicks == 0) return false; - if (monster._mmode != MonsterMode::Stand) + if (monster.mode != MonsterMode::Stand) return false; - if (monster._mgoal != MGOAL_NORMAL && monster._mgoal != MGOAL_MOVE && monster._mgoal != MGOAL_ATTACK2) + if (monster.goal != MGOAL_NORMAL && monster.goal != MGOAL_MOVE && monster.goal != MGOAL_ATTACK2) return false; if (monster.position.tile.x == 1 && monster.position.tile.y == 0) return false; @@ -1974,18 +1974,18 @@ bool AiPlanPath(int monsterId) [&monster](Point position) { return IsTileAvailable(monster, position); }, monster.position.tile, monster.enemyPosition); - if (!clear || (monster._pathcount >= 5 && monster._pathcount < 8)) { - if ((monster._mFlags & MFLAG_CAN_OPEN_DOOR) != 0) + if (!clear || (monster.pathCount >= 5 && monster.pathCount < 8)) { + if ((monster.flags & MFLAG_CAN_OPEN_DOOR) != 0) MonstCheckDoors(monster); - monster._pathcount++; - if (monster._pathcount < 5) + monster.pathCount++; + if (monster.pathCount < 5) return false; if (AiPlanWalk(monsterId)) return true; } if (monster.type().type != MT_GOLEM) - monster._pathcount = 0; + monster.pathCount = 0; return false; } @@ -1995,7 +1995,7 @@ void AiAvoidance(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -2004,44 +2004,44 @@ void AiAvoidance(int monsterId) int mx = monster.position.tile.x - fx; int my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - if (monster._msquelch < UINT8_MAX) + if (monster.activeForTicks < UINT8_MAX) MonstCheckDoors(monster); int v = GenerateRnd(100); - if ((abs(mx) >= 2 || abs(my) >= 2) && monster._msquelch == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { - if (monster._mgoal == MGOAL_MOVE || ((abs(mx) >= 4 || abs(my) >= 4) && GenerateRnd(4) == 0)) { - if (monster._mgoal != MGOAL_MOVE) { - monster._mgoalvar1 = 0; - monster._mgoalvar2 = GenerateRnd(2); + if ((abs(mx) >= 2 || abs(my) >= 2) && monster.activeForTicks == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { + if (monster.goal == MGOAL_MOVE || ((abs(mx) >= 4 || abs(my) >= 4) && GenerateRnd(4) == 0)) { + if (monster.goal != MGOAL_MOVE) { + monster.goalVar1 = 0; + monster.goalVar2 = GenerateRnd(2); } - monster._mgoal = MGOAL_MOVE; + monster.goal = MGOAL_MOVE; int dist = std::max(abs(mx), abs(my)); - if ((monster._mgoalvar1++ >= 2 * dist && DirOK(monsterId, md)) || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { - monster._mgoal = MGOAL_NORMAL; - } else if (!RoundWalk(monsterId, md, &monster._mgoalvar2)) { + if ((monster.goalVar1++ >= 2 * dist && DirOK(monsterId, md)) || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { + monster.goal = MGOAL_NORMAL; + } else if (!RoundWalk(monsterId, md, &monster.goalVar2)) { AiDelay(monster, GenerateRnd(10) + 10); } } } else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } - if (monster._mgoal == MGOAL_NORMAL) { + if (monster.goal == MGOAL_NORMAL) { if (abs(mx) >= 2 || abs(my) >= 2) { - if ((monster._mVar2 > 20 && v < 2 * monster._mint + 28) - || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) - && monster._mVar2 == 0 - && v < 2 * monster._mint + 78)) { + if ((monster.var2 > 20 && v < 2 * monster.intelligence + 28) + || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) + && monster.var2 == 0 + && v < 2 * monster.intelligence + 78)) { RandomWalk(monsterId, md); } - } else if (v < 2 * monster._mint + 23) { - monster._mdir = md; - if (IsAnyOf(monster._mAi, AI_GOATMC, AI_GARBUD) && monster._mhitpoints < (monster._mmaxhp / 2) && GenerateRnd(2) != 0) + } else if (v < 2 * monster.intelligence + 23) { + monster.direction = md; + if (IsAnyOf(monster.ai, AI_GOATMC, AI_GARBUD) && monster.hitPoints < (monster.maxHitPoints / 2) && GenerateRnd(2) != 0) StartSpecialAttack(monster); else StartAttack(monster); } } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } missile_id GetMissileType(_mai_id ai) @@ -2085,40 +2085,40 @@ void AiRanged(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } - if (monster._msquelch == UINT8_MAX || (monster._mFlags & MFLAG_TARGETS_MONSTER) != 0) { + if (monster.activeForTicks == UINT8_MAX || (monster.flags & MFLAG_TARGETS_MONSTER) != 0) { int fx = monster.enemyPosition.x; int fy = monster.enemyPosition.y; int mx = monster.position.tile.x - fx; int my = monster.position.tile.y - fy; Direction md = GetMonsterDirection(monster); - if (monster._msquelch < UINT8_MAX) + if (monster.activeForTicks < UINT8_MAX) MonstCheckDoors(monster); - monster._mdir = md; - if (static_cast(monster._mVar1) == MonsterMode::RangedAttack) { + monster.direction = md; + if (static_cast(monster.var1) == MonsterMode::RangedAttack) { AiDelay(monster, GenerateRnd(20)); } else if (abs(mx) < 4 && abs(my) < 4) { - if (GenerateRnd(100) < 10 * (monster._mint + 7)) + if (GenerateRnd(100) < 10 * (monster.intelligence + 7)) RandomWalk(monsterId, Opposite(md)); } - if (monster._mmode == MonsterMode::Stand) { + if (monster.mode == MonsterMode::Stand) { if (LineClearMissile(monster.position.tile, { fx, fy })) { - missile_id missileType = GetMissileType(monster._mAi); - if (monster._mAi == AI_ACIDUNIQ) + missile_id missileType = GetMissileType(monster.ai); + if (monster.ai == AI_ACIDUNIQ) StartRangedSpecialAttack(monster, missileType, 4); else StartRangedAttack(monster, missileType, 4); } else { - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } } return; } - if (monster._msquelch != 0) { + if (monster.activeForTicks != 0) { int fx = monster.position.last.x; int fy = monster.position.last.y; Direction md = GetDirection(monster.position.tile, { fx, fy }); @@ -2131,7 +2131,7 @@ void AiRangedAvoidance(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -2140,49 +2140,49 @@ void AiRangedAvoidance(int monsterId) int mx = monster.position.tile.x - fx; int my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - if (IsAnyOf(monster._mAi, AI_MAGMA, AI_STORM, AI_BONEDEMON) && monster._msquelch < UINT8_MAX) + if (IsAnyOf(monster.ai, AI_MAGMA, AI_STORM, AI_BONEDEMON) && monster.activeForTicks < UINT8_MAX) MonstCheckDoors(monster); - int lessmissiles = (monster._mAi == AI_ACID) ? 1 : 0; - int dam = (monster._mAi == AI_DIABLO) ? 40 : 4; - missile_id missileType = GetMissileType(monster._mAi); + int lessmissiles = (monster.ai == AI_ACID) ? 1 : 0; + int dam = (monster.ai == AI_DIABLO) ? 40 : 4; + missile_id missileType = GetMissileType(monster.ai); int v = GenerateRnd(10000); int dist = std::max(abs(mx), abs(my)); - if (dist >= 2 && monster._msquelch == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { - if (monster._mgoal == MGOAL_MOVE || (dist >= 3 && GenerateRnd(4 << lessmissiles) == 0)) { - if (monster._mgoal != MGOAL_MOVE) { - monster._mgoalvar1 = 0; - monster._mgoalvar2 = GenerateRnd(2); + if (dist >= 2 && monster.activeForTicks == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { + if (monster.goal == MGOAL_MOVE || (dist >= 3 && GenerateRnd(4 << lessmissiles) == 0)) { + if (monster.goal != MGOAL_MOVE) { + monster.goalVar1 = 0; + monster.goalVar2 = GenerateRnd(2); } - monster._mgoal = MGOAL_MOVE; - if (monster._mgoalvar1++ >= 2 * dist && DirOK(monsterId, md)) { - monster._mgoal = MGOAL_NORMAL; - } else if (v < (500 * (monster._mint + 1) >> lessmissiles) + monster.goal = MGOAL_MOVE; + if (monster.goalVar1++ >= 2 * dist && DirOK(monsterId, md)) { + monster.goal = MGOAL_NORMAL; + } else if (v < (500 * (monster.intelligence + 1) >> lessmissiles) && (LineClearMissile(monster.position.tile, { fx, fy }))) { StartRangedSpecialAttack(monster, missileType, dam); } else { - RoundWalk(monsterId, md, &monster._mgoalvar2); + RoundWalk(monsterId, md, &monster.goalVar2); } } } else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } - if (monster._mgoal == MGOAL_NORMAL) { - if (((dist >= 3 && v < ((500 * (monster._mint + 2)) >> lessmissiles)) - || v < ((500 * (monster._mint + 1)) >> lessmissiles)) + if (monster.goal == MGOAL_NORMAL) { + if (((dist >= 3 && v < ((500 * (monster.intelligence + 2)) >> lessmissiles)) + || v < ((500 * (monster.intelligence + 1)) >> lessmissiles)) && LineClearMissile(monster.position.tile, { fx, fy })) { StartRangedSpecialAttack(monster, missileType, dam); } else if (dist >= 2) { v = GenerateRnd(100); - if (v < 1000 * (monster._mint + 5) - || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) && monster._mVar2 == 0 && v < 1000 * (monster._mint + 8))) { + if (v < 1000 * (monster.intelligence + 5) + || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) && monster.var2 == 0 && v < 1000 * (monster.intelligence + 8))) { RandomWalk(monsterId, md); } - } else if (v < 1000 * (monster._mint + 6)) { - monster._mdir = md; + } else if (v < 1000 * (monster.intelligence + 6)) { + monster.direction = md; StartAttack(monster); } } - if (monster._mmode == MonsterMode::Stand) { + if (monster.mode == MonsterMode::Stand) { AiDelay(monster, GenerateRnd(10) + 5); } } @@ -2192,7 +2192,7 @@ void ZombieAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } @@ -2200,12 +2200,12 @@ void ZombieAi(int monsterId) return; } - if (GenerateRnd(100) < 2 * monster._mint + 10) { + if (GenerateRnd(100) < 2 * monster.intelligence + 10) { int dist = monster.enemyPosition.WalkingDistance(monster.position.tile); if (dist >= 2) { - if (dist >= 2 * monster._mint + 4) { - Direction md = monster._mdir; - if (GenerateRnd(100) < 2 * monster._mint + 20) { + if (dist >= 2 * monster.intelligence + 4) { + Direction md = monster.direction; + if (GenerateRnd(100) < 2 * monster.intelligence + 20) { md = static_cast(GenerateRnd(8)); } DumbWalk(monsterId, md); @@ -2217,7 +2217,7 @@ void ZombieAi(int monsterId) } } - monster.CheckStandAnimationIsLoaded(monster._mdir); + monster.checkStandAnimationIsLoaded(monster.direction); } void OverlordAi(int monsterId) @@ -2225,29 +2225,29 @@ void OverlordAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } int mx = monster.position.tile.x - monster.enemyPosition.x; int my = monster.position.tile.y - monster.enemyPosition.y; Direction md = GetMonsterDirection(monster); - monster._mdir = md; + monster.direction = md; int v = GenerateRnd(100); if (abs(mx) >= 2 || abs(my) >= 2) { - if ((monster._mVar2 > 20 && v < 4 * monster._mint + 20) - || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) - && monster._mVar2 == 0 - && v < 4 * monster._mint + 70)) { + if ((monster.var2 > 20 && v < 4 * monster.intelligence + 20) + || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) + && monster.var2 == 0 + && v < 4 * monster.intelligence + 70)) { RandomWalk(monsterId, md); } - } else if (v < 4 * monster._mint + 15) { + } else if (v < 4 * monster.intelligence + 15) { StartAttack(monster); - } else if (v < 4 * monster._mint + 20) { + } else if (v < 4 * monster.intelligence + 20) { StartSpecialAttack(monster); } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void SkeletonAi(int monsterId) @@ -2255,29 +2255,29 @@ void SkeletonAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } int x = monster.position.tile.x - monster.enemyPosition.x; int y = monster.position.tile.y - monster.enemyPosition.y; Direction md = GetDirection(monster.position.tile, monster.position.last); - monster._mdir = md; + monster.direction = md; if (abs(x) >= 2 || abs(y) >= 2) { - if (static_cast(monster._mVar1) == MonsterMode::Delay || (GenerateRnd(100) >= 35 - 4 * monster._mint)) { + if (static_cast(monster.var1) == MonsterMode::Delay || (GenerateRnd(100) >= 35 - 4 * monster.intelligence)) { RandomWalk(monsterId, md); } else { - AiDelay(monster, 15 - 2 * monster._mint + GenerateRnd(10)); + AiDelay(monster, 15 - 2 * monster.intelligence + GenerateRnd(10)); } } else { - if (static_cast(monster._mVar1) == MonsterMode::Delay || (GenerateRnd(100) < 2 * monster._mint + 20)) { + if (static_cast(monster.var1) == MonsterMode::Delay || (GenerateRnd(100) < 2 * monster.intelligence + 20)) { StartAttack(monster); } else { - AiDelay(monster, 2 * (5 - monster._mint) + GenerateRnd(10)); + AiDelay(monster, 2 * (5 - monster.intelligence) + GenerateRnd(10)); } } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void SkeletonBowAi(int monsterId) @@ -2285,7 +2285,7 @@ void SkeletonBowAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -2293,28 +2293,28 @@ void SkeletonBowAi(int monsterId) int my = monster.position.tile.y - monster.enemyPosition.y; Direction md = GetMonsterDirection(monster); - monster._mdir = md; + monster.direction = md; int v = GenerateRnd(100); bool walking = false; if (abs(mx) < 4 && abs(my) < 4) { - if ((monster._mVar2 > 20 && v < 2 * monster._mint + 13) - || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) - && monster._mVar2 == 0 - && v < 2 * monster._mint + 63)) { + if ((monster.var2 > 20 && v < 2 * monster.intelligence + 13) + || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) + && monster.var2 == 0 + && v < 2 * monster.intelligence + 63)) { walking = DumbWalk(monsterId, Opposite(md)); } } if (!walking) { - if (GenerateRnd(100) < 2 * monster._mint + 3) { + if (GenerateRnd(100) < 2 * monster.intelligence + 3) { if (LineClearMissile(monster.position.tile, monster.enemyPosition)) StartRangedAttack(monster, MIS_ARROW, 4); } } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } std::optional ScavengerFindCorpse(const Monster &scavenger) @@ -2345,59 +2345,59 @@ void ScavengerAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) + if (monster.mode != MonsterMode::Stand) return; - if (monster._mhitpoints < (monster._mmaxhp / 2) && monster._mgoal != MGOAL_HEALING) { + if (monster.hitPoints < (monster.maxHitPoints / 2) && monster.goal != MGOAL_HEALING) { if (monster.leaderRelation != LeaderRelation::None) { if (monster.leaderRelation == LeaderRelation::Leashed) - Monsters[monster.leader].packsize--; + Monsters[monster.leader].packSize--; monster.leaderRelation = LeaderRelation::None; } - monster._mgoal = MGOAL_HEALING; - monster._mgoalvar3 = 10; + monster.goal = MGOAL_HEALING; + monster.goalVar3 = 10; } - if (monster._mgoal == MGOAL_HEALING && monster._mgoalvar3 != 0) { - monster._mgoalvar3--; + if (monster.goal == MGOAL_HEALING && monster.goalVar3 != 0) { + monster.goalVar3--; if (dCorpse[monster.position.tile.x][monster.position.tile.y] != 0) { StartEating(monster); - if ((monster._mFlags & MFLAG_NOHEAL) == 0) { + if ((monster.flags & MFLAG_NOHEAL) == 0) { if (gbIsHellfire) { - int mMaxHP = monster._mmaxhp; // BUGFIX use _mmaxhp or we loose health when difficulty isn't normal (fixed) - monster._mhitpoints += mMaxHP / 8; - if (monster._mhitpoints > monster._mmaxhp) - monster._mhitpoints = monster._mmaxhp; - if (monster._mgoalvar3 <= 0 || monster._mhitpoints == monster._mmaxhp) + int mMaxHP = monster.maxHitPoints; // BUGFIX use maxHitPoints or we loose health when difficulty isn't normal (fixed) + monster.hitPoints += mMaxHP / 8; + if (monster.hitPoints > monster.maxHitPoints) + monster.hitPoints = monster.maxHitPoints; + if (monster.goalVar3 <= 0 || monster.hitPoints == monster.maxHitPoints) dCorpse[monster.position.tile.x][monster.position.tile.y] = 0; } else { - monster._mhitpoints += 64; + monster.hitPoints += 64; } } - int targetHealth = monster._mmaxhp; + int targetHealth = monster.maxHitPoints; if (!gbIsHellfire) - targetHealth = (monster._mmaxhp / 2) + (monster._mmaxhp / 4); - if (monster._mhitpoints >= targetHealth) { - monster._mgoal = MGOAL_NORMAL; - monster._mgoalvar1 = 0; - monster._mgoalvar2 = 0; + targetHealth = (monster.maxHitPoints / 2) + (monster.maxHitPoints / 4); + if (monster.hitPoints >= targetHealth) { + monster.goal = MGOAL_NORMAL; + monster.goalVar1 = 0; + monster.goalVar2 = 0; } } else { - if (monster._mgoalvar1 == 0) { + if (monster.goalVar1 == 0) { std::optional position = ScavengerFindCorpse(monster); if (position) { - monster._mgoalvar1 = position->x + 1; - monster._mgoalvar2 = position->y + 1; + monster.goalVar1 = position->x + 1; + monster.goalVar2 = position->y + 1; } } - if (monster._mgoalvar1 != 0) { - int x = monster._mgoalvar1 - 1; - int y = monster._mgoalvar2 - 1; - monster._mdir = GetDirection(monster.position.tile, { x, y }); - RandomWalk(monsterId, monster._mdir); + if (monster.goalVar1 != 0) { + int x = monster.goalVar1 - 1; + int y = monster.goalVar2 - 1; + monster.direction = GetDirection(monster.position.tile, { x, y }); + RandomWalk(monsterId, monster.direction); } } } - if (monster._mmode == MonsterMode::Stand) + if (monster.mode == MonsterMode::Stand) SkeletonAi(monsterId); } @@ -2406,7 +2406,7 @@ void RhinoAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -2415,55 +2415,55 @@ void RhinoAi(int monsterId) int mx = monster.position.tile.x - fx; int my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - if (monster._msquelch < UINT8_MAX) + if (monster.activeForTicks < UINT8_MAX) MonstCheckDoors(monster); int v = GenerateRnd(100); int dist = std::max(abs(mx), abs(my)); if (dist >= 2) { - if (monster._mgoal == MGOAL_MOVE || (dist >= 5 && GenerateRnd(4) != 0)) { - if (monster._mgoal != MGOAL_MOVE) { - monster._mgoalvar1 = 0; - monster._mgoalvar2 = GenerateRnd(2); + if (monster.goal == MGOAL_MOVE || (dist >= 5 && GenerateRnd(4) != 0)) { + if (monster.goal != MGOAL_MOVE) { + monster.goalVar1 = 0; + monster.goalVar2 = GenerateRnd(2); } - monster._mgoal = MGOAL_MOVE; - if (monster._mgoalvar1++ >= 2 * dist || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { - monster._mgoal = MGOAL_NORMAL; - } else if (!RoundWalk(monsterId, md, &monster._mgoalvar2)) { + monster.goal = MGOAL_MOVE; + if (monster.goalVar1++ >= 2 * dist || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { + monster.goal = MGOAL_NORMAL; + } else if (!RoundWalk(monsterId, md, &monster.goalVar2)) { AiDelay(monster, GenerateRnd(10) + 10); } } } else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } - if (monster._mgoal == MGOAL_NORMAL) { + if (monster.goal == MGOAL_NORMAL) { if (dist >= 5 - && v < 2 * monster._mint + 43 + && v < 2 * monster.intelligence + 43 && LineClear([&monster](Point position) { return IsTileAvailable(monster, position); }, monster.position.tile, { fx, fy })) { if (AddMissile(monster.position.tile, { fx, fy }, md, MIS_RHINO, TARGET_PLAYERS, monsterId, 0, 0) != nullptr) { if (monster.data().snd_special) PlayEffect(monster, 3); dMonster[monster.position.tile.x][monster.position.tile.y] = -(monsterId + 1); - monster._mmode = MonsterMode::Charge; + monster.mode = MonsterMode::Charge; } } else { if (dist >= 2) { v = GenerateRnd(100); - if (v >= 2 * monster._mint + 33 - && (IsNoneOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) - || monster._mVar2 != 0 - || v >= 2 * monster._mint + 83)) { + if (v >= 2 * monster.intelligence + 33 + && (IsNoneOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) + || monster.var2 != 0 + || v >= 2 * monster.intelligence + 83)) { AiDelay(monster, GenerateRnd(10) + 10); } else { RandomWalk(monsterId, md); } - } else if (v < 2 * monster._mint + 28) { - monster._mdir = md; + } else if (v < 2 * monster.intelligence + 28) { + monster.direction = md; StartAttack(monster); } } } - monster.CheckStandAnimationIsLoaded(monster._mdir); + monster.checkStandAnimationIsLoaded(monster.direction); } void FallenAi(int monsterId) @@ -2471,35 +2471,35 @@ void FallenAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mgoal == MGOAL_ATTACK2) { - if (monster._mgoalvar1 != 0) - monster._mgoalvar1--; + if (monster.goal == MGOAL_ATTACK2) { + if (monster.goalVar1 != 0) + monster.goalVar1--; else - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } - if (monster._mgoal == MGOAL_RETREAT) { - if (monster._mgoalvar1-- == 0) { - monster._mgoal = MGOAL_NORMAL; - M_StartStand(monster, Opposite(static_cast(monster._mgoalvar2))); + if (monster.goal == MGOAL_RETREAT) { + if (monster.goalVar1-- == 0) { + monster.goal = MGOAL_NORMAL; + M_StartStand(monster, Opposite(static_cast(monster.goalVar2))); } } - if (monster.AnimInfo.currentFrame == monster.AnimInfo.numberOfFrames - 1) { + if (monster.animInfo.currentFrame == monster.animInfo.numberOfFrames - 1) { if (GenerateRnd(4) != 0) { return; } - if ((monster._mFlags & MFLAG_NOHEAL) == 0) { - StartSpecialStand(monster, monster._mdir); - if (monster._mmaxhp - (2 * monster._mint + 2) >= monster._mhitpoints) - monster._mhitpoints += 2 * monster._mint + 2; + if ((monster.flags & MFLAG_NOHEAL) == 0) { + StartSpecialStand(monster, monster.direction); + if (monster.maxHitPoints - (2 * monster.intelligence + 2) >= monster.hitPoints) + monster.hitPoints += 2 * monster.intelligence + 2; else - monster._mhitpoints = monster._mmaxhp; + monster.hitPoints = monster.maxHitPoints; } - int rad = 2 * monster._mint + 4; + int rad = 2 * monster.intelligence + 4; for (int y = -rad; y <= rad; y++) { for (int x = -rad; x <= rad; x++) { int xpos = monster.position.tile.x + x; @@ -2511,18 +2511,18 @@ void FallenAi(int monsterId) continue; auto &otherMonster = Monsters[m - 1]; - if (otherMonster._mAi != AI_FALLEN) + if (otherMonster.ai != AI_FALLEN) continue; - otherMonster._mgoal = MGOAL_ATTACK2; - otherMonster._mgoalvar1 = 30 * monster._mint + 105; + otherMonster.goal = MGOAL_ATTACK2; + otherMonster.goalVar1 = 30 * monster.intelligence + 105; } } } - } else if (monster._mgoal == MGOAL_RETREAT) { - monster._mdir = static_cast(monster._mgoalvar2); - RandomWalk(monsterId, monster._mdir); - } else if (monster._mgoal == MGOAL_ATTACK2) { + } else if (monster.goal == MGOAL_RETREAT) { + monster.direction = static_cast(monster.goalVar2); + RandomWalk(monsterId, monster.direction); + } else if (monster.goal == MGOAL_ATTACK2) { int xpos = monster.position.tile.x - monster.enemyPosition.x; int ypos = monster.position.tile.y - monster.enemyPosition.y; if (abs(xpos) < 2 && abs(ypos) < 2) @@ -2538,7 +2538,7 @@ void LeoricAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -2547,29 +2547,29 @@ void LeoricAi(int monsterId) int mx = monster.position.tile.x - fx; int my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - if (monster._msquelch < UINT8_MAX) + if (monster.activeForTicks < UINT8_MAX) MonstCheckDoors(monster); int v = GenerateRnd(100); int dist = std::max(abs(mx), abs(my)); - if (dist >= 2 && monster._msquelch == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { - if (monster._mgoal == MGOAL_MOVE || ((abs(mx) >= 3 || abs(my) >= 3) && GenerateRnd(4) == 0)) { - if (monster._mgoal != MGOAL_MOVE) { - monster._mgoalvar1 = 0; - monster._mgoalvar2 = GenerateRnd(2); + if (dist >= 2 && monster.activeForTicks == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { + if (monster.goal == MGOAL_MOVE || ((abs(mx) >= 3 || abs(my) >= 3) && GenerateRnd(4) == 0)) { + if (monster.goal != MGOAL_MOVE) { + monster.goalVar1 = 0; + monster.goalVar2 = GenerateRnd(2); } - monster._mgoal = MGOAL_MOVE; - if ((monster._mgoalvar1++ >= 2 * dist && DirOK(monsterId, md)) || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { - monster._mgoal = MGOAL_NORMAL; - } else if (!RoundWalk(monsterId, md, &monster._mgoalvar2)) { + monster.goal = MGOAL_MOVE; + if ((monster.goalVar1++ >= 2 * dist && DirOK(monsterId, md)) || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { + monster.goal = MGOAL_NORMAL; + } else if (!RoundWalk(monsterId, md, &monster.goalVar2)) { AiDelay(monster, GenerateRnd(10) + 10); } } } else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } - if (monster._mgoal == MGOAL_NORMAL) { + if (monster.goal == MGOAL_NORMAL) { if (!gbIsMultiplayer - && ((dist >= 3 && v < 4 * monster._mint + 35) || v < 6) + && ((dist >= 3 && v < 4 * monster.intelligence + 35) || v < 6) && LineClearMissile(monster.position.tile, { fx, fy })) { Point newPosition = monster.position.tile + md; if (IsTileAvailable(monster, newPosition) && ActiveMonsterCount < MaxMonsters) { @@ -2579,20 +2579,20 @@ void LeoricAi(int monsterId) } else { if (dist >= 2) { v = GenerateRnd(100); - if (v >= monster._mint + 25 - && (IsNoneOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) || monster._mVar2 != 0 || (v >= monster._mint + 75))) { + if (v >= monster.intelligence + 25 + && (IsNoneOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) || monster.var2 != 0 || (v >= monster.intelligence + 75))) { AiDelay(monster, GenerateRnd(10) + 10); } else { RandomWalk(monsterId, md); } - } else if (v < monster._mint + 20) { - monster._mdir = md; + } else if (v < monster.intelligence + 20) { + monster.direction = md; StartAttack(monster); } } } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void BatAi(int monsterId) @@ -2600,25 +2600,25 @@ void BatAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } int xd = monster.position.tile.x - monster.enemyPosition.x; int yd = monster.position.tile.y - monster.enemyPosition.y; Direction md = GetDirection(monster.position.tile, monster.position.last); - monster._mdir = md; + monster.direction = md; int v = GenerateRnd(100); - if (monster._mgoal == MGOAL_RETREAT) { - if (monster._mgoalvar1 == 0) { + if (monster.goal == MGOAL_RETREAT) { + if (monster.goalVar1 == 0) { RandomWalk(monsterId, Opposite(md)); - monster._mgoalvar1++; + monster.goalVar1++; } else { if (GenerateRnd(2) != 0) RandomWalk(monsterId, Left(md)); else RandomWalk(monsterId, Right(md)); - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } return; } @@ -2627,29 +2627,29 @@ void BatAi(int monsterId) int fy = monster.enemyPosition.y; if (monster.type().type == MT_GLOOM && (abs(xd) >= 5 || abs(yd) >= 5) - && v < 4 * monster._mint + 33 + && v < 4 * monster.intelligence + 33 && LineClear([&monster](Point position) { return IsTileAvailable(monster, position); }, monster.position.tile, { fx, fy })) { if (AddMissile(monster.position.tile, { fx, fy }, md, MIS_RHINO, TARGET_PLAYERS, monsterId, 0, 0) != nullptr) { dMonster[monster.position.tile.x][monster.position.tile.y] = -(monsterId + 1); - monster._mmode = MonsterMode::Charge; + monster.mode = MonsterMode::Charge; } } else if (abs(xd) >= 2 || abs(yd) >= 2) { - if ((monster._mVar2 > 20 && v < monster._mint + 13) - || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) - && monster._mVar2 == 0 - && v < monster._mint + 63)) { + if ((monster.var2 > 20 && v < monster.intelligence + 13) + || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) + && monster.var2 == 0 + && v < monster.intelligence + 63)) { RandomWalk(monsterId, md); } - } else if (v < 4 * monster._mint + 8) { + } else if (v < 4 * monster.intelligence + 8) { StartAttack(monster); - monster._mgoal = MGOAL_RETREAT; - monster._mgoalvar1 = 0; + monster.goalVar1 = MGOAL_RETREAT; + monster.goalVar2 = 0; if (monster.type().type == MT_FAMILIAR) { AddMissile(monster.enemyPosition, { monster.enemyPosition.x + 1, 0 }, Direction::South, MIS_LIGHTNING, TARGET_PLAYERS, monsterId, GenerateRnd(10) + 1, 0); } } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void GargoyleAi(int monsterId) @@ -2660,29 +2660,29 @@ void GargoyleAi(int monsterId) int dx = monster.position.tile.x - monster.position.last.x; int dy = monster.position.tile.y - monster.position.last.y; Direction md = GetMonsterDirection(monster); - if (monster._msquelch != 0 && (monster._mFlags & MFLAG_ALLOW_SPECIAL) != 0) { + if (monster.activeForTicks != 0 && (monster.flags & MFLAG_ALLOW_SPECIAL) != 0) { UpdateEnemy(monster); int mx = monster.position.tile.x - monster.enemyPosition.x; int my = monster.position.tile.y - monster.enemyPosition.y; - if (abs(mx) < monster._mint + 2 && abs(my) < monster._mint + 2) { - monster._mFlags &= ~MFLAG_ALLOW_SPECIAL; + if (abs(mx) < monster.intelligence + 2 && abs(my) < monster.intelligence + 2) { + monster.flags &= ~MFLAG_ALLOW_SPECIAL; } return; } - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } - if (monster._mhitpoints < (monster._mmaxhp / 2)) - if ((monster._mFlags & MFLAG_NOHEAL) == 0) - monster._mgoal = MGOAL_RETREAT; - if (monster._mgoal == MGOAL_RETREAT) { - if (abs(dx) >= monster._mint + 2 || abs(dy) >= monster._mint + 2) { - monster._mgoal = MGOAL_NORMAL; + if (monster.hitPoints < (monster.maxHitPoints / 2)) + if ((monster.flags & MFLAG_NOHEAL) == 0) + monster.goal = MGOAL_RETREAT; + if (monster.goal == MGOAL_RETREAT) { + if (abs(dx) >= monster.intelligence + 2 || abs(dy) >= monster.intelligence + 2) { + monster.goal = MGOAL_NORMAL; StartHeal(monster); } else if (!RandomWalk(monsterId, Opposite(md))) { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } } AiAvoidance(monsterId); @@ -2693,7 +2693,7 @@ void ButcherAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -2703,14 +2703,14 @@ void ButcherAi(int monsterId) int y = my - monster.enemyPosition.y; Direction md = GetDirection({ mx, my }, monster.position.last); - monster._mdir = md; + monster.direction = md; if (abs(x) >= 2 || abs(y) >= 2) RandomWalk(monsterId, md); else StartAttack(monster); - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void SneakAi(int monsterId) @@ -2718,7 +2718,7 @@ void SneakAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } int mx = monster.position.tile.x; @@ -2729,20 +2729,20 @@ void SneakAi(int monsterId) mx -= monster.enemyPosition.x; my -= monster.enemyPosition.y; - int dist = 5 - monster._mint; - if (static_cast(monster._mVar1) == MonsterMode::HitRecovery) { - monster._mgoal = MGOAL_RETREAT; - monster._mgoalvar1 = 0; - } else if (abs(mx) >= dist + 3 || abs(my) >= dist + 3 || monster._mgoalvar1 > 8) { - monster._mgoal = MGOAL_NORMAL; - monster._mgoalvar1 = 0; + int dist = 5 - monster.intelligence; + if (static_cast(monster.var1) == MonsterMode::HitRecovery) { + monster.goal = MGOAL_RETREAT; + monster.goalVar1 = 0; + } else if (abs(mx) >= dist + 3 || abs(my) >= dist + 3 || monster.goalVar1 > 8) { + monster.goal = MGOAL_NORMAL; + monster.goalVar1 = 0; } Direction md = GetMonsterDirection(monster); - if (monster._mgoal == MGOAL_RETREAT && (monster._mFlags & MFLAG_NO_ENEMY) == 0) { - if ((monster._mFlags & MFLAG_TARGETS_MONSTER) != 0) - md = GetDirection(monster.position.tile, Monsters[monster._menemy].position.tile); + if (monster.goal == MGOAL_RETREAT && (monster.flags & MFLAG_NO_ENEMY) == 0) { + if ((monster.flags & MFLAG_TARGETS_MONSTER) != 0) + md = GetDirection(monster.position.tile, Monsters[monster.enemy].position.tile); else - md = GetDirection(monster.position.tile, Players[monster._menemy].position.last); + md = GetDirection(monster.position.tile, Players[monster.enemy].position.last); md = Opposite(md); if (monster.type().type == MT_UNSEEN) { if (GenerateRnd(2) != 0) @@ -2751,24 +2751,24 @@ void SneakAi(int monsterId) md = Right(md); } } - monster._mdir = md; + monster.direction = md; int v = GenerateRnd(100); - if (abs(mx) < dist && abs(my) < dist && (monster._mFlags & MFLAG_HIDDEN) != 0) { + if (abs(mx) < dist && abs(my) < dist && (monster.flags & MFLAG_HIDDEN) != 0) { StartFadein(monster, md, false); } else { - if ((abs(mx) >= dist + 1 || abs(my) >= dist + 1) && (monster._mFlags & MFLAG_HIDDEN) == 0) { + if ((abs(mx) >= dist + 1 || abs(my) >= dist + 1) && (monster.flags & MFLAG_HIDDEN) == 0) { StartFadeout(monster, md, true); } else { - if (monster._mgoal == MGOAL_RETREAT - || ((abs(mx) >= 2 || abs(my) >= 2) && ((monster._mVar2 > 20 && v < 4 * monster._mint + 14) || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) && monster._mVar2 == 0 && v < 4 * monster._mint + 64)))) { - monster._mgoalvar1++; + if (monster.goal == MGOAL_RETREAT + || ((abs(mx) >= 2 || abs(my) >= 2) && ((monster.var2 > 20 && v < 4 * monster.intelligence + 14) || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) && monster.var2 == 0 && v < 4 * monster.intelligence + 64)))) { + monster.goalVar1++; RandomWalk(monsterId, md); } } } - if (monster._mmode == MonsterMode::Stand) { - if (abs(mx) >= 2 || abs(my) >= 2 || v >= 4 * monster._mint + 10) - monster.ChangeAnimationData(MonsterGraphic::Stand); + if (monster.mode == MonsterMode::Stand) { + if (abs(mx) >= 2 || abs(my) >= 2 || v >= 4 * monster.intelligence + 10) + monster.changeAnimationData(MonsterGraphic::Stand); else StartAttack(monster); } @@ -2779,26 +2779,26 @@ void GharbadAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } Direction md = GetMonsterDirection(monster); - if (monster.mtalkmsg >= TEXT_GARBUD1 - && monster.mtalkmsg <= TEXT_GARBUD3 + if (monster.talkMsg >= TEXT_GARBUD1 + && monster.talkMsg <= TEXT_GARBUD3 && !IsTileVisible(monster.position.tile) - && monster._mgoal == MGOAL_TALKING) { - monster._mgoal = MGOAL_INQUIRING; - switch (monster.mtalkmsg) { + && monster.goal == MGOAL_TALKING) { + monster.goal = MGOAL_INQUIRING; + switch (monster.talkMsg) { case TEXT_GARBUD1: - monster.mtalkmsg = TEXT_GARBUD2; + monster.talkMsg = TEXT_GARBUD2; break; case TEXT_GARBUD2: - monster.mtalkmsg = TEXT_GARBUD3; + monster.talkMsg = TEXT_GARBUD3; break; case TEXT_GARBUD3: - monster.mtalkmsg = TEXT_GARBUD4; + monster.talkMsg = TEXT_GARBUD4; break; default: break; @@ -2806,19 +2806,19 @@ void GharbadAi(int monsterId) } if (IsTileVisible(monster.position.tile)) { - if (monster.mtalkmsg == TEXT_GARBUD4) { - if (!effect_is_playing(USFX_GARBUD4) && monster._mgoal == MGOAL_TALKING) { - monster._mgoal = MGOAL_NORMAL; - monster._msquelch = UINT8_MAX; - monster.mtalkmsg = TEXT_NONE; + if (monster.talkMsg == TEXT_GARBUD4) { + if (!effect_is_playing(USFX_GARBUD4) && monster.goal == MGOAL_TALKING) { + monster.goal = MGOAL_NORMAL; + monster.activeForTicks = UINT8_MAX; + monster.talkMsg = TEXT_NONE; } } } - if (monster._mgoal == MGOAL_NORMAL || monster._mgoal == MGOAL_MOVE) + if (monster.goal == MGOAL_NORMAL || monster.goal == MGOAL_MOVE) AiAvoidance(monsterId); - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void SnotSpilAi(int monsterId) @@ -2826,40 +2826,40 @@ void SnotSpilAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } Direction md = GetMonsterDirection(monster); - if (monster.mtalkmsg == TEXT_BANNER10 && !IsTileVisible(monster.position.tile) && monster._mgoal == MGOAL_TALKING) { - monster.mtalkmsg = TEXT_BANNER11; - monster._mgoal = MGOAL_INQUIRING; + if (monster.talkMsg == TEXT_BANNER10 && !IsTileVisible(monster.position.tile) && monster.goal == MGOAL_TALKING) { + monster.talkMsg = TEXT_BANNER11; + monster.goal = MGOAL_INQUIRING; } - if (monster.mtalkmsg == TEXT_BANNER11 && Quests[Q_LTBANNER]._qvar1 == 3) { - monster.mtalkmsg = TEXT_NONE; - monster._mgoal = MGOAL_NORMAL; + if (monster.talkMsg == TEXT_BANNER11 && Quests[Q_LTBANNER]._qvar1 == 3) { + monster.talkMsg = TEXT_NONE; + monster.goal = MGOAL_NORMAL; } if (IsTileVisible(monster.position.tile)) { - if (monster.mtalkmsg == TEXT_BANNER12) { - if (!effect_is_playing(USFX_SNOT3) && monster._mgoal == MGOAL_TALKING) { + if (monster.talkMsg == TEXT_BANNER12) { + if (!effect_is_playing(USFX_SNOT3) && monster.goal == MGOAL_TALKING) { ObjChangeMap(SetPiece.position.x, SetPiece.position.y, SetPiece.position.x + SetPiece.size.width + 1, SetPiece.position.y + SetPiece.size.height + 1); Quests[Q_LTBANNER]._qvar1 = 3; RedoPlayerVision(); - monster._msquelch = UINT8_MAX; - monster.mtalkmsg = TEXT_NONE; - monster._mgoal = MGOAL_NORMAL; + monster.activeForTicks = UINT8_MAX; + monster.talkMsg = TEXT_NONE; + monster.goal = MGOAL_NORMAL; } } if (Quests[Q_LTBANNER]._qvar1 == 3) { - if (monster._mgoal == MGOAL_NORMAL || monster._mgoal == MGOAL_ATTACK2) + if (monster.goal == MGOAL_NORMAL || monster.goal == MGOAL_ATTACK2) FallenAi(monsterId); } } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void SnakeAi(int monsterId) @@ -2868,34 +2868,34 @@ void SnakeAi(int monsterId) auto &monster = Monsters[monsterId]; char pattern[6] = { 1, 1, 0, -1, -1, 0 }; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) return; int fx = monster.enemyPosition.x; int fy = monster.enemyPosition.y; int mx = monster.position.tile.x - fx; int my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - monster._mdir = md; + monster.direction = md; if (abs(mx) >= 2 || abs(my) >= 2) { - if (abs(mx) < 3 && abs(my) < 3 && LineClear([&monster](Point position) { return IsTileAvailable(monster, position); }, monster.position.tile, { fx, fy }) && static_cast(monster._mVar1) != MonsterMode::Charge) { + if (abs(mx) < 3 && abs(my) < 3 && LineClear([&monster](Point position) { return IsTileAvailable(monster, position); }, monster.position.tile, { fx, fy }) && static_cast(monster.var1) != MonsterMode::Charge) { if (AddMissile(monster.position.tile, { fx, fy }, md, MIS_RHINO, TARGET_PLAYERS, monsterId, 0, 0) != nullptr) { PlayEffect(monster, 0); dMonster[monster.position.tile.x][monster.position.tile.y] = -(monsterId + 1); - monster._mmode = MonsterMode::Charge; + monster.mode = MonsterMode::Charge; } - } else if (static_cast(monster._mVar1) == MonsterMode::Delay || GenerateRnd(100) >= 35 - 2 * monster._mint) { - if (pattern[monster._mgoalvar1] == -1) + } else if (static_cast(monster.var1) == MonsterMode::Delay || GenerateRnd(100) >= 35 - 2 * monster.intelligence) { + if (pattern[monster.goalVar1] == -1) md = Left(md); - else if (pattern[monster._mgoalvar1] == 1) + else if (pattern[monster.goalVar1] == 1) md = Right(md); - monster._mgoalvar1++; - if (monster._mgoalvar1 > 5) - monster._mgoalvar1 = 0; + monster.goalVar1++; + if (monster.goalVar1 > 5) + monster.goalVar1 = 0; - Direction targetDirection = static_cast(monster._mgoalvar2); + Direction targetDirection = static_cast(monster.goalVar2); if (md != targetDirection) { - int drift = static_cast(md) - monster._mgoalvar2; + int drift = static_cast(md) - monster.goalVar2; if (drift < 0) drift += 8; @@ -2903,23 +2903,23 @@ void SnakeAi(int monsterId) md = Right(targetDirection); else if (drift > 4) md = Left(targetDirection); - monster._mgoalvar2 = static_cast(md); + monster.goalVar2 = static_cast(md); } if (!DumbWalk(monsterId, md)) - RandomWalk2(monsterId, monster._mdir); + RandomWalk2(monsterId, monster.direction); } else { - AiDelay(monster, 15 - monster._mint + GenerateRnd(10)); + AiDelay(monster, 15 - monster.intelligence + GenerateRnd(10)); } } else { - if (IsAnyOf(static_cast(monster._mVar1), MonsterMode::Delay, MonsterMode::Charge) - || (GenerateRnd(100) < monster._mint + 20)) { + if (IsAnyOf(static_cast(monster.var1), MonsterMode::Delay, MonsterMode::Charge) + || (GenerateRnd(100) < monster.intelligence + 20)) { StartAttack(monster); } else - AiDelay(monster, 10 - monster._mint + GenerateRnd(10)); + AiDelay(monster, 10 - monster.intelligence + GenerateRnd(10)); } - monster.CheckStandAnimationIsLoaded(monster._mdir); + monster.checkStandAnimationIsLoaded(monster.direction); } void CounselorAi(int monsterId) @@ -2927,7 +2927,7 @@ void CounselorAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } int fx = monster.enemyPosition.x; @@ -2935,56 +2935,56 @@ void CounselorAi(int monsterId) int mx = monster.position.tile.x - fx; int my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - if (monster._msquelch < UINT8_MAX) + if (monster.activeForTicks < UINT8_MAX) MonstCheckDoors(monster); int v = GenerateRnd(100); - if (monster._mgoal == MGOAL_RETREAT) { - if (monster._mgoalvar1++ <= 3) + if (monster.goal == MGOAL_RETREAT) { + if (monster.goalVar1++ <= 3) RandomWalk(monsterId, Opposite(md)); else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; StartFadein(monster, md, true); } - } else if (monster._mgoal == MGOAL_MOVE) { + } else if (monster.goal == MGOAL_MOVE) { int dist = std::max(abs(mx), abs(my)); - if (dist >= 2 && monster._msquelch == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { - if (monster._mgoalvar1++ < 2 * dist || !DirOK(monsterId, md)) { - RoundWalk(monsterId, md, &monster._mgoalvar2); + if (dist >= 2 && monster.activeForTicks == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { + if (monster.goalVar1++ < 2 * dist || !DirOK(monsterId, md)) { + RoundWalk(monsterId, md, &monster.goalVar2); } else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; StartFadein(monster, md, true); } } else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; StartFadein(monster, md, true); } - } else if (monster._mgoal == MGOAL_NORMAL) { + } else if (monster.goal == MGOAL_NORMAL) { if (abs(mx) >= 2 || abs(my) >= 2) { - if (v < 5 * (monster._mint + 10) && LineClearMissile(monster.position.tile, { fx, fy })) { + if (v < 5 * (monster.intelligence + 10) && LineClearMissile(monster.position.tile, { fx, fy })) { constexpr missile_id MissileTypes[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS_FIREBALL }; - StartRangedAttack(monster, MissileTypes[monster._mint], monster.mMinDamage + GenerateRnd(monster.mMaxDamage - monster.mMinDamage + 1)); + StartRangedAttack(monster, MissileTypes[monster.intelligence], monster.minDamage + GenerateRnd(monster.maxDamage - monster.minDamage + 1)); } else if (GenerateRnd(100) < 30) { - monster._mgoal = MGOAL_MOVE; - monster._mgoalvar1 = 0; + monster.goal = MGOAL_MOVE; + monster.goalVar1 = 0; StartFadeout(monster, md, false); } else - AiDelay(monster, GenerateRnd(10) + 2 * (5 - monster._mint)); + AiDelay(monster, GenerateRnd(10) + 2 * (5 - monster.intelligence)); } else { - monster._mdir = md; - if (monster._mhitpoints < (monster._mmaxhp / 2)) { - monster._mgoal = MGOAL_RETREAT; - monster._mgoalvar1 = 0; + monster.direction = md; + if (monster.hitPoints < (monster.maxHitPoints / 2)) { + monster.goal = MGOAL_RETREAT; + monster.goalVar1 = 0; StartFadeout(monster, md, false); - } else if (static_cast(monster._mVar1) == MonsterMode::Delay - || GenerateRnd(100) < 2 * monster._mint + 20) { + } else if (static_cast(monster.var1) == MonsterMode::Delay + || GenerateRnd(100) < 2 * monster.intelligence + 20) { StartRangedAttack(monster, MIS_NULL, 0); - AddMissile(monster.position.tile, { 0, 0 }, monster._mdir, MIS_FLASH, TARGET_PLAYERS, monsterId, 4, 0); - AddMissile(monster.position.tile, { 0, 0 }, monster._mdir, MIS_FLASH2, TARGET_PLAYERS, monsterId, 4, 0); + AddMissile(monster.position.tile, { 0, 0 }, monster.direction, MIS_FLASH, TARGET_PLAYERS, monsterId, 4, 0); + AddMissile(monster.position.tile, { 0, 0 }, monster.direction, MIS_FLASH2, TARGET_PLAYERS, monsterId, 4, 0); } else - AiDelay(monster, GenerateRnd(10) + 2 * (5 - monster._mint)); + AiDelay(monster, GenerateRnd(10) + 2 * (5 - monster.intelligence)); } } - if (monster._mmode == MonsterMode::Stand) { + if (monster.mode == MonsterMode::Stand) { AiDelay(monster, GenerateRnd(10) + 5); } } @@ -2994,30 +2994,30 @@ void ZharAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } Direction md = GetMonsterDirection(monster); - if (monster.mtalkmsg == TEXT_ZHAR1 && !IsTileVisible(monster.position.tile) && monster._mgoal == MGOAL_TALKING) { - monster.mtalkmsg = TEXT_ZHAR2; - monster._mgoal = MGOAL_INQUIRING; + if (monster.talkMsg == TEXT_ZHAR1 && !IsTileVisible(monster.position.tile) && monster.goal == MGOAL_TALKING) { + monster.talkMsg = TEXT_ZHAR2; + monster.goal = MGOAL_INQUIRING; } if (IsTileVisible(monster.position.tile)) { - if (monster.mtalkmsg == TEXT_ZHAR2) { - if (!effect_is_playing(USFX_ZHAR2) && monster._mgoal == MGOAL_TALKING) { - monster._msquelch = UINT8_MAX; - monster.mtalkmsg = TEXT_NONE; - monster._mgoal = MGOAL_NORMAL; + if (monster.talkMsg == TEXT_ZHAR2) { + if (!effect_is_playing(USFX_ZHAR2) && monster.goal == MGOAL_TALKING) { + monster.activeForTicks = UINT8_MAX; + monster.talkMsg = TEXT_NONE; + monster.goal = MGOAL_NORMAL; } } } - if (monster._mgoal == MGOAL_NORMAL || monster._mgoal == MGOAL_RETREAT || monster._mgoal == MGOAL_MOVE) + if (monster.goal == MGOAL_NORMAL || monster.goal == MGOAL_RETREAT || monster.goal == MGOAL_MOVE) CounselorAi(monsterId); - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void MegaAi(int monsterId) @@ -3032,7 +3032,7 @@ void MegaAi(int monsterId) return; } - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -3041,50 +3041,50 @@ void MegaAi(int monsterId) mx = monster.position.tile.x - fx; my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - if (monster._msquelch < UINT8_MAX) + if (monster.activeForTicks < UINT8_MAX) MonstCheckDoors(monster); int v = GenerateRnd(100); int dist = std::max(abs(mx), abs(my)); - if (dist >= 2 && monster._msquelch == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { - if (monster._mgoal == MGOAL_MOVE || dist >= 3) { - if (monster._mgoal != MGOAL_MOVE) { - monster._mgoalvar1 = 0; - monster._mgoalvar2 = GenerateRnd(2); + if (dist >= 2 && monster.activeForTicks == UINT8_MAX && dTransVal[monster.position.tile.x][monster.position.tile.y] == dTransVal[fx][fy]) { + if (monster.goal == MGOAL_MOVE || dist >= 3) { + if (monster.goal != MGOAL_MOVE) { + monster.goalVar1 = 0; + monster.goalVar2 = GenerateRnd(2); } - monster._mgoal = MGOAL_MOVE; - monster._mgoalvar3 = 4; - if (monster._mgoalvar1++ < 2 * dist || !DirOK(monsterId, md)) { - if (v < 5 * (monster._mint + 16)) - RoundWalk(monsterId, md, &monster._mgoalvar2); + monster.goal = MGOAL_MOVE; + monster.goalVar3 = 4; + if (monster.goalVar1++ < 2 * dist || !DirOK(monsterId, md)) { + if (v < 5 * (monster.intelligence + 16)) + RoundWalk(monsterId, md, &monster.goalVar2); } else - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } } else { - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } - if (monster._mgoal == MGOAL_NORMAL) { - if (((dist >= 3 && v < 5 * (monster._mint + 2)) || v < 5 * (monster._mint + 1) || monster._mgoalvar3 == 4) && LineClearMissile(monster.position.tile, { fx, fy })) { + if (monster.goal == MGOAL_NORMAL) { + if (((dist >= 3 && v < 5 * (monster.intelligence + 2)) || v < 5 * (monster.intelligence + 1) || monster.goalVar3 == 4) && LineClearMissile(monster.position.tile, { fx, fy })) { StartRangedSpecialAttack(monster, MIS_FLAMEC, 0); } else if (dist >= 2) { v = GenerateRnd(100); - if (v < 2 * (5 * monster._mint + 25) - || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) - && monster._mVar2 == 0 - && v < 2 * (5 * monster._mint + 40))) { + if (v < 2 * (5 * monster.intelligence + 25) + || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) + && monster.var2 == 0 + && v < 2 * (5 * monster.intelligence + 40))) { RandomWalk(monsterId, md); } } else { - if (GenerateRnd(100) < 10 * (monster._mint + 4)) { - monster._mdir = md; + if (GenerateRnd(100) < 10 * (monster.intelligence + 4)) { + monster.direction = md; if (GenerateRnd(2) != 0) StartAttack(monster); else StartRangedSpecialAttack(monster, MIS_FLAMEC, 0); } } - monster._mgoalvar3 = 1; + monster.goalVar3 = 1; } - if (monster._mmode == MonsterMode::Stand) { + if (monster.mode == MonsterMode::Stand) { AiDelay(monster, GenerateRnd(10) + 5); } } @@ -3094,7 +3094,7 @@ void LazarusAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } @@ -3102,38 +3102,38 @@ void LazarusAi(int monsterId) if (IsTileVisible(monster.position.tile)) { if (!gbIsMultiplayer) { Player &myPlayer = *MyPlayer; - if (monster.mtalkmsg == TEXT_VILE13 && monster._mgoal == MGOAL_INQUIRING && myPlayer.position.tile == Point { 35, 46 }) { + if (monster.talkMsg == TEXT_VILE13 && monster.goal == MGOAL_INQUIRING && myPlayer.position.tile == Point { 35, 46 }) { PlayInGameMovie("gendata\\fprst3.smk"); - monster._mmode = MonsterMode::Talk; + monster.mode = MonsterMode::Talk; Quests[Q_BETRAYER]._qvar1 = 5; } - if (monster.mtalkmsg == TEXT_VILE13 && !effect_is_playing(USFX_LAZ1) && monster._mgoal == MGOAL_TALKING) { + if (monster.talkMsg == TEXT_VILE13 && !effect_is_playing(USFX_LAZ1) && monster.goal == MGOAL_TALKING) { ObjChangeMap(1, 18, 20, 24); RedoPlayerVision(); Quests[Q_BETRAYER]._qvar1 = 6; - monster._mgoal = MGOAL_NORMAL; - monster._msquelch = UINT8_MAX; - monster.mtalkmsg = TEXT_NONE; + monster.goal = MGOAL_NORMAL; + monster.activeForTicks = UINT8_MAX; + monster.talkMsg = TEXT_NONE; } } - if (gbIsMultiplayer && monster.mtalkmsg == TEXT_VILE13 && monster._mgoal == MGOAL_INQUIRING && Quests[Q_BETRAYER]._qvar1 <= 3) { - monster._mmode = MonsterMode::Talk; + if (gbIsMultiplayer && monster.talkMsg == TEXT_VILE13 && monster.goal == MGOAL_INQUIRING && Quests[Q_BETRAYER]._qvar1 <= 3) { + monster.mode = MonsterMode::Talk; } } - if (monster._mgoal == MGOAL_NORMAL || monster._mgoal == MGOAL_RETREAT || monster._mgoal == MGOAL_MOVE) { - if (!gbIsMultiplayer && Quests[Q_BETRAYER]._qvar1 == 4 && monster.mtalkmsg == TEXT_NONE) { // Fix save games affected by teleport bug + if (monster.goal == MGOAL_NORMAL || monster.goal == MGOAL_RETREAT || monster.goal == MGOAL_MOVE) { + if (!gbIsMultiplayer && Quests[Q_BETRAYER]._qvar1 == 4 && monster.talkMsg == TEXT_NONE) { // Fix save games affected by teleport bug ObjChangeMapResync(1, 18, 20, 24); RedoPlayerVision(); Quests[Q_BETRAYER]._qvar1 = 6; } - monster.mtalkmsg = TEXT_NONE; + monster.talkMsg = TEXT_NONE; CounselorAi(monsterId); } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void LazarusMinionAi(int monsterId) @@ -3141,7 +3141,7 @@ void LazarusMinionAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) + if (monster.mode != MonsterMode::Stand) return; Direction md = GetMonsterDirection(monster); @@ -3149,18 +3149,18 @@ void LazarusMinionAi(int monsterId) if (IsTileVisible(monster.position.tile)) { if (!gbIsMultiplayer) { if (Quests[Q_BETRAYER]._qvar1 <= 5) { - monster._mgoal = MGOAL_INQUIRING; + monster.goal = MGOAL_INQUIRING; } else { - monster._mgoal = MGOAL_NORMAL; - monster.mtalkmsg = TEXT_NONE; + monster.goal = MGOAL_NORMAL; + monster.talkMsg = TEXT_NONE; } } else - monster._mgoal = MGOAL_NORMAL; + monster.goal = MGOAL_NORMAL; } - if (monster._mgoal == MGOAL_NORMAL) + if (monster.goal == MGOAL_NORMAL) AiRanged(monsterId); - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void LachdananAi(int monsterId) @@ -3168,28 +3168,28 @@ void LachdananAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } Direction md = GetMonsterDirection(monster); - if (monster.mtalkmsg == TEXT_VEIL9 && !IsTileVisible(monster.position.tile) && monster._mgoal == MGOAL_TALKING) { - monster.mtalkmsg = TEXT_VEIL10; - monster._mgoal = MGOAL_INQUIRING; + if (monster.talkMsg == TEXT_VEIL9 && !IsTileVisible(monster.position.tile) && monster.goal == MGOAL_TALKING) { + monster.talkMsg = TEXT_VEIL10; + monster.goal = MGOAL_INQUIRING; } if (IsTileVisible(monster.position.tile)) { - if (monster.mtalkmsg == TEXT_VEIL11) { - if (!effect_is_playing(USFX_LACH3) && monster._mgoal == MGOAL_TALKING) { - monster.mtalkmsg = TEXT_NONE; + if (monster.talkMsg == TEXT_VEIL11) { + if (!effect_is_playing(USFX_LACH3) && monster.goal == MGOAL_TALKING) { + monster.talkMsg = TEXT_NONE; Quests[Q_VEIL]._qactive = QUEST_DONE; StartMonsterDeath(monster, -1, true); } } } - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void WarlordAi(int monsterId) @@ -3197,25 +3197,25 @@ void WarlordAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand) { + if (monster.mode != MonsterMode::Stand) { return; } Direction md = GetMonsterDirection(monster); if (IsTileVisible(monster.position.tile)) { - if (monster.mtalkmsg == TEXT_WARLRD9 && monster._mgoal == MGOAL_INQUIRING) - monster._mmode = MonsterMode::Talk; - if (monster.mtalkmsg == TEXT_WARLRD9 && !effect_is_playing(USFX_WARLRD1) && monster._mgoal == MGOAL_TALKING) { - monster._msquelch = UINT8_MAX; - monster.mtalkmsg = TEXT_NONE; - monster._mgoal = MGOAL_NORMAL; + if (monster.talkMsg == TEXT_WARLRD9 && monster.goal == MGOAL_INQUIRING) + monster.mode = MonsterMode::Talk; + if (monster.talkMsg == TEXT_WARLRD9 && !effect_is_playing(USFX_WARLRD1) && monster.goal == MGOAL_TALKING) { + monster.activeForTicks = UINT8_MAX; + monster.talkMsg = TEXT_NONE; + monster.goal = MGOAL_NORMAL; } } - if (monster._mgoal == MGOAL_NORMAL) + if (monster.goal == MGOAL_NORMAL) SkeletonAi(monsterId); - monster.CheckStandAnimationIsLoaded(md); + monster.checkStandAnimationIsLoaded(md); } void HorkDemonAi(int monsterId) @@ -3223,7 +3223,7 @@ void HorkDemonAi(int monsterId) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mmode != MonsterMode::Stand || monster._msquelch == 0) { + if (monster.mode != MonsterMode::Stand || monster.activeForTicks == 0) { return; } @@ -3233,43 +3233,43 @@ void HorkDemonAi(int monsterId) int my = monster.position.tile.y - fy; Direction md = GetDirection(monster.position.tile, monster.position.last); - if (monster._msquelch < 255) { + if (monster.activeForTicks < 255) { MonstCheckDoors(monster); } int v = GenerateRnd(100); if (abs(mx) < 2 && abs(my) < 2) { - monster._mgoal = MGOAL_NORMAL; - } else if (monster._mgoal == 4 || ((abs(mx) >= 5 || abs(my) >= 5) && GenerateRnd(4) != 0)) { - if (monster._mgoal != 4) { - monster._mgoalvar1 = 0; - monster._mgoalvar2 = GenerateRnd(2); + monster.goal = MGOAL_NORMAL; + } else if (monster.goal == 4 || ((abs(mx) >= 5 || abs(my) >= 5) && GenerateRnd(4) != 0)) { + if (monster.goal != 4) { + monster.goalVar1 = 0; + monster.goalVar2 = GenerateRnd(2); } - monster._mgoal = MGOAL_MOVE; + monster.goal = MGOAL_MOVE; int dist = std::max(abs(mx), abs(my)); - if (monster._mgoalvar1++ >= 2 * dist || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { - monster._mgoal = MGOAL_NORMAL; - } else if (!RoundWalk(monsterId, md, &monster._mgoalvar2)) { + if (monster.goalVar1++ >= 2 * dist || dTransVal[monster.position.tile.x][monster.position.tile.y] != dTransVal[fx][fy]) { + monster.goal = MGOAL_NORMAL; + } else if (!RoundWalk(monsterId, md, &monster.goalVar2)) { AiDelay(monster, GenerateRnd(10) + 10); } } - if (monster._mgoal == 1) { - if ((abs(mx) >= 3 || abs(my) >= 3) && v < 2 * monster._mint + 43) { - Point position = monster.position.tile + monster._mdir; + if (monster.goal == 1) { + if ((abs(mx) >= 3 || abs(my) >= 3) && v < 2 * monster.intelligence + 43) { + Point position = monster.position.tile + monster.direction; if (IsTileAvailable(monster, position) && ActiveMonsterCount < MaxMonsters) { StartRangedSpecialAttack(monster, MIS_HORKDMN, 0); } } else if (abs(mx) < 2 && abs(my) < 2) { - if (v < 2 * monster._mint + 28) { - monster._mdir = md; + if (v < 2 * monster.intelligence + 28) { + monster.direction = md; StartAttack(monster); } } else { v = GenerateRnd(100); - if (v < 2 * monster._mint + 33 - || (IsAnyOf(static_cast(monster._mVar1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) && monster._mVar2 == 0 && v < 2 * monster._mint + 83)) { + if (v < 2 * monster.intelligence + 33 + || (IsAnyOf(static_cast(monster.var1), MonsterMode::MoveNorthwards, MonsterMode::MoveSouthwards, MonsterMode::MoveSideways) && monster.var2 == 0 && v < 2 * monster.intelligence + 83)) { RandomWalk(monsterId, md); } else { AiDelay(monster, GenerateRnd(10) + 10); @@ -3277,7 +3277,7 @@ void HorkDemonAi(int monsterId) } } - monster.CheckStandAnimationIsLoaded(monster._mdir); + monster.checkStandAnimationIsLoaded(monster.direction); } string_view GetMonsterTypeText(const MonsterData &monsterData) @@ -3383,103 +3383,103 @@ bool IsMonsterAvalible(const MonsterData &monsterData) void InitTRNForUniqueMonster(Monster &monster) { char filestr[64]; - *fmt::format_to(filestr, FMT_COMPILE(R"(Monsters\Monsters\{}.TRN)"), UniqueMonstersData[monster._uniqtype - 1].mTrnName) = '\0'; - monster.uniqueTRN = LoadFileInMem(filestr); + *fmt::format_to(filestr, FMT_COMPILE(R"(Monsters\Monsters\{}.TRN)"), UniqueMonstersData[monster.uniqType - 1].mTrnName) = '\0'; + monster.uniqueMonsterTRN = LoadFileInMem(filestr); } void PrepareUniqueMonst(Monster &monster, int uniqindex, int miniontype, int bosspacksize, const UniqueMonsterData &uniqueMonsterData) { - monster._uniqtype = uniqindex + 1; + monster.uniqType = uniqindex + 1; if (uniqueMonsterData.mlevel != 0) { - monster.mLevel = 2 * uniqueMonsterData.mlevel; + monster.level = 2 * uniqueMonsterData.mlevel; } else { - monster.mLevel = monster.data().mLevel + 5; + monster.level = monster.data().mLevel + 5; } - monster.mExp *= 2; - monster.mName = pgettext("monster", uniqueMonsterData.mName).data(); - monster._mmaxhp = uniqueMonsterData.mmaxhp << 6; + monster.exp *= 2; + monster.name = pgettext("monster", uniqueMonsterData.mName).data(); + monster.maxHitPoints = uniqueMonsterData.mmaxhp << 6; if (!gbIsMultiplayer) - monster._mmaxhp = std::max(monster._mmaxhp / 2, 64); - - monster._mhitpoints = monster._mmaxhp; - monster._mAi = uniqueMonsterData.mAi; - monster._mint = uniqueMonsterData.mint; - monster.mMinDamage = uniqueMonsterData.mMinDamage; - monster.mMaxDamage = uniqueMonsterData.mMaxDamage; - monster.mMinDamage2 = uniqueMonsterData.mMinDamage; - monster.mMaxDamage2 = uniqueMonsterData.mMaxDamage; - monster.mMagicRes = uniqueMonsterData.mMagicRes; - monster.mtalkmsg = uniqueMonsterData.mtalkmsg; + monster.maxHitPoints = std::max(monster.maxHitPoints / 2, 64); + + monster.hitPoints = monster.maxHitPoints; + monster.ai = uniqueMonsterData.mAi; + monster.intelligence = uniqueMonsterData.mint; + monster.minDamage = uniqueMonsterData.mMinDamage; + monster.maxDamage = uniqueMonsterData.mMaxDamage; + monster.minDamage2 = uniqueMonsterData.mMinDamage; + monster.maxDamage2 = uniqueMonsterData.mMaxDamage; + monster.magicResistance = uniqueMonsterData.mMagicRes; + monster.talkMsg = uniqueMonsterData.mtalkmsg; if (uniqindex == UMT_HORKDMN) - monster.mlid = NO_LIGHT; // BUGFIX monsters initial light id should be -1 (fixed) + monster.lightId = NO_LIGHT; // BUGFIX monsters initial light id should be -1 (fixed) else - monster.mlid = AddLight(monster.position.tile, 3); + monster.lightId = AddLight(monster.position.tile, 3); if (gbIsMultiplayer) { - if (monster._mAi == AI_LAZHELP) - monster.mtalkmsg = TEXT_NONE; - if (monster._mAi == AI_LAZARUS && Quests[Q_BETRAYER]._qvar1 > 3) { - monster._mgoal = MGOAL_NORMAL; - } else if (monster.mtalkmsg != TEXT_NONE) { - monster._mgoal = MGOAL_INQUIRING; + if (monster.ai == AI_LAZHELP) + monster.talkMsg = TEXT_NONE; + if (monster.ai == AI_LAZARUS && Quests[Q_BETRAYER]._qvar1 > 3) { + monster.goal = MGOAL_NORMAL; + } else if (monster.talkMsg != TEXT_NONE) { + monster.goal = MGOAL_INQUIRING; } - } else if (monster.mtalkmsg != TEXT_NONE) { - monster._mgoal = MGOAL_INQUIRING; + } else if (monster.talkMsg != TEXT_NONE) { + monster.goal = MGOAL_INQUIRING; } if (sgGameInitInfo.nDifficulty == DIFF_NIGHTMARE) { - monster._mmaxhp = 3 * monster._mmaxhp; + monster.maxHitPoints = 3 * monster.maxHitPoints; if (gbIsHellfire) - monster._mmaxhp += (gbIsMultiplayer ? 100 : 50) << 6; + monster.maxHitPoints += (gbIsMultiplayer ? 100 : 50) << 6; else - monster._mmaxhp += 64; - monster.mLevel += 15; - monster._mhitpoints = monster._mmaxhp; - monster.mExp = 2 * (monster.mExp + 1000); - monster.mMinDamage = 2 * (monster.mMinDamage + 2); - monster.mMaxDamage = 2 * (monster.mMaxDamage + 2); - monster.mMinDamage2 = 2 * (monster.mMinDamage2 + 2); - monster.mMaxDamage2 = 2 * (monster.mMaxDamage2 + 2); + monster.maxHitPoints += 64; + monster.level += 15; + monster.hitPoints = monster.maxHitPoints; + monster.exp = 2 * (monster.exp + 1000); + monster.minDamage = 2 * (monster.minDamage + 2); + monster.maxDamage = 2 * (monster.maxDamage + 2); + monster.minDamage2 = 2 * (monster.minDamage2 + 2); + monster.maxDamage2 = 2 * (monster.maxDamage2 + 2); } else if (sgGameInitInfo.nDifficulty == DIFF_HELL) { - monster._mmaxhp = 4 * monster._mmaxhp; + monster.maxHitPoints = 4 * monster.maxHitPoints; if (gbIsHellfire) - monster._mmaxhp += (gbIsMultiplayer ? 200 : 100) << 6; + monster.maxHitPoints += (gbIsMultiplayer ? 200 : 100) << 6; else - monster._mmaxhp += 192; - monster.mLevel += 30; - monster._mhitpoints = monster._mmaxhp; - monster.mExp = 4 * (monster.mExp + 1000); - monster.mMinDamage = 4 * monster.mMinDamage + 6; - monster.mMaxDamage = 4 * monster.mMaxDamage + 6; - monster.mMinDamage2 = 4 * monster.mMinDamage2 + 6; - monster.mMaxDamage2 = 4 * monster.mMaxDamage2 + 6; + monster.maxHitPoints += 192; + monster.level += 30; + monster.hitPoints = monster.maxHitPoints; + monster.exp = 4 * (monster.exp + 1000); + monster.minDamage = 4 * monster.minDamage + 6; + monster.maxDamage = 4 * monster.maxDamage + 6; + monster.minDamage2 = 4 * monster.minDamage2 + 6; + monster.maxDamage2 = 4 * monster.maxDamage2 + 6; } InitTRNForUniqueMonster(monster); - monster._uniqtrans = uniquetrans++; + monster.uniqTrans = uniquetrans++; if (uniqueMonsterData.customToHit != 0) { - monster.mHit = uniqueMonsterData.customToHit; - monster.mHit2 = uniqueMonsterData.customToHit; + monster.hit = uniqueMonsterData.customToHit; + monster.hit2 = uniqueMonsterData.customToHit; if (sgGameInitInfo.nDifficulty == DIFF_NIGHTMARE) { - monster.mHit += NightmareToHitBonus; - monster.mHit2 += NightmareToHitBonus; + monster.hit += NightmareToHitBonus; + monster.hit2 += NightmareToHitBonus; } else if (sgGameInitInfo.nDifficulty == DIFF_HELL) { - monster.mHit += HellToHitBonus; - monster.mHit2 += HellToHitBonus; + monster.hit += HellToHitBonus; + monster.hit2 += HellToHitBonus; } } if (uniqueMonsterData.customArmorClass != 0) { - monster.mArmorClass = uniqueMonsterData.customArmorClass; + monster.armorClass = uniqueMonsterData.customArmorClass; if (sgGameInitInfo.nDifficulty == DIFF_NIGHTMARE) { - monster.mArmorClass += NightmareAcBonus; + monster.armorClass += NightmareAcBonus; } else if (sgGameInitInfo.nDifficulty == DIFF_HELL) { - monster.mArmorClass += HellAcBonus; + monster.armorClass += HellAcBonus; } } @@ -3489,11 +3489,11 @@ void PrepareUniqueMonst(Monster &monster, int uniqindex, int miniontype, int bos PlaceGroup(miniontype, bosspacksize, uniqueMonsterData.monsterPack, ActiveMonsterCount - 1); } - if (monster._mAi != AI_GARG) { - monster.ChangeAnimationData(MonsterGraphic::Stand); - monster.AnimInfo.currentFrame = GenerateRnd(monster.AnimInfo.numberOfFrames - 1); - monster._mFlags &= ~MFLAG_ALLOW_SPECIAL; - monster._mmode = MonsterMode::Stand; + if (monster.ai != AI_GARG) { + monster.changeAnimationData(MonsterGraphic::Stand); + monster.animInfo.currentFrame = GenerateRnd(monster.animInfo.numberOfFrames - 1); + monster.flags &= ~MFLAG_ALLOW_SPECIAL; + monster.mode = MonsterMode::Stand; } } @@ -3701,11 +3701,11 @@ void WeakenNaKrul() auto &monster = Monsters[UberDiabloMonsterIndex]; PlayEffect(monster, 2); Quests[Q_NAKRUL]._qlog = false; - monster.mArmorClass -= 50; - int hp = monster._mmaxhp / 2; - monster.mMagicRes = 0; - monster._mhitpoints = hp; - monster._mmaxhp = hp; + monster.armorClass -= 50; + int hp = monster.maxHitPoints / 2; + monster.magicResistance = 0; + monster.hitPoints = hp; + monster.maxHitPoints = hp; } void InitGolems() @@ -3838,7 +3838,7 @@ void AddDoppelganger(Monster &monster) if (target != Point { 0, 0 }) { for (int j = 0; j < MaxLvlMTypes; j++) { if (LevelMonsterTypes[j].type == monster.type().type) { - AddMonster(target, monster._mdir, j, true); + AddMonster(target, monster.direction, j, true); break; } } @@ -3847,7 +3847,7 @@ void AddDoppelganger(Monster &monster) bool M_Talker(const Monster &monster) { - return IsAnyOf(monster._mAi, AI_LAZARUS, AI_WARLORD, AI_GARBUD, AI_ZHAR, AI_SNOTSPIL, AI_LACHDAN, AI_LAZHELP); + return IsAnyOf(monster.ai, AI_LAZARUS, AI_WARLORD, AI_GARBUD, AI_ZHAR, AI_SNOTSPIL, AI_LACHDAN, AI_LAZHELP); } void M_StartStand(Monster &monster, Direction md) @@ -3857,9 +3857,9 @@ void M_StartStand(Monster &monster, Direction md) NewMonsterAnim(monster, MonsterGraphic::Walk, md); else NewMonsterAnim(monster, MonsterGraphic::Stand, md); - monster._mVar1 = static_cast(monster._mmode); - monster._mVar2 = 0; - monster._mmode = MonsterMode::Stand; + monster.var1 = static_cast(monster.mode); + monster.var2 = 0; + monster.mode = MonsterMode::Stand; monster.position.offset = { 0, 0 }; monster.position.future = monster.position.tile; monster.position.old = monster.position.tile; @@ -3876,7 +3876,7 @@ void M_ClearSquares(const Monster &monster) void M_GetKnockback(Monster &monster) { - Direction dir = Opposite(monster._mdir); + Direction dir = Opposite(monster.direction); if (!IsRelativeMoveOK(monster, monster.position.old, dir)) { return; } @@ -3890,16 +3890,16 @@ void M_StartHit(Monster &monster, int dam) { PlayEffect(monster, 1); - if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.mLevel + 3) { + if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.level + 3) { if (monster.type().type == MT_BLINK) { Teleport(monster); } else if (IsAnyOf(monster.type().type, MT_NSCAV, MT_BSCAV, MT_WSCAV, MT_YSCAV) || monster.type().type == MT_GRAVEDIG) { - monster._mgoal = MGOAL_NORMAL; - monster._mgoalvar1 = 0; - monster._mgoalvar2 = 0; + monster.goalVar1 = MGOAL_NORMAL; + monster.goalVar2 = 0; + monster.goalVar3 = 0; } - if (monster._mmode != MonsterMode::Petrified) { + if (monster.mode != MonsterMode::Petrified) { StartMonsterGotHit(monster); } } @@ -3907,16 +3907,16 @@ void M_StartHit(Monster &monster, int dam) void M_StartHit(Monster &monster, int pnum, int dam) { - monster.mWhoHit |= 1 << pnum; + monster.whoHit |= 1 << pnum; if (pnum == MyPlayerId) { delta_monster_hp(monster, *MyPlayer); NetSendCmdMonDmg(false, monster.getId(), dam); } - if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.mLevel + 3) { - monster._menemy = pnum; + if (IsAnyOf(monster.type().type, MT_SNEAK, MT_STALKER, MT_UNSEEN, MT_ILLWEAV) || dam >> 6 >= monster.level + 3) { + monster.enemy = pnum; monster.enemyPosition = Players[pnum].position.future; - monster._mFlags &= ~MFLAG_TARGETS_MONSTER; - monster._mdir = GetMonsterDirection(monster); + monster.flags &= ~MFLAG_TARGETS_MONSTER; + monster.direction = GetMonsterDirection(monster); } M_StartHit(monster, dam); @@ -3924,7 +3924,7 @@ void M_StartHit(Monster &monster, int pnum, int dam) void StartMonsterDeath(Monster &monster, int pnum, bool sendmsg) { - Direction md = pnum >= 0 ? GetDirection(monster.position.tile, Players[pnum].position.tile) : monster._mdir; + Direction md = pnum >= 0 ? GetDirection(monster.position.tile, Players[pnum].position.tile) : monster.direction; MonsterDeath(monster, pnum, md, sendmsg); } @@ -3950,7 +3950,7 @@ void M_SyncStartKill(int monsterId, Point position, int pnum) assert(monsterId >= 0 && monsterId < MaxMonsters); auto &monster = Monsters[monsterId]; - if (monster._mhitpoints == 0 || monster._mmode == MonsterMode::Death) { + if (monster.hitPoints == 0 || monster.mode == MonsterMode::Death) { return; } @@ -3975,7 +3975,7 @@ void M_UpdateLeader(int monsterId) } if (monster.leaderRelation == LeaderRelation::Leashed) { - Monsters[monster.leader].packsize--; + Monsters[monster.leader].packSize--; } } @@ -4088,32 +4088,32 @@ void GolumAi(int monsterId) return; } - if (IsAnyOf(golem._mmode, MonsterMode::Death, MonsterMode::SpecialStand) || golem.IsWalking()) { + if (IsAnyOf(golem.mode, MonsterMode::Death, MonsterMode::SpecialStand) || golem.isWalking()) { return; } - if ((golem._mFlags & MFLAG_TARGETS_MONSTER) == 0) + if ((golem.flags & MFLAG_TARGETS_MONSTER) == 0) UpdateEnemy(golem); - if (golem._mmode == MonsterMode::MeleeAttack) { + if (golem.mode == MonsterMode::MeleeAttack) { return; } - if ((golem._mFlags & MFLAG_NO_ENEMY) == 0) { - auto &enemy = Monsters[golem._menemy]; + if ((golem.flags & MFLAG_NO_ENEMY) == 0) { + auto &enemy = Monsters[golem.enemy]; int mex = golem.position.tile.x - enemy.position.future.x; int mey = golem.position.tile.y - enemy.position.future.y; - golem._mdir = GetDirection(golem.position.tile, enemy.position.tile); + golem.direction = GetDirection(golem.position.tile, enemy.position.tile); if (abs(mex) < 2 && abs(mey) < 2) { golem.enemyPosition = enemy.position.tile; - if (enemy._msquelch == 0) { - enemy._msquelch = UINT8_MAX; + if (enemy.activeForTicks == 0) { + enemy.activeForTicks = UINT8_MAX; enemy.position.last = golem.position.tile; for (int j = 0; j < 5; j++) { for (int k = 0; k < 5; k++) { int enemyId = dMonster[golem.position.tile.x + k - 2][golem.position.tile.y + j - 2]; // BUGFIX: Check if indexes are between 0 and 112 if (enemyId > 0) - Monsters[enemyId - 1]._msquelch = UINT8_MAX; // BUGFIX: should be `Monsters[_menemy-1]`, not Monsters[_menemy]. (fixed) + Monsters[enemyId - 1].activeForTicks = UINT8_MAX; // BUGFIX: should be `Monsters[enemy-1]`, not Monsters[enemy]. (fixed) } } } @@ -4124,14 +4124,14 @@ void GolumAi(int monsterId) return; } - golem._pathcount++; - if (golem._pathcount > 8) - golem._pathcount = 5; + golem.pathCount++; + if (golem.pathCount > 8) + golem.pathCount = 5; if (RandomWalk(monsterId, Players[monsterId]._pdir)) return; - Direction md = Left(golem._mdir); + Direction md = Left(golem.direction); bool ok = false; for (int j = 0; j < 8 && !ok; j++) { md = Right(md); @@ -4145,17 +4145,17 @@ void DeleteMonsterList() { for (int i = 0; i < MAX_PLRS; i++) { auto &golem = Monsters[i]; - if (!golem._mDelFlag) + if (!golem.isInvalid) continue; golem.position.tile = GolemHoldingCell; golem.position.future = { 0, 0 }; golem.position.old = { 0, 0 }; - golem._mDelFlag = false; + golem.isInvalid = false; } for (int i = MAX_PLRS; i < ActiveMonsterCount;) { - if (Monsters[ActiveMonsters[i]]._mDelFlag) { + if (Monsters[ActiveMonsters[i]].isInvalid) { if (pcursmonst == ActiveMonsters[i]) // Unselect monster if player highlighted it pcursmonst = -1; DeleteMonster(i); @@ -4176,19 +4176,19 @@ void ProcessMonsters() FollowTheLeader(monster); bool raflag = false; if (gbIsMultiplayer) { - SetRndSeed(monster._mAISeed); - monster._mAISeed = AdvanceRndSeed(); + SetRndSeed(monster.aiSeed); + monster.aiSeed = AdvanceRndSeed(); } - if ((monster._mFlags & MFLAG_NOHEAL) == 0 && monster._mhitpoints < monster._mmaxhp && monster._mhitpoints >> 6 > 0) { - if (monster.mLevel > 1) { - monster._mhitpoints += monster.mLevel / 2; + if ((monster.flags & MFLAG_NOHEAL) == 0 && monster.hitPoints < monster.maxHitPoints && monster.hitPoints >> 6 > 0) { + if (monster.level > 1) { + monster.hitPoints += monster.level / 2; } else { - monster._mhitpoints += monster.mLevel; + monster.hitPoints += monster.level; } - monster._mhitpoints = std::min(monster._mhitpoints, monster._mmaxhp); // prevent going over max HP with part of a single regen tick + monster.hitPoints = std::min(monster.hitPoints, monster.maxHitPoints); // prevent going over max HP with part of a single regen tick } - if (IsTileVisible(monster.position.tile) && monster._msquelch == 0) { + if (IsTileVisible(monster.position.tile) && monster.activeForTicks == 0) { if (monster.type().type == MT_CLEAVER) { PlaySFX(USFX_CLEAVER); } @@ -4207,33 +4207,33 @@ void ProcessMonsters() UpdateEnemy(monster); } - if ((monster._mFlags & MFLAG_TARGETS_MONSTER) != 0) { - assert(monster._menemy >= 0 && monster._menemy < MaxMonsters); - monster.position.last = Monsters[monster._menemy].position.future; + if ((monster.flags & MFLAG_TARGETS_MONSTER) != 0) { + assert(monster.enemy >= 0 && monster.enemy < MaxMonsters); + monster.position.last = Monsters[monster.enemy].position.future; monster.enemyPosition = monster.position.last; } else { - assert(monster._menemy >= 0 && monster._menemy < MAX_PLRS); - Player &player = Players[monster._menemy]; + assert(monster.enemy >= 0 && monster.enemy < MAX_PLRS); + Player &player = Players[monster.enemy]; monster.enemyPosition = player.position.future; if (IsTileVisible(monster.position.tile)) { - monster._msquelch = UINT8_MAX; + monster.activeForTicks = UINT8_MAX; monster.position.last = player.position.future; - } else if (monster._msquelch != 0 && monster.type().type != MT_DIABLO) { - monster._msquelch--; + } else if (monster.activeForTicks != 0 && monster.type().type != MT_DIABLO) { + monster.activeForTicks--; } } do { - if ((monster._mFlags & MFLAG_SEARCH) == 0 || !AiPlanPath(monsterId)) { - AiProc[monster._mAi](monsterId); + if ((monster.flags & MFLAG_SEARCH) == 0 || !AiPlanPath(monsterId)) { + AiProc[monster.ai](monsterId); } - switch (monster._mmode) { + switch (monster.mode) { case MonsterMode::Stand: raflag = MonsterIdle(monster); break; case MonsterMode::MoveNorthwards: case MonsterMode::MoveSouthwards: case MonsterMode::MoveSideways: - raflag = MonsterWalk(monster, monster._mmode); + raflag = MonsterWalk(monster, monster.mode); break; case MonsterMode::MeleeAttack: raflag = MonsterAttack(monsterId); @@ -4282,8 +4282,8 @@ void ProcessMonsters() GroupUnity(monster); } } while (raflag); - if (monster._mmode != MonsterMode::Petrified && (monster._mFlags & MFLAG_ALLOW_SPECIAL) == 0) { - monster.AnimInfo.processAnimation((monster._mFlags & MFLAG_LOCK_ANIMATION) != 0); + if (monster.mode != MonsterMode::Petrified && (monster.flags & MFLAG_ALLOW_SPECIAL) == 0) { + monster.animInfo.processAnimation((monster.flags & MFLAG_LOCK_ANIMATION) != 0); } } @@ -4308,7 +4308,7 @@ bool DirOK(int monsterId, Direction mdir) if (monster.leaderRelation == LeaderRelation::Leashed) { return futurePosition.WalkingDistance(Monsters[monster.leader].position.future) < 4; } - if (monster._uniqtype == 0 || UniqueMonstersData[monster._uniqtype - 1].monsterPack != UniqueMonsterPack::Leashed) + if (monster.uniqType == 0 || UniqueMonstersData[monster.uniqType - 1].monsterPack != UniqueMonsterPack::Leashed) return true; int mcount = 0; for (int x = futurePosition.x - 3; x <= futurePosition.x + 3; x++) { @@ -4325,7 +4325,7 @@ bool DirOK(int monsterId, Direction mdir) } } } - return mcount == monster.packsize; + return mcount == monster.packSize; } bool PosOkMissile(Point position) @@ -4416,22 +4416,22 @@ void SyncMonsterAnim(Monster &monster) { #ifdef _DEBUG // fix for saves with debug monsters having type originally not on the level - if (LevelMonsterTypes[monster._mMTidx].data == nullptr) { - InitMonsterGFX(monster._mMTidx); - LevelMonsterTypes[monster._mMTidx].corpseId = 1; + if (LevelMonsterTypes[monster.levelType].data == nullptr) { + InitMonsterGFX(monster.levelType); + LevelMonsterTypes[monster.levelType].corpseId = 1; } #endif - if (monster._uniqtype != 0) - monster.mName = pgettext("monster", UniqueMonstersData[monster._uniqtype - 1].mName).data(); + if (monster.uniqType != 0) + monster.name = pgettext("monster", UniqueMonstersData[monster.uniqType - 1].mName).data(); else - monster.mName = pgettext("monster", monster.data().mName).data(); + monster.name = pgettext("monster", monster.data().mName).data(); - if (monster._uniqtype != 0) + if (monster.uniqType != 0) InitTRNForUniqueMonster(monster); MonsterGraphic graphic = MonsterGraphic::Stand; - switch (monster._mmode) { + switch (monster.mode) { case MonsterMode::Stand: case MonsterMode::Delay: case MonsterMode::Talk: @@ -4461,14 +4461,14 @@ void SyncMonsterAnim(Monster &monster) break; case MonsterMode::Charge: graphic = MonsterGraphic::Attack; - monster.AnimInfo.currentFrame = 0; + monster.animInfo.currentFrame = 0; break; default: - monster.AnimInfo.currentFrame = 0; + monster.animInfo.currentFrame = 0; break; } - monster.ChangeAnimationData(graphic); + monster.changeAnimationData(graphic); } void M_FallenFear(Point position) @@ -4481,13 +4481,13 @@ void M_FallenFear(Point position) if (m == 0) continue; Monster &monster = Monsters[abs(m) - 1]; - if (monster._mAi != AI_FALLEN || monster._mhitpoints >> 6 <= 0) + if (monster.ai != AI_FALLEN || monster.hitPoints >> 6 <= 0) continue; int runDistance = std::max((8 - monster.data().mLevel), 2); - monster._mgoal = MGOAL_RETREAT; - monster._mgoalvar1 = runDistance; - monster._mgoalvar2 = static_cast(GetDirection(position, monster.position.tile)); + monster.goalVar1 = MGOAL_RETREAT; + monster.goalVar2 = runDistance; + monster.goalVar3 = static_cast(GetDirection(position, monster.position.tile)); } } @@ -4566,7 +4566,7 @@ void PrintUniqueHistory() AddPanelString(fmt::format(fmt::runtime(_("Type: {:s}")), GetMonsterTypeText(monster.data()))); } - int res = monster.mMagicRes & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING); + int res = monster.magicResistance & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING); if (res == 0) { AddPanelString(_("No resistances")); AddPanelString(_("No Immunities")); @@ -4594,7 +4594,7 @@ void PlayEffect(Monster &monster, int mode) return; } - int mi = monster._mMTidx; + int mi = monster.levelType; TSnd *snd = LevelMonsterTypes[mi].sounds[mode][sndIdx].get(); if (snd == nullptr || snd->isPlaying()) { return; @@ -4617,10 +4617,10 @@ void MissToMonst(Missile &missile, Point position) Point oldPosition = missile.position.tile; dMonster[position.x][position.y] = monsterId + 1; - monster._mdir = static_cast(missile._mimfnum); + monster.direction = static_cast(missile._mimfnum); monster.position.tile = position; - M_StartStand(monster, monster._mdir); - if ((monster._mFlags & MFLAG_TARGETS_MONSTER) == 0) + M_StartStand(monster, monster.direction); + if ((monster.flags & MFLAG_TARGETS_MONSTER) == 0) M_StartHit(monster, 0); else HitMonster(monsterId, 0); @@ -4628,12 +4628,12 @@ void MissToMonst(Missile &missile, Point position) if (monster.type().type == MT_GLOOM) return; - if ((monster._mFlags & MFLAG_TARGETS_MONSTER) == 0) { + if ((monster.flags & MFLAG_TARGETS_MONSTER) == 0) { if (dPlayer[oldPosition.x][oldPosition.y] <= 0) return; int pnum = dPlayer[oldPosition.x][oldPosition.y] - 1; - MonsterAttackPlayer(monsterId, pnum, 500, monster.mMinDamage2, monster.mMaxDamage2); + MonsterAttackPlayer(monsterId, pnum, 500, monster.minDamage2, monster.maxDamage2); if (IsAnyOf(monster.type().type, MT_NSNAKE, MT_RSNAKE, MT_BSNAKE, MT_GSNAKE)) return; @@ -4641,7 +4641,7 @@ void MissToMonst(Missile &missile, Point position) Player &player = Players[pnum]; if (player._pmode != PM_GOTHIT && player._pmode != PM_DEATH) StartPlrHit(pnum, 0, true); - Point newPosition = oldPosition + monster._mdir; + Point newPosition = oldPosition + monster.direction; if (PosOkPlayer(player, newPosition)) { player.position.tile = newPosition; FixPlayerLocation(player, player._pdir); @@ -4656,12 +4656,12 @@ void MissToMonst(Missile &missile, Point position) return; int mid = dMonster[oldPosition.x][oldPosition.y] - 1; - MonsterAttackMonster(monsterId, mid, 500, monster.mMinDamage2, monster.mMaxDamage2); + MonsterAttackMonster(monsterId, mid, 500, monster.minDamage2, monster.maxDamage2); if (IsAnyOf(monster.type().type, MT_NSNAKE, MT_RSNAKE, MT_BSNAKE, MT_GSNAKE)) return; - Point newPosition = oldPosition + monster._mdir; + Point newPosition = oldPosition + monster.direction; if (IsTileAvailable(Monsters[mid], newPosition)) { monsterId = dMonster[oldPosition.x][oldPosition.y]; dMonster[newPosition.x][newPosition.y] = monsterId; @@ -4771,23 +4771,23 @@ Monster *PreSpawnSkeleton() void TalktoMonster(Monster &monster) { - Player &player = Players[monster._menemy]; - monster._mmode = MonsterMode::Talk; - if (monster._mAi != AI_SNOTSPIL && monster._mAi != AI_LACHDAN) { + Player &player = Players[monster.enemy]; + monster.mode = MonsterMode::Talk; + if (monster.ai != AI_SNOTSPIL && monster.ai != AI_LACHDAN) { return; } if (Quests[Q_LTBANNER].IsAvailable() && Quests[Q_LTBANNER]._qvar1 == 2) { if (RemoveInventoryItemById(player, IDI_BANNER)) { Quests[Q_LTBANNER]._qactive = QUEST_DONE; - monster.mtalkmsg = TEXT_BANNER12; - monster._mgoal = MGOAL_INQUIRING; + monster.talkMsg = TEXT_BANNER12; + monster.goal = MGOAL_INQUIRING; } } - if (Quests[Q_VEIL].IsAvailable() && monster.mtalkmsg >= TEXT_VEIL9) { + if (Quests[Q_VEIL].IsAvailable() && monster.talkMsg >= TEXT_VEIL9) { if (RemoveInventoryItemById(player, IDI_GLDNELIX)) { - monster.mtalkmsg = TEXT_VEIL11; - monster._mgoal = MGOAL_INQUIRING; + monster.talkMsg = TEXT_VEIL11; + monster.goal = MGOAL_INQUIRING; } } } @@ -4802,50 +4802,50 @@ void SpawnGolem(int id, Point position, Missile &missile) golem.position.tile = position; golem.position.future = position; golem.position.old = position; - golem._pathcount = 0; - golem._mmaxhp = 2 * (320 * missile._mispllvl + player._pMaxMana / 3); - golem._mhitpoints = golem._mmaxhp; - golem.mArmorClass = 25; - golem.mHit = 5 * (missile._mispllvl + 8) + 2 * player._pLevel; - golem.mMinDamage = 2 * (missile._mispllvl + 4); - golem.mMaxDamage = 2 * (missile._mispllvl + 8); - golem._mFlags |= MFLAG_GOLEM; + golem.pathCount = 0; + golem.maxHitPoints = 2 * (320 * missile._mispllvl + player._pMaxMana / 3); + golem.hitPoints = golem.maxHitPoints; + golem.armorClass = 25; + golem.hit = 5 * (missile._mispllvl + 8) + 2 * player._pLevel; + golem.minDamage = 2 * (missile._mispllvl + 4); + golem.maxDamage = 2 * (missile._mispllvl + 8); + golem.flags |= MFLAG_GOLEM; StartSpecialStand(golem, Direction::South); UpdateEnemy(golem); if (id == MyPlayerId) { NetSendCmdGolem( golem.position.tile.x, golem.position.tile.y, - golem._mdir, - golem._menemy, - golem._mhitpoints, + golem.direction, + golem.enemy, + golem.hitPoints, GetLevelForMultiplayer(player)); } } bool CanTalkToMonst(const Monster &monster) { - return IsAnyOf(monster._mgoal, MGOAL_INQUIRING, MGOAL_TALKING); + return IsAnyOf(monster.goal, MGOAL_INQUIRING, MGOAL_TALKING); } int encode_enemy(Monster &monster) { - if ((monster._mFlags & MFLAG_TARGETS_MONSTER) != 0) - return monster._menemy + MAX_PLRS; + if ((monster.flags & MFLAG_TARGETS_MONSTER) != 0) + return monster.enemy + MAX_PLRS; - return monster._menemy; + return monster.enemy; } void decode_enemy(Monster &monster, int enemyId) { if (enemyId < MAX_PLRS) { - monster._mFlags &= ~MFLAG_TARGETS_MONSTER; - monster._menemy = enemyId; + monster.flags &= ~MFLAG_TARGETS_MONSTER; + monster.enemy = enemyId; monster.enemyPosition = Players[enemyId].position.future; } else { - monster._mFlags |= MFLAG_TARGETS_MONSTER; + monster.flags |= MFLAG_TARGETS_MONSTER; enemyId -= MAX_PLRS; - monster._menemy = enemyId; + monster.enemy = enemyId; monster.enemyPosition = Monsters[enemyId].position.future; } } @@ -4855,23 +4855,23 @@ void decode_enemy(Monster &monster, int enemyId) return std::distance(&Monsters[0], this); } -void Monster::CheckStandAnimationIsLoaded(Direction mdir) +void Monster::checkStandAnimationIsLoaded(Direction mdir) { - if (IsAnyOf(_mmode, MonsterMode::Stand, MonsterMode::Talk)) { - _mdir = mdir; - ChangeAnimationData(MonsterGraphic::Stand); + if (IsAnyOf(mode, MonsterMode::Stand, MonsterMode::Talk)) { + direction = mdir; + changeAnimationData(MonsterGraphic::Stand); } } -void Monster::Petrify() +void Monster::petrify() { - _mmode = MonsterMode::Petrified; - AnimInfo.isPetrified = true; + mode = MonsterMode::Petrified; + animInfo.isPetrified = true; } -bool Monster::IsWalking() const +bool Monster::isWalking() const { - switch (_mmode) { + switch (mode) { case MonsterMode::MoveNorthwards: case MonsterMode::MoveSouthwards: case MonsterMode::MoveSideways: @@ -4881,47 +4881,47 @@ bool Monster::IsWalking() const } } -bool Monster::IsImmune(missile_id mName) const +bool Monster::isImmune(missile_id missileType) const { - missile_resistance missileElement = MissilesData[mName].mResist; + missile_resistance missileElement = MissilesData[missileType].mResist; - if (((mMagicRes & IMMUNE_MAGIC) != 0 && missileElement == MISR_MAGIC) - || ((mMagicRes & IMMUNE_FIRE) != 0 && missileElement == MISR_FIRE) - || ((mMagicRes & IMMUNE_LIGHTNING) != 0 && missileElement == MISR_LIGHTNING) - || ((mMagicRes & IMMUNE_ACID) != 0 && missileElement == MISR_ACID)) + if (((magicResistance & IMMUNE_MAGIC) != 0 && missileElement == MISR_MAGIC) + || ((magicResistance & IMMUNE_FIRE) != 0 && missileElement == MISR_FIRE) + || ((magicResistance & IMMUNE_LIGHTNING) != 0 && missileElement == MISR_LIGHTNING) + || ((magicResistance & IMMUNE_ACID) != 0 && missileElement == MISR_ACID)) return true; - if (mName == MIS_HBOLT && type().type != MT_DIABLO && data().mMonstClass != MonsterClass::Undead) + if (missileType == MIS_HBOLT && type().type != MT_DIABLO && data().mMonstClass != MonsterClass::Undead) return true; return false; } -bool Monster::IsResistant(missile_id mName) const +bool Monster::isResistant(missile_id missileType) const { - missile_resistance missileElement = MissilesData[mName].mResist; + missile_resistance missileElement = MissilesData[missileType].mResist; - if (((mMagicRes & RESIST_MAGIC) != 0 && missileElement == MISR_MAGIC) - || ((mMagicRes & RESIST_FIRE) != 0 && missileElement == MISR_FIRE) - || ((mMagicRes & RESIST_LIGHTNING) != 0 && missileElement == MISR_LIGHTNING)) + if (((magicResistance & RESIST_MAGIC) != 0 && missileElement == MISR_MAGIC) + || ((magicResistance & RESIST_FIRE) != 0 && missileElement == MISR_FIRE) + || ((magicResistance & RESIST_LIGHTNING) != 0 && missileElement == MISR_LIGHTNING)) return true; - if (gbIsHellfire && mName == MIS_HBOLT && IsAnyOf(type().type, MT_DIABLO, MT_BONEDEMN)) + if (gbIsHellfire && missileType == MIS_HBOLT && IsAnyOf(type().type, MT_DIABLO, MT_BONEDEMN)) return true; return false; } -bool Monster::IsPossibleToHit() const +bool Monster::isPossibleToHit() const { - return !(_mhitpoints >> 6 <= 0 - || mtalkmsg != TEXT_NONE - || (type().type == MT_ILLWEAV && _mgoal == MGOAL_RETREAT) - || _mmode == MonsterMode::Charge - || (IsAnyOf(type().type, MT_COUNSLR, MT_MAGISTR, MT_CABALIST, MT_ADVOCATE) && _mgoal != MGOAL_NORMAL)); + return !(hitPoints >> 6 <= 0 + || talkMsg != TEXT_NONE + || (type().type == MT_ILLWEAV && goalVar1 == MGOAL_RETREAT) + || mode == MonsterMode::Charge + || (IsAnyOf(type().type, MT_COUNSLR, MT_MAGISTR, MT_CABALIST, MT_ADVOCATE) && goalVar1 != MGOAL_NORMAL)); } -bool Monster::TryLiftGargoyle() +bool Monster::tryLiftGargoyle() { - if (_mAi == AI_GARG && (_mFlags & MFLAG_ALLOW_SPECIAL) != 0) { - _mFlags &= ~MFLAG_ALLOW_SPECIAL; - _mmode = MonsterMode::SpecialMeleeAttack; + if (ai == AI_GARG && (flags & MFLAG_ALLOW_SPECIAL) != 0) { + flags &= ~MFLAG_ALLOW_SPECIAL; + mode = MonsterMode::SpecialMeleeAttack; return true; } return false; diff --git a/Source/monster.h b/Source/monster.h index bc59ab950..b9a0e8315 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -46,7 +46,7 @@ enum monster_flag : uint16_t { // clang-format on }; -/** This enum contains indexes from UniqueMonstersData array for special unique monsters (usually quest related) */ +/** Indexes from UniqueMonstersData array for special unique monsters (usually quest related) */ enum : uint8_t { UMT_GARBUD, UMT_SKELKING, @@ -149,7 +149,6 @@ struct AnimStruct { struct CMonster { _monster_id type; /** placeflag enum as a flags*/ - uint8_t placeFlags; std::unique_ptr animData; AnimStruct anims[6]; @@ -168,100 +167,113 @@ struct CMonster { extern CMonster LevelMonsterTypes[MaxLvlMTypes]; struct Monster { // note: missing field _mAFNum - const char *mName; - std::unique_ptr uniqueTRN; - AnimationInfo AnimInfo; - int _mgoalvar1; - int _mgoalvar2; - int _mgoalvar3; - int _mVar1; - int _mVar2; - int _mVar3; - int _mmaxhp; - int _mhitpoints; - uint32_t _mFlags; + const char *name; + std::unique_ptr uniqueMonsterTRN; + /** + * @brief Contains information for current animation + */ + AnimationInfo animInfo; + /** Specifies current goal of the monster */ + monster_goal goal; + /** Specifies monster's behaviour regarding moving and changing goals. */ + int goalVar1; + /** + * @brief Specifies turning direction for @p RoundWalk in most cases. + * Used in custom way by @p FallenAi, @p SnakeAi, @p M_FallenFear and @p FallenAi. + */ + int goalVar2; + /** + * @brief Controls monster's behaviour regarding special actions. + * Used only by @p ScavengerAi and @p MegaAi. + */ + int goalVar3; + int var1; + int var2; + int var3; + int maxHitPoints; + int hitPoints; + uint32_t flags; /** Seed used to determine item drops on death */ - uint32_t _mRndSeed; + uint32_t rndItemSeed; /** Seed used to determine AI behaviour/sync sounds in multiplayer games? */ - uint32_t _mAISeed; - - uint16_t mExp; - uint16_t mHit; - uint16_t mHit2; - uint16_t mMagicRes; - _speech_id mtalkmsg; + uint32_t aiSeed; + uint16_t exp; + uint16_t hit; + uint16_t hit2; + uint16_t magicResistance; + _speech_id talkMsg; ActorPosition position; /** Usually corresponds to the enemy's future position */ WorldTilePosition enemyPosition; - uint8_t _mMTidx; - MonsterMode _mmode; - monster_goal _mgoal; - uint8_t _pathcount; + uint8_t levelType; + MonsterMode mode; + uint8_t pathCount; /** Direction faced by monster (direction enum) */ - Direction _mdir; - /** The current target of the monster. An index in to either the plr or monster array based on the _meflag value. */ - uint8_t _menemy; - + Direction direction; + /** The current target of the monster. An index in to either the player or monster array based on the _meflag value. */ + uint8_t enemy; + bool isInvalid; + _mai_id ai; /** - * @brief Contains information for current animation + * @brief Specifies monster's behaviour across various actions. + * Generally, when monster thinks it decides what to do based on this value, among other things. + * Higher values should result in more aggressive behaviour (e.g. some monsters use this to calculate the @p AiDelay). */ - bool _mDelFlag; - - _mai_id _mAi; - uint8_t _mint; - uint8_t _msquelch; - uint8_t _uniqtype; - uint8_t _uniqtrans; - int8_t _udeadval; - int8_t mWhoHit; - int8_t mLevel; - uint8_t mMinDamage; - uint8_t mMaxDamage; - uint8_t mMinDamage2; - uint8_t mMaxDamage2; - uint8_t mArmorClass; + uint8_t intelligence; + /** Stores information for how many ticks the monster will remain active */ + uint8_t activeForTicks; + uint8_t uniqType; + uint8_t uniqTrans; + int8_t corpseId; + int8_t whoHit; + int8_t level; + uint8_t minDamage; + uint8_t maxDamage; + uint8_t minDamage2; + uint8_t maxDamage2; + uint8_t armorClass; uint8_t leader; LeaderRelation leaderRelation; - uint8_t packsize; - int8_t mlid; // BUGFIX -1 is used when not emitting light this should be signed (fixed) + uint8_t packSize; + int8_t lightId; /** - * @brief Sets the current cell sprite to match the desired direction and animation sequence + * @brief Sets the current cell sprite to match the desired desiredDirection and animation sequence * @param graphic Animation sequence of interest - * @param direction Desired direction the monster should be visually facing + * @param desiredDirection Desired desiredDirection the monster should be visually facing */ - void ChangeAnimationData(MonsterGraphic graphic, Direction direction) + void changeAnimationData(MonsterGraphic graphic, Direction desiredDirection) { auto &animationData = type().getAnimData(graphic); // Passing the Frames and rate properties here is only relevant when initialising a monster, but doesn't cause any harm when switching animations. - this->AnimInfo.changeAnimationData(animationData.getCelSpritesForDirection(direction), animationData.frames, animationData.rate); + this->animInfo.changeAnimationData(animationData.getCelSpritesForDirection(desiredDirection), animationData.frames, animationData.rate); } /** * @brief Sets the current cell sprite to match the desired animation sequence using the direction the monster is currently facing * @param graphic Animation sequence of interest */ - void ChangeAnimationData(MonsterGraphic graphic) + void changeAnimationData(MonsterGraphic graphic) { - this->ChangeAnimationData(graphic, this->_mdir); + this->changeAnimationData(graphic, this->direction); } /** - * @brief Check thats the correct stand Animation is loaded. This is needed if direction is changed (monster stands and looks to player). - * @param mdir direction of the monster + * @brief Check if the correct stand Animation is loaded. This is needed if direction is changed (monster stands and looks at the player). + * @param dir direction of the monster */ - void CheckStandAnimationIsLoaded(Direction mdir); + void checkStandAnimationIsLoaded(Direction dir); /** - * @brief Sets _mmode to MonsterMode::Petrified + * @brief Sets mode to MonsterMode::Petrified */ - void Petrify(); + void petrify(); const CMonster &type() const { - return LevelMonsterTypes[_mMTidx]; + return LevelMonsterTypes[levelType]; } const MonsterData &data() const @@ -279,11 +291,11 @@ struct Monster { // note: missing field _mAFNum /** * @brief Is the monster currently walking? */ - bool IsWalking() const; - bool IsImmune(missile_id mitype) const; - bool IsResistant(missile_id mitype) const; - bool IsPossibleToHit() const; - bool TryLiftGargoyle(); + bool isWalking() const; + bool isImmune(missile_id mitype) const; + bool isResistant(missile_id mitype) const; + bool isPossibleToHit() const; + bool tryLiftGargoyle(); }; extern int LevelMonsterTypeCount; diff --git a/Source/msg.cpp b/Source/msg.cpp index a73047aca..9fa735bdc 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -62,7 +62,7 @@ struct DMonsterStr { Direction _mdir; uint8_t _menemy; uint8_t _mactive; - int32_t _mhitpoints; + int32_t hitPoints; int8_t mWhoHit; }; @@ -506,7 +506,7 @@ void DeltaSyncGolem(const TCmdGolem &message, int pnum, uint8_t level) monster._mactive = UINT8_MAX; monster._menemy = message._menemy; monster._mdir = message._mdir; - monster._mhitpoints = message._mhitpoints; + monster.hitPoints = message._mhitpoints; } void DeltaLeaveSync(uint8_t bLevel) @@ -523,16 +523,16 @@ void DeltaLeaveSync(uint8_t bLevel) for (int i = 0; i < ActiveMonsterCount; i++) { int ma = ActiveMonsters[i]; auto &monster = Monsters[ma]; - if (monster._mhitpoints == 0) + if (monster.hitPoints == 0) continue; sgbDeltaChanged = true; DMonsterStr &delta = deltaLevel.monster[ma]; delta.position = monster.position.tile; - delta._mdir = monster._mdir; + delta._mdir = monster.direction; delta._menemy = encode_enemy(monster); - delta._mhitpoints = monster._mhitpoints; - delta._mactive = monster._msquelch; - delta.mWhoHit = monster.mWhoHit; + delta.hitPoints = monster.hitPoints; + delta._mactive = monster.activeForTicks; + delta.mWhoHit = monster.whoHit; } LocalLevels.insert_or_assign(bLevel, AutomapView); } @@ -1588,11 +1588,11 @@ DWORD OnMonstDamage(const TCmd *pCmd, int pnum) Player &player = Players[pnum]; if (player.isOnActiveLevel() && message.wMon < MaxMonsters) { auto &monster = Monsters[message.wMon]; - monster.mWhoHit |= 1 << pnum; - if (monster._mhitpoints > 0) { - monster._mhitpoints -= message.dwDam; - if ((monster._mhitpoints >> 6) < 1) - monster._mhitpoints = 1 << 6; + monster.whoHit |= 1 << pnum; + if (monster.hitPoints > 0) { + monster.hitPoints -= message.dwDam; + if ((monster.hitPoints >> 6) < 1) + monster.hitPoints = 1 << 6; delta_monster_hp(monster, player); } } @@ -2217,8 +2217,8 @@ void delta_kill_monster(int mi, Point position, const Player &player) sgbDeltaChanged = true; DMonsterStr *pD = &GetDeltaLevel(player).monster[mi]; pD->position = position; - pD->_mdir = Monsters[mi]._mdir; - pD->_mhitpoints = 0; + pD->_mdir = Monsters[mi].direction; + pD->hitPoints = 0; } void delta_monster_hp(const Monster &monster, const Player &player) @@ -2228,8 +2228,8 @@ void delta_monster_hp(const Monster &monster, const Player &player) sgbDeltaChanged = true; DMonsterStr *pD = &GetDeltaLevel(player).monster[monster.getId()]; - if (pD->_mhitpoints > monster._mhitpoints) - pD->_mhitpoints = monster._mhitpoints; + if (pD->hitPoints > monster.hitPoints) + pD->hitPoints = monster.hitPoints; } void delta_sync_monster(const TSyncMonster &monsterSync, uint8_t level) @@ -2241,14 +2241,14 @@ void delta_sync_monster(const TSyncMonster &monsterSync, uint8_t level) sgbDeltaChanged = true; DMonsterStr &monster = GetDeltaLevel(level).monster[monsterSync._mndx]; - if (monster._mhitpoints == 0) + if (monster.hitPoints == 0) return; monster.position.x = monsterSync._mx; monster.position.y = monsterSync._my; monster._mactive = UINT8_MAX; monster._menemy = monsterSync._menemy; - monster._mhitpoints = monsterSync._mhitpoints; + monster.hitPoints = monsterSync._mhitpoints; monster.mWhoHit = monsterSync.mWhoHit; } @@ -2410,20 +2410,20 @@ void DeltaLoadLevel() monster.position.old = position; monster.position.future = position; } - if (deltaLevel.monster[i]._mhitpoints != -1) { - monster._mhitpoints = deltaLevel.monster[i]._mhitpoints; - monster.mWhoHit = deltaLevel.monster[i].mWhoHit; + if (deltaLevel.monster[i].hitPoints != -1) { + monster.hitPoints = deltaLevel.monster[i].hitPoints; + monster.whoHit = deltaLevel.monster[i].mWhoHit; } - if (deltaLevel.monster[i]._mhitpoints == 0) { + if (deltaLevel.monster[i].hitPoints == 0) { M_ClearSquares(monster); - if (monster._mAi != AI_DIABLO) { - if (monster._uniqtype == 0) { - AddCorpse(monster.position.tile, monster.type().corpseId, monster._mdir); + if (monster.ai != AI_DIABLO) { + if (monster.uniqType == 0) { + AddCorpse(monster.position.tile, monster.type().corpseId, monster.direction); } else { - AddCorpse(monster.position.tile, monster._udeadval, monster._mdir); + AddCorpse(monster.position.tile, monster.corpseId, monster.direction); } } - monster._mDelFlag = true; + monster.isInvalid = true; M_UpdateLeader(i); } else { decode_enemy(monster, deltaLevel.monster[i]._menemy); @@ -2431,11 +2431,11 @@ void DeltaLoadLevel() dMonster[monster.position.tile.x][monster.position.tile.y] = i + 1; if (monster.type().type == MT_GOLEM) { GolumAi(i); - monster._mFlags |= (MFLAG_TARGETS_MONSTER | MFLAG_GOLEM); + monster.flags |= (MFLAG_TARGETS_MONSTER | MFLAG_GOLEM); } else { - M_StartStand(monster, monster._mdir); + M_StartStand(monster, monster.direction); } - monster._msquelch = deltaLevel.monster[i]._mactive; + monster.activeForTicks = deltaLevel.monster[i]._mactive; } } auto localLevelIt = LocalLevels.find(localLevel); diff --git a/Source/multi.cpp b/Source/multi.cpp index 8ffe96aa6..56215319f 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -193,7 +193,7 @@ void MonsterSeeds() sgdwGameLoops++; const uint32_t seed = (sgdwGameLoops >> 8) | (sgdwGameLoops << 24); // _rotr(sgdwGameLoops, 8) for (int i = 0; i < MaxMonsters; i++) - Monsters[i]._mAISeed = seed + i; + Monsters[i].aiSeed = seed + i; } void HandleTurnUpperBit(int pnum) diff --git a/Source/objects.cpp b/Source/objects.cpp index bce3ab7fd..3fe381632 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -3438,14 +3438,14 @@ void OperateBookCase(int i, bool sendmsg, bool sendLootMsg) if (Quests[Q_ZHAR].IsAvailable()) { auto &zhar = Monsters[MAX_PLRS]; - if (zhar._mmode == MonsterMode::Stand // prevents playing the "angry" message for the second time if zhar got aggroed by losing vision and talking again - && zhar._uniqtype - 1 == UMT_ZHAR - && zhar._msquelch == UINT8_MAX - && zhar._mhitpoints > 0) { - zhar.mtalkmsg = TEXT_ZHAR2; - M_StartStand(zhar, zhar._mdir); // BUGFIX: first parameter in call to M_StartStand should be MAX_PLRS, not 0. (fixed) - zhar._mgoal = MGOAL_ATTACK2; - zhar._mmode = MonsterMode::Talk; + if (zhar.mode == MonsterMode::Stand // prevents playing the "angry" message for the second time if zhar got aggroed by losing vision and talking again + && zhar.uniqType - 1 == UMT_ZHAR + && zhar.activeForTicks == UINT8_MAX + && zhar.hitPoints > 0) { + zhar.talkMsg = TEXT_ZHAR2; + M_StartStand(zhar, zhar.direction); // BUGFIX: first parameter in call to M_StartStand should be MAX_PLRS, not 0. (fixed) + zhar.goal = MGOAL_ATTACK2; + zhar.mode = MonsterMode::Talk; } } if (sendmsg) diff --git a/Source/player.cpp b/Source/player.cpp index b7a3d7a70..e2d5d7d9b 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -810,7 +810,7 @@ bool PlrHitMonst(int pnum, int monsterId, bool adjacentDamage = false) } Player &player = Players[pnum]; - if (!monster.IsPossibleToHit()) + if (!monster.isPossibleToHit()) return false; if (adjacentDamage) { @@ -821,14 +821,14 @@ bool PlrHitMonst(int pnum, int monsterId, bool adjacentDamage = false) } int hit = GenerateRnd(100); - if (monster._mmode == MonsterMode::Petrified) { + if (monster.mode == MonsterMode::Petrified) { hit = 0; } - hper += player.GetMeleePiercingToHit() - player.CalculateArmorPierce(monster.mArmorClass, true); + hper += player.GetMeleePiercingToHit() - player.CalculateArmorPierce(monster.armorClass, true); hper = clamp(hper, 5, 95); - if (monster.TryLiftGargoyle()) + if (monster.tryLiftGargoyle()) return true; if (hit >= hper) { @@ -889,7 +889,7 @@ bool PlrHitMonst(int pnum, int monsterId, bool adjacentDamage = false) dam *= 3; } - if (HasAnyOf(player.pDamAcFlags, ItemSpecialEffectHf::Doppelganger) && monster.type().type != MT_DIABLO && monster._uniqtype == 0 && GenerateRnd(100) < 10) { + if (HasAnyOf(player.pDamAcFlags, ItemSpecialEffectHf::Doppelganger) && monster.type().type != MT_DIABLO && monster.uniqType == 0 && GenerateRnd(100) < 10) { AddDoppelganger(monster); } @@ -912,7 +912,7 @@ bool PlrHitMonst(int pnum, int monsterId, bool adjacentDamage = false) } dam *= 2; } - monster._mhitpoints -= dam; + monster.hitPoints -= dam; } int skdam = 0; @@ -963,21 +963,20 @@ bool PlrHitMonst(int pnum, int monsterId, bool adjacentDamage = false) drawhpflag = true; } if (HasAnyOf(player._pIFlags, ItemSpecialEffect::NoHealOnPlayer)) { // Why is there a different ItemSpecialEffect here? (see missile.cpp) is this a BUG? - monster._mFlags |= MFLAG_NOHEAL; + monster.flags |= MFLAG_NOHEAL; } #ifdef _DEBUG if (DebugGodMode) { - monster._mhitpoints = 0; /* double check */ + monster.hitPoints = 0; /* double check */ } #endif - if ((monster._mhitpoints >> 6) <= 0) { + if ((monster.hitPoints >> 6) <= 0) { M_StartKill(monsterId, pnum); } else { - if (monster._mmode != MonsterMode::Petrified && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback)) + if (monster.mode != MonsterMode::Petrified && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback)) M_GetKnockback(monster); M_StartHit(monster, pnum, dam); } - return true; } @@ -1455,7 +1454,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled) case ACTION_RATTACKMON: case ACTION_SPELLMON: monster = &Monsters[targetId]; - if ((monster->_mhitpoints >> 6) <= 0) { + if ((monster->hitPoints >> 6) <= 0) { player.Stop(); return; } @@ -1503,7 +1502,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled) if (x < 2 && y < 2) { ClrPlrPath(player); - if (player.destAction == ACTION_ATTACKMON && monster->mtalkmsg != TEXT_NONE && monster->mtalkmsg != TEXT_VILE14) { + if (player.destAction == ACTION_ATTACKMON && monster->talkMsg != TEXT_NONE && monster->talkMsg != TEXT_VILE14) { TalktoMonster(*monster); } else { StartAttack(pnum, d); @@ -1578,7 +1577,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled) y = abs(player.position.tile.y - monster->position.future.y); if (x <= 1 && y <= 1) { d = GetDirection(player.position.future, monster->position.future); - if (monster->mtalkmsg != TEXT_NONE && monster->mtalkmsg != TEXT_VILE14) { + if (monster->talkMsg != TEXT_NONE && monster->talkMsg != TEXT_VILE14) { TalktoMonster(*monster); } else { StartAttack(pnum, d); @@ -1599,7 +1598,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled) break; case ACTION_RATTACKMON: d = GetDirection(player.position.future, monster->position.future); - if (monster->mtalkmsg != TEXT_NONE && monster->mtalkmsg != TEXT_VILE14) { + if (monster->talkMsg != TEXT_NONE && monster->talkMsg != TEXT_VILE14) { TalktoMonster(*monster); } else { StartRangeAttack(pnum, d, monster->position.future.x, monster->position.future.y); @@ -3188,18 +3187,18 @@ void RemovePlrMissiles(const Player &player) auto &golem = Monsters[MyPlayerId]; if (golem.position.tile.x != 1 || golem.position.tile.y != 0) { M_StartKill(MyPlayerId, MyPlayerId); - AddCorpse(golem.position.tile, golem.type().corpseId, golem._mdir); + AddCorpse(golem.position.tile, golem.type().corpseId, golem.direction); int mx = golem.position.tile.x; int my = golem.position.tile.y; dMonster[mx][my] = 0; - golem._mDelFlag = true; + golem.isInvalid = true; DeleteMonsterList(); } } for (auto &missile : Missiles) { if (missile._mitype == MIS_STONE && &Players[missile._misource] == &player) { - Monsters[missile.var2]._mmode = static_cast(missile.var1); + Monsters[missile.var2].mode = static_cast(missile.var1); } } } @@ -3429,7 +3428,7 @@ bool PosOkPlayer(const Player &player, Point position) if (dMonster[position.x][position.y] <= 0) { return false; } - if ((Monsters[dMonster[position.x][position.y] - 1]._mhitpoints >> 6) > 0) { + if ((Monsters[dMonster[position.x][position.y] - 1].hitPoints >> 6) > 0) { return false; } } diff --git a/Source/qol/monhealthbar.cpp b/Source/qol/monhealthbar.cpp index 801ee1621..c3318f099 100644 --- a/Source/qol/monhealthbar.cpp +++ b/Source/qol/monhealthbar.cpp @@ -87,20 +87,20 @@ void DrawMonsterHealthBar(const Surface &out) const int border = 3; int multiplier = 0; - int currLife = monster._mhitpoints; + int currLife = monster.hitPoints; // lifestealing monsters can reach HP exceeding their max - if (monster._mhitpoints > monster._mmaxhp) { - multiplier = monster._mhitpoints / monster._mmaxhp; - currLife = monster._mhitpoints - monster._mmaxhp * multiplier; + if (monster.hitPoints > monster.maxHitPoints) { + multiplier = monster.hitPoints / monster.maxHitPoints; + currLife = monster.hitPoints - monster.maxHitPoints * multiplier; if (currLife == 0 && multiplier > 0) { multiplier--; - currLife = monster._mmaxhp; + currLife = monster.maxHitPoints; } } DrawArt(out, position, &healthBox); DrawHalfTransparentRectTo(out, position.x + border, position.y + border, width - (border * 2), height - (border * 2)); - int barProgress = (barWidth * currLife) / monster._mmaxhp; + int barProgress = (barWidth * currLife) / monster.maxHitPoints; if (barProgress != 0) { DrawArt(out, position + Displacement { border + 1, border + 1 }, multiplier > 0 ? &healthBlue : &health, 0, barProgress, height - (border * 2) - 2); } @@ -132,27 +132,27 @@ void DrawMonsterHealthBar(const Surface &out) } UiFlags style = UiFlags::AlignCenter | UiFlags::VerticalCenter; - DrawString(out, monster.mName, { position + Displacement { -1, 1 }, { width, height } }, style | UiFlags::ColorBlack); - if (monster._uniqtype != 0) + DrawString(out, monster.name, { position + Displacement { -1, 1 }, { width, height } }, style | UiFlags::ColorBlack); + if (monster.uniqType != 0) style |= UiFlags::ColorWhitegold; else if (monster.leader != 0) style |= UiFlags::ColorBlue; else style |= UiFlags::ColorWhite; - DrawString(out, monster.mName, { position, { width, height } }, style); + DrawString(out, monster.name, { position, { width, height } }, style); if (multiplier > 0) DrawString(out, fmt::format("x{:d}", multiplier), { position, { width - 2, height } }, UiFlags::ColorWhite | UiFlags::AlignRight | UiFlags::VerticalCenter); - if (monster._uniqtype != 0 || MonsterKillCounts[monster.type().type] >= 15) { + if (monster.uniqType != 0 || MonsterKillCounts[monster.type().type] >= 15) { monster_resistance immunes[] = { IMMUNE_MAGIC, IMMUNE_FIRE, IMMUNE_LIGHTNING }; monster_resistance resists[] = { RESIST_MAGIC, RESIST_FIRE, RESIST_LIGHTNING }; int resOffset = 5; for (int i = 0; i < 3; i++) { - if ((monster.mMagicRes & immunes[i]) != 0) { + if ((monster.magicResistance & immunes[i]) != 0) { DrawArt(out, position + Displacement { resOffset, height - 6 }, &resistance, i * 2 + 1); resOffset += resistance.w() + 2; - } else if ((monster.mMagicRes & resists[i]) != 0) { + } else if ((monster.magicResistance & resists[i]) != 0) { DrawArt(out, position + Displacement { resOffset, height - 6 }, &resistance, i * 2); resOffset += resistance.w() + 2; } @@ -161,7 +161,7 @@ void DrawMonsterHealthBar(const Surface &out) int tagOffset = 5; for (int i = 0; i < MAX_PLRS; i++) { - if (1 << i & monster.mWhoHit) { + if (1 << i & monster.whoHit) { DrawArt(out, position + Displacement { tagOffset, height - 31 }, &playerExpTags, i + 1); } else if (Players[i].plractive) { DrawArt(out, position + Displacement { tagOffset, height - 31 }, &playerExpTags, 0); diff --git a/Source/quests.cpp b/Source/quests.cpp index b0cfe8fa2..0026c6b5b 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -418,13 +418,13 @@ void CheckQuestKill(const Monster &monster, bool sendmsg) myPlayer.Say(HeroSpeech::TheSpiritsOfTheDeadAreNowAvenged, 30); if (sendmsg) NetSendCmdQuest(true, quest); - } else if (monster._uniqtype - 1 == UMT_GARBUD) { //"Gharbad the Weak" + } else if (monster.uniqType - 1 == UMT_GARBUD) { //"Gharbad the Weak" Quests[Q_GARBUD]._qactive = QUEST_DONE; myPlayer.Say(HeroSpeech::ImNotImpressed, 30); - } else if (monster._uniqtype - 1 == UMT_ZHAR) { //"Zhar the Mad" + } else if (monster.uniqType - 1 == UMT_ZHAR) { //"Zhar the Mad" Quests[Q_ZHAR]._qactive = QUEST_DONE; myPlayer.Say(HeroSpeech::ImSorryDidIBreakYourConcentration, 30); - } else if (monster._uniqtype - 1 == UMT_LAZARUS) { //"Arch-Bishop Lazarus" + } else if (monster.uniqType - 1 == UMT_LAZARUS) { //"Arch-Bishop Lazarus" auto &betrayerQuest = Quests[Q_BETRAYER]; betrayerQuest._qactive = QUEST_DONE; myPlayer.Say(HeroSpeech::YourMadnessEndsHereBetrayer, 30); @@ -451,7 +451,7 @@ void CheckQuestKill(const Monster &monster, bool sendmsg) betrayerQuest._qvar2 = 4; AddMissile({ 35, 32 }, { 35, 32 }, Direction::South, MIS_RPORTAL, TARGET_MONSTERS, MyPlayerId, 0, 0); } - } else if (monster._uniqtype - 1 == UMT_WARLORD) { //"Warlord of Blood" + } else if (monster.uniqType - 1 == UMT_WARLORD) { //"Warlord of Blood" Quests[Q_WARLORD]._qactive = QUEST_DONE; myPlayer.Say(HeroSpeech::YourReignOfPainHasEnded, 30); } diff --git a/Source/sync.cpp b/Source/sync.cpp index 10d954f9c..41c842065 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -25,7 +25,7 @@ void SyncOneMonster() int m = ActiveMonsters[i]; auto &monster = Monsters[m]; sgnMonsterPriority[m] = MyPlayer->position.tile.ManhattanDistance(monster.position.tile); - if (monster._msquelch == 0) { + if (monster.activeForTicks == 0) { sgnMonsterPriority[m] += 0x1000; } else if (sgwLRU[m] != 0) { sgwLRU[m]--; @@ -41,11 +41,11 @@ void SyncMonsterPos(TSyncMonster &monsterSync, int ndx) monsterSync._my = monster.position.tile.y; monsterSync._menemy = encode_enemy(monster); monsterSync._mdelta = sgnMonsterPriority[ndx] > 255 ? 255 : sgnMonsterPriority[ndx]; - monsterSync.mWhoHit = monster.mWhoHit; - monsterSync._mhitpoints = monster._mhitpoints; + monsterSync.mWhoHit = monster.whoHit; + monsterSync._mhitpoints = monster.hitPoints; sgnMonsterPriority[ndx] = 0xFFFF; - sgwLRU[ndx] = monster._msquelch == 0 ? 0xFFFF : 0xFFFE; + sgwLRU[ndx] = monster.activeForTicks == 0 ? 0xFFFF : 0xFFFE; } bool SyncMonsterActive(TSyncMonster &monsterSync) @@ -152,14 +152,14 @@ void SyncMonster(bool isOwner, const TSyncMonster &monsterSync) { const int monsterId = monsterSync._mndx; Monster &monster = Monsters[monsterId]; - if (monster._mhitpoints <= 0 || monster._mmode == MonsterMode::Death) { + if (monster.hitPoints <= 0 || monster.mode == MonsterMode::Death) { return; } const Point position { monsterSync._mx, monsterSync._my }; const int enemyId = monsterSync._menemy; - if (monster._msquelch != 0) { + if (monster.activeForTicks != 0) { uint32_t delta = MyPlayer->position.tile.ManhattanDistance(monster.position.tile); if (delta > 255) { delta = 255; @@ -172,18 +172,18 @@ void SyncMonster(bool isOwner, const TSyncMonster &monsterSync) return; } } - if (IsAnyOf(monster._mmode, MonsterMode::Charge, MonsterMode::Petrified)) { + if (IsAnyOf(monster.mode, MonsterMode::Charge, MonsterMode::Petrified)) { return; } if (monster.position.tile.WalkingDistance(position) <= 2) { - if (!monster.IsWalking()) { + if (!monster.isWalking()) { Direction md = GetDirection(monster.position.tile, position); if (DirOK(monsterId, md)) { M_ClearSquares(monster); dMonster[monster.position.tile.x][monster.position.tile.y] = monsterId + 1; M_WalkDir(monster, md); - monster._msquelch = UINT8_MAX; + monster.activeForTicks = UINT8_MAX; } } } else if (dMonster[position.x][position.y] == 0) { @@ -193,11 +193,11 @@ void SyncMonster(bool isOwner, const TSyncMonster &monsterSync) decode_enemy(monster, enemyId); Direction md = GetDirection(position, monster.enemyPosition); M_StartStand(monster, md); - monster._msquelch = UINT8_MAX; + monster.activeForTicks = UINT8_MAX; } decode_enemy(monster, enemyId); - monster.mWhoHit |= monsterSync.mWhoHit; + monster.whoHit |= monsterSync.mWhoHit; } bool IsEnemyIdValid(const Monster &monster, int enemyId) @@ -221,7 +221,7 @@ bool IsEnemyIdValid(const Monster &monster, int enemyId) return false; } - if (enemy._mhitpoints <= 0) { + if (enemy.hitPoints <= 0) { return false; } diff --git a/Source/track.cpp b/Source/track.cpp index 4172cf081..85be226e1 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -39,8 +39,8 @@ void InvalidateTargets() { if (pcursmonst != -1) { const Monster &monster = Monsters[pcursmonst]; - if (monster._mDelFlag || monster._mhitpoints >> 6 <= 0 - || (monster._mFlags & MFLAG_HIDDEN) != 0 + if (monster.isInvalid || monster.hitPoints >> 6 <= 0 + || (monster.flags & MFLAG_HIDDEN) != 0 || !IsTileLit(monster.position.tile)) { pcursmonst = -1; }