diff --git a/src/BattleParamsIndex.cc b/src/BattleParamsIndex.cc index 8d97d08b..10fbfd1a 100644 --- a/src/BattleParamsIndex.cc +++ b/src/BattleParamsIndex.cc @@ -9,38 +9,20 @@ using namespace std; -string BattleParamsIndex::PhysicalData::str() const { - return string_printf( - "PhysicalData[ATP=%hu PSV=%hu EVP=%hu HP=%hu DFP=%hu ATA=%hu LCK=%hu ESP=%hu a1=[%g, %g] a2=%" PRIu32 " EXP=%" PRIu32 " diff=%" PRIu32 "]", - this->atp.load(), - this->psv.load(), - this->evp.load(), - this->hp.load(), - this->dfp.load(), - this->ata.load(), - this->lck.load(), - this->esp.load(), - this->unknown_a1[0].load(), - this->unknown_a1[1].load(), - this->unknown_a2.load(), - this->experience.load(), - this->difficulty.load()); -} - void BattleParamsIndex::Table::print(FILE* stream) const { - auto print_entry = +[](FILE* stream, const PhysicalData& e) { + auto print_entry = +[](FILE* stream, const PlayerStats& e) { fprintf(stream, "%5hu %5hu %5hu %5hu %5hu %5hu %5hu %5hu %5" PRIu32 " %5" PRIu32, - e.atp.load(), - e.psv.load(), - e.evp.load(), - e.hp.load(), - e.dfp.load(), - e.ata.load(), - e.lck.load(), - e.esp.load(), + e.char_stats.atp.load(), + e.char_stats.mst.load(), + e.char_stats.evp.load(), + e.char_stats.hp.load(), + e.char_stats.dfp.load(), + e.char_stats.ata.load(), + e.char_stats.lck.load(), + e.unknown_a1.load(), e.experience.load(), - e.difficulty.load()); + e.meseta.load()); }; for (size_t diff = 0; diff < 4; diff++) { @@ -48,7 +30,7 @@ void BattleParamsIndex::Table::print(FILE* stream) const { abbreviation_for_difficulty(diff)); for (size_t z = 0; z < 0x60; z++) { fprintf(stream, " %02zX ", z); - print_entry(stream, this->physical_data[diff][z]); + print_entry(stream, this->stats[diff][z]); fputc('\n', stream); } } diff --git a/src/BattleParamsIndex.hh b/src/BattleParamsIndex.hh index 139f21ad..6932ae17 100644 --- a/src/BattleParamsIndex.hh +++ b/src/BattleParamsIndex.hh @@ -10,6 +10,7 @@ #include #include "EnemyType.hh" +#include "LevelTable.hh" #include "StaticGameData.hh" #include "Text.hh" @@ -17,28 +18,10 @@ class BattleParamsIndex { public: // These files are little-endian, even on PSO GC. - struct PhysicalData { - /* 00 */ le_uint16_t atp; - /* 02 */ le_uint16_t psv; // Perseverance (intelligence?) - /* 04 */ le_uint16_t evp; - /* 06 */ le_uint16_t hp; - /* 08 */ le_uint16_t dfp; - /* 0A */ le_uint16_t ata; - /* 0C */ le_uint16_t lck; - /* 0E */ le_uint16_t esp; // Unknown - /* 10 */ parray unknown_a1; - /* 18 */ le_uint32_t unknown_a2; - /* 1C */ le_uint32_t experience; - /* 20 */ le_uint32_t difficulty; - /* 24 */ - - std::string str() const; - } __attribute__((packed)); - struct AttackData { /* 00 */ le_int16_t unknown_a1; - /* 02 */ le_int16_t unknown_a2; - /* 04 */ le_uint16_t unknown_a3; + /* 02 */ le_int16_t atp; + /* 04 */ le_int16_t ata_bonus; /* 06 */ le_uint16_t unknown_a4; /* 08 */ le_float distance_x; /* 0C */ le_float angle_x; @@ -87,7 +70,7 @@ public: } __attribute__((packed)); struct Table { - /* 0000 */ parray, 4> physical_data; + /* 0000 */ parray, 4> stats; /* 3600 */ parray, 4> attack_data; /* 7E00 */ parray, 4> resist_data; /* AE00 */ parray, 4> movement_data; diff --git a/src/QuestScript.cc b/src/QuestScript.cc index 48f92304..853a35de 100644 --- a/src/QuestScript.cc +++ b/src/QuestScript.cc @@ -1406,8 +1406,8 @@ std::string disassemble_quest_script(const void* data, size_t size, QuestScriptV print_as_struct.template operator()([&](const AttackData& attack) -> void { lines.emplace_back(" // As AttackData"); lines.emplace_back(string_printf(" %04zX a1 %04hX /* %hd */", l->offset + offsetof(AttackData, unknown_a1), attack.unknown_a1.load(), attack.unknown_a1.load())); - lines.emplace_back(string_printf(" %04zX a2 %04hX /* %hd */", l->offset + offsetof(AttackData, unknown_a2), attack.unknown_a2.load(), attack.unknown_a2.load())); - lines.emplace_back(string_printf(" %04zX a3 %04hX /* %hu */", l->offset + offsetof(AttackData, unknown_a3), attack.unknown_a3.load(), attack.unknown_a3.load())); + lines.emplace_back(string_printf(" %04zX atp %04hX /* %hd */", l->offset + offsetof(AttackData, atp), attack.atp.load(), attack.atp.load())); + lines.emplace_back(string_printf(" %04zX ata_bonus %04hX /* %hd */", l->offset + offsetof(AttackData, ata_bonus), attack.ata_bonus.load(), attack.ata_bonus.load())); lines.emplace_back(string_printf(" %04zX a4 %04hX /* %hu */", l->offset + offsetof(AttackData, unknown_a4), attack.unknown_a4.load(), attack.unknown_a4.load())); lines.emplace_back(string_printf(" %04zX distance_x %08" PRIX32 " /* %g */", l->offset + offsetof(AttackData, distance_x), attack.distance_x.load_raw(), attack.distance_x.load())); lines.emplace_back(string_printf(" %04zX angle_x %08" PRIX32 " /* %g */", l->offset + offsetof(AttackData, angle_x), attack.angle_x.load_raw(), attack.angle_x.load())); diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index a46f2a53..486a6097 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -1524,7 +1524,7 @@ static void on_steal_exp_bb(shared_ptr c, uint8_t, uint8_t, const void* uint32_t bp_index = battle_param_index_for_enemy_type(l->episode, enemy.type); const auto& bp_table = s->battle_params->get_table(l->mode == GameMode::SOLO, l->episode); uint32_t percent = 8 + ((special - 9) << 1) + (char_class_is_android(p->disp.visual.char_class) ? 30 : 0); - uint32_t enemy_exp = bp_table.physical_data[l->difficulty][bp_index].experience; + uint32_t enemy_exp = bp_table.stats[l->difficulty][bp_index].experience; uint32_t stolen_exp = min((enemy_exp * percent) / 100, 80); if (c->options.debug) { send_text_message_printf(c, "$C5+%" PRIu32 " E-%hX %s", @@ -1571,7 +1571,7 @@ static void on_enemy_killed_bb(shared_ptr c, uint8_t command, uint8_t fl try { const auto& bp_table = s->battle_params->get_table(l->mode == GameMode::SOLO, l->episode); uint32_t bp_index = battle_param_index_for_enemy_type(l->episode, e.type); - experience = bp_table.physical_data[l->difficulty][bp_index].experience * l->exp_multiplier; + experience = bp_table.stats[l->difficulty][bp_index].experience * l->exp_multiplier; } catch (const exception& e) { if (c->options.debug) { send_text_message_printf(c, "$C5E-%hX __MISSING__\n%s", cmd.enemy_id.load(), e.what());