From 6b8adfde9ee8764f21a8e5c2c9d2f969a61075a0 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 29 Oct 2023 07:58:55 +0100 Subject: [PATCH] crossbow:: fire_mode can now be enabled even while reloading --- crossbow.cpp | 11 ++++++++--- hud.cpp | 13 ++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crossbow.cpp b/crossbow.cpp index 561f454f..7b69dcd4 100644 --- a/crossbow.cpp +++ b/crossbow.cpp @@ -220,15 +220,14 @@ EX bool fire_mode; EX void switch_fire_mode() { if(!crossbow_mode()) { addMessage(XLAT("You fire an angry glance at your enemies.")); return; } - if(items[itCrossbow]) { addMessage(XLAT("You need more time to reload your crossbow!")); return; } if(!fire_mode) { - addMessage(XLAT("Double-click tile to fire.")); + addMessage(items[itCrossbow] ? XLAT("Note: cannot fire again yet. Turns to reload: %1.", its(items[itCrossbow])) : XLAT("Fire crossbow! Click to aim, click again to confirm.")); fire_mode = true; clear_bowpath(); targets = {}; } else if(fire_mode) { - addMessage(XLAT("Firing cancelled.")); + addMessage(items[itCrossbow] ? XLAT("Fire mode disabled.") : XLAT("Firing cancelled.")); fire_mode = false; clear_bowpath(); } @@ -238,6 +237,12 @@ EX void add_fire(cell *c) { bool emp = target_at.empty(); auto& t = target_at[c->cpdist]; if(t == c && !bow::bowpath.empty()) { + if(items[itCrossbow]) { + clear_bowpath(); + addMessage(XLAT("Cannot fire again yet. Turns to reload: %1.", its(items[itCrossbow]))); + fire_mode = false; + return; + } clear_bowpath(); checked_move_issue = miVALID; pcmove pcm; diff --git a/hud.cpp b/hud.cpp index a99f271d..07b80d01 100644 --- a/hud.cpp +++ b/hud.cpp @@ -145,9 +145,9 @@ int glyphflags(int gid) { if(gid < ittypes) { eItem i = eItem(gid); if(itemclass(i) == IC_NAI && i != itFatigue && i != itCrossbow) f |= GLYPH_NONUMBER; - if(i == itCrossbow && items[i] == 0) { + if(i == itCrossbow) { + if(items[i] == 0) f |= GLYPH_NONUMBER; if(bow::fire_mode) f |= GLYPH_ACTIVE; - f |= GLYPH_NONUMBER; } if(isElementalShard(i)) { f |= GLYPH_LOCAL | GLYPH_INSQUARE; @@ -335,7 +335,14 @@ void displayglyph2(int cx, int cy, int buttonsize, int i) { getcstat = 'i'; } if(it == itCrossbow) { - mouseovers += XLAT(" (click to use)"); + if(items[it]) + mouseovers += XLAT(" (turns to reload: %1)", its(items[it])); + else if(items[it] && bow::fire_mode) + mouseovers += XLAT(" (fire mode on / turns to reload: %1)", its(items[it])); + else if(bow::fire_mode) + mouseovers += XLAT(" (fire mode on)"); + else + mouseovers += XLAT(" (click to fire)"); getcstat = 'f'; } if(imp & GLYPH_LOCAL) mouseovers += XLAT(" (local treasure)");