[Tradeskills] Fix for Lore Conflict (#2977)

* [Tradeskills] Fix for Lore Conflict

* Cleanup

* formatting

* it's beautiful

* container fix
This commit is contained in:
Aeadoin 2023-02-24 14:14:36 -05:00 committed by GitHub
parent 5acc181d64
commit f39155952f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 35 deletions

View File

@ -792,6 +792,7 @@ public:
void SendTradeskillDetails(uint32 recipe_id); void SendTradeskillDetails(uint32 recipe_id);
bool TradeskillExecute(DBTradeskillRecipe_Struct *spec); bool TradeskillExecute(DBTradeskillRecipe_Struct *spec);
void CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float skillup_modifier, uint16 success_modifier, EQ::skills::SkillType tradeskill); void CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float skillup_modifier, uint16 success_modifier, EQ::skills::SkillType tradeskill);
bool CheckTradeskillLoreConflict(int32 recipe_id);
void InitInnates(); void InitInnates();
void GMKill(); void GMKill();

View File

@ -469,23 +469,12 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
} }
// Check if Combine would result in Lore conflict // Check if Combine would result in Lore conflict
for (const auto& e : spec.onsuccess) { if (user->CheckTradeskillLoreConflict(spec.recipe_id)) {
auto success_item_inst = database.GetItem(e.first);
if (success_item_inst->LoreGroup > 0) {
continue;
}
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); auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp); user->QueuePacket(outapp);
safe_delete(outapp); safe_delete(outapp);
return; return;
} }
}
// final check for any additional quest requirements .. "check_zone" in this case - exported as variable [validate_type] // final check for any additional quest requirements .. "check_zone" in this case - exported as variable [validate_type]
if (parse->PlayerHasQuestSub(EVENT_COMBINE_VALIDATE)) { if (parse->PlayerHasQuestSub(EVENT_COMBINE_VALIDATE)) {
@ -622,9 +611,9 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
} }
//pull the list of components //pull the list of components
std::string query = StringFormat("SELECT tre.item_id, tre.componentcount " const auto query = fmt::format("SELECT item_id, componentcount "
"FROM tradeskill_recipe_entries AS tre " "FROM tradeskill_recipe_entries "
"WHERE tre.componentcount > 0 AND tre.recipe_id = %u", "WHERE componentcount > 0 AND recipe_id = {}",
rac->recipe_id); rac->recipe_id);
auto results = content_db.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
@ -698,6 +687,13 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
return; return;
} }
// Check if Combine would result in Lore conflict
if (user->CheckTradeskillLoreConflict(rac->recipe_id)) {
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
//now we know they have everything... //now we know they have everything...
//remove all the items from the players inventory, with updates... //remove all the items from the players inventory, with updates...
@ -727,22 +723,6 @@ 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);
@ -1882,3 +1862,35 @@ bool ZoneDatabase::DisableRecipe(uint32 recipe_id)
return false; return false;
} }
bool Client::CheckTradeskillLoreConflict(int32 recipe_id)
{
const auto& recipe_entries = TradeskillRecipeEntriesRepository::GetWhere(
content_db,
fmt::format(
"recipe_id = {} ORDER BY id ASC",
recipe_id
)
);
if (recipe_entries.empty()) {
return false;
}
for (auto& e : recipe_entries) {
auto item_inst = database.GetItem(e.item_id);
if (item_inst) {
if (item_inst->LoreGroup == 0 || e.componentcount > 0 || e.iscontainer) {
continue;
}
if (CheckLoreConflict(item_inst)) {
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemData);
linker.SetItemData(item_inst);
auto item_link = linker.GenerateLink();
MessageString(Chat::Red, TRADESKILL_COMBINE_LORE, item_link.c_str());
return true;
}
}
}
return false;
}