1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-07-19 09:22:49 +00:00

ru:: help while paused

This commit is contained in:
Zeno Rogue 2025-05-03 18:07:30 +02:00
parent 7875de00e4
commit 828160f548
4 changed files with 61 additions and 18 deletions

View File

@ -213,6 +213,8 @@ struct entity {
invinc_end = gframeid + 150; invinc_end = gframeid + 150;
return true; return true;
} }
virtual string get_help() { return "No help about this."; }
}; };
struct man : public entity { struct man : public entity {
@ -234,6 +236,7 @@ struct man : public entity {
void draw() override; void draw() override;
virtual bool hurt_by_spikes() { return true; } virtual bool hurt_by_spikes() { return true; }
string get_name() override { return "alchemist"; } string get_name() override { return "alchemist"; }
string get_help() override { return "This is you."; }
}; };
extern man m; extern man m;
@ -249,7 +252,8 @@ struct moving_platform : public entity {
void act() override; void act() override;
virtual moving_platform* as_platform() { return this; } virtual moving_platform* as_platform() { return this; }
string get_name() override { return "moving platform"; } string get_name() override { return "moving platform"; }
}; string get_help() override { return "Moving platforms move."; }
};
struct ferris_platform : public moving_platform { struct ferris_platform : public moving_platform {
xy location_at(ld t) override; xy location_at(ld t) override;
@ -265,6 +269,7 @@ struct npc : public entity {
color_t color() override { return col; } color_t color() override { return col; }
void act() override; void act() override;
string get_name() override { return name; } string get_name() override { return name; }
string get_help() override { return "Stay awhile and listen."; }
}; };
struct boar : public entity { struct boar : public entity {
@ -278,6 +283,7 @@ struct boar : public entity {
void attacked(int s) override; void attacked(int s) override;
void on_kill() override { entity::on_kill(); num_kills++; } void on_kill() override { entity::on_kill(); num_kills++; }
string get_name() override { return "giant boar"; } string get_name() override { return "giant boar"; }
string get_help() override { return "Beware their tusks."; }
}; };
struct hint : public entity { struct hint : public entity {
@ -306,6 +312,7 @@ struct item : public entity {
} }
} }
string get_name() override { return powers[id].name; } string get_name() override { return powers[id].name; }
string get_help() override { return powers[id].get_desc(); }
}; };
struct missile : public entity { struct missile : public entity {

View File

@ -108,6 +108,10 @@ bbox extend(bbox a, int l, int r, int u, int d) {
return a; return a;
} }
bool contains(bbox a, xy pos) {
return pos.x >= a.minx && pos.x < a.maxx && pos.y >= a.miny && pos.y < a.maxy;
}
bbox extend_all(bbox a, int x) { return extend(a, x, x, x, x); } bbox extend_all(bbox a, int x) { return extend(a, x, x, x, x); }
bbox get_intersect(bbox a, bbox b) { bbox get_intersect(bbox a, bbox b) {

View File

@ -52,6 +52,7 @@ struct ruwall {
string glyph; string glyph;
color_t color; color_t color;
flagtype flags; flagtype flags;
string help;
}; };
enum eWall { wAir, wWall, wBouncy, wSpike, wWater, wFrozen, wDoor, wSmashedDoor, wLockedDoor, wFountain0, wFountain1, wBluePortal, wOrangePortal, wPlatform, wStaircase, wColumn, wForge, wGUARD }; enum eWall { wAir, wWall, wBouncy, wSpike, wWater, wFrozen, wDoor, wSmashedDoor, wLockedDoor, wFountain0, wFountain1, wBluePortal, wOrangePortal, wPlatform, wStaircase, wColumn, wForge, wGUARD };
@ -67,23 +68,23 @@ flagtype W_FROZEN = 64;
constexpr int qwall = int(wGUARD); constexpr int qwall = int(wGUARD);
ruwall walls[qwall] = { ruwall walls[qwall] = {
{"air", ".", 0x40404080, W_TRANS}, {"air", ".", 0x40404080, W_TRANS, "Looks like an empty space, but actually necessary for survival."},
{"wall", "#", 0xFFFFFFFF, W_BLOCK}, {"wall", "#", 0xFFFFFFFF, W_BLOCK, "These kinds of tough walls can never be destroyed."},
{"bouncy wall", "#", 0x80FF80FF, W_BLOCK | W_BOUNCY}, {"bouncy wall", "#", 0x80FF80FF, W_BLOCK | W_BOUNCY, "Like walls, but things bounce off them."},
{"spike", "^", 0xC08080FF, W_TRANS | W_PAIN}, {"spike", "^", 0xC08080FF, W_TRANS | W_PAIN, "Dangerous!"},
{"water", "~", 0x0000FFFF, W_BLOCK | W_TRANS}, {"water", "~", 0x0000FFFF, W_BLOCK | W_TRANS, "Not used yet."},
{"frozen water", "#", 0xC0C0FFFF, W_BLOCK | W_FROZEN}, {"frozen water", "#", 0xC0C0FFFF, W_BLOCK | W_FROZEN, "Water magically turned into a slippery wall."},
{"door", "+", 0xC06000FF, W_BLOCK}, {"door", "+", 0xC06000FF, W_BLOCK, "Attack the doors with your weapon to open them."},
{"smashed door", "'", 0xC06000FF, W_TRANS}, {"smashed door", "'", 0xC06000FF, W_TRANS, "This door has been already opened."},
{"locked door", "+", 0xA05000FF, W_BLOCK}, {"locked door", "+", 0xA05000FF, W_BLOCK, "What is behind this door is not your business."},
{"magic fountain", "!", 0x8080C0FF, W_TRANS}, {"magic fountain", "!", 0x8080C0FF, W_TRANS, "Wow! A magic fountain!"},
{"magic fountain (active)", "!", 0xA0A0FFFF, W_TRANS}, {"magic fountain (active)", "!", 0xA0A0FFFF, W_TRANS, "Wow! An active magic fountain!"},
{"blue portal", "=", 0x4040C0FF, W_TRANS}, {"blue portal", "=", 0x4040C0FF, W_TRANS, "Blue portal."},
{"orange portal", "=", 0xC08040FF, W_TRANS}, {"orange portal", "=", 0xC08040FF, W_TRANS, "Orange portal."},
{"platform", "-", 0xFFFFFFFF, W_PLATFORM | W_TRANS }, {"platform", "-", 0xFFFFFFFF, W_PLATFORM | W_TRANS, "You can fall down through such platforms."},
{"staircase", "-", 0xFFFF80FF, W_PLATFORM | W_TRANS | W_STAIRCASE }, {"staircase", "-", 0xFFFF80FF, W_PLATFORM | W_TRANS | W_STAIRCASE, "You can climb staircases and ladders." },
{"column", "|", 0x40404080, W_TRANS}, {"column", "|", 0x40404080, W_TRANS, "A background decoration." },
{"forge", "&", 0xB0202080, W_TRANS | W_PAIN}, {"forge", "&", 0xB0202080, W_TRANS | W_PAIN, "Used by runesmiths."},
}; };
int sel = 1; int sel = 1;

View File

@ -264,6 +264,37 @@ void run() {
if(current_target && current_target->existing) if(current_target && current_target->existing)
displayfr(vid.xres - vid.fsize, vid.fsize, 2, vid.fsize, "HP " + its(current_target->hp) + "/" + its(current_target->max_hp()) + " " + current_target->get_name(), titlecolor, 16); displayfr(vid.xres - vid.fsize, vid.fsize, 2, vid.fsize, "HP " + its(current_target->hp) + "/" + its(current_target->max_hp()) + " " + current_target->get_name(), titlecolor, 16);
} }
if(cmode == mode::paused) {
xy mousep(mousepx, mousepy);
string helpstr = "";
entity* help_entity = nullptr;
if(contains(m.get_pixel_bbox(), mousep)) {
help_entity = &m;
}
for(auto& e: current_room->entities)
if(e->existing && e->visible(current_room) && e->visible_inv() && e->have_help())
if(contains(e->get_pixel_bbox(), mousep))
help_entity = &*e;
if(help_entity) {
mouseovers = help_entity->get_name();
helpstr = help_entity->get_help();
}
int x = mousepx / block_x, y = mousepy / block_y;
if(!help_entity && x >= 0 && y >= 0 && x < room_x && y < room_y) {
if(!current_room->fov[y][x]) mouseovers = "invisible", helpstr = "You need to explore to see what is there.";
else {
auto&w = walls[current_room->block_at[y][x] >> 3];
mouseovers = w.name;
helpstr = w.help;
}
}
dialog::add_key_action(SDLK_F1, [helpstr] { gotoHelp(helpstr); });
}
draw_pentagon(); draw_pentagon();
break; break;