fix $edit level

This commit is contained in:
Martin Michelsen
2025-11-18 17:28:48 -08:00
parent 886e9b9f4f
commit 328980628a
3 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -922,7 +922,7 @@ ChatCommandDefinition cc_edit(
p->disp.stats.experience = stoul(tokens.at(1));
} else if (tokens.at(0) == "level" && (cheats_allowed || !s->cheat_flags.edit_stats)) {
p->disp.stats.level = stoul(tokens.at(1)) - 1;
p->recompute_stats(s->level_table(a.c->version()));
p->recompute_stats(s->level_table(a.c->version()), true);
} else if (((tokens.at(0) == "material") || (tokens.at(0) == "mat")) && !is_v1_or_v2(a.c->version()) && (cheats_allowed || !s->cheat_flags.reset_materials)) {
if (tokens.at(1) == "reset") {
const auto& which = tokens.at(2);
@@ -960,7 +960,7 @@ ChatCommandDefinition cc_edit(
} else {
throw precondition_failed("$C6Invalid subcommand");
}
p->recompute_stats(s->level_table(a.c->version()));
p->recompute_stats(s->level_table(a.c->version()), false);
} else if (tokens.at(0) == "namecolor") {
p->disp.visual.name_color = stoul(tokens.at(1), nullptr, 16);
} else if (tokens.at(0) == "language" || tokens.at(0) == "lang") {
+4 -2
View File
@@ -1415,12 +1415,14 @@ void PSOBBCharacterFile::import_tethealla_material_usage(std::shared_ptr<const L
this->set_material_usage(MaterialType::LUCK, luck);
}
void PSOBBCharacterFile::recompute_stats(std::shared_ptr<const LevelTable> level_table) {
void PSOBBCharacterFile::recompute_stats(std::shared_ptr<const LevelTable> level_table, bool reset_exp) {
uint32_t level = this->disp.stats.level;
uint32_t exp = this->disp.stats.experience;
level_table->reset_to_base(this->disp.stats, this->disp.visual.char_class);
level_table->advance_to_level(this->disp.stats, level, this->disp.visual.char_class);
this->disp.stats.experience = exp;
if (!reset_exp) {
this->disp.stats.experience = exp;
}
this->disp.stats.char_stats.atp += (this->get_material_usage(MaterialType::POWER) * 2);
this->disp.stats.char_stats.mst += (this->get_material_usage(MaterialType::MIND) * 2);
+1 -1
View File
@@ -920,7 +920,7 @@ struct PSOBBCharacterFile {
void set_material_usage(MaterialType which, uint8_t usage);
void clear_all_material_usage();
void import_tethealla_material_usage(std::shared_ptr<const LevelTable> level_table);
void recompute_stats(std::shared_ptr<const LevelTable> level_table);
void recompute_stats(std::shared_ptr<const LevelTable> level_table, bool reset_exp = false);
} __packed_ws__(PSOBBCharacterFile, 0x2EA4);
struct PSOCHARFile {