2021-12-05 17:54:36 +00:00
|
|
|
#include "ImmunityBehavior.h"
|
|
|
|
|
|
|
|
#include "BehaviorBranchContext.h"
|
|
|
|
#include "BehaviorContext.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "Game.h"
|
2023-10-21 23:31:55 +00:00
|
|
|
#include "Logger.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "DestroyableComponent.h"
|
2023-01-07 05:59:19 +00:00
|
|
|
#include "ControllablePhysicsComponent.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eStateChangeType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-02-27 07:25:44 +00:00
|
|
|
void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
if (!target) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Failed to find target (%llu)!", branch.target);
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
|
|
|
if (destroyableComponent) {
|
|
|
|
destroyableComponent->SetStatusImmunity(
|
|
|
|
eStateChangeType::PUSH,
|
|
|
|
this->m_ImmuneToBasicAttack,
|
|
|
|
this->m_ImmuneToDamageOverTime,
|
|
|
|
this->m_ImmuneToKnockback,
|
|
|
|
this->m_ImmuneToInterrupt,
|
|
|
|
this->m_ImmuneToSpeed,
|
|
|
|
this->m_ImmuneToImaginationGain,
|
|
|
|
this->m_ImmuneToImaginationLoss,
|
|
|
|
this->m_ImmuneToQuickbuildInterrupt,
|
|
|
|
this->m_ImmuneToPullToPoint
|
|
|
|
);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
|
|
if (controllablePhysicsComponent) {
|
|
|
|
controllablePhysicsComponent->SetStunImmunity(
|
|
|
|
eStateChangeType::PUSH,
|
|
|
|
context->caster,
|
|
|
|
this->m_ImmuneToStunAttack,
|
|
|
|
this->m_ImmuneToStunEquip,
|
|
|
|
this->m_ImmuneToStunInteract,
|
|
|
|
this->m_ImmuneToStunJump,
|
|
|
|
this->m_ImmuneToStunMove,
|
|
|
|
this->m_ImmuneToStunTurn,
|
|
|
|
this->m_ImmuneToStunUseItem
|
|
|
|
);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
|
|
|
}
|
|
|
|
|
2024-02-27 07:25:44 +00:00
|
|
|
void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
2021-12-05 17:54:36 +00:00
|
|
|
Handle(context, bitStream, branch);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second) {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* target = Game::entityManager->GetEntity(second);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
if (!target) {
|
2023-10-21 23:31:55 +00:00
|
|
|
LOG("Failed to find target (%llu)!", second);
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
|
|
|
if (destroyableComponent) {
|
|
|
|
destroyableComponent->SetStatusImmunity(
|
|
|
|
eStateChangeType::POP,
|
|
|
|
this->m_ImmuneToBasicAttack,
|
|
|
|
this->m_ImmuneToDamageOverTime,
|
|
|
|
this->m_ImmuneToKnockback,
|
|
|
|
this->m_ImmuneToInterrupt,
|
|
|
|
this->m_ImmuneToSpeed,
|
|
|
|
this->m_ImmuneToImaginationGain,
|
|
|
|
this->m_ImmuneToImaginationLoss,
|
|
|
|
this->m_ImmuneToQuickbuildInterrupt,
|
|
|
|
this->m_ImmuneToPullToPoint
|
|
|
|
);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
|
|
if (controllablePhysicsComponent) {
|
|
|
|
controllablePhysicsComponent->SetStunImmunity(
|
|
|
|
eStateChangeType::POP,
|
|
|
|
context->caster,
|
|
|
|
this->m_ImmuneToStunAttack,
|
|
|
|
this->m_ImmuneToStunEquip,
|
|
|
|
this->m_ImmuneToStunInteract,
|
|
|
|
this->m_ImmuneToStunJump,
|
|
|
|
this->m_ImmuneToStunMove,
|
|
|
|
this->m_ImmuneToStunTurn,
|
|
|
|
this->m_ImmuneToStunUseItem
|
|
|
|
);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImmunityBehavior::Load() {
|
2023-01-07 05:59:19 +00:00
|
|
|
//Stun
|
|
|
|
this->m_ImmuneToStunAttack = GetBoolean("immune_stun_attack", false);
|
|
|
|
this->m_ImmuneToStunEquip = GetBoolean("immune_stun_equip", false);
|
|
|
|
this->m_ImmuneToStunInteract = GetBoolean("immune_stun_interact", false);
|
|
|
|
this->m_ImmuneToStunMove = GetBoolean("immune_stun_move", false);
|
|
|
|
this->m_ImmuneToStunTurn = GetBoolean("immune_stun_rotate", false);
|
|
|
|
|
|
|
|
// Status
|
|
|
|
this->m_ImmuneToBasicAttack = GetBoolean("immune_basic_attack", false);
|
|
|
|
this->m_ImmuneToDamageOverTime = GetBoolean("immune_damage_over_time", false);
|
|
|
|
this->m_ImmuneToKnockback = GetBoolean("immune_knockback", false);
|
|
|
|
this->m_ImmuneToInterrupt = GetBoolean("immune_interrupt", false);
|
|
|
|
this->m_ImmuneToSpeed = GetBoolean("immune_speed", false);
|
|
|
|
this->m_ImmuneToImaginationGain = GetBoolean("immune_imagination_gain", false);
|
|
|
|
this->m_ImmuneToImaginationLoss = GetBoolean("immune_imagination_loss", false);
|
|
|
|
this->m_ImmuneToQuickbuildInterrupt = GetBoolean("immune_quickbuild_interrupts", false);
|
|
|
|
this->m_ImmuneToPullToPoint = GetBoolean("immune_pulltopoint", false);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|