mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-09-08 13:25:59 +00:00
ru:: talking to NPCs
This commit is contained in:
@@ -166,6 +166,8 @@ struct man : public entity {
|
|||||||
int jump_control, next_jump_control;
|
int jump_control, next_jump_control;
|
||||||
int coyote_time, next_coyote_time;
|
int coyote_time, next_coyote_time;
|
||||||
|
|
||||||
|
int last_action;
|
||||||
|
|
||||||
man() { facing = 1; attack_facing = 1; }
|
man() { facing = 1; attack_facing = 1; }
|
||||||
double sx() override { return 12; }
|
double sx() override { return 12; }
|
||||||
double sy() override { return 12; }
|
double sy() override { return 12; }
|
||||||
@@ -181,10 +183,12 @@ struct npc : public entity {
|
|||||||
string sglyph, name;
|
string sglyph, name;
|
||||||
color_t col;
|
color_t col;
|
||||||
string text;
|
string text;
|
||||||
|
int talk_on;
|
||||||
double sx() override { return 12; }
|
double sx() override { return 12; }
|
||||||
double sy() override { return 12; }
|
double sy() override { return 12; }
|
||||||
string glyph() override { return sglyph; }
|
string glyph() override { return sglyph; }
|
||||||
color_t color() override { return col; }
|
color_t color() override { return col; }
|
||||||
|
void act() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct item : public entity {
|
struct item : public entity {
|
||||||
|
@@ -178,4 +178,20 @@ void missile::act() {
|
|||||||
if(where_x > screen_x || where_x < 0 || where_y < 0 || where_y > screen_y) destroyed = true;
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,7 @@ extern array<array<location, 256>, 256> all_locations;
|
|||||||
|
|
||||||
enum class mapmode { standard, poincare, klein };
|
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;
|
mode cmode = mode::playing;
|
||||||
|
|
||||||
|
@@ -28,6 +28,8 @@ void man::act() {
|
|||||||
vel_x += dat.dx * dat.d * dat.modv * 0.02;
|
vel_x += dat.dx * dat.d * dat.modv * 0.02;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!(on_floor && !dat.dx)) last_action = gframeid;
|
||||||
|
|
||||||
if(dat.dx) facing = dat.dx;
|
if(dat.dx) facing = dat.dx;
|
||||||
|
|
||||||
current_room->fov_from(where_x / block_x, where_y / block_y);
|
current_room->fov_from(where_x / block_x, where_y / block_y);
|
||||||
|
@@ -264,6 +264,9 @@ void run() {
|
|||||||
dialog::add_key_action('v', [] { cmode = mode::menu; });
|
dialog::add_key_action('v', [] { cmode = mode::menu; });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case mode::talking:
|
||||||
|
break;
|
||||||
|
|
||||||
case mode::menu:
|
case mode::menu:
|
||||||
nomap = true;
|
nomap = true;
|
||||||
emptyscreen();
|
emptyscreen();
|
||||||
|
Reference in New Issue
Block a user