mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-20 08:27:39 +00:00
implemented the magic fountains (except ghosts and bones mechanics)
This commit is contained in:
@@ -4,6 +4,16 @@ void handle_powers(data& d);
|
||||
|
||||
bool on_fountain;
|
||||
room *fountain_room;
|
||||
xy fountain_where;
|
||||
|
||||
void regenerate_all() {
|
||||
m.hp = m.max_hp();
|
||||
for(auto& p: powers) p.refill();
|
||||
for(auto& r: rooms) for(auto& e: r.second.entities) e->regenerate();
|
||||
revert_all(fountain_revert);
|
||||
current_target = nullptr;
|
||||
shuffle_all();
|
||||
}
|
||||
|
||||
void check_fountains() {
|
||||
bool next_on_fountain = false;
|
||||
@@ -14,13 +24,12 @@ void check_fountains() {
|
||||
if(b == wFountain) next_on_fountain = true;
|
||||
}
|
||||
if(next_on_fountain && !on_fountain) {
|
||||
fountain_room = current_room;
|
||||
if(extra_life->flags & ACTIVE) {
|
||||
fountain_room = current_room;
|
||||
fountain_where = m.where;
|
||||
}
|
||||
addMessage("A magic fountain! You feel safe and refill your potions.");
|
||||
m.hp = m.max_hp();
|
||||
for(auto& p: powers) p.refill();
|
||||
for(auto& r: rooms) for(auto& e: r.second.entities) e->regenerate();
|
||||
current_target = nullptr;
|
||||
shuffle_all();
|
||||
regenerate_all();
|
||||
}
|
||||
swap(on_fountain, next_on_fountain);
|
||||
}
|
||||
@@ -58,4 +67,20 @@ void man::act() {
|
||||
check_fountains();
|
||||
}
|
||||
|
||||
void man::on_kill() {
|
||||
entity::on_kill();
|
||||
if(extra_life->flags & ACTIVE)
|
||||
addMessage("You die... Press [key:Extra Life] to revive.");
|
||||
else
|
||||
addMessage("You die... permanently. You will have to create a new character. Or just press [key:Extra Life] for a narrative cheat.");
|
||||
}
|
||||
|
||||
void add_revert(revert_stack& s, const reaction_t& what) {
|
||||
s.push_back(what);
|
||||
}
|
||||
|
||||
void revert_all(revert_stack& s) {
|
||||
while(!s.empty()) { s.back()(); s.pop_back(); }
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user