Update DarkInspirationBehavior.cpp (#897)

This commit is contained in:
David Markowitz 2022-12-23 18:05:30 -08:00 committed by GitHub
parent 675cf1d2a4
commit bbd5a49ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 98 additions and 21 deletions

View File

@ -48,9 +48,8 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b
void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
auto* self = EntityManager::Instance()->GetEntity(context->caster); auto* self = EntityManager::Instance()->GetEntity(context->caster);
if (self == nullptr) { if (self == nullptr) {
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!", context->originator); Game::logger->Log("AreaOfEffectBehavior", "Invalid self for (%llu)!", context->originator);
return; return;
} }
@ -79,7 +78,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
auto* entity = EntityManager::Instance()->GetEntity(validTarget); auto* entity = EntityManager::Instance()->GetEntity(validTarget);
if (entity == nullptr) { 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; continue;
} }

View File

@ -61,6 +61,7 @@
#include "DamageReductionBehavior.h" #include "DamageReductionBehavior.h"
#include "JetPackBehavior.h" #include "JetPackBehavior.h"
#include "ChangeIdleFlagsBehavior.h" #include "ChangeIdleFlagsBehavior.h"
#include "DarkInspirationBehavior.h"
//CDClient includes //CDClient includes
#include "CDBehaviorParameterTable.h" #include "CDBehaviorParameterTable.h"
@ -169,7 +170,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) {
case BehaviorTemplates::BEHAVIOR_SPEED: case BehaviorTemplates::BEHAVIOR_SPEED:
behavior = new SpeedBehavior(behaviorId); behavior = new SpeedBehavior(behaviorId);
break; break;
case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION: break; case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION:
behavior = new DarkInspirationBehavior(behaviorId);
break;
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF: case BehaviorTemplates::BEHAVIOR_LOOT_BUFF:
behavior = new LootBuffBehavior(behaviorId); behavior = new LootBuffBehavior(behaviorId);
break; break;

View File

@ -18,6 +18,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
"ClearTargetBehavior.cpp" "ClearTargetBehavior.cpp"
"DamageAbsorptionBehavior.cpp" "DamageAbsorptionBehavior.cpp"
"DamageReductionBehavior.cpp" "DamageReductionBehavior.cpp"
"DarkInspirationBehavior.cpp"
"DurationBehavior.cpp" "DurationBehavior.cpp"
"EmptyBehavior.cpp" "EmptyBehavior.cpp"
"EndBehavior.cpp" "EndBehavior.cpp"

View 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");
}

View 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;
};

View File

@ -694,7 +694,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
auto* inventoryComponent = owner->GetComponent<InventoryComponent>(); auto* inventoryComponent = owner->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr && isEnemy) { if (inventoryComponent != nullptr && isEnemy) {
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed); inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_Parent);
} }
auto* missions = owner->GetComponent<MissionComponent>(); auto* missions = owner->GetComponent<MissionComponent>();

View File

@ -1196,9 +1196,9 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) {
} }
} }
void InventoryComponent::TriggerPassiveAbility(PassiveAbilityTrigger trigger) { void InventoryComponent::TriggerPassiveAbility(PassiveAbilityTrigger trigger, Entity* target) {
for (auto* set : m_Itemsets) { for (auto* set : m_Itemsets) {
set->TriggerPassiveAbility(trigger); set->TriggerPassiveAbility(trigger, target);
} }
} }

View File

