Corrected action for OverTimeBehavior

This commit is contained in:
EmosewaMC 2022-04-25 16:56:40 -07:00
parent 4117ceb6c1
commit 7d233a04c0
2 changed files with 12 additions and 42 deletions

View File

@ -7,62 +7,26 @@
#include "SkillComponent.h" #include "SkillComponent.h"
#include "DestroyableComponent.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) void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{ {
const auto originator = context->originator; const auto originator = context->originator;
auto* entity = EntityManager::Instance()->GetEntity(originator); auto* entity = EntityManager::Instance()->GetEntity(originator);
if (entity == nullptr) if (entity == nullptr) return;
{
return;
}
for (size_t i = 0; i < m_NumIntervals; i++) for (size_t i = 0; i < m_NumIntervals; i++)
{ {
entity->AddCallbackTimer((i + 1) * m_Delay, [originator, branch, this]() { entity->AddCallbackTimer((i + 1) * m_Delay, [originator, branch, this]() {
auto* entity = EntityManager::Instance()->GetEntity(originator); auto* entity = EntityManager::Instance()->GetEntity(originator);
if (entity == nullptr) if (entity == nullptr) return;
{
return;
}
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto* skillComponent = entity->GetComponent<SkillComponent>();
if (skillComponent == nullptr) if (skillComponent == nullptr) return;
{
return;
}
skillComponent->CalculateBehavior(0, m_Action->m_behaviorId, branch.target, true, true); skillComponent->CalculateBehavior(m_Action, m_ActionBehaviorId, 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;
}
}); });
} }
} }
@ -74,7 +38,12 @@ void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bi
void OverTimeBehavior::Load() 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_Delay = GetFloat("delay");
m_NumIntervals = GetInt("num_intervals"); m_NumIntervals = GetInt("num_intervals");
} }

View File

@ -4,7 +4,8 @@
class OverTimeBehavior final : public Behavior class OverTimeBehavior final : public Behavior
{ {
public: public:
Behavior* m_Action; uint32_t m_Action;
uint32_t m_ActionBehaviorId;
float m_Delay; float m_Delay;
int32_t m_NumIntervals; int32_t m_NumIntervals;