From f331d3b5a4f2d650fc1206bd121a76c0fd7fe2cc Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 5 Sep 2019 15:12:53 +0200 Subject: [PATCH] Backport Hellfire cleanups --- Source/missiles.cpp | 8 ++++---- Source/monster.cpp | 38 +++++++++++++++----------------------- Source/player.cpp | 36 ++++++++++++++++++------------------ Source/player.h | 2 +- 4 files changed, 38 insertions(+), 46 deletions(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 0fd397ce2..73c75e7b6 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1835,9 +1835,9 @@ void AddFlare(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, i missile[mi]._mlid = AddLight(sx, sy, 8); if (!mienemy) { UseMana(id, SPL_FLARE); - drawhpflag = TRUE; plr[id]._pHitPoints -= 320; plr[id]._pHPBase -= 320; + drawhpflag = TRUE; if (plr[id]._pHitPoints <= 0) SyncPlrKill(id, 0); } else { @@ -1858,10 +1858,10 @@ void AddAcid(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in { GetMissileVel(mi, sx, sy, dx, dy, 16); SetMissDir(mi, GetDirection16(sx, sy, dx, dy)); + missile[mi]._mirange = 5 * (monster[id]._mint + 4); missile[mi]._mlid = -1; missile[mi]._miVar1 = sx; missile[mi]._miVar2 = sy; - missile[mi]._mirange = 5 * (monster[id]._mint + 4); PutMissile(mi); } @@ -2104,11 +2104,11 @@ void AddFirewallC(int mi, int sx, int sy, int dx, int dy, int midir, char mienem k = dPiece[tx][ty]; if (LineClear(sx, sy, tx, ty)) { if ((sx != tx || sy != ty) && !(nSolidTable[k] | dObject[tx][ty])) { - missile[mi]._miDelFlag = FALSE; missile[mi]._miVar1 = tx; missile[mi]._miVar2 = ty; missile[mi]._miVar5 = tx; missile[mi]._miVar6 = ty; + missile[mi]._miDelFlag = FALSE; i = 6; break; } @@ -2466,7 +2466,7 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas missile[mi]._mirnd = 0; if (missiledata[mitype].mlSFX != -1) { - PlaySfxLoc(missiledata[mitype].mlSFX, sx, sy); + PlaySfxLoc(missiledata[mitype].mlSFX, missile[mi]._misx, missile[mi]._misy); } missiledata[mitype].mAddProc(mi, sx, sy, dx, dy, midir, micaster, id, midam); diff --git a/Source/monster.cpp b/Source/monster.cpp index 5c9bf9275..c684add59 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -398,16 +398,16 @@ void InitMonster(int i, int rd, int mtype, int x, int y) monster[i]._mfuty = y; monster[i]._moldx = x; monster[i]._moldy = y; - monster[i]._mmode = MM_STAND; monster[i]._mMTidx = mtype; + monster[i]._mmode = MM_STAND; monster[i].mName = monst->MData->mName; monster[i].MType = monst; monster[i].MData = monst->MData; monster[i]._mAnimData = monst->Anims[MA_STAND].Data[rd]; monster[i]._mAnimDelay = monst->Anims[MA_STAND].Rate; - monster[i]._mAnimCnt = random(88, monst->Anims[MA_STAND].Rate - 1); + monster[i]._mAnimCnt = random(88, monster[i]._mAnimDelay - 1); monster[i]._mAnimLen = monst->Anims[MA_STAND].Frames; - monster[i]._mAnimFrame = random(88, monst->Anims[MA_STAND].Frames - 1) + 1; + monster[i]._mAnimFrame = random(88, monster[i]._mAnimLen - 1) + 1; if (monst->mtype == MT_DIABLO) { monster[i]._mmaxhp = (random(88, 1) + 1666) << 6; @@ -429,11 +429,11 @@ void InitMonster(int i, int rd, int mtype, int x, int y) monster[i]._mgoalvar1 = 0; monster[i]._mgoalvar2 = 0; monster[i]._mgoalvar3 = 0; + monster[i].field_18 = 0; monster[i]._pathcount = 0; + monster[i]._mDelFlag = FALSE; monster[i]._uniqtype = 0; monster[i]._msquelch = 0; - monster[i].field_18 = 0; - monster[i]._mDelFlag = FALSE; monster[i]._mRndSeed = GetRndSeed(); monster[i]._mAISeed = GetRndSeed(); monster[i].mWhoHit = 0; @@ -460,28 +460,28 @@ void InitMonster(int i, int rd, int mtype, int x, int y) } if (gnDifficulty == DIFF_NIGHTMARE) { - monster[i].mLevel += 15; - monster[i].mHit += 85; - monster[i].mHit2 += 85; monster[i]._mmaxhp = 3 * monster[i]._mmaxhp + 64; monster[i]._mhitpoints = monster[i]._mmaxhp; + monster[i].mLevel += 15; monster[i].mExp = 2 * (monster[i].mExp + 1000); + monster[i].mHit += 85; monster[i].mMinDamage = 2 * (monster[i].mMinDamage + 2); monster[i].mMaxDamage = 2 * (monster[i].mMaxDamage + 2); + monster[i].mHit2 += 85; monster[i].mMinDamage2 = 2 * (monster[i].mMinDamage2 + 2); monster[i].mMaxDamage2 = 2 * (monster[i].mMaxDamage2 + 2); monster[i].mArmorClass += 50; } if (gnDifficulty == DIFF_HELL) { - monster[i].mLevel += 30; monster[i]._mmaxhp = 4 * monster[i]._mmaxhp + 192; monster[i]._mhitpoints = monster[i]._mmaxhp; - monster[i].mHit += 120; - monster[i].mHit2 += 120; + monster[i].mLevel += 30; monster[i].mExp = 4 * (monster[i].mExp + 1000); + monster[i].mHit += 120; monster[i].mMinDamage = 4 * monster[i].mMinDamage + 6; monster[i].mMaxDamage = 4 * monster[i].mMaxDamage + 6; + monster[i].mHit2 += 120; monster[i].mMinDamage2 = 4 * monster[i].mMinDamage2 + 6; monster[i].mMaxDamage2 = 4 * monster[i].mMaxDamage2 + 6; monster[i].mArmorClass += 80; @@ -849,22 +849,14 @@ void PlaceGroup(int mtype, int num, int leaderf, int leader) dMonster[monster[nummonsters]._mx][monster[nummonsters]._my] = 0; } - x1 = 0; - y1 = 0; - xp = 0; - yp = 0; if (leaderf & 1) { int offset = random(92, 8); - xp = monster[leader]._mx + offset_x[offset]; - yp = monster[leader]._my + offset_y[offset]; - x1 = xp; - y1 = yp; + x1 = xp = monster[leader]._mx + offset_x[offset]; + y1 = yp = monster[leader]._my + offset_y[offset]; } else { do { - xp = random(93, 80) + 16; - x1 = xp; - yp = random(93, 80) + 16; - y1 = yp; + x1 = xp = random(93, 80) + 16; + y1 = yp = random(93, 80) + 16; } while (!MonstPlace(xp, yp)); } diff --git a/Source/player.cpp b/Source/player.cpp index 06caa495a..9b8934201 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -32,10 +32,10 @@ int plrxoff[9] = { 0, 2, 0, 2, 1, 0, 1, 2, 1 }; int plryoff[9] = { 0, 2, 2, 0, 1, 1, 0, 1, 2 }; int plrxoff2[9] = { 0, 1, 0, 1, 2, 0, 1, 2, 2 }; int plryoff2[9] = { 0, 0, 1, 1, 0, 2, 2, 1, 2 }; -char PlrGFXAnimLens[3][11] = { +char PlrGFXAnimLens[][11] = { { 10, 16, 8, 2, 20, 20, 6, 20, 8, 9, 14 }, { 8, 18, 8, 4, 20, 16, 7, 20, 8, 10, 12 }, - { 8, 16, 8, 6, 20, 12, 8, 20, 8, 12, 8 } + { 8, 16, 8, 6, 20, 12, 8, 20, 8, 12, 8 }, }; int PWVel[3][3] = { { 2048, 1024, 512 }, @@ -329,7 +329,8 @@ void InitPlrGFXMem(int pnum) DWORD GetPlrGFXSize(char *szCel) { - int c, a, w; + int c; + const char *a, *w; DWORD dwSize, dwMaxSize; HANDLE hsFile; char pszName[256]; @@ -342,13 +343,13 @@ DWORD GetPlrGFXSize(char *szCel) if (c != 0) continue; #endif - for (a = 0; ArmourChar[a]; a++) { + for (a = &ArmourChar[0]; *a; a++) { #ifdef SPAWN - if (&ArmourChar[a] != &ArmourChar[0]) + if (a != &ArmourChar[0]) break; #endif - for (w = 0; WepChar[w]; w++) { // BUGFIX loads non-existing animagions; DT is only for N, BT is only for U, D & H - sprintf(Type, "%c%c%c", CharChar[c], ArmourChar[a], WepChar[w]); + for (w = &WepChar[0]; *w; w++) { // BUGFIX loads non-existing animagions; DT is only for N, BT is only for U, D & H + sprintf(Type, "%c%c%c", CharChar[c], *a, *w); sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTbl[c], Type, Type, szCel); if (WOpenFile(pszName, &hsFile, TRUE)) { /// ASSERT: assert(hsFile); @@ -422,8 +423,6 @@ void SetPlrAnims(int pnum) app_fatal("SetPlrAnims: illegal player %d", pnum); } - pc = plr[pnum]._pClass; - plr[pnum]._pNWidth = 96; plr[pnum]._pWWidth = 96; plr[pnum]._pAWidth = 128; @@ -432,6 +431,8 @@ void SetPlrAnims(int pnum) plr[pnum]._pDWidth = 128; plr[pnum]._pBWidth = 96; + pc = plr[pnum]._pClass; + if (leveltype == DTYPE_TOWN) { plr[pnum]._pNFrames = PlrGFXAnimLens[pc][7]; plr[pnum]._pWFrames = PlrGFXAnimLens[pc][8]; @@ -666,7 +667,7 @@ void CreatePlayer(int pnum, char c) plr[pnum]._pLvlChanging = FALSE; plr[pnum].pTownWarps = 0; plr[pnum].pLvlLoad = 0; - plr[pnum].pBattleNet = 0; + plr[pnum].pBattleNet = FALSE; plr[pnum].pManaShield = FALSE; InitDungMsgs(pnum); @@ -691,7 +692,6 @@ int CalcStatDiff(int pnum) void NextPlrLevel(int pnum) { - char l, c; int hp, mana; if ((DWORD)pnum >= MAX_PLRS) { @@ -699,8 +699,6 @@ void NextPlrLevel(int pnum) } plr[pnum]._pLevel++; - l = plr[pnum]._pLevel; - plr[pnum]._pMaxLvl++; if (CalcStatDiff(pnum) < 5) { @@ -709,11 +707,9 @@ void NextPlrLevel(int pnum) plr[pnum]._pStatPts += 5; } - plr[pnum]._pNextExper = ExpLvlsTbl[l]; - - c = plr[pnum]._pClass; + plr[pnum]._pNextExper = ExpLvlsTbl[plr[pnum]._pLevel]; - hp = c == PC_SORCERER ? 64 : 128; + hp = plr[pnum]._pClass == PC_SORCERER ? 64 : 128; if (gbMaxPlayers == 1) { hp++; } @@ -726,7 +722,11 @@ void NextPlrLevel(int pnum) drawhpflag = TRUE; } - mana = c != PC_WARRIOR ? 128 : 64; + if (plr[pnum]._pClass == PC_WARRIOR) + mana = 64; + else + mana = 128; + if (gbMaxPlayers == 1) { mana++; } diff --git a/Source/player.h b/Source/player.h index 193de42da..bc6943b7f 100644 --- a/Source/player.h +++ b/Source/player.h @@ -121,7 +121,7 @@ extern int plrxoff[9]; extern int plryoff[9]; extern int plrxoff2[9]; extern int plryoff2[9]; -extern char PlrGFXAnimLens[3][11]; +extern char PlrGFXAnimLens[][11]; extern int PWVel[3][3]; extern int AnimLenFromClass[3]; extern int StrengthTbl[3];