fix profession

This commit is contained in:
luis
2026-11-15 08:43:17 -03:00
parent 7a08902c4c
commit a39762d6d8
6 changed files with 103 additions and 2 deletions
+61
View File
@@ -656,6 +656,44 @@ SpellCastResult Crafting::DoCraft(uint32 craftingDataId)
else if (progress > 1.0f)
progress = 1.0f;
// First craft bonus. Every recipe carries a hidden flag that the client uses to tell whether the
// item was already crafted: an older QuestV2 flag (no objectives, no reward, only the completed
// bit) or a PlayerDataFlagCharacter bit for the newer recipes. Nothing on the server ever set
// those flags, so a first craft stayed "not yet crafted" forever and the knowledge currency was
// never awarded. The flag is resolved before crafting so an unknown flag never awards twice.
bool isFirstCraft = false;
if (!_recraft)
{
if (_craftingData->FirstCraftFlagQuestID > 0)
{
uint32 firstCraftQuestId = uint32(_craftingData->FirstCraftFlagQuestID);
isFirstCraft = sDB2Manager.GetQuestUniqueBitFlag(firstCraftQuestId) != 0
&& !_player->IsQuestCompletedBitSet(firstCraftQuestId);
}
else if (_craftingData->FirstCraftPlayerDataFlagCharacterID > 0)
{
uint32 firstCraftFlagId = uint32(_craftingData->FirstCraftPlayerDataFlagCharacterID);
isFirstCraft = sPlayerDataFlagCharacterStore.LookupEntry(firstCraftFlagId) != nullptr
&& !_player->HasDataFlagCharacter(firstCraftFlagId);
}
}
uint32 firstCraftKnowledgeCurrency = 0;
if (isFirstCraft && skillAbility)
{
auto findKnowledgeCurrency = [&](uint32 skillLineId)
{
return visitSkillLineChain(skillLineId, [&](uint32 line)
{
firstCraftKnowledgeCurrency = sDB2Manager.GetProfessionKnowledgeCurrencyForSkillLine(line);
return firstCraftKnowledgeCurrency != 0;
});
};
if (!findKnowledgeCurrency(skillAbility->SkillLine))
findKnowledgeCurrency(skillAbility->SkillupSkillLineID);
}
WorldPackets::Crafting::CraftingData craftingData;
craftingData.CraftingQualityID = quality.CraftingQualityID;
craftingData.QualityProgress = progress;
@@ -678,8 +716,31 @@ SpellCastResult Crafting::DoCraft(uint32 craftingDataId)
craftingData.ConcentrationSpent = concentrationSpent;
craftingData.ApplyConcentration = concentrationApplied;
craftingData.ResourcesReturned = std::move(resourcesReturned);
craftingData.IsFirstCraft = isFirstCraft;
if (isFirstCraft)
craftingData.OperationID = _craftingData->ID;
_player->SendNewItem(createdItem, totalCount, true, true, false, 0, &craftingData);
// The knowledge gain is sent as a plain currency update, with the craft operation id attached so
// the client can link the "first craft" toast to the craft that produced it.
if (isFirstCraft)
{
_player->SetCurrentCraftOperationID(_craftingData->ID);
if (firstCraftKnowledgeCurrency)
_player->ModifyCurrency(firstCraftKnowledgeCurrency, 1, CurrencyGainSource::ProfessionInitialAward);
_player->SetCurrentCraftOperationID(Optional<uint32>());
// SetRewardedQuest persists the completed bit through character_queststatus_rewarded;
// a bare SetQuestCompletedBit would be lost on relog for QuestV2-only flag quests.
if (_craftingData->FirstCraftFlagQuestID > 0)
_player->SetRewardedQuest(uint32(_craftingData->FirstCraftFlagQuestID));
else if (_craftingData->FirstCraftPlayerDataFlagCharacterID > 0)
_player->SetDataFlagCharacter(uint32(_craftingData->FirstCraftPlayerDataFlagCharacterID), true);
}
_player->UpdateCraftSkill(_spell->GetSpellInfo());
return SpellCastResult::SPELL_CAST_OK;
}
+1 -1
View File
@@ -9057,7 +9057,7 @@ struct CraftingDataLoadInfo
{.IsSigned = false, .Type = FT_FLOAT, .Name = "Field_10_0_0_45141_011" },
{.IsSigned = true, .Type = FT_INT, .Name = "FirstCraftFlagQuestID" },
{.IsSigned = true, .Type = FT_INT, .Name = "FirstCraftTreasureID" },
{.IsSigned = true, .Type = FT_INT, .Name = "Field_10_2_5_52432_014" },
{.IsSigned = true, .Type = FT_INT, .Name = "FirstCraftPlayerDataFlagCharacterID" },
{.IsSigned = true, .Type = FT_INT, .Name = "CraftedTreasureID" },
};
+32
View File
@@ -747,6 +747,7 @@ namespace
std::unordered_map<uint32, std::vector<ProfessionEffectValue>> _professionEffectsByTraitDefinition;
std::unordered_map<int32, ProfessionEffectValue> _professionEffectById;
std::unordered_map<uint32, uint32> _concentrationCurrencyBySkillLine;
std::unordered_map<uint32, uint32> _professionKnowledgeCurrencyBySkillLine;
std::unordered_map<uint32, std::pair<float, float>> _multicraftExtraPercentBySkillLine;
std::unordered_map<uint32, std::pair<float, float>> _resourcefulEffectBySkillLine;
@@ -2254,6 +2255,31 @@ void DB2Manager::IndexLoadedStores()
itemIds.push_back(row.ItemId);
}
//WowCommunity
// Profession knowledge is a currency, and the specialization trees are the only place where the
// client links a profession skill line to the currency that is spent in it. TraitCurrency rows of
// type CurrencyTypesBased point at the knowledge currency of that profession and expansion.
{
std::unordered_map<uint32 /*traitTreeId*/, uint32 /*currencyId*/> knowledgeCurrencyByTraitTree;
for (TraitTreeXTraitCurrencyEntry const* link : sTraitTreeXTraitCurrencyStore)
{
TraitCurrencyEntry const* traitCurrency = sTraitCurrencyStore.LookupEntry(uint32(link->TraitCurrencyID));
if (!traitCurrency || traitCurrency->GetType() != TraitCurrencyType::CurrencyTypesBased || traitCurrency->CurrencyTypesID <= 0)
continue;
knowledgeCurrencyByTraitTree[link->TraitTreeID] = uint32(traitCurrency->CurrencyTypesID);
}
for (SkillLineXTraitTreeEntry const* link : sSkillLineXTraitTreeStore)
{
auto itr = knowledgeCurrencyByTraitTree.find(link->TraitTreeID);
if (itr == knowledgeCurrencyByTraitTree.end())
continue;
_professionKnowledgeCurrencyBySkillLine[link->SkillLineID] = itr->second;
}
}
for (SoulbindConduitRankEntry const* soulbindConduitRank : sSoulbindConduitRankStore)
_soulbindConduitRanks[{ soulbindConduitRank->SoulbindConduitID, soulbindConduitRank->RankIndex }] = soulbindConduitRank;
@@ -4377,6 +4403,12 @@ uint32 DB2Manager::GetConcentrationCurrencyForSkillLine(uint32 skillLineId) cons
return itr != _concentrationCurrencyBySkillLine.end() ? itr->second : 0;
}
uint32 DB2Manager::GetProfessionKnowledgeCurrencyForSkillLine(uint32 skillLineId) const
{
auto itr = _professionKnowledgeCurrencyBySkillLine.find(skillLineId);
return itr != _professionKnowledgeCurrencyBySkillLine.end() ? itr->second : 0;
}
bool DB2Manager::GetMulticraftExtraQuantityRange(uint32 skillLineId, float& minPercent, float& maxPercent) const
{
auto itr = _multicraftExtraPercentBySkillLine.find(skillLineId);
+1
View File
@@ -760,6 +760,7 @@ public:
void AccumulateProfessionTraitEffects(int32 traitDefinitionId, int32 rank, ProfessionEffectTotals& totals) const;
void AccumulateProfessionEffect(int32 effectId, int32 stacks, ProfessionEffectTotals& totals) const;
uint32 GetConcentrationCurrencyForSkillLine(uint32 skillLineId) const;
uint32 GetProfessionKnowledgeCurrencyForSkillLine(uint32 skillLineId) const;
bool GetMulticraftExtraQuantityRange(uint32 skillLineId, float& minPercent, float& maxPercent) const;
bool GetResourcefulEffectRange(uint32 skillLineId, float& minPercent, float& maxPercent) const;
std::vector<RenownRewardsEntry const*> const* GetRenownRewards(int32 covenantId, int32 level) const;
+1 -1
View File
@@ -6456,7 +6456,7 @@ struct CraftingDataEntry
float Field_10_0_0_45141_011;
int32 FirstCraftFlagQuestID;
int32 FirstCraftTreasureID;
int32 Field_10_2_5_52432_014;
int32 FirstCraftPlayerDataFlagCharacterID;
int32 CraftedTreasureID;
};
@@ -20935,6 +20935,13 @@ void Player::_LoadQuestStatusRewarded(PreparedQueryResult result)
if (quest->CanIncreaseRewardedQuestCounters())
m_RewardedQuests.insert(quest_id);
}
else
{
// Quests without a quest_template row can still carry a QuestV2 UniqueBitFlag
// (e.g. profession first-craft flags). The bit only needs the flag, not a Quest
// object, and SetQuestCompletedBit no-ops when the id has no bit assigned.
SetQuestCompletedBit(quest_id, true);
}
} while (result->NextRow());
}
}