fix equip state after item combinations applied

This commit is contained in:
Martin Michelsen
2024-05-04 20:39:52 -07:00
parent c411cec06c
commit 2e7c792b97
6 changed files with 29 additions and 13 deletions
+1 -1
View File
@@ -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);
}
}
+14 -8
View File
@@ -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;
}
}
}
+4 -2
View File
@@ -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;
+4 -1
View File
@@ -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;
+5
View File
@@ -119,21 +119,25 @@ void player_use_item(shared_ptr<Client> c, size_t item_index, shared_ptr<PSOLFGE
} else if (primary_identifier == 0x00330000) {
// Unseal Sealed J-Sword => 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<Client> c, size_t item_index, shared_ptr<PSOLFGE
inv_item.data.data1[2] = combo.result_item[2];
inv_item.data.data1[3] = 0; // Grind
inv_item.data.data1[4] = 0; // Flags + special
inv_item.flags &= (~8); // Unequip it
} catch (const out_of_range&) {
}
}
+1 -1
View File
@@ -3435,7 +3435,7 @@ static void on_enemy_exp_request_bb(shared_ptr<Client> 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);
}
}
}