1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-06-23 16:54:07 +00:00

ru:: talking to NPCs

This commit is contained in:
Zeno Rogue 2025-04-27 01:37:17 +02:00
parent 58ce8a7f5c
commit 7ab4f6f580
5 changed files with 26 additions and 1 deletions

View File

@ -166,6 +166,8 @@ struct man : public entity {
int jump_control, next_jump_control;
int coyote_time, next_coyote_time;
int last_action;
man() { facing = 1; attack_facing = 1; }
double sx() override { return 12; }
double sy() override { return 12; }
@ -181,10 +183,12 @@ struct npc : public entity {
string sglyph, name;
color_t col;
string text;
int talk_on;
double sx() override { return 12; }
double sy() override { return 12; }
string glyph() override { return sglyph; }
color_t color() override { return col; }
void act() override;
};
struct item : public entity {

View File

@ -178,4 +178,20 @@ void missile::act() {
if(where_x > screen_x || where_x < 0 || where_y < 0 || where_y > screen_y) destroyed = true;
}
void npc::act() {
kino();
if(gframeid > m.last_action + 300 && intersect(get_pixel_bbox(), m.get_pixel_bbox()) && talk_on != m.last_action) {
talk_on = m.last_action = gframeid;
cmode = mode::talking;
pushScreen([&] { cmode = mode::playing; popScreen(); });
pushScreen([&] {
dialog::init(name, col >> 8);
dialog::addInfo(text);
dialog::addBreak(100);
dialog::addBack();
dialog::display();
});
}
}
}

View File

@ -116,7 +116,7 @@ extern array<array<location, 256>, 256> all_locations;
enum class mapmode { standard, poincare, klein };
enum class mode { editmap, menu, playing, paused, inventory };
enum class mode { editmap, menu, playing, paused, inventory, talking };
mode cmode = mode::playing;

View File

@ -28,6 +28,8 @@ void man::act() {
vel_x += dat.dx * dat.d * dat.modv * 0.02;
}
if(!(on_floor && !dat.dx)) last_action = gframeid;
if(dat.dx) facing = dat.dx;
current_room->fov_from(where_x / block_x, where_y / block_y);

View File

@ -264,6 +264,9 @@ void run() {
dialog::add_key_action('v', [] { cmode = mode::menu; });
break;
case mode::talking:
break;
case mode::menu:
nomap = true;
emptyscreen();