throwing potions now identifies it

This commit is contained in:
2024-07-20 15:40:11 -04:00
parent 48dc219642
commit 842a171016
4 changed files with 11 additions and 5 deletions

View File

@ -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\

View File

@ -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<player_base *>(ch)->set_potion_known(
npotion->get_type());
ch->apply_effect(std::move(npotion));
}

View File

@ -141,9 +141,12 @@ long_result player_base::throw_potion(level *lvl, std::unique_ptr<potion> 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() + ". "};
}
}

View File

@ -35,6 +35,9 @@ protected:
inventory inv;
int MAX_THROW_DIST;
long_result throw_potion(level *lvl,
std::unique_ptr<potion> 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<potion> p, direction dir);
void set_potion_known(const potion_type &type);
};