add material reset to $edit

This commit is contained in:
Martin Michelsen
2024-07-28 12:42:13 -07:00
parent cd09bfa7e8
commit f8162d442a
4 changed files with 86 additions and 10 deletions
+35 -4
View File
@@ -1310,6 +1310,8 @@ static void server_command_edit(shared_ptr<Client> c, const std::string& args) {
string encoded_args = phosg::tolower(args);
vector<string> tokens = phosg::split(encoded_args, ' ');
using MatType = PSOBBCharacterFile::MaterialType;
try {
auto p = c->character();
if (tokens.at(0) == "atp" && cheats_allowed) {
@@ -1331,10 +1333,39 @@ static void server_command_edit(shared_ptr<Client> c, const std::string& args) {
} else if (tokens.at(0) == "exp" && cheats_allowed) {
p->disp.stats.experience = stoul(tokens.at(1));
} else if (tokens.at(0) == "level" && cheats_allowed) {
uint32_t level = stoul(tokens.at(1)) - 1;
auto level_table = s->level_table(c->version());
level_table->reset_to_base(p->disp.stats, p->disp.visual.char_class);
level_table->advance_to_level(p->disp.stats, level, p->disp.visual.char_class);
p->disp.stats.level = stoul(tokens.at(1)) - 1;
p->recompute_stats(s->level_table(c->version()));
} else if (((tokens.at(0) == "material") || (tokens.at(0) == "mat")) && !is_v1_or_v2(c->version())) {
if (tokens.at(1) == "reset") {
const auto& which = tokens.at(2);
if (which == "power") {
p->set_material_usage(MatType::POWER, 0);
} else if (which == "mind") {
p->set_material_usage(MatType::MIND, 0);
} else if (which == "evade") {
p->set_material_usage(MatType::EVADE, 0);
} else if (which == "def") {
p->set_material_usage(MatType::DEF, 0);
} else if (which == "luck") {
p->set_material_usage(MatType::LUCK, 0);
} else if (which == "hp") {
p->set_material_usage(MatType::HP, 0);
} else if (which == "tp") {
p->set_material_usage(MatType::TP, 0);
} else if (which == "all") {
p->set_material_usage(MatType::POWER, 0);
p->set_material_usage(MatType::MIND, 0);
p->set_material_usage(MatType::EVADE, 0);
p->set_material_usage(MatType::DEF, 0);
p->set_material_usage(MatType::LUCK, 0);
p->set_material_usage(MatType::HP, 0);
p->set_material_usage(MatType::TP, 0);
}
} else {
send_text_message(c, "$C6Invalid subcommand");
return;
}
p->recompute_stats(s->level_table(c->version()));
} else if (tokens.at(0) == "namecolor") {
uint32_t new_color;
sscanf(tokens.at(1).c_str(), "%8X", &new_color);
+17 -5
View File
@@ -1124,11 +1124,23 @@ void PSOBBCharacterFile::import_tethealla_material_usage(std::shared_ptr<const L
// there are no limits, and we don't want to reject legitimate characters
// that have used more than 250 materials.
this->set_material_usage(PSOBBCharacterFile::MaterialType::POWER, pow);
this->set_material_usage(PSOBBCharacterFile::MaterialType::MIND, mind);
this->set_material_usage(PSOBBCharacterFile::MaterialType::EVADE, evade);
this->set_material_usage(PSOBBCharacterFile::MaterialType::DEF, def);
this->set_material_usage(PSOBBCharacterFile::MaterialType::LUCK, luck);
this->set_material_usage(MaterialType::POWER, pow);
this->set_material_usage(MaterialType::MIND, mind);
this->set_material_usage(MaterialType::EVADE, evade);
this->set_material_usage(MaterialType::DEF, def);
this->set_material_usage(MaterialType::LUCK, luck);
}
void PSOBBCharacterFile::recompute_stats(std::shared_ptr<const LevelTable> level_table) {
uint32_t level = this->disp.stats.level;
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.char_stats.atp += (this->get_material_usage(MaterialType::POWER) * 2);
this->disp.stats.char_stats.mst += (this->get_material_usage(MaterialType::MIND) * 2);
this->disp.stats.char_stats.evp += (this->get_material_usage(MaterialType::EVADE) * 2);
this->disp.stats.char_stats.dfp += (this->get_material_usage(MaterialType::DEF) * 2);
this->disp.stats.char_stats.lck += (this->get_material_usage(MaterialType::LUCK) * 2);
this->disp.stats.char_stats.hp += (this->get_material_usage(MaterialType::HP) * 2);
}
static uint16_t crc16(const void* data, size_t size) {
+1
View File
@@ -754,6 +754,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);
} __packed_ws__(PSOBBCharacterFile, 0x2EA4);
////////////////////////////////////////////////////////////////////////////////