diff --git a/src/ItemCreator.cc b/src/ItemCreator.cc index 08e4a611..4d310112 100644 --- a/src/ItemCreator.cc +++ b/src/ItemCreator.cc @@ -472,7 +472,7 @@ void ItemCreator::deduplicate_weapon_bonuses(ItemData& item) const { void ItemCreator::set_item_kill_count_if_unsealable(ItemData& item) const { if (this->item_parameter_table->is_unsealable_item(item)) { this->log.info("Item is unsealable; setting kill count to zero"); - item.set_sealed_item_kill_count(0); + item.set_kill_count(0); } } diff --git a/src/ItemData.cc b/src/ItemData.cc index aac18eef..28ea27a9 100644 --- a/src/ItemData.cc +++ b/src/ItemData.cc @@ -537,16 +537,22 @@ bool ItemData::has_encoded_v2_data() const { : (this->get_encoded_v2_data() != 0); } -uint16_t ItemData::get_sealed_item_kill_count() const { - return ((this->data1[10] << 8) | this->data1[11]) & 0x7FFF; +bool ItemData::has_kill_count() const { + return !this->is_s_rank_weapon() && (this->data1[10] & 0x80); } -void ItemData::set_sealed_item_kill_count(uint16_t v) { - if (v > 0x7FFF) { - this->data1w[5] = 0xFFFF; - } else { - this->data1[10] = (v >> 8) | 0x80; - this->data1[11] = v; +uint16_t ItemData::get_kill_count() const { + return this->has_kill_count() ? (((this->data1[10] << 8) | this->data1[11]) & 0x7FFF) : 0; +} + +void ItemData::set_kill_count(uint16_t v) { + if (!this->is_s_rank_weapon()) { + if (v > 0x7FFF) { + this->data1w[5] = 0xFFFF; + } else { + this->data1[10] = (v >> 8) | 0x80; + this->data1[11] = v; + } } } diff --git a/src/ItemData.hh b/src/ItemData.hh index bef317e1..60a19982 100644 --- a/src/ItemData.hh +++ b/src/ItemData.hh @@ -84,6 +84,7 @@ struct ItemData { // Mag: 02ZZLLWW HHHHIIII JJJJKKKK YYQQPPVV // Tool: 03ZZZZFF 00CC0000 00000000 00000000 // Meseta: 04000000 00000000 00000000 MMMMMMMM + // 01034D00 00000000 204E0000 // A = attribute type (for S-ranks, custom name) // B = attribute amount (for S-ranks, custom name) // C = stack size (for tools) @@ -173,8 +174,9 @@ struct ItemData { uint8_t get_encoded_v2_data() const; bool has_encoded_v2_data() const; - uint16_t get_sealed_item_kill_count() const; - void set_sealed_item_kill_count(uint16_t v); + bool has_kill_count() const; + uint16_t get_kill_count() const; + void set_kill_count(uint16_t v); uint8_t get_tool_item_amount(const StackLimits& limits) const; void set_tool_item_amount(const StackLimits& limits, uint8_t amount); int16_t get_armor_or_shield_defense_bonus() const; diff --git a/src/ItemNameIndex.cc b/src/ItemNameIndex.cc index fb6582ee..e0a4c4ce 100644 --- a/src/ItemNameIndex.cc +++ b/src/ItemNameIndex.cc @@ -208,7 +208,10 @@ std::string ItemNameIndex::describe_item(const ItemData& item, bool include_colo if (which == 0) { continue; } - if (which > 5) { + if (which & 0x80) { + uint16_t kill_count = ((which << 8) & 0x7F00) | (value & 0xFF); + ret_tokens.emplace_back(string_printf("K:%hu", kill_count)); + } else if (which > 5) { ret_tokens.emplace_back(string_printf("!PC:%02hhX%02hhX", which, value)); } else { bonuses[which - 1] = value; diff --git a/src/Items.cc b/src/Items.cc index 2d8707f5..76f3d516 100644 --- a/src/Items.cc +++ b/src/Items.cc @@ -119,21 +119,25 @@ void player_use_item(shared_ptr c, size_t item_index, shared_ptr Tsumikiri J-Sword item.data.data1[1] = 0x32; + item.flags &= (~8); // Unequip it should_delete_item = false; } else if (primary_identifier == 0x00AB0000) { // Unseal Lame d'Argent => Excalibur item.data.data1[1] = 0xAC; + item.flags &= (~8); // Unequip it should_delete_item = false; } else if (primary_identifier == 0x01034D00) { // Unseal Limiter => Adept item.data.data1[2] = 0x4E; + item.flags &= (~8); // Unequip it should_delete_item = false; } else if (primary_identifier == 0x01034F00) { // Unseal Swordsman Lore => Proof of Sword-Saint item.data.data1[2] = 0x50; + item.flags &= (~8); // Unequip it should_delete_item = false; } else if (primary_identifier == 0x030C0000) { @@ -242,6 +246,7 @@ void player_use_item(shared_ptr c, size_t item_index, shared_ptr c, uint8_t, uint8_t, void auto& item = inventory.items[z]; if ((item.flags & 0x08) && s->item_parameter_table(c->version())->is_unsealable_item(item.data)) { - item.data.set_sealed_item_kill_count(item.data.get_sealed_item_kill_count() + 1); + item.data.set_kill_count(item.data.get_kill_count() + 1); } } }