Fix combat text: separate incoming/outgoing positions and clarify dodge/parry

Outgoing events (player attacks enemy: damage dealt, Dodge/Parry when enemy
evades) now float on the right side of screen (near target) instead of above
the player character. Incoming events (enemy attacks player) remain at
center-left (near player).

Dodge/Parry labels now show direction: "Dodge"/"Parry" when the enemy evades
the player's attack (outgoing, gray), and "You Dodge"/"You Parry" when the
player evades an incoming attack (cyan). Crit damage now has distinct colors
for outgoing (bright yellow) vs incoming (orange).
This commit is contained in:
Kelsi 2026-02-17 15:24:39 -08:00
parent be424919e4
commit fa4f78ddcc

View file

@ -3656,11 +3656,16 @@ void GameScreen::renderCombatText(game::GameHandler& gameHandler) {
ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav; ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav;
if (ImGui::Begin("##CombatText", nullptr, flags)) { if (ImGui::Begin("##CombatText", nullptr, flags)) {
float centerX = screenW / 2.0f; // Incoming events (enemy attacks player) float near screen center (over the player).
int index = 0; // Outgoing events (player attacks enemy) float on the right side (near the target).
const float incomingX = screenW * 0.40f;
const float outgoingX = screenW * 0.68f;
int inIdx = 0, outIdx = 0;
for (const auto& entry : entries) { for (const auto& entry : entries) {
float alpha = 1.0f - (entry.age / game::CombatTextEntry::LIFETIME); float alpha = 1.0f - (entry.age / game::CombatTextEntry::LIFETIME);
float yOffset = 200.0f - entry.age * 60.0f; float yOffset = 200.0f - entry.age * 60.0f;
const bool outgoing = entry.isPlayerSource;
ImVec4 color; ImVec4 color;
char text[64]; char text[64];
@ -3668,13 +3673,15 @@ void GameScreen::renderCombatText(game::GameHandler& gameHandler) {
case game::CombatTextEntry::MELEE_DAMAGE: case game::CombatTextEntry::MELEE_DAMAGE:
case game::CombatTextEntry::SPELL_DAMAGE: case game::CombatTextEntry::SPELL_DAMAGE:
snprintf(text, sizeof(text), "-%d", entry.amount); snprintf(text, sizeof(text), "-%d", entry.amount);
color = entry.isPlayerSource ? color = outgoing ?
ImVec4(1.0f, 1.0f, 0.3f, alpha) : // Outgoing = yellow ImVec4(1.0f, 1.0f, 0.3f, alpha) : // Outgoing = yellow
ImVec4(1.0f, 0.3f, 0.3f, alpha); // Incoming = red ImVec4(1.0f, 0.3f, 0.3f, alpha); // Incoming = red
break; break;
case game::CombatTextEntry::CRIT_DAMAGE: case game::CombatTextEntry::CRIT_DAMAGE:
snprintf(text, sizeof(text), "-%d!", entry.amount); snprintf(text, sizeof(text), "-%d!", entry.amount);
color = ImVec4(1.0f, 0.5f, 0.0f, alpha); // Orange for crit color = outgoing ?
ImVec4(1.0f, 0.8f, 0.0f, alpha) : // Outgoing crit = bright yellow
ImVec4(1.0f, 0.5f, 0.0f, alpha); // Incoming crit = orange
break; break;
case game::CombatTextEntry::HEAL: case game::CombatTextEntry::HEAL:
snprintf(text, sizeof(text), "+%d", entry.amount); snprintf(text, sizeof(text), "+%d", entry.amount);
@ -3689,12 +3696,16 @@ void GameScreen::renderCombatText(game::GameHandler& gameHandler) {
color = ImVec4(0.7f, 0.7f, 0.7f, alpha); color = ImVec4(0.7f, 0.7f, 0.7f, alpha);
break; break;
case game::CombatTextEntry::DODGE: case game::CombatTextEntry::DODGE:
snprintf(text, sizeof(text), "Dodge"); // outgoing=true: enemy dodged player's attack
color = ImVec4(0.7f, 0.7f, 0.7f, alpha); // outgoing=false: player dodged incoming attack
snprintf(text, sizeof(text), outgoing ? "Dodge" : "You Dodge");
color = outgoing ? ImVec4(0.6f, 0.6f, 0.6f, alpha)
: ImVec4(0.4f, 0.9f, 1.0f, alpha);
break; break;
case game::CombatTextEntry::PARRY: case game::CombatTextEntry::PARRY:
snprintf(text, sizeof(text), "Parry"); snprintf(text, sizeof(text), outgoing ? "Parry" : "You Parry");
color = ImVec4(0.7f, 0.7f, 0.7f, alpha); color = outgoing ? ImVec4(0.6f, 0.6f, 0.6f, alpha)
: ImVec4(0.4f, 0.9f, 1.0f, alpha);
break; break;
default: default:
snprintf(text, sizeof(text), "%d", entry.amount); snprintf(text, sizeof(text), "%d", entry.amount);
@ -3702,11 +3713,13 @@ void GameScreen::renderCombatText(game::GameHandler& gameHandler) {
break; break;
} }
// Stagger entries horizontally // Outgoing → right side (near target), incoming → center-left (near player)
float xOffset = centerX + (index % 3 - 1) * 80.0f; int& idx = outgoing ? outIdx : inIdx;
float baseX = outgoing ? outgoingX : incomingX;
float xOffset = baseX + (idx % 3 - 1) * 60.0f;
++idx;
ImGui::SetCursorPos(ImVec2(xOffset, yOffset)); ImGui::SetCursorPos(ImVec2(xOffset, yOffset));
ImGui::TextColored(color, "%s", text); ImGui::TextColored(color, "%s", text);
index++;
} }
} }
ImGui::End(); ImGui::End();