Skip to content

Commit

Permalink
Fix messaging and sidebar when negating inanimates
Browse files Browse the repository at this point in the history
  • Loading branch information
zenzombie committed Mar 23, 2024
1 parent ae8d652 commit 6ef7271
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 90 deletions.
1 change: 1 addition & 0 deletions changes/negate-inanimates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When an inanimate monster is negated (e.g. turret or totem), a combat message is now displayed and the sidebar will show the negated status.
173 changes: 84 additions & 89 deletions src/brogue/IO.c
Original file line number Diff line number Diff line change
Expand Up @@ -4633,103 +4633,98 @@ short printMonsterInfo(creature *monst, short y, boolean dim, boolean highlight)
}
}

if (monst != &player
&& (!(monst->info.flags & MONST_INANIMATE)
|| monst->creatureState == MONSTER_ALLY)) {

if (y < ROWS - 1) {
if (monst->wasNegated
&& monst->newPowerCount == monst->totalPowerCount
&& y < ROWS - 1
&& (!player.status[STATUS_HALLUCINATING] || rogue.playbackOmniscience )) {
printString(" Negated ", 0, y++, (dim ? &darkPink : &pink), &black, 0);
}
if (player.status[STATUS_HALLUCINATING] && !rogue.playbackOmniscience && y < ROWS - 1) {
printString(hallucinationStrings[rand_range(0, 9)], 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->bookkeepingFlags & MB_CAPTIVE && y < ROWS - 1) {
printString(" (Captive) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if ((monst->info.flags & MONST_RESTRICTED_TO_LIQUID)
&& !cellHasTMFlag(monst->loc, TM_ALLOWS_SUBMERGING)) {
printString(" (Helpless) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->creatureState == MONSTER_SLEEPING && y < ROWS - 1) {
printString(" (Sleeping) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if ((monst->creatureState == MONSTER_ALLY) && y < ROWS - 1) {
printString(" (Ally) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->creatureState == MONSTER_FLEEING && y < ROWS - 1) {
printString(" (Fleeing) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if ((monst->creatureState == MONSTER_WANDERING) && y < ROWS - 1) {
if ((monst->bookkeepingFlags & MB_FOLLOWER) && monst->leader && (monst->leader->info.flags & MONST_IMMOBILE)) {
// follower of an immobile leader -- i.e. a totem
printString(" (Worshiping) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if ((monst->bookkeepingFlags & MB_FOLLOWER) && monst->leader && (monst->leader->bookkeepingFlags & MB_CAPTIVE)) {
// actually a captor/torturer
printString(" (Guarding) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else {
printString(" (Wandering) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
}
} else if (monst->ticksUntilTurn > max(0, player.ticksUntilTurn) + player.movementSpeed) {
printString(" (Off balance) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if ((monst->creatureState == MONSTER_TRACKING_SCENT) && y < ROWS - 1) {
printString(" (Hunting) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
}
}
} else if (monst == &player) {
if (y < ROWS - 1) {
tempColorEscape[0] = '\0';
grayColorEscape[0] = '\0';
if (player.status[STATUS_WEAKENED]) {
tempColor = red;
if (dim) {
applyColorAverage(&tempColor, &black, 50);
}
encodeMessageColor(tempColorEscape, 0, &tempColor);
encodeMessageColor(grayColorEscape, 0, (dim ? &darkGray : &gray));
}

if (!rogue.armor || rogue.armor->flags & ITEM_IDENTIFIED || rogue.playbackOmniscience) {

sprintf(buf, "Str: %s%i%s Armor: %i",
tempColorEscape,
rogue.strength - player.weaknessAmount,
grayColorEscape,
displayedArmorValue());
} else {
sprintf(buf, "Str: %s%i%s Armor: %i?",
tempColorEscape,
rogue.strength - player.weaknessAmount,
grayColorEscape,
estimatedArmorValue());
}
//buf[20] = '\0';
printString(" ", 0, y, &white, &black, 0);
printString(buf, (20 - strLenWithoutEscapes(buf)) / 2, y++, (dim ? &darkGray : &gray), &black, 0);
}
if (y < ROWS - 1 && rogue.gold) {
sprintf(buf, "Gold: %li", rogue.gold);
buf[20] = '\0';
printString(" ", 0, y, &white, &black, 0);
printString(buf, (20 - strLenWithoutEscapes(buf)) / 2, y++, (dim ? &darkGray : &gray), &black, 0);
}
if (y < ROWS - 1) {
tempColorEscape[0] = '\0';
grayColorEscape[0] = '\0';
tempColor = playerInShadowColor;
percent = (rogue.stealthRange - 2) * 100 / 28;
applyColorAverage(&tempColor, &black, percent);
applyColorAugment(&tempColor, &playerInLightColor, percent);
if (monst == &player) {
if (y < ROWS - 1) {
tempColorEscape[0] = '\0';
grayColorEscape[0] = '\0';
if (player.status[STATUS_WEAKENED]) {
tempColor = red;
if (dim) {
applyColorAverage(&tempColor, &black, 50);
}
encodeMessageColor(tempColorEscape, 0, &tempColor);
encodeMessageColor(grayColorEscape, 0, (dim ? &darkGray : &gray));
sprintf(buf, "%sStealth range: %i%s",
}

if (!rogue.armor || rogue.armor->flags & ITEM_IDENTIFIED || rogue.playbackOmniscience) {

sprintf(buf, "Str: %s%i%s Armor: %i",
tempColorEscape,
rogue.strength - player.weaknessAmount,
grayColorEscape,
displayedArmorValue());
} else {
sprintf(buf, "Str: %s%i%s Armor: %i?",
tempColorEscape,
rogue.stealthRange,
grayColorEscape);
printString(" ", 0, y, &white, &black, 0);
printString(buf, 1, y++, (dim ? &darkGray : &gray), &black, 0);
rogue.strength - player.weaknessAmount,
grayColorEscape,
estimatedArmorValue());
}
//buf[20] = '\0';
printString(" ", 0, y, &white, &black, 0);
printString(buf, (20 - strLenWithoutEscapes(buf)) / 2, y++, (dim ? &darkGray : &gray), &black, 0);
}
if (y < ROWS - 1 && rogue.gold) {
sprintf(buf, "Gold: %li", rogue.gold);
buf[20] = '\0';
printString(" ", 0, y, &white, &black, 0);
printString(buf, (20 - strLenWithoutEscapes(buf)) / 2, y++, (dim ? &darkGray : &gray), &black, 0);
}
if (y < ROWS - 1) {
tempColorEscape[0] = '\0';
grayColorEscape[0] = '\0';
tempColor = playerInShadowColor;
percent = (rogue.stealthRange - 2) * 100 / 28;
applyColorAverage(&tempColor, &black, percent);
applyColorAugment(&tempColor, &playerInLightColor, percent);
if (dim) {
applyColorAverage(&tempColor, &black, 50);
}
encodeMessageColor(tempColorEscape, 0, &tempColor);
encodeMessageColor(grayColorEscape, 0, (dim ? &darkGray : &gray));
sprintf(buf, "%sStealth range: %i%s",
tempColorEscape,
rogue.stealthRange,
grayColorEscape);
printString(" ", 0, y, &white, &black, 0);
printString(buf, 1, y++, (dim ? &darkGray : &gray), &black, 0);
}
} else if (y < ROWS - 1) {
if (monst->wasNegated && monst->newPowerCount == monst->totalPowerCount
&& (!player.status[STATUS_HALLUCINATING] || rogue.playbackOmniscience )) {
printString(" Negated ", 0, y++, (dim ? &darkPink : &pink), &black, 0);
}
if (!(monst->info.flags & MONST_INANIMATE) && (y < ROWS - 1)) {
if (player.status[STATUS_HALLUCINATING] && !rogue.playbackOmniscience) {
printString(hallucinationStrings[rand_range(0, 9)], 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->bookkeepingFlags & MB_CAPTIVE) {
printString(" (Captive) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if ((monst->info.flags & MONST_RESTRICTED_TO_LIQUID)
&& !cellHasTMFlag(monst->loc, TM_ALLOWS_SUBMERGING)) {
printString(" (Helpless) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->creatureState == MONSTER_SLEEPING) {
printString(" (Sleeping) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->creatureState == MONSTER_ALLY) {
printString(" (Ally) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->creatureState == MONSTER_FLEEING) {
printString(" (Fleeing) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->creatureState == MONSTER_WANDERING) {
if ((monst->bookkeepingFlags & MB_FOLLOWER) && monst->leader && (monst->leader->info.flags & MONST_IMMOBILE)) {
// follower of an immobile leader -- i.e. a totem
printString(" (Worshiping) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if ((monst->bookkeepingFlags & MB_FOLLOWER) && monst->leader && (monst->leader->bookkeepingFlags & MB_CAPTIVE)) {
// actually a captor/torturer
printString(" (Guarding) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else {
printString(" (Wandering) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
}
} else if (monst->ticksUntilTurn > max(0, player.ticksUntilTurn) + player.movementSpeed) {
printString(" (Off balance) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
} else if (monst->creatureState == MONSTER_TRACKING_SCENT) {
printString(" (Hunting) ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
}
}
}

if (y < ROWS - 1) {
printString(" ", 0, y++, (dim ? &darkGray : &gray), &black, 0);
Expand Down
3 changes: 2 additions & 1 deletion src/brogue/Items.c
Original file line number Diff line number Diff line change
Expand Up @@ -3736,9 +3736,10 @@ boolean negate(creature *monst) {
}
for (i = 0; i < 20; i++) {
backupBolts[i] = monst->info.bolts[i];
monst->info.bolts[i] = BOLT_NONE;
if (monst->info.bolts[i] && !(boltCatalog[monst->info.bolts[i]].flags & BF_NOT_NEGATABLE)) {
monst->info.bolts[i] = BOLT_NONE;
negated = true;
monst->wasNegated = true;
}
}
for (i = 0, j = 0; i < 20 && backupBolts[i]; i++) {
Expand Down

0 comments on commit 6ef7271

Please sign in to comment.