diff --git a/src/ItemCreator.cc b/src/ItemCreator.cc index 5c5c561c..58868a64 100644 --- a/src/ItemCreator.cc +++ b/src/ItemCreator.cc @@ -708,17 +708,17 @@ void ItemCreator::generate_common_weapon_special( if (this->rand_int(100) >= this->pt->special_percent[area_norm]) { return; } - item.data1[4] = this->unknown_8011CA54( + item.data1[4] = this->choose_weapon_special( special_mult * this->rand_float_0_1_from_crypt(10)); } -uint8_t ItemCreator::unknown_8011CA54(uint8_t det) { +uint8_t ItemCreator::choose_weapon_special(uint8_t det) { if (det < 4) { static const uint8_t maxes[4] = {8, 10, 11, 11}; uint8_t det2 = this->rand_int(maxes[det]); size_t index = 0; for (size_t z = 1; z < 0x29; z++) { - if (det + 1 == this->unknown_8011C63C(z)) { + if (det + 1 == this->item_parameter_table->get_special_stars(z)) { if (index == det2) { return z; } else { @@ -730,15 +730,6 @@ uint8_t ItemCreator::unknown_8011CA54(uint8_t det) { return 0; } -uint8_t ItemCreator::unknown_8011C63C(uint8_t det) const { - if (!(det & 0x3F) || (det & 0x80)) { - return 0; - } - // Note: PSO GC uses 0x1CB here. 0x256 was chosen to point to the same data in - // PSO BB's ItemPMT file. - return this->item_parameter_table->get_item_stars(det + 0x0256); -} - void ItemCreator::generate_unit_weights_tables() { @@ -1489,10 +1480,10 @@ void ItemCreator::generate_weapon_shop_item_special( item.data1[4] = 0; break; case 1: - item.data1[4] = this->unknown_8011CA54(0); + item.data1[4] = this->choose_weapon_special(0); break; case 2: - item.data1[4] = this->unknown_8011CA54(1); + item.data1[4] = this->choose_weapon_special(1); break; default: throw runtime_error("invalid special mode"); diff --git a/src/ItemCreator.hh b/src/ItemCreator.hh index 1cf41f2b..cc3286d4 100644 --- a/src/ItemCreator.hh +++ b/src/ItemCreator.hh @@ -144,8 +144,7 @@ private: uint8_t offset_within_subtype_range); void generate_common_weapon_bonuses(ItemData& item, uint8_t area_norm); void generate_common_weapon_special(ItemData& item, uint8_t area_norm); - uint8_t unknown_8011CA54(uint8_t det); - uint8_t unknown_8011C63C(uint8_t det) const; + uint8_t choose_weapon_special(uint8_t det); void generate_unit_weights_tables(); void generate_common_unit_variances(uint8_t det, ItemData& item); void choose_tech_disk_level_for_tool_shop( diff --git a/src/ItemParameterTable.cc b/src/ItemParameterTable.cc index d20b4f4e..ed189eb5 100644 --- a/src/ItemParameterTable.cc +++ b/src/ItemParameterTable.cc @@ -120,6 +120,15 @@ uint8_t ItemParameterTable::get_item_stars(uint16_t slot) const { return 0; } +uint8_t ItemParameterTable::get_special_stars(uint8_t det) const { + if (!(det & 0x3F) || (det & 0x80)) { + return 0; + } + // Note: PSO GC uses 0x1CB here. 0x256 was chosen to point to the same data in + // PSO BB's ItemPMT file. + return this->get_item_stars(det + 0x0256); +} + uint8_t ItemParameterTable::get_max_tech_level(uint8_t char_class, uint8_t tech_num) const { if (char_class >= 12) { throw logic_error("invalid character class"); diff --git a/src/ItemParameterTable.hh b/src/ItemParameterTable.hh index b88da083..66e67d16 100644 --- a/src/ItemParameterTable.hh +++ b/src/ItemParameterTable.hh @@ -225,6 +225,7 @@ public: float get_sale_divisor(uint8_t data1_0, uint8_t data1_1) const; const MagFeedResult& get_mag_feed_result(uint8_t table_index, uint8_t which) const; uint8_t get_item_stars(uint16_t slot) const; + uint8_t get_special_stars(uint8_t det) const; uint8_t get_max_tech_level(uint8_t char_class, uint8_t tech_num) const; const ItemBase& get_item_definition(const ItemData& item) const;