mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-05-17 19:52:06 +00:00
ru:: save the man/power/randeff parameters
This commit is contained in:
@@ -25,6 +25,7 @@ struct randeff {
|
||||
int qty, a, b, c, d;
|
||||
powerfun act;
|
||||
randeff (string name, string desc, string effect, powerfun act);
|
||||
void hs(struct stater& s);
|
||||
};
|
||||
|
||||
enum class mod { burning, freezing, disarming };
|
||||
@@ -41,7 +42,7 @@ struct power {
|
||||
int id_status;
|
||||
int qty_filled;
|
||||
int qty_owned;
|
||||
flagtype flags;
|
||||
int flags;
|
||||
int random_value;
|
||||
vector<struct randeff*> randeffs;
|
||||
void init();
|
||||
@@ -64,6 +65,7 @@ struct power {
|
||||
power& be_jewelry(string jtype, string desc);
|
||||
power& be_potion();
|
||||
power& gain(int qf, int qo) { qty_filled += qf; qty_owned += qo; return self; }
|
||||
void hs(struct stater& s);
|
||||
};
|
||||
|
||||
extern vector<power> powers;
|
||||
@@ -405,6 +407,8 @@ struct man : public entity {
|
||||
}
|
||||
|
||||
void launch_attack(power *p, int fac, boxfun f);
|
||||
|
||||
virtual void hs(stater& s);
|
||||
};
|
||||
|
||||
extern man m;
|
||||
|
||||
@@ -49,12 +49,43 @@ void statdata::reset() {
|
||||
}
|
||||
|
||||
man::man() {
|
||||
id = "Alchemist";
|
||||
facing = 1; attack_facing = 1;
|
||||
for(auto s: allstats) base_stats[s] = 10;
|
||||
next.reset(); current.reset();
|
||||
hs(fountain_resetter);
|
||||
}
|
||||
|
||||
void man::hs(stater& s) {
|
||||
entity::hs(s);
|
||||
s.act("facing", facing, 1)
|
||||
.act("attack_facing", attack_facing, 1)
|
||||
.act("attack_when", attack_when, 0)
|
||||
.act("on_floor_when", on_floor_when, 0)
|
||||
.act("xp", experience, 0)
|
||||
.act("last_action", last_action, 0);
|
||||
sact(s, "hair", hair);
|
||||
sact(s, "eyes", eye);
|
||||
string z = unspace(backstory);
|
||||
s.act("backstory", z, "");
|
||||
backstory = respace(z);
|
||||
int prof = (int) profession; s.act("profession", prof, -1); profession = (stat) prof;
|
||||
for(auto st: allstats) s.act(statinfos[st].name, base_stats[st], 10);
|
||||
|
||||
auto sdata = [&s] (statdata& sd, string prefix) {
|
||||
for(auto st: allstats) s.act(prefix + statinfos[st].name, sd.stats[st], 10);
|
||||
s.act(prefix + "jump_control", sd.jump_control, 0);
|
||||
s.act(prefix + "coyote_time", sd.coyote_time, 0);
|
||||
s.act(prefix + "hallucinating", sd.hallucinating, 0);
|
||||
s.act(prefix + "detect_area", sd.detect_area, 0);
|
||||
s.act(prefix + "detect_cross", sd.detect_cross, 0);
|
||||
s.act(prefix + "rough_detect", sd.rough_detect, 0);
|
||||
};
|
||||
|
||||
sdata(current, "curr.");
|
||||
sdata(next, "next.");
|
||||
}
|
||||
|
||||
void man::act() {
|
||||
kino();
|
||||
|
||||
|
||||
+34
-10
@@ -8,9 +8,42 @@ void save_revert(hstream& f, const revert_type& r) {
|
||||
println(f);
|
||||
}
|
||||
|
||||
void power::hs(stater& s) {
|
||||
sact(s, "flavor", fl);
|
||||
s.act("id", id_status, 0).act("qf", qty_filled, 0).act("qo", qty_owned, 0).act("flags", flags, 0).act("rv", random_value, 0);
|
||||
}
|
||||
|
||||
void randeff::hs(stater& s) {
|
||||
string str = which_weapon ? which_weapon->id : "NONE";
|
||||
s.act("wpn", str, "NONE");
|
||||
try {
|
||||
which_weapon = (str != "NONE") ? &find_power_by_id(str) : nullptr;
|
||||
}
|
||||
catch(hr_name_error& e) { which_weapon = &find_power_by_id("dagger"); }
|
||||
}
|
||||
|
||||
template<class T> void save_via_stater(fhstream& f, T& t, string cat, bool always = false) {
|
||||
changeseeker cs;
|
||||
t.hs(cs);
|
||||
if(cs.changed || always) {
|
||||
println(f, cat, " ", t.id);
|
||||
saver sav(f);
|
||||
t.hs(sav);
|
||||
println(f);
|
||||
}
|
||||
}
|
||||
|
||||
void save() {
|
||||
fhstream f(save_name, "wt");
|
||||
|
||||
save_via_stater(f, m, "MAN", false);
|
||||
|
||||
// list current powers
|
||||
for(auto& p: powers) {
|
||||
save_via_stater(f, p, "POWER", isize(p.randeffs));
|
||||
for(auto& r: p.randeffs) save_via_stater(f, *r, "EFFECT", true);
|
||||
}
|
||||
|
||||
for(auto& [c,r]: rooms) {
|
||||
if(!r.save_to_save) continue;
|
||||
int seen_count = 0;
|
||||
@@ -26,16 +59,7 @@ void save() {
|
||||
for(int x=0; x<room_y; x++) println(ss, r.fov[y][x] ? '1' : '0');
|
||||
println(f, as_hexstring(compress_string(ss.s)));
|
||||
|
||||
for(auto& e: r.entities) {
|
||||
changeseeker cs;
|
||||
e->hs(cs);
|
||||
if(cs.changed) {
|
||||
println(f, "ENTITY ", e->id);
|
||||
saver sav(f);
|
||||
e->hs(sav);
|
||||
println(f);
|
||||
}
|
||||
}
|
||||
for(auto& e: r.entities) save_via_stater(f, *e, "ENTITY");
|
||||
println(f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user