From ef64f49c4cc4474504a3597af57636a9ad33817d Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Wed, 13 Jan 2021 01:50:32 +0100 Subject: [PATCH 01/26] control: add BUGFIX comment for DrawSpellBook The render of the spellbook page 3 and page 4 buttons were both off by one pixel. --- Source/control.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/control.cpp b/Source/control.cpp index 24582d01e..0ea632df6 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -2498,6 +2498,14 @@ void DrawSpellBook() if (sbooktab < 5) CelDraw(RIGHT_PANEL_X + 61 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 61); #else + // BUGFIX: rendering of page 3 and page 4 buttons are both off-by-one pixel. + // The fix would look as follows: + // + // int sx = RIGHT_PANEL_X + 76 * sbooktab + 7; + // if (sbooktab == 2 || sbooktab == 3) { + // sx++; + // } + // CelDraw(sx, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76); CelDraw(RIGHT_PANEL_X + 76 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76); #endif From 16796a4fc2a7c17be3d01164ec16e7d3c83bd54d Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Jan 2021 22:52:01 +0100 Subject: [PATCH 02/26] [hellfire] M_StartHit --- Source/monster.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 1be5c53a7..34a8f9c4c 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1751,21 +1751,33 @@ void M_StartHit(int i, int pnum, int dam) monster[i].mWhoHit |= 1 << pnum; if (pnum == myplr) { delta_monster_hp(i, monster[i]._mhitpoints, currlevel); +#ifdef HELLFIRE + NetSendCmdMonDmg(FALSE, i, dam); +#else NetSendCmdParam2(FALSE, CMD_MONSTDAMAGE, i, dam); +#endif } PlayEffect(i, 1); if (monster[i].MType->mtype >= MT_SNEAK && monster[i].MType->mtype <= MT_ILLWEAV || dam >> 6 >= monster[i].mLevel + 3) { if (pnum >= 0) { - monster[i]._mFlags &= ~MFLAG_TARGETS_MONSTER; monster[i]._menemy = pnum; monster[i]._menemyx = plr[pnum]._pfutx; monster[i]._menemyy = plr[pnum]._pfuty; + monster[i]._mFlags &= ~MFLAG_TARGETS_MONSTER; monster[i]._mdir = M_GetDir(i); } if (monster[i].MType->mtype == MT_BLINK) { M_Teleport(i); - } else if (monster[i].MType->mtype >= MT_NSCAV && monster[i].MType->mtype <= MT_YSCAV) { + } else if ((monster[i].MType->mtype >= MT_NSCAV && monster[i].MType->mtype <= MT_YSCAV) +#ifdef HELLFIRE + || monster[i].MType->mtype == MT_GRAVEDIG +#endif + ) { monster[i]._mgoal = MGOAL_NORMAL; +#ifdef HELLFIRE + monster[i]._mgoalvar1 = 0; + monster[i]._mgoalvar2 = 0; +#endif } if (monster[i]._mmode != MM_STONE) { NewMonsterAnim(i, monster[i].MType->Anims[MA_GOTHIT], monster[i]._mdir); @@ -1776,6 +1788,8 @@ void M_StartHit(int i, int pnum, int dam) monster[i]._my = monster[i]._moldy; monster[i]._mfutx = monster[i]._moldx; monster[i]._mfuty = monster[i]._moldy; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; M_CheckEFlag(i); M_ClearSquares(i); dMonster[monster[i]._mx][monster[i]._my] = i + 1; From 1e86577fc8f41c006f19472b2ee5d0c688c6a137 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Jan 2021 18:44:54 +0100 Subject: [PATCH 03/26] Some random cleanups --- Source/items.cpp | 2 +- Source/monster.cpp | 2 +- Source/player.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index e8b12287b..03b1f27d4 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3148,7 +3148,7 @@ void CreateTypeItem(int x, int y, BOOL onlygood, int itype, int imisc, BOOL send idx = RndTypeItems(itype, imisc); #endif else - idx = 0; + idx = IDI_GOLD; if (numitems < MAXITEMS) { ii = itemavail[0]; diff --git a/Source/monster.cpp b/Source/monster.cpp index 34a8f9c4c..5a87c474f 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -3414,7 +3414,7 @@ BOOL M_CallWalk2(int i, int md) int mdtemp; mdtemp = md; - ok = DirOK(i, md); // Can we continue in the same direction + ok = DirOK(i, md); // Can we continue in the same direction if (random_(101, 2) != 0) { // Randomly go left or right ok = ok || (mdtemp = left[md], DirOK(i, left[md])) || (mdtemp = right[md], DirOK(i, right[md])); } else { diff --git a/Source/player.cpp b/Source/player.cpp index 142960b86..91b2e3f6f 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -810,7 +810,7 @@ void CreatePlayer(int pnum, char c) } else if (plr[pnum]._pClass == PC_ROGUE || plr[pnum]._pClass == PC_MONK || plr[pnum]._pClass == PC_BARD) { #else } - if (plr[pnum]._pClass == PC_ROGUE == PC_ROGUE) { + if (plr[pnum]._pClass == PC_ROGUE) { #endif plr[pnum]._pHitPoints += plr[pnum]._pHitPoints >> 1; } From ae3570f221ce2ac1d0ae2bcdeae18eab2ffdf8cc Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Jan 2021 22:25:09 +0100 Subject: [PATCH 04/26] [hellfire] M_Enemy --- Source/monster.cpp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 5a87c474f..97bcf4062 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1352,7 +1352,7 @@ void M_Enemy(int i) int mi, pnum; int dist, best_dist; int _menemy; - BOOL sameroom, bestsameroom; + DIABOOL sameroom, bestsameroom; MonsterStruct *Monst; BYTE enemyx, enemyy; @@ -1360,14 +1360,28 @@ void M_Enemy(int i) best_dist = -1; bestsameroom = 0; Monst = &monster[i]; - if (!(Monst->_mFlags & MFLAG_GOLEM)) { + if ( +#ifdef HELLFIRE + Monst->_mFlags & MFLAG_BERSERK || +#endif + !(Monst->_mFlags & MFLAG_GOLEM)) { for (pnum = 0; pnum < MAX_PLRS; pnum++) { - if (!plr[pnum].plractive || currlevel != plr[pnum].plrlevel || plr[pnum]._pLvlChanging || (plr[pnum]._pHitPoints == 0 && gbMaxPlayers != 1)) + if (!plr[pnum].plractive || currlevel != plr[pnum].plrlevel || plr[pnum]._pLvlChanging +#ifdef HELLFIRE + || ((plr[pnum]._pHitPoints >> 6) == 0) +#else + || (plr[pnum]._pHitPoints == 0 && gbMaxPlayers != 1) +#endif + ) continue; +#ifdef HELLFIRE + sameroom = (dTransVal[Monst->_mx][Monst->_my] == dTransVal[plr[pnum]._px][plr[pnum]._py]); +#else if (dTransVal[Monst->_mx][Monst->_my] == dTransVal[plr[pnum]._px][plr[pnum]._py]) sameroom = TRUE; else sameroom = FALSE; +#endif if (abs(Monst->_mx - plr[pnum]._px) > abs(Monst->_my - plr[pnum]._py)) dist = Monst->_mx - plr[pnum]._px; else @@ -1389,13 +1403,25 @@ void M_Enemy(int i) mi = monstactive[j]; if (mi == i) continue; +#ifdef HELLFIRE + if (!((monster[mi]._mhitpoints >> 6) > 0)) + continue; +#endif if (monster[mi]._mx == 1 && monster[mi]._my == 0) continue; if (M_Talker(mi) && monster[mi].mtalkmsg) continue; - if (!(Monst->_mFlags & MFLAG_GOLEM) - && ((abs(monster[mi]._mx - Monst->_mx) >= 2 || abs(monster[mi]._my - Monst->_my) >= 2) && !M_Ranged(i) - || (!(Monst->_mFlags & MFLAG_GOLEM) && !(monster[mi]._mFlags & MFLAG_GOLEM)))) { + if ((!(Monst->_mFlags & MFLAG_GOLEM) +#ifdef HELLFIRE + && !(Monst->_mFlags & MFLAG_BERSERK) +#endif + && (abs(monster[mi]._mx - Monst->_mx) >= 2 || abs(monster[mi]._my - Monst->_my) >= 2) + && !M_Ranged(i)) + || (!(Monst->_mFlags & MFLAG_GOLEM) +#ifdef HELLFIRE + && !(Monst->_mFlags & MFLAG_BERSERK) +#endif + && !(monster[mi]._mFlags & MFLAG_GOLEM))) { continue; } sameroom = dTransVal[Monst->_mx][Monst->_my] == dTransVal[monster[mi]._mx][monster[mi]._my]; From 6a16d458b91b87043081d5d7ceb454b8b365a0cc Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 09:21:15 +0100 Subject: [PATCH 05/26] [hellfire] M2MStartHit --- Source/monster.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 97bcf4062..0b58db43c 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1917,18 +1917,30 @@ void SpawnLoot(int i, BOOL sendmsg) void M2MStartHit(int mid, int i, int dam) { if ((DWORD)mid >= MAXMONSTERS) { +#ifdef HELLFIRE + return; +#else app_fatal("Invalid monster %d getting hit by monster", mid); +#endif } if (monster[mid].MType == NULL) { +#ifdef HELLFIRE + return; +#else app_fatal("Monster %d \"%s\" getting hit by monster: MType NULL", mid, monster[mid].mName); +#endif } if (i >= 0) monster[i].mWhoHit |= 1 << i; delta_monster_hp(mid, monster[mid]._mhitpoints, currlevel); +#ifdef HELLFIRE + NetSendCmdMonDmg(FALSE, mid, dam); +#else NetSendCmdParam2(FALSE, CMD_MONSTDAMAGE, mid, dam); +#endif PlayEffect(mid, 1); if (monster[mid].MType->mtype >= MT_SNEAK && monster[mid].MType->mtype <= MT_ILLWEAV || dam >> 6 >= monster[mid].mLevel + 3) { @@ -1937,8 +1949,16 @@ void M2MStartHit(int mid, int i, int dam) if (monster[mid].MType->mtype == MT_BLINK) { M_Teleport(mid); - } else if (monster[mid].MType->mtype >= MT_NSCAV && monster[mid].MType->mtype <= MT_YSCAV) { + } else if (monster[mid].MType->mtype >= MT_NSCAV && monster[mid].MType->mtype <= MT_YSCAV +#ifdef HELLFIRE + || monster[mid].MType->mtype == MT_GRAVEDIG +#endif + ) { monster[mid]._mgoal = MGOAL_NORMAL; +#ifdef HELLFIRE + monster[mid]._mgoalvar1 = 0; + monster[mid]._mgoalvar2 = 0; +#endif } if (monster[mid]._mmode != MM_STONE) { @@ -1953,6 +1973,8 @@ void M2MStartHit(int mid, int i, int dam) monster[mid]._my = monster[mid]._moldy; monster[mid]._mfutx = monster[mid]._moldx; monster[mid]._mfuty = monster[mid]._moldy; + monster[mid]._moldx = monster[mid]._mx; + monster[mid]._moldy = monster[mid]._my; M_CheckEFlag(mid); M_ClearSquares(mid); dMonster[monster[mid]._mx][monster[mid]._my] = mid + 1; From 74a0f68babece8e81f96e99948600375959e4d8c Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 09:52:50 +0100 Subject: [PATCH 06/26] [hellfire] M2MStartKill --- Source/monster.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 0b58db43c..d5580e462 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -2059,13 +2059,26 @@ void M2MStartKill(int i, int mid) int md; if ((DWORD)i >= MAXMONSTERS) { +#ifdef HELLFIRE + return; +#else app_fatal("M2MStartKill: Invalid monster (attacker) %d", i); +#endif } +#ifdef HELLFIRE + if ((DWORD)mid >= MAXMONSTERS) { + return; +#else if ((DWORD)i >= MAXMONSTERS) { /// BUGFIX: should check `mid` app_fatal("M2MStartKill: Invalid monster (killed) %d", mid); +#endif } if (monster[i].MType == NULL) +#ifdef HELLFIRE + return; +#else app_fatal("M2MStartKill: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); +#endif delta_kill_monster(mid, monster[mid]._mx, monster[mid]._my, currlevel); NetSendCmdLocParam1(FALSE, CMD_MONSTDEATH, monster[mid]._mx, monster[mid]._my, mid); @@ -2078,14 +2091,20 @@ void M2MStartKill(int i, int mid) monster[mid]._mhitpoints = 0; SetRndSeed(monster[mid]._mRndSeed); +#ifdef HELLFIRE + SpawnLoot(mid, TRUE); +#else if (mid >= MAX_PLRS) SpawnItem(mid, monster[mid]._mx, monster[mid]._my, TRUE); +#endif if (monster[mid].MType->mtype == MT_DIABLO) M_DiabloDeath(mid, TRUE); else +#ifndef HELLFIRE PlayEffect(i, 2); +#endif PlayEffect(mid, 2); md = (monster[i]._mdir - 4) & 7; @@ -2099,8 +2118,10 @@ void M2MStartKill(int i, int mid) monster[mid]._myoff = 0; monster[mid]._mx = monster[mid]._moldx; monster[mid]._my = monster[mid]._moldy; - monster[mid]._mfutx = monster[mid]._moldx; - monster[mid]._mfuty = monster[mid]._moldy; + monster[mid]._mfutx = monster[mid]._mx; + monster[mid]._mfuty = monster[mid]._my; + monster[mid]._moldx = monster[mid]._mx; + monster[mid]._moldy = monster[mid]._my; M_CheckEFlag(mid); M_ClearSquares(mid); dMonster[monster[mid]._mx][monster[mid]._my] = mid + 1; @@ -2108,6 +2129,10 @@ void M2MStartKill(int i, int mid) M_FallenFear(monster[mid]._mx, monster[mid]._my); if (monster[mid].MType->mtype >= MT_NACID && monster[mid].MType->mtype <= MT_XACID) AddMissile(monster[mid]._mx, monster[mid]._my, 0, 0, 0, MIS_ACIDPUD, TARGET_PLAYERS, mid, monster[mid]._mint + 1, 0); + +#ifdef HELLFIRE + M_StartStand(i, monster[i]._mdir); +#endif } void M_StartKill(int i, int pnum) From f3bf2f4f0513fade4ab5df6becbae9d4e39835aa Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 11:08:23 +0100 Subject: [PATCH 07/26] [hellfire] M_TryM2MHit --- Source/monster.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index d5580e462..37ddff576 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -2511,10 +2511,18 @@ void M_TryM2MHit(int i, int mid, int hper, int mind, int maxd) BOOL ret; if ((DWORD)mid >= MAXMONSTERS) { +#ifdef HELLFIRE + return; +#else app_fatal("M_TryM2MHit: Invalid monster %d", mid); +#endif } if (monster[mid].MType == NULL) +#ifdef HELLFIRE + return; +#else app_fatal("M_TryM2MHit: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); +#endif if (monster[mid]._mhitpoints >> 6 > 0 && (monster[mid].MType->mtype != MT_ILLWEAV || monster[mid]._mgoal != MGOAL_RETREAT)) { int hit = random_(4, 100); if (monster[mid]._mmode == MM_STONE) From 7d169f83345706b46f0d0af9377ed2188c92ca24 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 19:39:04 +0100 Subject: [PATCH 08/26] [hellfire] MAI_Scav --- Source/monster.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 37ddff576..2f9eae627 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4346,7 +4346,6 @@ void MAI_Scav(int i) { BOOL done; int x, y; - int _mx, _my; MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) @@ -4356,8 +4355,6 @@ void MAI_Scav(int i) app_fatal("MAI_Scav: Invalid monster %d", i); #endif Monst = &monster[i]; - _mx = Monst->_mx; - _my = Monst->_my; done = FALSE; if (monster[i]._mmode != MM_STAND) return; @@ -4373,9 +4370,25 @@ void MAI_Scav(int i) Monst->_mgoalvar3--; if (dDead[Monst->_mx][Monst->_my] != 0) { M_StartEat(i); - if (!(Monst->_mFlags & MFLAG_NOHEAL)) + if (!(Monst->_mFlags & MFLAG_NOHEAL)) { +#ifdef HELLFIRE + int mMaxHP = Monst->MType->mMaxHP << 6; + if (gbMaxPlayers == 1) + mMaxHP >>= 1; + Monst->_mhitpoints += mMaxHP >> 3; + if (Monst->_mhitpoints > mMaxHP) + Monst->_mhitpoints = mMaxHP; + if (Monst->_mmaxhp < Monst->_mhitpoints) + Monst->_mmaxhp = Monst->_mhitpoints; + if (Monst->_mgoalvar3 <= 0 || Monst->_mhitpoints == mMaxHP) + dDead[Monst->_mx][Monst->_my] = 0; + } + if (Monst->_mhitpoints == Monst->_mmaxhp) { +#else Monst->_mhitpoints += 64; + } if (Monst->_mhitpoints >= (Monst->_mmaxhp >> 1) + (Monst->_mmaxhp >> 2)) { +#endif Monst->_mgoal = MGOAL_NORMAL; Monst->_mgoalvar1 = 0; Monst->_mgoalvar2 = 0; @@ -4430,7 +4443,11 @@ void MAI_Scav(int i) } } } +#ifdef HELLFIRE + else +#else if (Monst->_mmode == MM_STAND) +#endif MAI_SkelSd(i); } From fd41a5767bf9e184620122c15e03ef77ada44fb4 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 19:52:44 +0100 Subject: [PATCH 09/26] [hellfire] MAI_Garg --- Source/monster.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 2f9eae627..e35403ca9 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4457,7 +4457,11 @@ void MAI_Garg(int i) int mx, my, dx, dy, md; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_Garg: Invalid monster %d", i); +#endif Monst = &monster[i]; dx = Monst->_mx - Monst->_lastx; @@ -4477,8 +4481,11 @@ void MAI_Garg(int i) return; } - if (Monst->_mhitpoints < (Monst->_mmaxhp >> 1) && !(Monst->_mFlags & MFLAG_NOHEAL)) - Monst->_mgoal = MGOAL_RETREAT; + if (Monst->_mhitpoints < (Monst->_mmaxhp >> 1)) +#ifndef HELLFIRE + if (!(Monst->_mFlags & MFLAG_NOHEAL)) +#endif + Monst->_mgoal = MGOAL_RETREAT; if (Monst->_mgoal == MGOAL_RETREAT) { if (abs(dx) >= Monst->_mint + 2 || abs(dy) >= Monst->_mint + 2) { Monst->_mgoal = MGOAL_NORMAL; From 4a75c2c275a5afc61bd17026c22820ad5047dafc Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 21:44:57 +0100 Subject: [PATCH 10/26] [hellfire] Better monster AI naming --- Source/monster.cpp | 32 ++++++++++++++++---------------- Source/monster.h | 16 ++++++++-------- comparer-config/hellfire.toml | 16 ++++++++-------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index e35403ca9..509ef7f62 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -120,14 +120,14 @@ void (*AiProc[])(int i) = { &MAI_Lachdanan, &MAI_Warlord, #ifdef HELLFIRE - &mai_ranged_441680, - &mai_ranged_44168B, - &mai_horkdemon, - &mai_ranged_441649, - &mai_ranged_441654, - &mai_ranged_44165F, - &mai_ranged_44166A, - &mai_roundranged_441EA0 + &MAI_Firebat, + &MAI_Torchant, + &MAI_HorkDemon, + &MAI_Lich, + &MAI_ArchLich, + &MAI_Psychorb, + &MAI_Necromorb, + &MAI_BoneDemon #endif }; @@ -4304,22 +4304,22 @@ void MAI_Succ(int i) } #ifdef HELLFIRE -void mai_ranged_441649(int i) +void MAI_Lich(int i) { MAI_Ranged(i, MIS_LICH, FALSE); } -void mai_ranged_441654(int i) +void MAI_ArchLich(int i) { MAI_Ranged(i, MIS_ARCHLICH, FALSE); } -void mai_ranged_44165F(int i) +void MAI_Psychorb(int i) { MAI_Ranged(i, MIS_PSYCHORB, FALSE); } -void mai_ranged_44166A(int i) +void MAI_Necromorb(int i) { MAI_Ranged(i, MIS_NECROMORB, FALSE); } @@ -4331,12 +4331,12 @@ void MAI_AcidUniq(int i) } #ifdef HELLFIRE -void mai_ranged_441680(int i) +void MAI_Firebat(int i) { MAI_Ranged(i, MIS_FIREBOLT, FALSE); } -void mai_ranged_44168B(int i) +void MAI_Torchant(int i) { MAI_Ranged(i, MIS_FIREBALL, FALSE); } @@ -4577,7 +4577,7 @@ void MAI_Storm(int i) } #ifdef HELLFIRE -void mai_roundranged_441EA0(int i) +void MAI_BoneDemon(int i) { MAI_RoundRanged(i, MIS_BONEDEMON, TRUE, 4, 0); } @@ -4891,7 +4891,7 @@ void MAI_Rhino(int i) } #ifdef HELLFIRE -void mai_horkdemon(int i) +void MAI_HorkDemon(int i) { MonsterStruct *Monst; int fx, fy, mx, my, md, v, dist; diff --git a/Source/monster.h b/Source/monster.h index 70fca6216..62292b54e 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -63,15 +63,15 @@ void MAI_Ranged(int i, int missile_type, BOOL special); void MAI_GoatBow(int i); void MAI_Succ(int i); #ifdef HELLFIRE -void mai_ranged_441649(int i); -void mai_ranged_441654(int i); -void mai_ranged_44165F(int i); -void mai_ranged_44166A(int i); +void MAI_Lich(int i); +void MAI_ArchLich(int i); +void MAI_Psychorb(int i); +void MAI_Necromorb(int i); #endif void MAI_AcidUniq(int i); #ifdef HELLFIRE -void mai_ranged_441680(int i); -void mai_ranged_44168B(int i); +void MAI_Firebat(int i); +void MAI_Torchant(int i); #endif void MAI_Scav(int i); void MAI_Garg(int i); @@ -79,7 +79,7 @@ void MAI_RoundRanged(int i, int missile_type, BOOL checkdoors, int dam, int less void MAI_Magma(int i); void MAI_Storm(int i); #ifdef HELLFIRE -void mai_roundranged_441EA0(int i); +void MAI_BoneDemon(int i); #endif void MAI_Acid(int i); void MAI_Diablo(int i); @@ -88,7 +88,7 @@ void MAI_Golum(int i); void MAI_SkelKing(int i); void MAI_Rhino(int i); #ifdef HELLFIRE -void mai_horkdemon(int i); +void MAI_HorkDemon(int i); #endif void MAI_Counselor(int i); void MAI_Garbud(int i); diff --git a/comparer-config/hellfire.toml b/comparer-config/hellfire.toml index 8261073dd..9fad3b438 100644 --- a/comparer-config/hellfire.toml +++ b/comparer-config/hellfire.toml @@ -5188,22 +5188,22 @@ addr = 0x44163E size = 0xB [[func]] -name = "mai_ranged_441649" +name = "MAI_Lich" addr = 0x441649 size = 0xB [[func]] -name = "mai_ranged_441654" +name = "MAI_ArchLich" addr = 0x441654 size = 0xB [[func]] -name = "mai_ranged_44165F" +name = "MAI_Psychorb" addr = 0x44165F size = 0xB [[func]] -name = "mai_ranged_44166A" +name = "MAI_Necromorb" addr = 0x44166A size = 0xB @@ -5213,12 +5213,12 @@ addr = 0x441675 size = 0xB [[func]] -name = "mai_ranged_441680" +name = "MAI_Firebat" addr = 0x441680 size = 0xB [[func]] -name = "mai_ranged_44168B" +name = "MAI_Torchant" addr = 0x44168B size = 0xB @@ -5258,7 +5258,7 @@ addr = 0x441E91 size = 0xF [[func]] -name = "mai_roundranged_441EA0" +name = "MAI_BoneDemon" addr = 0x441EA0 size = 0xF @@ -5298,7 +5298,7 @@ addr = 0x44271A size = 0x2EA [[func]] -name = "mai_horkdemon" +name = "MAI_HorkDemon" addr = 0x442A04 size = 0x2B1 From 6862028680aca99be3b31e94df4579adda7a2eef Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 22:16:08 +0100 Subject: [PATCH 11/26] [hellfire] MAI_RR2 --- Source/monster.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index 509ef7f62..91c921667 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4600,7 +4600,11 @@ void MAI_RR2(int i, int mistype, int dam) int dist, v, md; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_RR2: Invalid monster %d", i); +#endif Monst = &monster[i]; mx = Monst->_mx - Monst->_menemyx; From b455cbc688378a9213f22d158909ff9730b27f1b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 23:55:51 +0100 Subject: [PATCH 12/26] [hellfire] MAI_Golum --- Source/monster.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 91c921667..585d89d5e 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4685,7 +4685,11 @@ void MAI_Golum(int i) BOOL have_enemy, ok; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_Golum: Invalid monster %d", i); +#endif Monst = &monster[i]; if (Monst->_mx == 1 && Monst->_my == 0) { @@ -4715,10 +4719,7 @@ void MAI_Golum(int i) _mey = my - monster[_menemy]._mfuty; md = GetDirection(mx, my, monster[_menemy]._mx, monster[_menemy]._my); monster[i]._mdir = md; - if (abs(_mex) >= 2 || abs(_mey) >= 2) { - if (have_enemy && MAI_Path(i)) - return; - } else if (have_enemy) { + if (abs(_mex) < 2 && abs(_mey) < 2 && have_enemy) { _menemy = monster[i]._menemy; monster[i]._menemyx = monster[_menemy]._mx; monster[i]._menemyy = monster[_menemy]._my; @@ -4738,22 +4739,24 @@ void MAI_Golum(int i) return; } + if (have_enemy && MAI_Path(i)) + return; + monster[i]._pathcount++; if (monster[i]._pathcount > 8) monster[i]._pathcount = 5; ok = M_CallWalk(i, plr[i]._pdir); - if (!ok) { - md = (md - 1) & 7; - for (j = 0; j < 8 && !ok; j++) { - md = (md + 1) & 7; - ok = DirOK(i, md); - } - if (!ok) { - return; - } - M_WalkDir(i, md); + if (ok) + return; + + md = (md - 1) & 7; + for (j = 0; j < 8 && !ok; j++) { + md = (md + 1) & 7; + ok = DirOK(i, md); } + if (ok) + M_WalkDir(i, md); } void MAI_SkelKing(int i) From b683b5d2d0217fb48db32578c053911cea5da652 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 00:05:51 +0100 Subject: [PATCH 13/26] [hellfire] TalktoMonster --- Source/monster.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 585d89d5e..b33606e9a 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -6461,7 +6461,11 @@ void TalktoMonster(int i) void SpawnGolum(int i, int x, int y, int mi) { if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("SpawnGolum: Invalid monster %d", i); +#endif dMonster[x][y] = i + 1; monster[i]._mx = x; @@ -6471,13 +6475,13 @@ void SpawnGolum(int i, int x, int y, int mi) monster[i]._moldx = x; monster[i]._moldy = y; monster[i]._pathcount = 0; - monster[i]._mFlags |= MFLAG_GOLEM; - monster[i].mArmorClass = 25; monster[i]._mmaxhp = 2 * (320 * missile[mi]._mispllvl + plr[i]._pMaxMana / 3); monster[i]._mhitpoints = monster[i]._mmaxhp; + monster[i].mArmorClass = 25; monster[i].mHit = 5 * (missile[mi]._mispllvl + 8) + 2 * plr[i]._pLevel; monster[i].mMinDamage = 2 * (missile[mi]._mispllvl + 4); monster[i].mMaxDamage = 2 * (missile[mi]._mispllvl + 8); + monster[i]._mFlags |= MFLAG_GOLEM; M_StartSpStand(i, 0); M_Enemy(i); if (i == myplr) { From 9d3bcb0de38379e04f52249206bea30ee747c2dc Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 00:07:26 +0100 Subject: [PATCH 14/26] [hellfire] MAI_Zhar --- Source/monster.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index b33606e9a..37e3b7f31 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5098,7 +5098,11 @@ void MAI_Zhar(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_Zhar: Invalid monster %d", i); +#endif Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { From d0328a3ee8721db367f22799805f1f9b8030bc54 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 00:09:21 +0100 Subject: [PATCH 15/26] [hellfire] MAI_SnotSpil --- Source/monster.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 37e3b7f31..c32113358 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5094,7 +5094,7 @@ void MAI_Garbud(int i) void MAI_Zhar(int i) { - int mx, my, _mx, _my, md; + int mx, my, md; MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) @@ -5118,12 +5118,12 @@ void MAI_Zhar(int i) } if (dFlags[mx][my] & BFLAG_VISIBLE) { - _mx = Monst->_mx - Monst->_menemyx; - _my = Monst->_my - Monst->_menemyy; - if (abs(_mx) > abs(_my)) - abs(_mx); + mx = Monst->_mx - Monst->_menemyx; + my = Monst->_my - Monst->_menemyy; + if (abs(mx) > abs(my)) + abs(mx); else - abs(_my); + abs(my); #ifndef SPAWN if (Monst->mtalkmsg == TEXT_ZHAR2) { if (!effect_is_playing(USFX_ZHAR2) && Monst->_mgoal == MGOAL_TALKING) { @@ -5150,7 +5150,11 @@ void MAI_SnotSpil(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_SnotSpil: Invalid monster %d", i); +#endif Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { From 5f9719d210d0472fc548ca53ef9f848e4173211d Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 00:24:29 +0100 Subject: [PATCH 16/26] [hellfire] MAI_SkelKing --- Source/monster.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index c32113358..052df3f50 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4766,7 +4766,11 @@ void MAI_SkelKing(int i) int dist, v, md; if ((DWORD)i >= MAXMONSTERS) - app_fatal("MAI_SkelKing: Invalid monster %d", i); +#ifdef HELLFIRE + return; +#else + app_fatal("MAI_SkelKing: Invalid monster %d",i); +#endif Monst = &monster[i]; if (Monst->_mmode == MM_STAND && Monst->_msquelch != 0) { fx = Monst->_menemyx; From 4dfc1f667496bccca8a902c63b48cc7b95b11b95 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 00:26:29 +0100 Subject: [PATCH 17/26] [hellfire] MAI_Counselor --- Source/monster.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index 052df3f50..7a3fb1289 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4981,7 +4981,11 @@ void MAI_Counselor(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_Counselor: Invalid monster %d", i); +#endif if (monster[i]._mmode == MM_STAND && monster[i]._msquelch != 0) { Monst = &monster[i]; fx = Monst->_menemyx; From 0c01aa99282360e4d94ad49d28bb975100362392 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 14 Jan 2021 18:29:16 +0100 Subject: [PATCH 18/26] [hellfire] M_TryH2HHit --- Source/missiles.cpp | 6 ++-- Source/monster.cpp | 81 ++++++++++++++++++++++++++++++++++++--------- Source/pack.cpp | 6 ++-- Source/player.cpp | 4 +-- structs.h | 4 +-- 5 files changed, 76 insertions(+), 25 deletions(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 0728fd7b4..4159e634a 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1474,7 +1474,7 @@ void InitMissiles() } } #ifdef HELLFIRE - plr[myplr].wReflection = FALSE; + plr[myplr].wReflections = 0; #endif } @@ -1616,7 +1616,7 @@ void missiles_reflection(int mi, int sx, int sy, int dx, int dy, int midir, char lvl = missile[mi]._mispllvl; else lvl = 2; - plr[id].wReflection += lvl * plr[id]._pLevel; + plr[id].wReflections += lvl * plr[id]._pLevel; UseMana(id, SPL_REFLECT); } missile[mi]._mirange = 0; @@ -4448,7 +4448,7 @@ void mi_reflect(int i) } if (src != myplr && currlevel != plr[src].plrlevel) missile[i]._miDelFlag = TRUE; - if ((WORD)plr[src].wReflection <= 0) { + if (plr[src].wReflections <= 0) { missile[i]._miDelFlag = TRUE; NetSendCmd(TRUE, CMD_REFLECT); } diff --git a/Source/monster.cpp b/Source/monster.cpp index 7a3fb1289..fc415da7d 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -2556,12 +2556,20 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) int blk, blkper; int dam, mdam; int newx, newy; - int j, misnum, ms_num, cur_ms_num, new_hp; + int j, misnum, ms_num, cur_ms_num, new_hp, dir, ac; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("M_TryH2HHit: Invalid monster %d", i); +#endif if (monster[i].MType == NULL) +#ifdef HELLFIRE + return; +#else app_fatal("M_TryH2HHit: Monster %d \"%s\" MType NULL", i, monster[i].mName); +#endif if (monster[i]._mFlags & MFLAG_TARGETS_MONSTER) { M_TryM2MHit(i, pnum, Hit, MinDam, MaxDam); return; @@ -2577,12 +2585,18 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) #ifdef _DEBUG if (debug_mode_dollar_sign || debug_mode_key_inverted_v) hper = 1000; +#endif + ac = plr[pnum]._pIBonusAC + plr[pnum]._pIAC; +#ifdef HELLFIRE + if (plr[pnum].pDamAcFlags & 0x20 && monster[i].MData->mMonstClass == MC_DEMON) + ac += 40; + if (plr[pnum].pDamAcFlags & 0x40 && monster[i].MData->mMonstClass == MC_UNDEAD) + ac += 20; #endif hit = Hit + 2 * (monster[i].mLevel - plr[pnum]._pLevel) + 30 - - plr[pnum]._pIBonusAC - - plr[pnum]._pIAC + - ac - plr[pnum]._pDexterity / 5; if (hit < 15) hit = 15; @@ -2608,7 +2622,26 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) if (hper >= hit) return; if (blkper < blk) { - StartPlrBlock(pnum, GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mx, monster[i]._my)); + dir = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mx, monster[i]._my); + StartPlrBlock(pnum, dir); +#ifdef HELLFIRE + if (pnum == myplr && plr[pnum].wReflections > 0) { + plr[pnum].wReflections--; + dam = random_(99, (MaxDam - MinDam + 1) << 6) + (MinDam << 6); + dam += plr[pnum]._pIGetHit << 6; + if (dam < 64) + dam = 64; + mdam = dam * (0.01 * (random_(100, 10) + 20)); + monster[i]._mhitpoints -= mdam; + dam -= mdam; + if (dam < 0) + dam = 0; + if (monster[i]._mhitpoints >> 6 <= 0) + M_StartKill(i, pnum); + else + M_StartHit(i, pnum, mdam); + } +#endif return; } if (monster[i].MType->mtype == MT_YZOMBIE && pnum == myplr) { @@ -2624,20 +2657,21 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) ms_num = misnum; } if (plr[pnum]._pMaxHP > 64) { - if (plr[pnum]._pMaxHPBase > 64) { - new_hp = plr[pnum]._pMaxHP - 64; - plr[pnum]._pMaxHP = new_hp; - if (plr[pnum]._pHitPoints > new_hp) { - plr[pnum]._pHitPoints = new_hp; +#ifndef HELLFIRE + if (plr[pnum]._pMaxHPBase > 64) +#endif + { + plr[pnum]._pMaxHP -= 64; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; if (cur_ms_num >= 0) - missile[cur_ms_num]._miVar1 = new_hp; + missile[cur_ms_num]._miVar1 = plr[pnum]._pHitPoints; } - new_hp = plr[pnum]._pMaxHPBase - 64; - plr[pnum]._pMaxHPBase = new_hp; - if (plr[pnum]._pHPBase > new_hp) { - plr[pnum]._pHPBase = new_hp; + plr[pnum]._pMaxHPBase -= 64; + if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; if (cur_ms_num >= 0) - missile[cur_ms_num]._miVar2 = new_hp; + missile[cur_ms_num]._miVar2 = plr[pnum]._pHPBase; } } } @@ -2647,6 +2681,20 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) if (dam < 64) dam = 64; if (pnum == myplr) { +#ifdef HELLFIRE + if (plr[pnum].wReflections > 0) { + plr[pnum].wReflections--; + mdam = dam * (0.01 * (random_(100, 10) + 20)); + monster[i]._mhitpoints -= mdam; + dam -= mdam; + if (dam < 0) + dam = 0; + if (monster[i]._mhitpoints >> 6 <= 0) + M_StartKill(i, pnum); + else + M_StartHit(i, pnum, mdam); + } +#endif plr[pnum]._pHitPoints -= dam; plr[pnum]._pHPBase -= dam; } @@ -2666,6 +2714,9 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) } if (plr[pnum]._pHitPoints >> 6 <= 0) { SyncPlrKill(pnum, 0); +#ifdef HELLFIRE + M_StartStand(i, monster[i]._mdir); +#endif return; } StartPlrHit(pnum, dam, FALSE); diff --git a/Source/pack.cpp b/Source/pack.cpp index 422a1d10d..65096ac34 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -78,7 +78,7 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) pPack->pMemSpells = pPlayer->_pMemSpells; #ifdef HELLFIRE - for (i = 0; i <= 36; i++) // Should be MAX_SPELLS-1 but set to 36 to make save games compatible + for (i = 0; i <= 36; i++) // Should be MAX_SPELLS-1 but set to 36 to make save games compatible pPack->pSplLvl[i] = pPlayer->_pSplLvl[i]; char *p = pPack->pSplLvl2; for (i = 37; i < 47; i++) @@ -120,7 +120,7 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) } #ifdef HELLFIRE - pPack->wReflection = pPlayer->wReflection; + pPack->wReflections = pPlayer->wReflections; pPack->pDiabloKillLevel = pPlayer->pDiabloKillLevel; pPack->pDifficulty = pPlayer->pDifficulty; pPack->pDamAcFlags = pPlayer->pDamAcFlags; @@ -288,7 +288,7 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok) CalcPlrInv(pnum, FALSE); #ifdef HELLFIRE - pPlayer->wReflection = pPack->wReflection; + pPlayer->wReflections = pPack->wReflections; #endif pPlayer->pTownWarps = 0; pPlayer->pDungMsgs = 0; diff --git a/Source/player.cpp b/Source/player.cpp index 91b2e3f6f..2d6ab6bcd 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -704,7 +704,7 @@ void ClearPlrRVars(PlayerStruct *p) p->bReserved[2] = 0; #ifndef HELLFIRE - p->wReflection = 0; + p->wReflections = 0; #endif p->wReserved[0] = 0; p->wReserved[1] = 0; @@ -934,7 +934,7 @@ void CreatePlayer(int pnum, char c) plr[pnum].pManaShield = FALSE; #else plr[pnum].pDamAcFlags = 0; - plr[pnum].wReflection = 0; + plr[pnum].wReflections = 0; #endif InitDungMsgs(pnum); diff --git a/structs.h b/structs.h index 30dd4ea5a..a12303d1d 100644 --- a/structs.h +++ b/structs.h @@ -348,7 +348,7 @@ typedef struct PlayerStruct { #endif BOOLEAN pManaShield; char bReserved[3]; - short wReflection; + WORD wReflections; short wReserved[7]; DWORD pDiabloKillLevel; int pDifficulty; @@ -1500,7 +1500,7 @@ typedef struct PkPlayerStruct { #endif BOOLEAN pManaShield; char bReserved[3]; - short wReflection; + WORD wReflections; short wReserved2; char pSplLvl2[10]; // Hellfire spells short wReserved8; From 92e193b7568b7441ae3bbbdc190157e5a422c651 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 02:39:20 +0100 Subject: [PATCH 19/26] [hellfire] MAI_Rhino --- Source/monster.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index fc415da7d..d83b8e8e4 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4820,7 +4820,7 @@ void MAI_SkelKing(int i) #ifdef HELLFIRE return; #else - app_fatal("MAI_SkelKing: Invalid monster %d",i); + app_fatal("MAI_SkelKing: Invalid monster %d", i); #endif Monst = &monster[i]; if (Monst->_mmode == MM_STAND && Monst->_msquelch != 0) { @@ -4889,7 +4889,11 @@ void MAI_Rhino(int i) int v, dist, md; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_Rhino: Invalid monster %d", i); +#endif Monst = &monster[i]; if (Monst->_mmode == MM_STAND && Monst->_msquelch != 0) { fx = Monst->_menemyx; @@ -4927,8 +4931,8 @@ void MAI_Rhino(int i) if (AddMissile(Monst->_mx, Monst->_my, fx, fy, md, MIS_RHINO, Monst->_menemy, i, 0, 0) != -1) { if (Monst->MData->snd_special) PlayEffect(i, 3); - Monst->_mmode = MM_CHARGE; dMonster[Monst->_mx][Monst->_my] = -1 - i; + Monst->_mmode = MM_CHARGE; } } else { if (abs(mx) >= 2 || abs(my) >= 2) { From e12f6a35bba0a6d5cdf704d5683e2a51641c0749 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 18:57:49 +0100 Subject: [PATCH 20/26] [hellfire] MAI_Lazurus --- Source/monster.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index d83b8e8e4..1e080efa7 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5269,7 +5269,11 @@ void MAI_Lazurus(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_Lazurus: Invalid monster %d", i); +#endif Monst = &monster[i]; if (monster[i]._mmode != MM_STAND) { @@ -5281,7 +5285,7 @@ void MAI_Lazurus(int i) md = M_GetDir(i); if (dFlags[mx][my] & BFLAG_VISIBLE) { if (gbMaxPlayers == 1) { - if (Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr]._px == TEXT_VILE13 && plr[myplr]._py == 46) { + if (Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr]._px == 35 && plr[myplr]._py == 46) { PlayInGameMovie("gendata\\fprst3.smk"); Monst->_mmode = MM_TALK; quests[Q_BETRAYER]._qvar1 = 5; @@ -5291,10 +5295,10 @@ void MAI_Lazurus(int i) if (Monst->mtalkmsg == TEXT_VILE13 && !effect_is_playing(USFX_LAZ1) && Monst->_mgoal == MGOAL_TALKING) { ObjChangeMapResync(1, 18, 20, 24); RedoPlayerVision(); - Monst->_msquelch = UCHAR_MAX; - Monst->mtalkmsg = 0; quests[Q_BETRAYER]._qvar1 = 6; Monst->_mgoal = MGOAL_NORMAL; + Monst->_msquelch = UCHAR_MAX; + Monst->mtalkmsg = 0; } #endif } @@ -5305,7 +5309,9 @@ void MAI_Lazurus(int i) } if (Monst->_mgoal == MGOAL_NORMAL || Monst->_mgoal == MGOAL_RETREAT || Monst->_mgoal == MGOAL_MOVE) { +#ifndef HELLFIRE Monst->mtalkmsg = 0; +#endif MAI_Counselor(i); } From b5f35674006ccb741170f35f170d86b92ea4b34e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 19:09:08 +0100 Subject: [PATCH 21/26] [hellfire] MAI_Lazhelp --- Source/monster.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 1e080efa7..9672ba4cc 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5328,7 +5328,11 @@ void MAI_Lazhelp(int i) MonsterStruct *Monst; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MAI_Lazhelp: Invalid monster %d", i); +#endif if (monster[i]._mmode != MM_STAND) return; @@ -5342,8 +5346,8 @@ void MAI_Lazhelp(int i) if (quests[Q_BETRAYER]._qvar1 <= 5) { Monst->_mgoal = MGOAL_INQUIRING; } else { - Monst->mtalkmsg = 0; Monst->_mgoal = MGOAL_NORMAL; + Monst->mtalkmsg = 0; } } else Monst->_mgoal = MGOAL_NORMAL; From 966ae9c8f58a6e4618423b5ea63d03cf85af1568 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 15 Jan 2021 23:00:42 +0100 Subject: [PATCH 22/26] [hellfire] DirOK --- Source/monster.cpp | 13 +++++++------ comparer-config/hellfire.toml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 9672ba4cc..436dfa7b8 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5661,7 +5661,11 @@ BOOL DirOK(int i, int mdir) int mcount, mi; if ((DWORD)i >= MAXMONSTERS) +#ifdef HELLFIRE + return FALSE; +#else app_fatal("DirOK: Invalid monster %d", i); +#endif fx = monster[i]._mx + offset_x[mdir]; fy = monster[i]._my + offset_y[mdir]; if (fy < 0 || fy >= MAXDUNY || fx < 0 || fx >= MAXDUNX || !PosOkMonst(i, fx, fy)) @@ -5669,16 +5673,13 @@ BOOL DirOK(int i, int mdir) if (mdir == DIR_E) { if (SolidLoc(fx, fy + 1) || dFlags[fx][fy + 1] & BFLAG_MONSTLR) return FALSE; - } - if (mdir == DIR_W) { + } else if (mdir == DIR_W) { if (SolidLoc(fx + 1, fy) || dFlags[fx + 1][fy] & BFLAG_MONSTLR) return FALSE; - } - if (mdir == DIR_N) { + } else if (mdir == DIR_N) { if (SolidLoc(fx + 1, fy) || SolidLoc(fx, fy + 1)) return FALSE; - } - if (mdir == DIR_S) + } else if (mdir == DIR_S) if (SolidLoc(fx - 1, fy) || SolidLoc(fx, fy - 1)) return FALSE; if (monster[i].leaderflag == 1) { diff --git a/comparer-config/hellfire.toml b/comparer-config/hellfire.toml index 9fad3b438..9f9b136bf 100644 --- a/comparer-config/hellfire.toml +++ b/comparer-config/hellfire.toml @@ -5360,7 +5360,7 @@ size = 0x6A [[func]] name = "DirOK" addr = 0x443C02 -size = 0x1FF +size = 0x1F6 [[func]] name = "PosOkMissile" From a6af2690f0d211d1685ece23bdb84911adfa8cee Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 16 Jan 2021 01:02:47 +0100 Subject: [PATCH 23/26] Clean up LineClearF --- Source/monster.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 436dfa7b8..cdd6b5287 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5730,6 +5730,7 @@ BOOL LineClearF(BOOL (*Clear)(int, int), int x1, int y1, int x2, int y2) int d; int xincD, yincD, dincD, dincH; int tmp; + BOOL done = FALSE; xorg = x1; yorg = y1; @@ -5748,16 +5749,16 @@ BOOL LineClearF(BOOL (*Clear)(int, int), int x1, int y1, int x2, int y2) } if (dy > 0) { d = 2 * dy - dx; - dincH = 2 * (dy - dx); dincD = 2 * dy; + dincH = 2 * (dy - dx); yincD = 1; } else { d = 2 * dy + dx; - dincH = 2 * (dx + dy); dincD = 2 * dy; + dincH = 2 * (dx + dy); yincD = -1; } - while (x1 != x2 || y1 != y2) { + while (!done && (x1 != x2 || y1 != y2)) { if ((d <= 0) ^ (yincD < 0)) { d += dincD; } else { @@ -5765,8 +5766,7 @@ BOOL LineClearF(BOOL (*Clear)(int, int), int x1, int y1, int x2, int y2) y1 += yincD; } x1++; - if ((x1 != xorg || y1 != yorg) && !Clear(x1, y1)) - break; + done = ((x1 != xorg || y1 != yorg) && !Clear(x1, y1)); } } else { if (dy < 0) { @@ -5781,16 +5781,16 @@ BOOL LineClearF(BOOL (*Clear)(int, int), int x1, int y1, int x2, int y2) } if (dx > 0) { d = 2 * dx - dy; - dincH = 2 * (dx - dy); dincD = 2 * dx; + dincH = 2 * (dx - dy); xincD = 1; } else { d = 2 * dx + dy; - dincH = 2 * (dy + dx); dincD = 2 * dx; + dincH = 2 * (dy + dx); xincD = -1; } - while (y1 != y2 || x1 != x2) { + while (!done && (y1 != y2 || x1 != x2)) { if ((d <= 0) ^ (xincD < 0)) { d += dincD; } else { @@ -5798,8 +5798,7 @@ BOOL LineClearF(BOOL (*Clear)(int, int), int x1, int y1, int x2, int y2) x1 += xincD; } y1++; - if ((y1 != yorg || x1 != xorg) && !Clear(x1, y1)) - break; + done = ((y1 != yorg || x1 != xorg) && !Clear(x1, y1)); } } return x1 == x2 && y1 == y2; From 578471a030dbea94a33fffe6663dbf9845fb8b19 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 16 Jan 2021 01:22:22 +0100 Subject: [PATCH 24/26] Clean up LineClear --- Source/monster.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index cdd6b5287..92fc75a53 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5811,11 +5811,12 @@ BOOL LineClear(int x1, int y1, int x2, int y2) BOOL LineClearF1(BOOL (*Clear)(int, int, int), int monst, int x1, int y1, int x2, int y2) { - int xorg, yorg; int dx, dy; int d; + int xorg, yorg; int xincD, yincD, dincD, dincH; int tmp; + BOOL done = FALSE; xorg = x1; yorg = y1; @@ -5834,16 +5835,16 @@ BOOL LineClearF1(BOOL (*Clear)(int, int, int), int monst, int x1, int y1, int x2 } if (dy > 0) { d = 2 * dy - dx; - dincH = 2 * (dy - dx); dincD = 2 * dy; + dincH = 2 * (dy - dx); yincD = 1; } else { d = 2 * dy + dx; - dincH = 2 * (dx + dy); dincD = 2 * dy; + dincH = 2 * (dx + dy); yincD = -1; } - while (x1 != x2 || y1 != y2) { + while (!done && (x1 != x2 || y1 != y2)) { if ((d <= 0) ^ (yincD < 0)) { d += dincD; } else { @@ -5851,8 +5852,7 @@ BOOL LineClearF1(BOOL (*Clear)(int, int, int), int monst, int x1, int y1, int x2 y1 += yincD; } x1++; - if ((x1 != xorg || y1 != yorg) && !Clear(monst, x1, y1)) - break; + done = ((x1 != xorg || y1 != yorg) && !Clear(monst, x1, y1)); } } else { if (dy < 0) { @@ -5867,16 +5867,16 @@ BOOL LineClearF1(BOOL (*Clear)(int, int, int), int monst, int x1, int y1, int x2 } if (dx > 0) { d = 2 * dx - dy; - dincH = 2 * (dx - dy); dincD = 2 * dx; + dincH = 2 * (dx - dy); xincD = 1; } else { d = 2 * dx + dy; - dincH = 2 * (dy + dx); dincD = 2 * dx; + dincH = 2 * (dy + dx); xincD = -1; } - while (y1 != y2 || x1 != x2) { + while (!done && (y1 != y2 || x1 != x2)) { if ((d <= 0) ^ (xincD < 0)) { d += dincD; } else { @@ -5884,8 +5884,7 @@ BOOL LineClearF1(BOOL (*Clear)(int, int, int), int monst, int x1, int y1, int x2 x1 += xincD; } y1++; - if ((y1 != yorg || x1 != xorg) && !Clear(monst, x1, y1)) - break; + done = ((y1 != yorg || x1 != xorg) && !Clear(monst, x1, y1)); } } return x1 == x2 && y1 == y2; From 8a0ab18ae96be29e7b11e247ccaa9eaf14c6b20c Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 16 Jan 2021 01:35:38 +0100 Subject: [PATCH 25/26] [hellfire] PrintMonstHistory --- Source/monster.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index 92fc75a53..f19703d67 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -6015,6 +6015,15 @@ void PrintMonstHistory(int mt) minHP = 1; if (maxHP < 1) maxHP = 1; +#ifdef HELLFIRE + if (gnDifficulty == DIFF_NIGHTMARE) { + minHP = 3 * minHP + (gbMaxPlayers == 1 ? 50 : 100); + maxHP = 3 * maxHP + (gbMaxPlayers == 1 ? 50 : 100); + } else if (gnDifficulty == DIFF_HELL) { + minHP = 4 * minHP + (gbMaxPlayers == 1 ? 100 : 200); + maxHP = 4 * maxHP + (gbMaxPlayers == 1 ? 100 : 200); + } +#else if (gnDifficulty == DIFF_NIGHTMARE) { minHP = 3 * minHP + 1; maxHP = 3 * maxHP + 1; @@ -6023,6 +6032,7 @@ void PrintMonstHistory(int mt) minHP = 4 * minHP + 3; maxHP = 4 * maxHP + 3; } +#endif sprintf(tempstr, "Hit Points : %i-%i", minHP, maxHP); AddPanelString(tempstr, TRUE); } From 21fe5b7daf8e08946afbfe628951e9bfac640a6f Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 16 Jan 2021 01:42:53 +0100 Subject: [PATCH 26/26] [hellfire] MissToMonst --- Source/monster.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index f19703d67..ae097da90 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -6107,13 +6107,21 @@ void MissToMonst(int i, int x, int y) MonsterStruct *Monst; if ((DWORD)i >= MAXMISSILES) +#ifdef HELLFIRE + return; +#else app_fatal("MissToMonst: Invalid missile %d", i); +#endif Miss = &missile[i]; m = Miss->_misource; if ((DWORD)m >= MAXMONSTERS) +#ifdef HELLFIRE + return; +#else app_fatal("MissToMonst: Invalid monster %d", m); +#endif Monst = &monster[m]; oldx = Miss->_mix;