From 82bc85ee603bc1464b25b223d65b59736674cfa6 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 14 May 2025 17:56:38 +0200 Subject: [PATCH] a message on spikes hurt --- rogueviz/ru/classes.cpp | 10 ++++++++++ rogueviz/ru/entity.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index 5e09ce03..8d712ffc 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -221,6 +221,10 @@ struct entity { virtual void attacked(int s) {} + virtual void spiked() { + reduce_hp(10); + } + virtual string glyph() = 0; virtual color_t color() = 0; @@ -283,6 +287,12 @@ struct man : public entity { string get_help() override { return "This is you."; } void on_kill() override; + + virtual void spiked() { + entity::spiked(); + addMessage("OUCH! These spikes hurt!"); + } + }; extern man m; diff --git a/rogueviz/ru/entity.cpp b/rogueviz/ru/entity.cpp index 648ff42c..dda60d4d 100644 --- a/rogueviz/ru/entity.cpp +++ b/rogueviz/ru/entity.cpp @@ -97,7 +97,7 @@ void entity::apply_walls() { auto pain_effect = [&] { if(!hurt_by_spikes()) return false; - reduce_hp(10); + spiked(); vel.x = -vel.x; vel.y = -vel.y; apply_grav(); return true; };