DarkflameServer/dScripts/02_server/Map/AM/AmBlueX.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.8 KiB
C++
Raw Permalink Normal View History

#include "AmBlueX.h"
#include "SkillComponent.h"
#include "EntityManager.h"
#include "EntityInfo.h"
#include "Character.h"
void AmBlueX::OnUse(Entity* self, Entity* user) {
auto* skillComponent = user->GetComponent<SkillComponent>();
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
auto* character = caster->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(self->GetVar<int32_t>(m_FlagVariable), true);
}
2022-07-28 13:39:57 +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
auto* fxObject = Game::entityManager->CreateEntity(info, nullptr, self);
Game::entityManager->ConstructEntity(fxObject);
2022-07-28 13:39:57 +00:00
auto fxObjectID = fxObject->GetObjectID();
auto playerID = caster->GetObjectID();
2022-07-28 13:39:57 +00:00
// Add a callback for the bomb to explode
self->AddCallbackTimer(m_BombTime, [this, self, fxObjectID, playerID]() {
auto* fxObject = Game::entityManager->GetEntity(fxObjectID);
auto* player = Game::entityManager->GetEntity(playerID);
auto* skillComponent = self->GetComponent<SkillComponent>();
2022-07-28 13:39:57 +00:00
if (skillComponent == nullptr)
return;
2022-07-28 13:39:57 +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
fxObject->Smash();
self->Smash();
});
}
}