mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 05:57:20 +00:00
eca87c7257
* fix: Buff FX not playing Fixes an issue where buff effects would not play at all. Tested that frakjaw and maelstrom dagger now play their respective effects when you are effected by them fix: buffs general improvements add new arguments * Remove duplicated code * fix times and remove buff
50 lines
1.8 KiB
C++
50 lines
1.8 KiB
C++
#include "ApplyBuffBehavior.h"
|
|
#include "EntityManager.h"
|
|
#include "BehaviorContext.h"
|
|
#include "BehaviorBranchContext.h"
|
|
#include "BuffComponent.h"
|
|
|
|
|
|
void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
auto* entity = Game::entityManager->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target);
|
|
|
|
if (entity == nullptr) return;
|
|
|
|
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
|
|
|
if (buffComponent == nullptr) return;
|
|
|
|
buffComponent->ApplyBuff(m_BuffId, m_Duration, context->originator, addImmunity, cancelOnDamaged, cancelOnDeath,
|
|
cancelOnLogout, cancelonRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone, m_ApplyOnTeammates);
|
|
}
|
|
|
|
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
|
auto* entity = Game::entityManager->GetEntity(branch.target);
|
|
|
|
if (entity == nullptr) return;
|
|
|
|
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
|
|
|
if (buffComponent == nullptr) return;
|
|
|
|
buffComponent->RemoveBuff(m_BuffId);
|
|
}
|
|
|
|
void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
Handle(context, bitStream, branch);
|
|
}
|
|
|
|
void ApplyBuffBehavior::Load() {
|
|
m_BuffId = GetInt("buff_id");
|
|
m_Duration = GetFloat("duration_secs");
|
|
addImmunity = GetBoolean("add_immunity");
|
|
cancelOnDamaged = GetBoolean("cancel_on_damaged");
|
|
cancelOnDeath = GetBoolean("cancel_on_death");
|
|
cancelOnLogout = GetBoolean("cancel_on_logout");
|
|
cancelonRemoveBuff = GetBoolean("cancel_on_remove_buff");
|
|
cancelOnUi = GetBoolean("cancel_on_ui");
|
|
cancelOnUnequip = GetBoolean("cancel_on_unequip");
|
|
cancelOnZone = GetBoolean("cancel_on_zone");
|
|
m_ApplyOnTeammates = GetBoolean("apply_on_teammates");
|
|
}
|