[Tradeskills] Check if combine would result in lore conflict (#2932)

* [Tradeskills] Check if Combine would result in Lore Conflict.

* formatting

* Add Saylinks to lore message output.

* Aknowledgement packets to prevent client issues.
This commit is contained in:
Aeadoin 2023-02-15 22:03:16 -05:00 committed by GitHub
parent 5ee2856133
commit 99e49cb2ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 2 deletions

View File

@ -383,8 +383,9 @@
#define FORAGE_MASTERY 6012 //Your forage mastery has enabled you to find something else! #define FORAGE_MASTERY 6012 //Your forage mastery has enabled you to find something else!
#define GUILD_BANK_CANNOT_DEPOSIT 6097 // Cannot deposit this item. Containers must be empty, and only one of each LORE and no NO TRADE or TEMPORARY items may be deposited. #define GUILD_BANK_CANNOT_DEPOSIT 6097 // Cannot deposit this item. Containers must be empty, and only one of each LORE and no NO TRADE or TEMPORARY items may be deposited.
#define GUILD_BANK_FULL 6098 // There is no more room in the Guild Bank. #define GUILD_BANK_FULL 6098 // There is no more room in the Guild Bank.
#define GUILD_BANK_TRANSFERRED 6100 // '%1' transferred to Guild Bank from Deposits. #define GUILD_BANK_TRANSFERRED 6100 // '%1' transferred to Guild Bank from Deposits.
#define GUILD_BANK_EMPTY_HANDS 6108 // You must empty your hands to withdraw from the Guild Bank. #define GUILD_BANK_EMPTY_HANDS 6108 // You must empty your hands to withdraw from the Guild Bank.
#define TRADESKILL_COMBINE_LORE 6199 // Combine would result in a LORE item (%1) you already possess.
#define TRANSFORM_FAILED 6326 //This mold cannot be applied to your %1. #define TRANSFORM_FAILED 6326 //This mold cannot be applied to your %1.
#define TRANSFORM_COMPLETE 6327 //You have successfully transformed your %1. #define TRANSFORM_COMPLETE 6327 //You have successfully transformed your %1.
#define DETRANSFORM_FAILED 6341 //%1 has no transformation that can be removed. #define DETRANSFORM_FAILED 6341 //%1 has no transformation that can be removed.

View File

@ -253,6 +253,9 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
{ {
if (!user || !in_combine) { if (!user || !in_combine) {
LogError("Client or NewCombine_Struct not set in Object::HandleCombine"); LogError("Client or NewCombine_Struct not set in Object::HandleCombine");
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return; return;
} }
@ -278,6 +281,9 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
Chat::Red, Chat::Red,
"Error: Server is not aware of the tradeskill container you are attempting to use" "Error: Server is not aware of the tradeskill container you are attempting to use"
); );
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return; return;
} }
c_type = worldo->m_type; c_type = worldo->m_type;
@ -304,6 +310,9 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
if (!inst || !inst->IsType(EQ::item::ItemClassBag)) { if (!inst || !inst->IsType(EQ::item::ItemClassBag)) {
user->Message(Chat::Red, "Error: Server does not recognize specified tradeskill container"); user->Message(Chat::Red, "Error: Server does not recognize specified tradeskill container");
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return; return;
} }
@ -427,22 +436,50 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
if (spec.tradeskill == EQ::skills::SkillAlchemy) { if (spec.tradeskill == EQ::skills::SkillAlchemy) {
if (user_pp.class_ != SHAMAN) { if (user_pp.class_ != SHAMAN) {
user->Message(Chat::Red, "This tradeskill can only be performed by a shaman."); user->Message(Chat::Red, "This tradeskill can only be performed by a shaman.");
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return; return;
} }
else if (user_pp.level < MIN_LEVEL_ALCHEMY) { else if (user_pp.level < MIN_LEVEL_ALCHEMY) {
user->Message(Chat::Red, "You cannot perform alchemy until you reach level %i.", MIN_LEVEL_ALCHEMY); user->Message(Chat::Red, "You cannot perform alchemy until you reach level %i.", MIN_LEVEL_ALCHEMY);
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return; return;
} }
} }
else if (spec.tradeskill == EQ::skills::SkillTinkering) { else if (spec.tradeskill == EQ::skills::SkillTinkering) {
if (user_pp.race != GNOME) { if (user_pp.race != GNOME) {
user->Message(Chat::Red, "Only gnomes can tinker."); user->Message(Chat::Red, "Only gnomes can tinker.");
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return; return;
} }
} }
else if (spec.tradeskill == EQ::skills::SkillMakePoison) { else if (spec.tradeskill == EQ::skills::SkillMakePoison) {
if (user_pp.class_ != ROGUE) { if (user_pp.class_ != ROGUE) {
user->Message(Chat::Red, "Only rogues can mix poisons."); user->Message(Chat::Red, "Only rogues can mix poisons.");
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
}
// Check if Combine would result in Lore conflict
for (const auto& e : spec.onsuccess) {
auto success_item_inst = database.GetItem(e.first);
if (user->CheckLoreConflict(success_item_inst)) {
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemData);
linker.SetItemData(success_item_inst);
auto item_link = linker.GenerateLink();
user->MessageString(Chat::Red, TRADESKILL_COMBINE_LORE, item_link.c_str());
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return; return;
} }
} }
@ -687,6 +724,22 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
} }
} }
DBTradeskillRecipe_Struct recipe_struct;
// Check if Combine would result in Lore conflict
for (const auto& e : recipe_struct.onsuccess) {
auto success_item_inst = database.GetItem(e.first);
if (user->CheckLoreConflict(success_item_inst)) {
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemData);
linker.SetItemData(success_item_inst);
auto item_link = linker.GenerateLink();
user->MessageString(Chat::Red, TRADESKILL_COMBINE_LORE, item_link.c_str());
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
}
//otherwise, we found it all... //otherwise, we found it all...
outp->reply_code = 0x00000000; //success for finding it... outp->reply_code = 0x00000000; //success for finding it...
user->QueuePacket(outapp); user->QueuePacket(outapp);