From 842a171016e366b594b50f79d753c138f92846b2 Mon Sep 17 00:00:00 2001 From: Peisong Xiao Date: Sat, 20 Jul 2024 15:40:11 -0400 Subject: [PATCH] throwing potions now identifies it --- src/arguments.cc | 2 +- src/enemies/witch.cc | 3 +++ src/player.cc | 5 ++++- src/player.h | 6 +++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/arguments.cc b/src/arguments.cc index b7f0f81..bad9016 100644 --- a/src/arguments.cc +++ b/src/arguments.cc @@ -288,7 +288,7 @@ const char *ENEMIES_LIST = "\ If PC doesn't have enough gold, hit instead with a strong attack of fixed Atk;\n\ Upon death, drops all stolen gold plus 5 extra.\n\n\ - Witch 'Z' (100 HP, 20 Atk, 15 Def, 1/2 Hit Rate):\n\ - Upon a successful hit, has a 1/5 chance of applying a random potion onto PC.\n\n\ + Upon a successful hit, has a 1/5 chance of applying a random potion onto PC (starts to take effect the next turn).\n\n\ - Hacker 'h' (90 HP, 15 Atk, 30 Def, 1/2 Hit Rate):\n\ He has been in grinding in MC for too long.\n\n\ - Baby Dragon 'B' (140 HP, 20 Atk, 40 Def, 1/3 Hit Rate):\n\ diff --git a/src/enemies/witch.cc b/src/enemies/witch.cc index 8fe0315..b0cee36 100644 --- a/src/enemies/witch.cc +++ b/src/enemies/witch.cc @@ -1,6 +1,7 @@ #include "witch.h" #include "../constants.h" +#include "../player.h" witch::witch(RNG *rng, const feature enabled_features, const position &pos, const int gen_room_num): @@ -22,6 +23,8 @@ long_result witch::attack(character *ch) { auto npotion = new_potion(type, {0, 0}); res.msg += std::string("Z's potion of ") + npotion->get_name() + " spilled onto PC. "; + static_cast(ch)->set_potion_known( + npotion->get_type()); ch->apply_effect(std::move(npotion)); } diff --git a/src/player.cc b/src/player.cc index acc3db9..2b3f893 100644 --- a/src/player.cc +++ b/src/player.cc @@ -141,9 +141,12 @@ long_result player_base::throw_potion(level *lvl, std::unique_ptr p, if (flag & WHAT_WALL) return {THROWN, "The potion shattered against a wall. "}; else if (flag & WHAT_ENEMY) { + std::string name{p->get_name()}; character *ch = lvl->get_elist()[flag ^ WHAT_ENEMY]; + known_potions |= 1 << p->get_type(); ch->apply_effect(std::move(p)); - return {THROWN, "The potion's contents spilled on " + + return {THROWN, "The potion of " + name + + "'s contents spilled on " + ch->get_abbrev() + ". "}; } } diff --git a/src/player.h b/src/player.h index 5029b78..795ac99 100644 --- a/src/player.h +++ b/src/player.h @@ -35,6 +35,9 @@ protected: inventory inv; int MAX_THROW_DIST; + + long_result throw_potion(level *lvl, + std::unique_ptr p, direction dir); public: player_base(RNG *rng, const feature enabled_features, const enum race &nrace); @@ -59,9 +62,6 @@ public: int get_DEF() const; int get_HP() const; - long_result throw_potion(level *lvl, - std::unique_ptr p, direction dir); - void set_potion_known(const potion_type &type); };