mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +00:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
d97f374a90
@ -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;
|
||||
};
|
@ -170,17 +170,10 @@ void BuffComponent::ApplyBuffEffect(int32_t id) {
|
||||
|
||||
destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination);
|
||||
} else if (parameter.name == "speed") {
|
||||
const auto speed = parameter.value;
|
||||
|
||||
auto* controllablePhysicsComponent = this->GetParent()->GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllablePhysicsComponent == nullptr) return;
|
||||
|
||||
const auto current = controllablePhysicsComponent->GetSpeedMultiplier();
|
||||
|
||||
controllablePhysicsComponent->SetSpeedMultiplier(current + ((speed - 500.0f) / 500.0f));
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(this->GetParent());
|
||||
if (!controllablePhysicsComponent) return;
|
||||
const auto speed = parameter.value;
|
||||
controllablePhysicsComponent->AddSpeedboost(speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,17 +206,10 @@ void BuffComponent::RemoveBuffEffect(int32_t id) {
|
||||
|
||||
destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination);
|
||||
} else if (parameter.name == "speed") {
|
||||
const auto speed = parameter.value;
|
||||
|
||||
auto* controllablePhysicsComponent = this->GetParent()->GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllablePhysicsComponent == nullptr) return;
|
||||
|
||||
const auto current = controllablePhysicsComponent->GetSpeedMultiplier();
|
||||
|
||||
controllablePhysicsComponent->SetSpeedMultiplier(current - ((speed - 500.0f) / 500.0f));
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(this->GetParent());
|
||||
if (!controllablePhysicsComponent) return;
|
||||
const auto speed = parameter.value;
|
||||
controllablePhysicsComponent->RemoveSpeedboost(speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
auto* inventoryComponent = owner->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent != nullptr && isEnemy) {
|
||||
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed);
|
||||
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_Parent);
|
||||
}
|
||||
|
||||
auto* missions = owner->GetComponent<MissionComponent>();
|
||||
|
@ -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) {
|
||||
set->TriggerPassiveAbility(trigger);
|
||||
set->TriggerPassiveAbility(trigger, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ public:
|
||||
* Triggers one of the passive abilities from the equipped item set
|
||||
* @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
|
||||
|
@ -4728,13 +4728,13 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
|
||||
|
||||
float sellScalar = vend->GetSellScalar();
|
||||
if (Inventory::IsValidItem(itemComp.currencyLOT)) {
|
||||
const auto altCurrency = (itemComp.altCurrencyCost * sellScalar) * count;
|
||||
const auto altCurrency = static_cast<uint32_t>(itemComp.altCurrencyCost * sellScalar) * count;
|
||||
inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eLootSourceType::LOOT_SOURCE_VENDOR); // Return alt currencies like faction tokens.
|
||||
}
|
||||
|
||||
//inv->RemoveItem(count, -1, iObjID);
|
||||
inv->MoveItemToInventory(item, eInventoryType::VENDOR_BUYBACK, count, true, false, true);
|
||||
character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar) * count)), eLootSourceType::LOOT_SOURCE_VENDOR);
|
||||
character->SetCoins(std::floor(character->GetCoins() + (static_cast<uint32_t>(itemComp.baseValue * sellScalar) * count)), eLootSourceType::LOOT_SOURCE_VENDOR);
|
||||
//EntityManager::Instance()->SerializeEntity(player); // so inventory updates
|
||||
GameMessages::SendVendorTransactionResult(entity, sysAddr);
|
||||
}
|
||||
@ -5763,11 +5763,7 @@ void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity
|
||||
|
||||
auto* item = inv->FindItemById(itemConsumed);
|
||||
|
||||
if (item == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
item->UseNonEquip();
|
||||
if (item) item->UseNonEquip(item);
|
||||
}
|
||||
|
||||
void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entity) {
|
||||
|
@ -262,7 +262,7 @@ bool Item::Consume() {
|
||||
return success;
|
||||
}
|
||||
|
||||
void Item::UseNonEquip() {
|
||||
void Item::UseNonEquip(Item* item) {
|
||||
LOT thisLot = this->GetLot();
|
||||
if (!GetInventory()) {
|
||||
Game::logger->LogDebug("Item", "item %i has no inventory??", this->GetLot());
|
||||
@ -292,6 +292,9 @@ void Item::UseNonEquip() {
|
||||
}
|
||||
// This precondition response is taken care of in SpawnPet().
|
||||
} else {
|
||||
bool success = false;
|
||||
auto inventory = item->GetInventory();
|
||||
if (inventory && inventory->GetType() == eInventoryType::ITEMS) {
|
||||
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
||||
|
||||
@ -320,7 +323,7 @@ void Item::UseNonEquip() {
|
||||
}
|
||||
if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) {
|
||||
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||
playerInventoryComponent->RemoveItem(lot, 1);
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
@ -333,6 +336,7 @@ void Item::UseNonEquip() {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot);
|
||||
GameMessages::SendUseItemResult(playerInventoryComponent->GetParent(), thisLot, success);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public:
|
||||
/**
|
||||
* Uses this item if its non equip, essentially an interface for the linked GM
|
||||
*/
|
||||
void UseNonEquip();
|
||||
void UseNonEquip(Item* item);
|
||||
|
||||
/**
|
||||
* Disassembles the part LOTs of this item back into the inventory, if it has any
|
||||
|
@ -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) {
|
||||
passiveAbility.Trigger(trigger);
|
||||
passiveAbility.Trigger(trigger, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
* Triggers all the passive abilities in this item set that match this trigger
|
||||
* @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
|
||||
|
@ -16,12 +16,12 @@ ItemSetPassiveAbility::ItemSetPassiveAbility(PassiveAbilityTrigger trigger, Enti
|
||||
ItemSetPassiveAbility::~ItemSetPassiveAbility() {
|
||||
}
|
||||
|
||||
void ItemSetPassiveAbility::Trigger(PassiveAbilityTrigger trigger) {
|
||||
void ItemSetPassiveAbility::Trigger(PassiveAbilityTrigger trigger, Entity* target) {
|
||||
if (m_Trigger != trigger || m_Cooldown > 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
Activate();
|
||||
Activate(target);
|
||||
}
|
||||
|
||||
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) {
|
||||
OnEnemySmshed();
|
||||
OnEnemySmshed(target);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -195,7 +195,7 @@ std::vector<ItemSetPassiveAbility> ItemSetPassiveAbility::FindAbilities(uint32_t
|
||||
return abilities;
|
||||
}
|
||||
|
||||
void ItemSetPassiveAbility::OnEnemySmshed() {
|
||||
void ItemSetPassiveAbility::OnEnemySmshed(Entity* target) {
|
||||
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||
auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
|
||||
|
||||
@ -293,8 +293,8 @@ void ItemSetPassiveAbility::OnEnemySmshed() {
|
||||
break;
|
||||
}
|
||||
case ItemSetPassiveAbilityID::ShinobiRank3: {
|
||||
if (equippedCount < 4) return;
|
||||
destroyableComponent->Imagine(3);
|
||||
if (equippedCount < 4 || !target) return;
|
||||
skillComponent->CalculateBehavior(695, 11399, target->GetObjectID());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* @param trigger the trigger to attempt to fire
|
||||
*/
|
||||
void Trigger(PassiveAbilityTrigger trigger);
|
||||
void Trigger(PassiveAbilityTrigger trigger, Entity* target = nullptr);
|
||||
|
||||
/**
|
||||
* Activates the passive ability
|
||||
*/
|
||||
void Activate();
|
||||
void Activate(Entity* target = nullptr);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
private:
|
||||
void OnEnemySmshed();
|
||||
void OnEnemySmshed(Entity* target = nullptr);
|
||||
|
||||
/**
|
||||
* The means of triggering this ability
|
||||
|
@ -12,7 +12,7 @@ void PropertyFXDamage::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
if (skills != nullptr && targetStats != nullptr) {
|
||||
auto targetFactions = targetStats->GetFactionIDs();
|
||||
if (std::find(targetFactions.begin(), targetFactions.end(), 1) != targetFactions.end()) {
|
||||
skills->CalculateBehavior(11386, 692, target->GetObjectID());
|
||||
skills->CalculateBehavior(692, 11386, target->GetObjectID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user