@ -283,7 +283,7 @@ public:
* Triggers one of the passive abilities from the equipped item set * Triggers one of the passive abilities from the equipped item set
* @param trigger the trigger to fire * @param trigger the trigger to fire
*/ */
void TriggerPassiveAbility(PassiveAbilityTrigger trigger); void TriggerPassiveAbility(PassiveAbilityTrigger trigger, Entity* target = nullptr);
/** /**
* Returns if the entity has any of the passed passive abilities equipped * Returns if the entity has any of the passed passive abilities equipped

View File

@ -180,9 +180,9 @@ void ItemSet::Update(float deltaTime) {
} }
} }
void ItemSet::TriggerPassiveAbility(PassiveAbilityTrigger trigger) { void ItemSet::TriggerPassiveAbility(PassiveAbilityTrigger trigger, Entity* target) {
for (auto& passiveAbility : m_PassiveAbilities) { for (auto& passiveAbility : m_PassiveAbilities) {
passiveAbility.Trigger(trigger); passiveAbility.Trigger(trigger, target);
} }
} }

View File

@ -52,7 +52,7 @@ public:
* Triggers all the passive abilities in this item set that match this trigger * Triggers all the passive abilities in this item set that match this trigger
* @param trigger the trigger to use to trigger passive abilities * @param trigger the trigger to use to trigger passive abilities
*/ */
void TriggerPassiveAbility(PassiveAbilityTrigger trigger); void TriggerPassiveAbility(PassiveAbilityTrigger trigger, Entity* target = nullptr);
/** /**
* Returns the skills that can be equipped for a specified amount of equipped items * Returns the skills that can be equipped for a specified amount of equipped items

View File

@ -16,12 +16,12 @@ ItemSetPassiveAbility::ItemSetPassiveAbility(PassiveAbilityTrigger trigger, Enti
ItemSetPassiveAbility::~ItemSetPassiveAbility() { ItemSetPassiveAbility::~ItemSetPassiveAbility() {
} }
void ItemSetPassiveAbility::Trigger(PassiveAbilityTrigger trigger) { void ItemSetPassiveAbility::Trigger(PassiveAbilityTrigger trigger, Entity* target) {
if (m_Trigger != trigger || m_Cooldown > 0.0f) { if (m_Trigger != trigger || m_Cooldown > 0.0f) {
return; return;
} }
Activate(); Activate(target);
} }
void ItemSetPassiveAbility::Update(float deltaTime) { void ItemSetPassiveAbility::Update(float deltaTime) {
@ -30,9 +30,9 @@ void ItemSetPassiveAbility::Update(float deltaTime) {
} }
} }
void ItemSetPassiveAbility::Activate() { void ItemSetPassiveAbility::Activate(Entity* target) {
if (m_Trigger == PassiveAbilityTrigger::EnemySmashed) { if (m_Trigger == PassiveAbilityTrigger::EnemySmashed) {
OnEnemySmshed(); OnEnemySmshed(target);
return; return;
} }
@ -195,7 +195,7 @@ std::vector<ItemSetPassiveAbility> ItemSetPassiveAbility::FindAbilities(uint32_t
return abilities; return abilities;
} }
void ItemSetPassiveAbility::OnEnemySmshed() { void ItemSetPassiveAbility::OnEnemySmshed(Entity* target) {
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>(); auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
auto* skillComponent = m_Parent->GetComponent<SkillComponent>(); auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
@ -293,8 +293,8 @@ void ItemSetPassiveAbility::OnEnemySmshed() {
break; break;
} }
case ItemSetPassiveAbilityID::ShinobiRank3: { case ItemSetPassiveAbilityID::ShinobiRank3: {
if (equippedCount < 4) return; if (equippedCount < 4 || !target) return;
destroyableComponent->Imagine(3); skillComponent->CalculateBehavior(695, 11399, target->GetObjectID());
break; break;
} }

View File

@ -30,12 +30,12 @@ public:
* Attempts to trigger a passive ability for this item set, if this is the wrong trigger this is a no-op * Attempts to trigger a passive ability for this item set, if this is the wrong trigger this is a no-op
* @param trigger the trigger to attempt to fire * @param trigger the trigger to attempt to fire
*/ */
void Trigger(PassiveAbilityTrigger trigger); void Trigger(PassiveAbilityTrigger trigger, Entity* target = nullptr);
/** /**
* Activates the passive ability * Activates the passive ability
*/ */
void Activate(); void Activate(Entity* target = nullptr);
/** /**
* Finds all the passive abilities associated with a certain item set * Finds all the passive abilities associated with a certain item set
@ -47,7 +47,7 @@ public:
static std::vector<ItemSetPassiveAbility> FindAbilities(uint32_t itemSetID, Entity* parent, ItemSet* itemSet); static std::vector<ItemSetPassiveAbility> FindAbilities(uint32_t itemSetID, Entity* parent, ItemSet* itemSet);
private: private:
void OnEnemySmshed(); void OnEnemySmshed(Entity* target = nullptr);
/** /**
* The means of triggering this ability * The means of triggering this ability