1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-06-25 14:43:01 +00:00

ru:: a better implementation of next/current stats

This commit is contained in:
Zeno Rogue 2025-05-19 12:19:42 +02:00
parent 1c4746d6d0
commit 131206f1e5
6 changed files with 34 additions and 28 deletions

View File

@ -260,31 +260,36 @@ struct entity {
virtual string get_help() { return "No help about this."; }
};
struct statdata {
statarray<int> stats;
int jump_control, coyote_time, hallucinating;
void reset();
};
struct man : public entity {
int facing;
int attack_facing;
int attack_when;
int on_floor_when;
int jump_control, next_jump_control;
int coyote_time, next_coyote_time;
int last_action;
int experience;
statarray<int> base_stats, current_stats, next_stats;
virtual int max_hp() { return 10 * current_stats[stat::con]; }
statarray<int> base_stats;
statdata current, next;
virtual int max_hp() { return 10 * current.stats[stat::con]; }
man() {
facing = 1; attack_facing = 1;
for(auto s: allstats) base_stats[s] = 10;
next_stats = base_stats; current_stats = base_stats;
next.reset(); current.reset();
postfix();
}
xy siz() override { return {12, 12}; }
string glyph() override { return hallucinating ? "f" : "@"; }
color_t color() override { return hallucinating ? 0x808080FF : 0xFF8080FF; }
string glyph() override { return "@"; }
color_t color() override { return 0xFF8080FF; }
void act() override;
void draw() override;
virtual bool hurt_by_spikes() { return true; }

View File

@ -99,8 +99,6 @@ ruwall walls[qwall] = {
int sel = 1;
bool hallucinating;
template<class T> bool in_range(T val, T minv, T maxv) { return val >= minv && val <= maxv; }
map<cell*, struct room> rooms;

View File

@ -37,6 +37,12 @@ void check_fountains() {
swap(on_fountain, next_on_fountain);
}
void statdata::reset() {
stats = m.base_stats;
coyote_time = 0;
jump_control = 0;
}
void man::act() {
kino();
@ -45,20 +51,17 @@ void man::act() {
stable_where = where;
}
current_stats = next_stats;
next_stats = base_stats;
current = next;
next.reset();
auto dat = get_dat();
coyote_time = next_coyote_time; next_coyote_time = 0;
jump_control = next_jump_control; next_jump_control = 0;
if(on_floor) on_floor_when = gframeid;
fallthru = false;
handle_powers(dat);
if((on_floor || jump_control || wallhug) && !on_ice) {
if((on_floor || current.jump_control || wallhug) && !on_ice) {
vel.x = zero_vel.x + dat.dx * dat.d * dat.modv * 2.5;
}

View File

@ -228,7 +228,7 @@ void gen_powers() {
[] (data& d) {
if(d.keystate & 1) {
bool can_jump = m.on_floor;
if(gframeid <= m.on_floor_when + m.coyote_time) can_jump = true;
if(gframeid <= m.on_floor_when + m.current.coyote_time) can_jump = true;
if(can_jump) m.vel.y = m.zero_vel.y-(non_hyperbolic ? 3 : 5) * d.d * d.modv, m.on_floor_when = -1000;
}
}
@ -265,7 +265,7 @@ void gen_powers() {
m.attack_facing = m.facing; m.attack_when = gframeid;
auto pb = m.get_pixel_bbox_at(xy{m.where.x + m.attack_facing * m.dsiz().x, m.where.y});
auto bb = pixel_to_block(pb);
for(auto& e: current_room->entities) if(e->existing && intersect(e->get_pixel_bbox(), pb)) e->attacked((m.current_stats[stat::str] + 1) * 3 / 2);
for(auto& e: current_room->entities) if(e->existing && intersect(e->get_pixel_bbox(), pb)) e->attacked((m.current.stats[stat::str] + 1) * 3 / 2);
for(int y=bb.miny; y<bb.maxy; y++)
for(int x=bb.minx; x<bb.maxx; x++) {
int b = current_room->at(x, y);
@ -304,8 +304,8 @@ void gen_powers() {
"This strange ring is too small to put on your finger, but maybe you could put it on your small toe?",
"=", 0xe1cbbeFF,
[] (data& d) {
if(d.p->flags & ACTIVE) m.next_coyote_time += 30;
if(!(d.p->flags & IDENTIFIED) && (gframeid <= m.on_floor_when + m.coyote_time) && !m.on_floor && (d.p->flags & ACTIVE)) {
if(d.p->flags & ACTIVE) m.next.coyote_time += 30;
if(!(d.p->flags & IDENTIFIED) && (gframeid <= m.on_floor_when + m.current.coyote_time) && !m.on_floor && (d.p->flags & ACTIVE)) {
d.p->flags |= IDENTIFIED;
addMessage("You feel a strange magical force wanting to hold your foot from below.");
}
@ -318,7 +318,7 @@ void gen_powers() {
"=", 0xFFD500FF,
[] (data& d) {
if(d.p->flags & ACTIVE) {
m.next_jump_control++;
m.next.jump_control++;
auto& ids = d.p->id_status;
bool id_up = (!!m.on_floor) == !!(ids & 1);
if(id_up) {
@ -350,7 +350,7 @@ void gen_powers() {
"=", 0xC04040FF,
[] (data& d) {
if(d.p->flags & ACTIVE) {
m.next_stats[stat::str] += d.p->qty_filled;
m.next.stats[stat::str] += d.p->qty_filled;
d.p->flags |= IDENTIFIED;
}
}
@ -362,7 +362,7 @@ void gen_powers() {
"=", 0xC04040FF,
[] (data& d) {
if(d.p->flags & ACTIVE) {
m.next_stats[stat::str] += d.p->qty_filled;
m.next.stats[stat::str] += d.p->qty_filled;
d.p->flags |= IDENTIFIED;
}
}
@ -374,7 +374,7 @@ void gen_powers() {
"=", 0xC04040FF,
[] (data& d) {
if(d.p->flags & ACTIVE) {
m.next_stats[stat::str] += d.p->qty_filled;
m.next.stats[stat::str] += d.p->qty_filled;
d.p->flags |= IDENTIFIED;
}
}
@ -386,7 +386,7 @@ void gen_powers() {
"=", 0xC04040FF,
[] (data& d) {
if(d.p->flags & ACTIVE) {
m.next_stats[stat::str] += d.p->qty_filled;
m.next.stats[stat::str] += d.p->qty_filled;
d.p->flags |= IDENTIFIED;
}
}

View File

@ -420,7 +420,7 @@ void add_platf_hooks() {
ld tscale = 1;
if(dexmode->flags & ACTIVE)
tscale *= 10. / (10 + m.current_stats[stat::dex]);
tscale *= 10. / (10 + m.current.stats[stat::dex]);
gtime += d * tscale;
while(gtime > 1000. / game_fps) {

View File

@ -23,7 +23,7 @@ void draw_stats() {
for(auto st: allstats) {
string s = its(m.base_stats[st]);
if(m.current_stats[st] != m.base_stats[st]) s += " (" + its(m.current_stats[st]) + ")";
if(m.current.stats[st] != m.base_stats[st]) s += " (" + its(m.current.stats[st]) + ")";
dialog::addSelItem(statdata[st].name, s, statdata[st].key);
dialog::add_action_push([st] {
render_the_map();
@ -32,7 +32,7 @@ void draw_stats() {
dialog::addHelp(statdata[st].desc);
dialog::addBreak(100);
dialog::addSelItem("base value", its(m.base_stats[st]), 0);
dialog::addSelItem("current value", its(m.current_stats[st]), 0);
dialog::addSelItem("current value", its(m.current.stats[st]), 0);
dialog::addBreak(100);
dialog::addBack();
dialog::display();