2021-12-05 17:54:36 +00:00
|
|
|
#include "AmBlueX.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
#include "EntityManager.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "EntityInfo.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "Character.h"
|
|
|
|
|
|
|
|
void AmBlueX::OnUse(Entity* self, Entity* user) {
|
2023-06-07 07:23:50 +00:00
|
|
|
auto skillComponent = user->GetComponent<SkillComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (skillComponent != nullptr) {
|
|
|
|
skillComponent->CalculateBehavior(m_SwordSkill, m_SwordBehavior, self->GetObjectID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmBlueX::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
|
|
|
|
if (message == "FireDukesStrike") {
|
|
|
|
self->SetNetworkVar<bool>(m_XUsedVariable, true);
|
|
|
|
self->SetNetworkVar<bool>(m_StartEffectVariable, true);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* character = caster->GetCharacter();
|
|
|
|
if (character != nullptr) {
|
2023-05-17 18:17:34 +00:00
|
|
|
character->SetPlayerFlag(self->GetVar<int32_t>(m_FlagVariable), true);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
EntityInfo info{};
|
|
|
|
info.lot = m_FXObject;
|
|
|
|
info.pos = self->GetPosition();
|
|
|
|
info.rot = self->GetRotation();
|
|
|
|
info.spawnerID = self->GetObjectID();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* fxObject = EntityManager::Instance()->CreateEntity(info, nullptr, self);
|
|
|
|
EntityManager::Instance()->ConstructEntity(fxObject);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
auto fxObjectID = fxObject->GetObjectID();
|
|
|
|
auto playerID = caster->GetObjectID();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
// Add a callback for the bomb to explode
|
|
|
|
self->AddCallbackTimer(m_BombTime, [this, self, fxObjectID, playerID]() {
|
|
|
|
auto* fxObject = EntityManager::Instance()->GetEntity(fxObjectID);
|
|
|
|
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
2023-06-07 07:23:50 +00:00
|
|
|
auto skillComponent = self->GetComponent<SkillComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (skillComponent == nullptr)
|
|
|
|
return;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
// Cast the skill that destroys the object
|
|
|
|
if (player != nullptr) {
|
|
|
|
skillComponent->CalculateBehavior(m_AOESkill, m_AOEBehavior, LWOOBJID_EMPTY, false, false, playerID);
|
|
|
|
} else {
|
|
|
|
skillComponent->CalculateBehavior(m_AOESkill, m_AOEBehavior, LWOOBJID_EMPTY);
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
fxObject->Smash();
|
|
|
|
self->Smash();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|