Closed arrowgent closed 4 years ago
Yes. Replace the
if (pcursmonst != -1) {
in https://github.com/Manuel-K/devilutionX-QOL-patches/blob/master/infernity_monster_hp_bar_v01.patch#L162 with
if (pcursmonst != -1 && currlevel != 0) {
.
patch -p1 < infernity_monster_hp_bar_v01.patch patching file Source/scrollrt.cpp Hunk #1 FAILED at 1 (different line endings). Hunk #2 FAILED at 943 (different line endings). Hunk #3 FAILED at 997 (different line endings). 3 out of 3 hunks FAILED -- saving rejects to file Source/scrollrt.cpp.rej
--- Source/scrollrt.cpp
+++ Source/scrollrt.cpp
@@ -1,5 +1,7 @@
#include "all.h"
+#include <sstream>
+
DEVILUTION_BEGIN_NAMESPACE
/**
@@ -943,6 +945,133 @@ static void DrawGame(int x, int y)
// DevilutionX extension.
extern void DrawControllerModifierHints();
+void DrawMonsterHealthBar(int monsterID)
+{
+ static const int yPos = 180;
+ static const int width = 250;
+ static const int ScreenWidth = 640;
+ static const int Screen_LeftBorder = 64;
+ static const int xPos = (ScreenWidth) / 2 - Screen_LeftBorder;
+ static const int height = 25;
+ static const int xOffset = 0;
+ static const int yOffset = 0; // was 1
+ static const int borderWidth = 2;
+ static const int borderColors[] = { 242/*undead*/,232/*demon*/,182/*beast*/ };
+ static const int filledColor = 142; // optimum balance in bright red between dark and light
+ static const bool fillCorners = true;
+ static const int square = 10;
+ static const char* immuText = "IMMU: ";
+ static const char* resText = "RES: ";
+ static const char* vulnText = ":VULN";
+ static const int resSize = 3;
+ static const int resistColors[] = { 148, 140, 129 };
+ static const unsigned short immunes[] = { 0x8, 0x10, 0x20 };
+ static const unsigned short resists[] = { 0x1, 0x2, 0x4 };
+ static const bool cheat = false;
+
+ if (!monster[monsterID].MData) {
+ return;
+ }
+
+ MonsterStruct* mon = &monster[monsterID];
+ BOOL specialMonster = !!mon->_uniqtype;
+ int currentLife = mon->_mhitpoints;
+ int maxLife = mon->_mmaxhp;
+ if (currentLife > maxLife) {
+ maxLife = currentLife;
+ }
+ int borderColor = borderColors[mon->MData->mMonstClass];
+ float FilledPercent = (float)currentLife / (float)maxLife;
+ unsigned short mres = mon->mMagicRes;
+ bool showHPNumbers = cheat || monstkills[mon->MType->mtype] >= 30;
+ bool showDamageModifiers = cheat || monstkills[mon->MType->mtype] >= 15;
+
+ if (showDamageModifiers) {
+ int resOffset = 0 + CalculateTextWidth(resText);
+ for (int k = 0; k < resSize; ++k) {
+ if (!(mres & resists[k])) {
+ continue;
+ }
+ DrawSolidRectangle(xPos + resOffset, square, yPos + height + yOffset + borderWidth + 2, square, resistColors[k]);
+ resOffset += 12;
+ }
+
+ int vulOffset = width - square - CalculateTextWidth(vulnText) - 4;
+ for (int k = 0; k < resSize; ++k) {
+ if (mres & resists[k] || mres & immunes[k]) {
+ continue;
+ }
+ DrawSolidRectangle(xPos + vulOffset, square, yPos + height + yOffset + borderWidth + 2, square, resistColors[k]);
+ vulOffset -= 12;
+ }
+ }
+
+ DrawSolidRectangle(xPos, (int) ceil(FilledPercent * width), yPos, height, filledColor);
+
+ static const int cornerMod = fillCorners ? borderWidth : 0;
+ static const int x0 = xPos - xOffset;
+ static const int dx = width + 2*xOffset + cornerMod;
+ static const int y0 = yPos - yOffset;
+ static const int dy = height + 2*yOffset + cornerMod;
+ DrawSolidRectangle(x0 - cornerMod, dx, yPos - yOffset - borderWidth, borderWidth, borderColor);
+ DrawSolidRectangle(x0 , dx, yPos + yOffset + height, borderWidth, borderColor);
+ DrawSolidRectangle(xPos - xOffset - borderWidth, borderWidth, y0, dy, borderColor);
+ DrawSolidRectangle(xPos + xOffset + width, borderWidth, y0 - cornerMod, dy, borderColor);
+
+ bool drawImmu = false;
+ if (showDamageModifiers) {
+ int immuOffset = 0 + CalculateTextWidth(immuText) - 5;
+ for (int k = 0; k < resSize; ++k) {
+ if (!(mres & immunes[k])) {
+ continue;
+ }
+ drawImmu = true;
+ DrawSolidRectangle(xPos + immuOffset, square, yPos + height + yOffset + borderWidth + 2 - 15, square, resistColors[k]);
+ immuOffset += 12;
+ }
+ }
+
+ static const int newX = xPos + Screen_LeftBorder;
+ static const int newY = yPos + height - 3;
+ std::stringstream name;
+ name << mon->mName;
+ if (mon->leader > 0) {
+ name << " (minion)";
+ }
+ int namecolor = COL_WHITE;
+ if (specialMonster) { // || name.str() == "The Dark Lord"
+ namecolor = COL_GOLD;
+ }
+
+ if (!showHPNumbers) {
+ PrintGameStr(newX - CalculateTextWidth((char*)name.str().c_str()) / 2, 37, (char*)name.str().c_str(), namecolor);
+ } else {
+ static const int TWSlash = CalculateTextWidth("/");
+ PrintGameStr(newX - CalculateTextWidth((char*)name.str().c_str()) / 2, 30, (char*)name.str().c_str(), namecolor);
+ PrintGameStr(newX - TWSlash / 2, 43, "/", COL_WHITE);
+ std::stringstream current;
+ current << (currentLife >> 6);
+ std::stringstream max;
+ max << (maxLife >> 6);
+ PrintGameStr(newX + TWSlash, 43, (char*)max.str().c_str(), COL_WHITE);
+ PrintGameStr(newX - CalculateTextWidth((char*)current.str().c_str()) - TWSlash, 43, (char*)current.str().c_str(), COL_WHITE);
+ }
+ if (showDamageModifiers) {
+ PrintGameStr(newX - width / 2, 59, resText, COL_GOLD);
+ }
+
+ std::stringstream kills;
+ kills << "Kills: " << monstkills[mon->MType->mtype];
+ PrintGameStr(newX - CalculateTextWidth("kills")/2-30, 59, (char*)(kills.str().c_str()), COL_WHITE);
+
+ if (drawImmu) {
+ PrintGameStr(newX - width / 2, 46-2, immuText, COL_GOLD);
+ }
+ if (showDamageModifiers) {
+ PrintGameStr(newX + width / 2 - CalculateTextWidth(vulnText), 59, vulnText, COL_RED);
+ }
+}
+
/**
* @brief Start rendering of screen, town variation
* @param StartX Center of view in dPiece coordinate
@@ -997,6 +1126,9 @@ void DrawView(int StartX, int StartY)
gmenu_draw_pause();
}
+ if (pcursmonst != -1 && currlevel != 0) {
+ DrawMonsterHealthBar(pcursmonst);
+ }
DrawControllerModifierHints();
DrawPlrMsg();
gmenu_draw();
hmmm seems to work anyways.
as the previous one also threw hunk FAILED errors on 1.0.1
many thanks!!
ok so it just removes the hp bar entirely instead...
seems that
+945,133 @@ static void DrawGame(int x, int y)
moved to line 799
and
+1126,9 @@ void DrawView(int StartX, int StartY)
moved to line 951
i was able to manually add each segment into the scrollrt.cpp where required and compile
works as expected
That's weird. The patch should apply cleanly if you've used the correct version. That's the whole point of the updates that I make..
it did previously! im not sure why the src changed from the releases i didnt use -master- because it has new commits just regular v1.0.1
found the problem today while trying to create DIFF files
infernity_item_hightlight_v03.patch
adds to the scrollrt.cpp
doing both patches and Alphabetically after
infernity_common_v01.patch
infernity_item_hightlight_v03.patch
infernity_monster_hp_bar_v01.patch
causes the patch to break
possible to remove the hpbar from the people in town?