mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-14 19:38:08 +00:00
two tables done
This commit is contained in:
@@ -1628,9 +1628,9 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
|
||||
std::vector<CDObjectSkills> skills = skillsTable->Query([=](CDObjectSkills entry) {return (entry.objectTemplate == p.second.lot); });
|
||||
for (CDObjectSkills skill : skills) {
|
||||
CDSkillBehaviorTable* skillBehTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
CDSkillBehavior behaviorData = skillBehTable->GetSkillByID(skill.skillID);
|
||||
|
||||
SkillComponent::HandleUnmanaged(behaviorData.behaviorID, GetObjectID());
|
||||
auto behaviorData = skillBehTable->GetSkillByID(skill.skillID);
|
||||
if (!behaviorData) continue;
|
||||
SkillComponent::HandleUnmanaged(behaviorData->behaviorID, GetObjectID());
|
||||
|
||||
auto* missionComponent = GetComponent<MissionComponent>();
|
||||
|
||||
|
@@ -42,7 +42,8 @@ void OverTimeBehavior::Load() {
|
||||
// Since m_Action is a skillID and not a behavior, get is correlated behaviorID.
|
||||
|
||||
CDSkillBehaviorTable* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
m_ActionBehaviorId = skillTable->GetSkillByID(m_Action).behaviorID;
|
||||
auto skillData = skillTable->GetSkillByID(m_Action);
|
||||
if (skillData) m_ActionBehaviorId = skillData->behaviorID;
|
||||
|
||||
m_Delay = GetFloat("delay");
|
||||
m_NumIntervals = GetInt("num_intervals");
|
||||
|
@@ -104,7 +104,12 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO
|
||||
if (parameter.name == "overtime") {
|
||||
auto* behaviorTemplateTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
|
||||
behaviorID = behaviorTemplateTable->GetSkillByID(parameter.values[0]).behaviorID;
|
||||
auto skillInfo = behaviorTemplateTable->GetSkillByID(parameter.values[0]);
|
||||
if (skillInfo) {
|
||||
behaviorID = skillInfo->behaviorID;
|
||||
} else {
|
||||
Game::logger->Log("BuffComponent", "Failed to find skill info for skill ID %d!", parameter.values[0]);
|
||||
}
|
||||
stacks = static_cast<int32_t>(parameter.values[1]);
|
||||
tick = parameter.values[2];
|
||||
const auto unknown2 = parameter.values[3]; // Always 0
|
||||
|
@@ -1341,8 +1341,12 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
|
||||
for (const auto& result : results) {
|
||||
if (result.castOnType == 1) {
|
||||
const auto entry = behaviors->GetSkillByID(result.skillID);
|
||||
if (!entry) {
|
||||
Game::logger->Log("InventoryComponent", "Buff %i not in database!", result.skillID);
|
||||
|
||||
if (entry.skillID == 0) {
|
||||
continue;
|
||||
}
|
||||
if (entry->skillID == 0) {
|
||||
Game::logger->Log("InventoryComponent", "Failed to find buff behavior for skill (%i)!", result.skillID);
|
||||
|
||||
continue;
|
||||
@@ -1353,7 +1357,7 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
|
||||
}
|
||||
|
||||
// If item is not a proxy, add its buff to the added buffs.
|
||||
if (item->GetParent() == LWOOBJID_EMPTY) buffs.push_back(static_cast<uint32_t>(entry.behaviorID));
|
||||
if (item->GetParent() == LWOOBJID_EMPTY) buffs.push_back(static_cast<uint32_t>(entry->behaviorID));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -235,7 +235,12 @@ bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LW
|
||||
// if it's not in the cache look it up and cache it
|
||||
if (pair == m_skillBehaviorCache.end()) {
|
||||
auto skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
behaviorId = skillTable->GetSkillByID(skillId).behaviorID;
|
||||
auto skill = skillTable->GetSkillByID(skillId);
|
||||
if (!skill) {
|
||||
Game::logger->LogDebug("SkillComponent", "Tried to cast skill %i but found no skill", skillId);
|
||||
return false;
|
||||
}
|
||||
behaviorId = skill->behaviorID;
|
||||
m_skillBehaviorCache.insert_or_assign(skillId, behaviorId);
|
||||
} else {
|
||||
behaviorId = pair->second;
|
||||
|
@@ -127,12 +127,12 @@ void VendorComponent::SetupConstants() {
|
||||
int componentID = compRegistryTable->GetByIDAndType(m_Parent->GetLOT(), eReplicaComponentType::VENDOR);
|
||||
|
||||
auto* vendorComponentTable = CDClientManager::Instance().GetTable<CDVendorComponentTable>();
|
||||
std::vector<CDVendorComponent> vendorComps = vendorComponentTable->Query([=](CDVendorComponent entry) { return (entry.id == componentID); });
|
||||
if (vendorComps.empty()) return;
|
||||
m_BuyScalar = vendorComps[0].buyScalar;
|
||||
m_SellScalar = vendorComps[0].sellScalar;
|
||||
m_RefreshTimeSeconds = vendorComps[0].refreshTimeSeconds;
|
||||
m_LootMatrixID = vendorComps[0].LootMatrixIndex;
|
||||
auto vendorCompData = vendorComponentTable->Query(componentID);
|
||||
if (!vendorCompData) return;
|
||||
m_BuyScalar = vendorCompData->buyScalar;
|
||||
m_SellScalar = vendorCompData->sellScalar;
|
||||
m_RefreshTimeSeconds = vendorCompData->refreshTimeSeconds;
|
||||
m_LootMatrixID = vendorCompData->LootMatrixIndex;
|
||||
}
|
||||
|
||||
bool VendorComponent::SellsItem(const LOT item) const {
|
||||
|
@@ -288,7 +288,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
}
|
||||
|
||||
CDSkillBehaviorTable* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
unsigned int behaviorId = skillTable->GetSkillByID(startSkill.skillID).behaviorID;
|
||||
auto skill = skillTable->GetSkillByID(startSkill.skillID);
|
||||
if (!skill) {
|
||||
Game::logger->Log("GameMessageHandler", "Failed to find skill %d in the skill table!", startSkill.skillID);
|
||||
return;
|
||||
}
|
||||
unsigned int behaviorId = skill->behaviorID;
|
||||
|
||||
bool success = false;
|
||||
|
||||
@@ -301,7 +306,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
|
||||
if (success && entity->GetCharacter()) {
|
||||
DestroyableComponent* destComp = entity->GetComponent<DestroyableComponent>();
|
||||
destComp->SetImagination(destComp->GetImagination() - skillTable->GetSkillByID(startSkill.skillID).imaginationcost);
|
||||
destComp->SetImagination(destComp->GetImagination() - skill->imaginationcost);
|
||||
}
|
||||
|
||||
delete bs;
|
||||
|
@@ -131,11 +131,12 @@ void ItemSet::OnEquip(const LOT lot) {
|
||||
for (const auto skill : skillSet) {
|
||||
auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
|
||||
const auto behaviorId = skillTable->GetSkillByID(skill).behaviorID;
|
||||
auto skillData = skillTable->GetSkillByID(skill);
|
||||
if (!skillData) continue;
|
||||
|
||||
missionComponent->Progress(eMissionTaskType::USE_SKILL, skill);
|
||||
|
||||
skillComponent->HandleUnmanaged(behaviorId, m_InventoryComponent->GetParent()->GetObjectID());
|
||||
skillComponent->HandleUnmanaged(skillData->behaviorID, m_InventoryComponent->GetParent()->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,9 +164,10 @@ void ItemSet::OnUnEquip(const LOT lot) {
|
||||
for (const auto skill : skillSet) {
|
||||
auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
||||
|
||||
const auto behaviorId = skillTable->GetSkillByID(skill).behaviorID;
|
||||
auto skillData = skillTable->GetSkillByID(skill);
|
||||
if (!skillData) continue;
|
||||
|
||||
skillComponent->HandleUnCast(behaviorId, m_InventoryComponent->GetParent()->GetObjectID());
|
||||
skillComponent->HandleUnCast(skillData->behaviorID, m_InventoryComponent->GetParent()->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user