mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Quest API] Add Recipe-based methods to Perl/Lua. (#2844)
* [Quest API] Add Recipe-based methods to Perl/Lua. # Perl - Add `quest::get_recipe_component_item_ids(recipe_id)`. - Add `quest::get_recipe_container_item_ids(recipe_id)`. - Add `quest::get_recipe_fail_item_ids(recipe_id)`. - Add `quest::get_recipe_salvage_item_ids(recipe_id)`. - Add `quest::get_recipe_success_item_ids(recipe_id)`. - Add `quest::get_recipe_component_count(recipe_id, item_id)`. - Add `quest::get_recipe_fail_count(recipe_id, item_id)`. - Add `quest::get_recipe_salvage_count(recipe_id, item_id)`. - Add `quest::get_recipe_success_count(recipe_id, item_id)`. # Lua - Add `eq.get_recipe_component_item_ids(recipe_id)`. - Add `eq.get_recipe_container_item_ids(recipe_id)`. - Add `eq.get_recipe_fail_item_ids(recipe_id)`. - Add `eq.get_recipe_salvage_item_ids(recipe_id)`. - Add `eq.get_recipe_success_item_ids(recipe_id)`. - Add `eq.get_recipe_component_count(recipe_id, item_id)`. - Add `eq.get_recipe_fail_count(recipe_id, item_id)`. - Add `eq.get_recipe_salvage_count(recipe_id, item_id)`. - Add `eq.get_recipe_success_count(recipe_id, item_id)`. # Notes - Before these methods, you would have to use DBI from Perl or Lua in order to get the components and their counts, these methods allow easy access to these values via the scripting API. - These should be used sparingly as they're each an individual database hit and could go crazy in a hot path. * Update eq_constants.h * Update zonedb.h * Update tradeskills.cpp * Reserve.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "../common/repositories/char_recipe_list_repository.h"
|
||||
#include "../common/zone_store.h"
|
||||
#include "../common/repositories/tradeskill_recipe_repository.h"
|
||||
#include "../common/repositories/tradeskill_recipe_entries_repository.h"
|
||||
|
||||
extern QueryServ* QServ;
|
||||
|
||||
@@ -1634,6 +1635,86 @@ void Client::LearnRecipe(uint32 recipe_id)
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<uint32> ZoneDatabase::GetRecipeComponentItemIDs(RecipeCountType count_type, uint32 recipe_id)
|
||||
{
|
||||
std::vector<uint32> l;
|
||||
|
||||
const auto& tr = TradeskillRecipeRepository::FindOne(content_db, recipe_id);
|
||||
if (!tr.id) {
|
||||
return l;
|
||||
}
|
||||
|
||||
std::string c;
|
||||
switch (count_type) {
|
||||
case RecipeCountType::Success:
|
||||
c = "successcount";
|
||||
break;
|
||||
case RecipeCountType::Fail:
|
||||
c = "failcount";
|
||||
break;
|
||||
case RecipeCountType::Component:
|
||||
c = "componentcount";
|
||||
break;
|
||||
case RecipeCountType::Salvage:
|
||||
c = "salvagecount";
|
||||
break;
|
||||
case RecipeCountType::Container:
|
||||
c = "iscontainer";
|
||||
break;
|
||||
}
|
||||
|
||||
const auto& tre = TradeskillRecipeEntriesRepository::GetWhere(
|
||||
content_db,
|
||||
fmt::format(
|
||||
"recipe_id = {} AND {} >= 1 ORDER BY id ASC",
|
||||
recipe_id,
|
||||
c
|
||||
)
|
||||
);
|
||||
if (tre.empty()) {
|
||||
return l;
|
||||
}
|
||||
|
||||
for (const auto& e : tre) {
|
||||
l.emplace_back(e.item_id);
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
int8 ZoneDatabase::GetRecipeComponentCount(RecipeCountType count_type, uint32 recipe_id, uint32 item_id)
|
||||
{
|
||||
const auto& tr = TradeskillRecipeRepository::FindOne(content_db, recipe_id);
|
||||
if (!tr.id) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const auto& tre = TradeskillRecipeEntriesRepository::GetWhere(
|
||||
content_db,
|
||||
fmt::format(
|
||||
"recipe_id = {} AND item_id = {} ORDER BY id ASC LIMIT 1",
|
||||
recipe_id,
|
||||
item_id
|
||||
)
|
||||
);
|
||||
if (tre.empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (count_type) {
|
||||
case RecipeCountType::Success:
|
||||
return tre[0].successcount;
|
||||
case RecipeCountType::Fail:
|
||||
return tre[0].failcount;
|
||||
case RecipeCountType::Component:
|
||||
return tre[0].componentcount;
|
||||
case RecipeCountType::Salvage:
|
||||
return tre[0].salvagecount;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool Client::CanIncreaseTradeskill(EQ::skills::SkillType tradeskill) {
|
||||
uint32 rawskill = GetRawSkill(tradeskill);
|
||||
uint16 maxskill = MaxSkill(tradeskill);
|
||||
|
||||
Reference in New Issue
Block a user