2022-06-28 04:36:18 +00:00
|
|
|
#include "FireFirstSkillonStartup.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
#include "CDClientDatabase.h"
|
|
|
|
#include "CDObjectSkillsTable.h"
|
2023-03-17 14:36:21 +00:00
|
|
|
#include "CDSkillBehaviorTable.h"
|
2022-12-18 15:46:04 +00:00
|
|
|
#include "CDClientManager.h"
|
2022-06-28 04:36:18 +00:00
|
|
|
|
|
|
|
void FireFirstSkillonStartup::OnStartup(Entity* self) {
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
2022-06-28 04:36:18 +00:00
|
|
|
if (!skillComponent) return;
|
|
|
|
|
|
|
|
// Get the skill IDs of this object.
|
2023-03-17 14:36:21 +00:00
|
|
|
CDObjectSkillsTable* skillsTable = CDClientManager::Instance().GetTable<CDObjectSkillsTable>();
|
2022-06-28 04:36:18 +00:00
|
|
|
std::vector<CDObjectSkills> skills = skillsTable->Query([=](CDObjectSkills entry) {return (entry.objectTemplate == self->GetLOT()); });
|
|
|
|
|
|
|
|
// For each skill, cast it with the associated behavior ID.
|
|
|
|
for (auto skill : skills) {
|
2023-03-17 14:36:21 +00:00
|
|
|
CDSkillBehaviorTable* skillBehaviorTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
|
2022-06-28 04:36:18 +00:00
|
|
|
CDSkillBehavior behaviorData = skillBehaviorTable->GetSkillByID(skill.skillID);
|
|
|
|
|
|
|
|
// Should parent entity be null, make the originator self.
|
|
|
|
const auto target = self->GetParentEntity() ? self->GetParentEntity()->GetObjectID() : self->GetObjectID();
|
|
|
|
skillComponent->CalculateBehavior(skill.skillID, behaviorData.behaviorID, LWOOBJID_EMPTY, false, false, target);
|
|
|
|
}
|
|
|
|
}
|