mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Update DarkInspirationBehavior.cpp (#897)
This commit is contained in:
@@ -48,9 +48,8 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b
|
||||
|
||||
void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto* self = EntityManager::Instance()->GetEntity(context->caster);
|
||||
|
||||
if (self == nullptr) {
|
||||
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!", context->originator);
|
||||
Game::logger->Log("AreaOfEffectBehavior", "Invalid self for (%llu)!", context->originator);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -79,7 +78,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
||||
auto* entity = EntityManager::Instance()->GetEntity(validTarget);
|
||||
|
||||
if (entity == nullptr) {
|
||||
Game::logger->Log("TacArcBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
|
||||
Game::logger->Log("AreaOfEffectBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@@ -61,6 +61,7 @@
|
||||
#include "DamageReductionBehavior.h"
|
||||
#include "JetPackBehavior.h"
|
||||
#include "ChangeIdleFlagsBehavior.h"
|
||||
#include "DarkInspirationBehavior.h"
|
||||
|
||||
//CDClient includes
|
||||
#include "CDBehaviorParameterTable.h"
|
||||
@@ -169,7 +170,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) {
|
||||
case BehaviorTemplates::BEHAVIOR_SPEED:
|
||||
behavior = new SpeedBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION: break;
|
||||
case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION:
|
||||
behavior = new DarkInspirationBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF:
|
||||
behavior = new LootBuffBehavior(behaviorId);
|
||||
break;
|
||||
|
@@ -18,6 +18,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"ClearTargetBehavior.cpp"
|
||||
"DamageAbsorptionBehavior.cpp"
|
||||
"DamageReductionBehavior.cpp"
|
||||
"DarkInspirationBehavior.cpp"
|
||||
"DurationBehavior.cpp"
|
||||
"EmptyBehavior.cpp"
|
||||
"EndBehavior.cpp"
|
||||
|
52
dGame/dBehaviors/DarkInspirationBehavior.cpp
Normal file
52
dGame/dBehaviors/DarkInspirationBehavior.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "DarkInspirationBehavior.h"
|
||||
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "Entity.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "BehaviorContext.h"
|
||||
|
||||
void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
if (target == nullptr) {
|
||||
Game::logger->LogDebug("DarkInspirationBehavior", "Failed to find target (%llu)!", branch.target);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (destroyableComponent->HasFaction(m_FactionList)) {
|
||||
this->m_ActionIfFactionMatches->Handle(context, bitStream, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
if (target == nullptr) {
|
||||
Game::logger->LogDebug("DarkInspirationBehavior", "Failed to find target (%llu)!", branch.target);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (destroyableComponent->HasFaction(m_FactionList)) {
|
||||
this->m_ActionIfFactionMatches->Calculate(context, bitStream, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void DarkInspirationBehavior::Load() {
|
||||
this->m_ActionIfFactionMatches = GetAction("action");
|
||||
|
||||
this->m_FactionList = GetInt("faction_list");
|
||||
}
|
22
dGame/dBehaviors/DarkInspirationBehavior.h
Normal file
22
dGame/dBehaviors/DarkInspirationBehavior.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "Behavior.h"
|
||||
|
||||
class DarkInspirationBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
|
||||
explicit DarkInspirationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||
}
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
private:
|
||||
Behavior* m_ActionIfFactionMatches;
|
||||
uint32_t m_FactionList;
|
||||
};
|
Reference in New Issue
Block a user