mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Feature] Evolving Item Support for RoF2 (#4496)
* basic evolving items framework created * Implement evolving tab in the inventory window * Implement experience and number of kills * Move zone evolving map to a evolvingitemsmanager class * rework gm commands * rework GetInventory * wip * wip loot testing * Fix Duplicate Message * reworked evolving item looting, swapping, etc * reworked const functions for evolving methods * Functioning Player Trade of evolving items test item_id is 89550 * First pass of Final Result link working * First pass of item upgrading when reaching 100% * Add strings and logic for displaying the evolving item xp transfer window in Corathus * Prototype of xp transfer window sending items * WIP for evolve xp transfer * WIP for evolve xp transfer. First tests passed * XP Transfer Cleanup * XP Transfer Cleanup * Add Rule for evolving items equip timer/ default is 30 secs * Add logging and player events Add logging and player events * Formatting * Database updates * Updates for linux build * Perl/Cleanup * Command cleanup * Lua * Added a crash condition check if final item id is blank or not found. * Review Changes Updates to resolve review comments and a rebase. * migrate to content_db for items_evolving_details migrate to content_db for items_evolving_details * Simplify, don't hit database unless evolving * Update 2025_01_19_items_evolving_details.sql * Update client.cpp * Update manifest with items_evolving_details * character_id vs char_id * Remove _Struct from structs * Remove license header in evolving.cpp * Move evolving constants from eq_constants.h to evolving.h since it is more specific * Update database_schema.h * General cleanup * Be more specific with `evolving_items` vs `evolving` --------- Co-authored-by: Kinglykrab <kinglykrab@gmail.com> Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
@@ -344,6 +344,8 @@ bool EQ::InventoryProfile::SwapItem(
|
||||
fail_state = swapNotAllowed;
|
||||
return false;
|
||||
}
|
||||
|
||||
source_item_instance->SetEvolveEquipped(false);
|
||||
if ((destination_slot >= invslot::EQUIPMENT_BEGIN && destination_slot <= invslot::EQUIPMENT_END)) {
|
||||
auto source_item = source_item_instance->GetItem();
|
||||
if (!source_item) {
|
||||
@@ -362,6 +364,9 @@ bool EQ::InventoryProfile::SwapItem(
|
||||
fail_state = swapLevel;
|
||||
return false;
|
||||
}
|
||||
if (source_item_instance->IsEvolving() > 0) {
|
||||
source_item_instance->SetEvolveEquipped(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +375,8 @@ bool EQ::InventoryProfile::SwapItem(
|
||||
fail_state = swapNotAllowed;
|
||||
return false;
|
||||
}
|
||||
|
||||
destination_item_instance->SetEvolveEquipped(false);
|
||||
if ((source_slot >= invslot::EQUIPMENT_BEGIN && source_slot <= invslot::EQUIPMENT_END)) {
|
||||
auto destination_item = destination_item_instance->GetItem();
|
||||
if (!destination_item) {
|
||||
@@ -388,6 +395,9 @@ bool EQ::InventoryProfile::SwapItem(
|
||||
fail_state = swapLevel;
|
||||
return false;
|
||||
}
|
||||
if (destination_item_instance->IsEvolving()) {
|
||||
destination_item_instance->SetEvolveEquipped(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1402,6 +1412,8 @@ int16 EQ::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
|
||||
int16 result = INVALID_INDEX;
|
||||
int16 parentSlot = INVALID_INDEX;
|
||||
|
||||
inst->SetEvolveEquipped(false);
|
||||
|
||||
if (slot_id == invslot::slotCursor) {
|
||||
// Replace current item on cursor, if exists
|
||||
m_cursor.pop(); // no memory delete, clients of this function know what they are doing
|
||||
@@ -1410,6 +1422,9 @@ int16 EQ::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
|
||||
}
|
||||
else if (slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) {
|
||||
if ((((uint64)1 << slot_id) & m_lookup->PossessionsBitmask) != 0) {
|
||||
if (inst->IsEvolving()) {
|
||||
inst->SetEvolveEquipped(true);
|
||||
}
|
||||
m_worn[slot_id] = inst;
|
||||
result = slot_id;
|
||||
}
|
||||
@@ -1808,3 +1823,182 @@ int16 EQ::InventoryProfile::FindFirstFreeSlotThatFitsItem(const EQ::ItemData *it
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//This function has the same flaw as noted above
|
||||
// Helper functions for evolving items
|
||||
int16 EQ::InventoryProfile::HasEvolvingItem(uint64 evolve_unique_id, uint8 quantity, uint8 where)
|
||||
{
|
||||
int16 slot_id = INVALID_INDEX;
|
||||
|
||||
// Altered by Father Nitwit to support a specification of
|
||||
// where to search, with a default value to maintain compatibility
|
||||
|
||||
// Check each inventory bucket
|
||||
if (where & invWhereWorn) {
|
||||
slot_id = _HasEvolvingItem(m_worn, evolve_unique_id, quantity);
|
||||
if (slot_id != INVALID_INDEX) {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (where & invWherePersonal) {
|
||||
slot_id = _HasEvolvingItem(m_inv, evolve_unique_id, quantity);
|
||||
if (slot_id != INVALID_INDEX) {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (where & invWhereBank) {
|
||||
slot_id = _HasEvolvingItem(m_bank, evolve_unique_id, quantity);
|
||||
if (slot_id != INVALID_INDEX) {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (where & invWhereSharedBank) {
|
||||
slot_id = _HasEvolvingItem(m_shbank, evolve_unique_id, quantity);
|
||||
if (slot_id != INVALID_INDEX) {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (where & invWhereTrading) {
|
||||
slot_id = _HasEvolvingItem(m_trade, evolve_unique_id, quantity);
|
||||
if (slot_id != INVALID_INDEX) {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Behavioral change - Limbo is no longer checked due to improper handling of return value
|
||||
if (where & invWhereCursor) {
|
||||
// Check cursor queue
|
||||
slot_id = _HasEvolvingItem(m_cursor, evolve_unique_id, quantity);
|
||||
if (slot_id != INVALID_INDEX) {
|
||||
return slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
// Internal Method: Checks an inventory bucket for a particular evolving item unique id
|
||||
int16 EQ::InventoryProfile::_HasEvolvingItem(
|
||||
std::map<int16, ItemInstance *> &bucket, uint64 evolve_unique_id, uint8 quantity)
|
||||
{
|
||||
uint32 quantity_found = 0;
|
||||
|
||||
for (auto const &[key, value]: bucket) {
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key <= EQ::invslot::POSSESSIONS_END && key >= EQ::invslot::POSSESSIONS_BEGIN) {
|
||||
if (((uint64) 1 << key & m_lookup->PossessionsBitmask) == 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (key <= EQ::invslot::BANK_END && key >= EQ::invslot::BANK_BEGIN) {
|
||||
if (key - EQ::invslot::BANK_BEGIN >= m_lookup->InventoryTypeSize.Bank) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (value->GetEvolveUniqueID() == evolve_unique_id) {
|
||||
quantity_found += value->GetCharges() <= 0 ? 1 : value->GetCharges();
|
||||
if (quantity_found >= quantity) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = invaug::SOCKET_BEGIN; index <= invaug::SOCKET_END; ++index) {
|
||||
if (value->GetAugmentEvolveUniqueID(index) == evolve_unique_id && quantity <= 1) {
|
||||
return invslot::SLOT_AUGMENT_GENERIC_RETURN;
|
||||
}
|
||||
}
|
||||
|
||||
if (!value->IsClassBag()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto const &[bag_key, bag_value]: *value->GetContents()) {
|
||||
if (!bag_value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bag_value->GetEvolveUniqueID() == evolve_unique_id) {
|
||||
quantity_found += bag_value->GetCharges() <= 0 ? 1 : bag_value->GetCharges();
|
||||
if (quantity_found >= quantity) {
|
||||
return CalcSlotId(key, bag_key);
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = invaug::SOCKET_BEGIN; index <= invaug::SOCKET_END; ++index) {
|
||||
if (bag_value->GetAugmentEvolveUniqueID(index) == evolve_unique_id && quantity <= 1) {
|
||||
return invslot::SLOT_AUGMENT_GENERIC_RETURN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return INVALID_INDEX;
|
||||
}
|
||||
|
||||
// Internal Method: Checks an inventory queue type bucket for a particular item
|
||||
int16 EQ::InventoryProfile::_HasEvolvingItem(ItemInstQueue &iqueue, uint64 evolve_unique_id, uint8 quantity)
|
||||
{
|
||||
// The downfall of this (these) queue procedure is that callers presume that when an item is
|
||||
// found, it is presented as being available on the cursor. In cases of a parity check, this
|
||||
// is sufficient. However, in cases where referential criteria is considered, this can lead
|
||||
// to unintended results. Funtionality should be observed when referencing the return value
|
||||
// of this query
|
||||
|
||||
uint32 quantity_found = 0;
|
||||
|
||||
for (auto const &inst: iqueue) {
|
||||
if (!inst) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inst->GetEvolveUniqueID() == evolve_unique_id) {
|
||||
quantity_found += inst->GetCharges() <= 0 ? 1 : inst->GetCharges();
|
||||
if (quantity_found >= quantity) {
|
||||
return invslot::slotCursor;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = invaug::SOCKET_BEGIN; index <= invaug::SOCKET_END; ++index) {
|
||||
if (inst->GetAugmentEvolveUniqueID(index) == evolve_unique_id && quantity <= 1) {
|
||||
return invslot::SLOT_AUGMENT_GENERIC_RETURN;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inst->IsClassBag()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto const &[bag_key, bag_value]: *inst->GetContents()) {
|
||||
if (!bag_value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bag_value->GetEvolveUniqueID() == evolve_unique_id) {
|
||||
quantity_found += bag_value->GetCharges() <= 0 ? 1 : bag_value->GetCharges();
|
||||
if (quantity_found >= quantity) {
|
||||
return CalcSlotId(invslot::slotCursor, bag_key);
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = invaug::SOCKET_BEGIN; index <= invaug::SOCKET_END; ++index) {
|
||||
if (bag_value->GetAugmentEvolveUniqueID(index) == evolve_unique_id && quantity <= 1) {
|
||||
return invslot::SLOT_AUGMENT_GENERIC_RETURN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We only check the visible cursor due to lack of queue processing ability (client allows duplicate in limbo)
|
||||
break;
|
||||
}
|
||||
|
||||
return INVALID_INDEX;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user