diff --git a/src/ItemData.cc b/src/ItemData.cc index 2bd7ff24..6ba25957 100644 --- a/src/ItemData.cc +++ b/src/ItemData.cc @@ -262,9 +262,17 @@ void ItemData::add_mag_photon_blast(uint8_t pb_num) { } } +uint16_t ItemData::get_sealed_item_kill_count() const { + return ((this->data1[10] << 8) | this->data1[11]) & 0x7FFF; +} + void ItemData::set_sealed_item_kill_count(uint16_t v) { - this->data1[10] = (v >> 8) | 0x80; - this->data1[11] = v; + if (v > 0x7FFF) { + this->data1w[5] = 0xFFFF; + } else { + this->data1[10] = (v >> 8) | 0x80; + this->data1[11] = v; + } } uint8_t ItemData::get_tool_item_amount() const { diff --git a/src/ItemData.hh b/src/ItemData.hh index 6bdf3257..8a07ba3f 100644 --- a/src/ItemData.hh +++ b/src/ItemData.hh @@ -129,6 +129,7 @@ struct ItemData { // 0x14 bytes bool mag_has_photon_blast_in_any_slot(uint8_t pb_num) const; void add_mag_photon_blast(uint8_t pb_num); + uint16_t get_sealed_item_kill_count() const; void set_sealed_item_kill_count(uint16_t v); uint8_t get_tool_item_amount() const; void set_tool_item_amount(uint8_t amount); diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index cf650352..17c34039 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -1497,8 +1497,16 @@ static void on_enemy_killed_bb(shared_ptr s, if (leveled_up) { send_level_up(l, other_c); } + } + } - // TODO: Update kill counts on unsealable items + // Update kill counts on unsealable items + auto& inventory = c->game_data.player()->inventory; + for (size_t z = 0; z < inventory.num_items; z++) { + auto& item = inventory.items[z]; + if ((item.flags & 0x08) && + s->item_parameter_table->is_unsealable_item(item.data)) { + item.data.set_sealed_item_kill_count(item.data.get_sealed_item_kill_count() + 1); } } }