implement Hunters Report item behavior

This commit is contained in:
Martin Michelsen
2025-10-17 23:16:04 -07:00
parent 3f2df68ac5
commit 6ffa656ad4
2 changed files with 13 additions and 4 deletions
+10
View File
@@ -200,6 +200,16 @@ void player_use_item(shared_ptr<Client> c, size_t item_index, shared_ptr<RandomG
}
}
} else if (primary_identifier == 0x03170000) { // Unopened Hunters Report
// The unopened Hunters Report's rank is stored in the kill count field; using the unopened report copies the rank
// to data1[2] and replaces the inventory item with a new item with the same ID. The game also moves the item to
// the end of the inventory, so we do the same.
const auto& stack_limits = *s->item_stack_limits(c->version());
auto report_item = player->remove_item(item.data.id, 1, stack_limits);
report_item.data1[2] = report_item.get_kill_count();
player->add_item(report_item, stack_limits);
should_delete_item = false;
} else {
// Use item combinations table from ItemPMT
bool combo_applied = false;
+3 -4
View File
@@ -2374,16 +2374,15 @@ static asio::awaitable<void> on_use_item(shared_ptr<Client> c, SubcommandMessage
size_t index = p->inventory.find_item(cmd.item_id);
string name;
{
// Note: We do this weird scoping thing because player_use_item will
// likely delete the item, which will break the reference here.
// Note: We manually downscope item here because player_use_item will likely move or delete the item, which will
// break the reference, so we don't want to accidentally use it again after that.
const auto& item = p->inventory.items[index].data;
name = s->describe_item(c->version(), item);
}
player_use_item(c, index, l->rand_crypt);
if (l->log.should_log(phosg::LogLevel::L_INFO)) {
l->log.info_f("Player {} used item {}:{:08X} ({})",
c->lobby_client_id, cmd.header.client_id, cmd.item_id, name);
l->log.info_f("Player {} used item {}:{:08X} ({})", c->lobby_client_id, cmd.header.client_id, cmd.item_id, name);
c->print_inventory();
}