mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 02:34:04 +00:00
Merge branch 'main' into main
This commit is contained in:
@@ -19,6 +19,12 @@ void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStre
|
||||
}
|
||||
}
|
||||
|
||||
void AndBehavior::UnCast(BehaviorContext* context, const BehaviorBranchContext branch) {
|
||||
for (auto behavior : this->m_behaviors) {
|
||||
behavior->UnCast(context, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void AndBehavior::Load()
|
||||
{
|
||||
const auto parameters = GetParameterNames();
|
||||
|
@@ -20,5 +20,7 @@ public:
|
||||
|
||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
};
|
||||
|
@@ -14,7 +14,7 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
if (destroyableComponent != nullptr) {
|
||||
PlayFx(u"onhit", entity->GetObjectID());
|
||||
destroyableComponent->Damage(this->m_maxDamage, context->originator);
|
||||
destroyableComponent->Damage(this->m_maxDamage, context->originator, context->skillID);
|
||||
}
|
||||
|
||||
this->m_onSuccess->Handle(context, bitStream, branch);
|
||||
@@ -56,7 +56,7 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
if (destroyableComponent != nullptr) {
|
||||
PlayFx(u"onhit", entity->GetObjectID());
|
||||
destroyableComponent->Damage(damageDealt, context->originator);
|
||||
destroyableComponent->Damage(damageDealt, context->originator, context->skillID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream*
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
if (damage != 0 && destroyableComponent != nullptr) {
|
||||
PlayFx(u"onhit", entity->GetObjectID(), 1);
|
||||
destroyableComponent->Damage(damage, context->originator, false);
|
||||
destroyableComponent->Damage(damage, context->originator, context->skillID, false);
|
||||
context->ScheduleUpdate(branch.target);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "AreaOfEffectBehavior.h"
|
||||
#include "DurationBehavior.h"
|
||||
#include "TacArcBehavior.h"
|
||||
#include "LootBuffBehavior.h"
|
||||
#include "AttackDelayBehavior.h"
|
||||
#include "BasicAttackBehavior.h"
|
||||
#include "ChainBehavior.h"
|
||||
@@ -172,7 +173,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
|
||||
behavior = new SpeedBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION: break;
|
||||
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF: break;
|
||||
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF:
|
||||
behavior = new LootBuffBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_VENTURE_VISION: break;
|
||||
case BehaviorTemplates::BEHAVIOR_SPAWN_OBJECT:
|
||||
behavior = new SpawnBehavior(behaviorId);
|
||||
|
@@ -64,8 +64,8 @@ void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* beha
|
||||
|
||||
void BehaviorContext::RegisterTimerBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second)
|
||||
{
|
||||
BehaviorTimerEntry entry
|
||||
;
|
||||
BehaviorTimerEntry entry;
|
||||
|
||||
entry.time = branchContext.duration;
|
||||
entry.behavior = behavior;
|
||||
entry.branchContext = branchContext;
|
||||
|
@@ -58,6 +58,8 @@ struct BehaviorContext
|
||||
|
||||
float skillTime = 0;
|
||||
|
||||
uint32_t skillID = 0;
|
||||
|
||||
uint32_t skillUId = 0;
|
||||
|
||||
bool failed = false;
|
||||
|
38
dGame/dBehaviors/LootBuffBehavior.cpp
Normal file
38
dGame/dBehaviors/LootBuffBehavior.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "LootBuffBehavior.h"
|
||||
|
||||
void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto target = EntityManager::Instance()->GetEntity(context->caster);
|
||||
if (!target) return;
|
||||
|
||||
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||
if (!controllablePhysicsComponent) return;
|
||||
|
||||
controllablePhysicsComponent->AddPickupRadiusScale(m_Scale);
|
||||
EntityManager::Instance()->SerializeEntity(target);
|
||||
|
||||
if (branch.duration > 0) context->RegisterTimerBehavior(this, branch);
|
||||
|
||||
}
|
||||
|
||||
void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void LootBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||
auto target = EntityManager::Instance()->GetEntity(context->caster);
|
||||
if (!target) return;
|
||||
|
||||
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||
if (!controllablePhysicsComponent) return;
|
||||
|
||||
controllablePhysicsComponent->RemovePickupRadiusScale(m_Scale);
|
||||
EntityManager::Instance()->SerializeEntity(target);
|
||||
}
|
||||
|
||||
void LootBuffBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||
UnCast(context, branch);
|
||||
}
|
||||
|
||||
void LootBuffBehavior::Load() {
|
||||
this->m_Scale = GetFloat("scale");
|
||||
}
|
32
dGame/dBehaviors/LootBuffBehavior.h
Normal file
32
dGame/dBehaviors/LootBuffBehavior.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "Behavior.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
|
||||
/**
|
||||
* @brief This is the behavior class to be used for all Loot Buff behavior nodes in the Behavior tree.
|
||||
*
|
||||
*/
|
||||
class LootBuffBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
|
||||
float m_Scale;
|
||||
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
|
||||
explicit LootBuffBehavior(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 UnCast(BehaviorContext* context, BehaviorBranchContext branch) override;
|
||||
|
||||
void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override;
|
||||
|
||||
void Load() override;
|
||||
};
|
@@ -7,62 +7,26 @@
|
||||
#include "SkillComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
/**
|
||||
* The OverTime behavior is very inconsistent in how it appears in the skill tree vs. how it should behave.
|
||||
*
|
||||
* Items like "Doc in a Box" use an overtime behavior which you would expect have health & armor regen, but is only fallowed by a stun.
|
||||
*
|
||||
* Due to this inconsistency, we have to implement a special case for some items.
|
||||
*/
|
||||
|
||||
void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
||||
{
|
||||
const auto originator = context->originator;
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (entity == nullptr) return;
|
||||
|
||||
for (size_t i = 0; i < m_NumIntervals; i++)
|
||||
{
|
||||
entity->AddCallbackTimer((i + 1) * m_Delay, [originator, branch, this]() {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (entity == nullptr) return;
|
||||
|
||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||
|
||||
if (skillComponent == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (skillComponent == nullptr) return;
|
||||
|
||||
skillComponent->CalculateBehavior(0, m_Action->m_behaviorId, branch.target, true, true);
|
||||
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special cases for inconsistent behavior.
|
||||
*/
|
||||
|
||||
switch (m_behaviorId)
|
||||
{
|
||||
case 26253: // "Doc in a Box", heal up to 6 health and regen up to 18 armor.
|
||||
destroyableComponent->Heal(1);
|
||||
destroyableComponent->Repair(3);
|
||||
break;
|
||||
}
|
||||
skillComponent->CalculateBehavior(m_Action, m_ActionBehaviorId, branch.target, true, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -74,7 +38,12 @@ void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bi
|
||||
|
||||
void OverTimeBehavior::Load()
|
||||
{
|
||||
m_Action = GetAction("action");
|
||||
m_Action = GetInt("action");
|
||||
// Since m_Action is a skillID and not a behavior, get is correlated behaviorID.
|
||||
|
||||
CDSkillBehaviorTable* skillTable = CDClientManager::Instance()->GetTable<CDSkillBehaviorTable>("SkillBehavior");
|
||||
m_ActionBehaviorId = skillTable->GetSkillByID(m_Action).behaviorID;
|
||||
|
||||
m_Delay = GetFloat("delay");
|
||||
m_NumIntervals = GetInt("num_intervals");
|
||||
}
|
||||
|
@@ -4,7 +4,8 @@
|
||||
class OverTimeBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
Behavior* m_Action;
|
||||
uint32_t m_Action;
|
||||
uint32_t m_ActionBehaviorId;
|
||||
float m_Delay;
|
||||
int32_t m_NumIntervals;
|
||||
|
||||
|
Reference in New Issue
Block a user