mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 14:37:25 +00:00
455f9470a5
* Move EntityManager to Game namespace * move initialization to later Need to wait for dZoneManager to be initialized. * Fix bugs - Cannot delete from a RandomAccessIterator while in a range based for loop. Touchup zone manager initialize replace magic numbers with better named constants replace magic zonecontrol id with a more readable hex alternative condense stack variables move initializers closer to their use initialize entity manager with zone control change initialize timings If zone is not zero we expect to initialize the entity manager during zone manager initialization Add constexpr for zone control LOT * Add proper error handling * revert vanity changes * Update WorldServer.cpp * Update dZoneManager.cpp
57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
#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);
|
|
|
|
auto* character = caster->GetCharacter();
|
|
if (character != nullptr) {
|
|
character->SetPlayerFlag(self->GetVar<int32_t>(m_FlagVariable), true);
|
|
}
|
|
|
|
EntityInfo info{};
|
|
info.lot = m_FXObject;
|
|
info.pos = self->GetPosition();
|
|
info.rot = self->GetRotation();
|
|
info.spawnerID = self->GetObjectID();
|
|
|
|
auto* fxObject = Game::entityManager->CreateEntity(info, nullptr, self);
|
|
Game::entityManager->ConstructEntity(fxObject);
|
|
|
|
auto fxObjectID = fxObject->GetObjectID();
|
|
auto playerID = caster->GetObjectID();
|
|
|
|
// 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>();
|
|
|
|
if (skillComponent == nullptr)
|
|
return;
|
|
|
|
// 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);
|
|
}
|
|
|
|
fxObject->Smash();
|
|
self->Smash();
|
|
});
|
|
}
|
|
}
|