combat: rewrite in Zig; add basic damage types and weapon archetypes

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ic8055a1cf6bdad1aca13673ea171b4b46a6a6964
This commit is contained in:
raf 2026-04-05 20:11:06 +03:00
commit 22ab6fc6eb
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
15 changed files with 802 additions and 158 deletions

View file

@ -138,24 +138,62 @@ void render_ui(const Player *p) {
int hp_text_w = MeasureText(hp_text, 14);
DrawText(hp_text, bar_x + (bar_width - hp_text_w) / 2, bar_y + 2, 14, WHITE);
// Status effect indicators next to HP bar
int effect_x = bar_x + bar_width + 5;
for (int i = 0; i < p->effect_count && i < MAX_EFFECTS; i++) {
Color eff_color;
const char *eff_label = "";
switch (p->effects[i].type) {
case EFFECT_POISON:
eff_color = (Color){50, 200, 50, 255};
eff_label = "PSN";
break;
case EFFECT_BLEED:
eff_color = (Color){200, 50, 50, 255};
eff_label = "BLD";
break;
case EFFECT_STUN:
eff_color = (Color){200, 200, 50, 255};
eff_label = "STN";
break;
case EFFECT_WEAKEN:
eff_color = (Color){120, 120, 120, 255};
eff_label = "WKN";
break;
case EFFECT_BURN:
eff_color = (Color){230, 130, 30, 255};
eff_label = "BRN";
break;
default:
continue;
}
if (p->effects[i].duration > 0) {
char eff_text[16];
snprintf(eff_text, sizeof(eff_text), "%s%d", eff_label, p->effects[i].duration);
DrawText(eff_text, effect_x, bar_y, 12, eff_color);
effect_x += 40;
}
}
// Stats row 1: Floor, ATK, DEF, Inv
int stats_x_start = (effect_x > bar_x + bar_width + 15) ? effect_x + 10 : bar_x + bar_width + 15;
int stats_y = bar_y;
DrawText("F1", bar_x + bar_width + 15, stats_y, 14, WHITE);
DrawText("ATK", bar_x + bar_width + 50, stats_y, 14, YELLOW);
DrawText("DEF", bar_x + bar_width + 100, stats_y, 14, BLUE);
DrawText("INV", bar_x + bar_width + 145, stats_y, 14, GREEN);
DrawText("F1", stats_x_start, stats_y, 14, WHITE);
DrawText("ATK", stats_x_start + 35, stats_y, 14, YELLOW);
DrawText("DEF", stats_x_start + 85, stats_y, 14, BLUE);
DrawText("INV", stats_x_start + 130, stats_y, 14, GREEN);
// Row 2: equipment slots and controls
int row2_y = stats_y + 24;
// Equipment (left side of row 2)
if (p->has_weapon) {
char weapon_text[48];
snprintf(weapon_text, sizeof(weapon_text), "Wpn:%s +%d", item_get_name(&p->equipped_weapon),
p->equipped_weapon.power);
char weapon_text[64];
snprintf(weapon_text, sizeof(weapon_text), "Wpn:%s +%d [%s]", item_get_name(&p->equipped_weapon),
p->equipped_weapon.power, dmg_class_get_short(p->equipped_weapon.dmg_class));
DrawText(weapon_text, 10, row2_y, 12, YELLOW);
} else {
DrawText("Wpn:---", 10, row2_y, 12, (Color){60, 60, 60, 255});
DrawText("Wpn:--- [IMP]", 10, row2_y, 12, (Color){60, 60, 60, 255});
}
if (p->has_armor) {