mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-11 01:48:07 +00:00
Refactor and combat changes
This commit is contained in:
@@ -36,6 +36,7 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
|
||||
m_Disabled = false;
|
||||
m_SkillEntries = {};
|
||||
m_SoftTimer = 5.0f;
|
||||
m_StunImmune = true;
|
||||
|
||||
//Grab the aggro information from BaseCombatAI:
|
||||
auto componentQuery = CDClientDatabase::CreatePreppedStmt(
|
||||
@@ -369,9 +370,9 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
|
||||
m_Timer = 0;
|
||||
|
||||
m_SkillTime = result.skillTime;
|
||||
m_SkillTime = result.skillTime / 2.0f;
|
||||
|
||||
entry.cooldown = entry.abilityCooldown + m_SkillTime;
|
||||
entry.cooldown = 0.1f; //entry.abilityCooldown + m_SkillTime;
|
||||
|
||||
m_SkillEntries[i] = entry;
|
||||
|
||||
@@ -619,6 +620,10 @@ void BaseCombatAIComponent::SetThreat(LWOOBJID offender, float threat) {
|
||||
m_DirtyThreat = true;
|
||||
}
|
||||
|
||||
const std::map<LWOOBJID, float>& BaseCombatAIComponent::GetThreats() const {
|
||||
return m_ThreatEntries;
|
||||
}
|
||||
|
||||
const NiPoint3& BaseCombatAIComponent::GetStartPosition() const {
|
||||
return m_StartPosition;
|
||||
}
|
||||
@@ -679,7 +684,7 @@ void BaseCombatAIComponent::OnAggro() {
|
||||
return;
|
||||
}
|
||||
|
||||
m_MovementAI->SetHaltDistance(m_AttackRadius);
|
||||
m_MovementAI->SetHaltDistance(0);
|
||||
|
||||
NiPoint3 targetPos = target->GetPosition();
|
||||
NiPoint3 currentPos = m_MovementAI->GetParent()->GetPosition();
|
||||
@@ -713,7 +718,7 @@ void BaseCombatAIComponent::OnTether() {
|
||||
return;
|
||||
}
|
||||
|
||||
m_MovementAI->SetHaltDistance(m_AttackRadius);
|
||||
m_MovementAI->SetHaltDistance(0);
|
||||
|
||||
NiPoint3 targetPos = target->GetPosition();
|
||||
NiPoint3 currentPos = m_MovementAI->ApproximateLocation();
|
||||
|
@@ -114,6 +114,12 @@ public:
|
||||
*/
|
||||
void SetThreat(LWOOBJID offender, float threat);
|
||||
|
||||
/**
|
||||
* Get all threats for this entity
|
||||
* @return all threats for this entity
|
||||
*/
|
||||
const std::map<LWOOBJID, float>& GetThreats() const;
|
||||
|
||||
/**
|
||||
* Gets the position where the entity spawned
|
||||
* @return the position where the entity spawned
|
||||
|
@@ -38,8 +38,7 @@
|
||||
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
|
||||
Implementation<bool, const Entity*> DestroyableComponent::IsEnemyImplentation;
|
||||
Implementation<bool, const Entity*> DestroyableComponent::IsFriendImplentation;
|
||||
Observable<Entity*, LWOOBJID, uint32_t, uint32_t&> DestroyableComponent::OnDamageCalculation;
|
||||
|
||||
DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) {
|
||||
m_iArmor = 0;
|
||||
@@ -421,7 +420,6 @@ void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignore
|
||||
}
|
||||
|
||||
bool DestroyableComponent::IsEnemy(const Entity* other) const {
|
||||
if (IsEnemyImplentation.ExecuteWithDefault(other, false)) return true;
|
||||
if (m_Parent->IsPlayer() && other->IsPlayer()) {
|
||||
auto* thisCharacterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
if (!thisCharacterComponent) return false;
|
||||
@@ -444,7 +442,6 @@ bool DestroyableComponent::IsEnemy(const Entity* other) const {
|
||||
}
|
||||
|
||||
bool DestroyableComponent::IsFriend(const Entity* other) const {
|
||||
if (IsFriendImplentation.ExecuteWithDefault(other, false)) return true;
|
||||
const auto* otherDestroyableComponent = other->GetComponent<DestroyableComponent>();
|
||||
if (otherDestroyableComponent != nullptr) {
|
||||
for (const auto enemyFaction : m_EnemyFactionIDs) {
|
||||
@@ -575,6 +572,8 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
return;
|
||||
}
|
||||
|
||||
OnDamageCalculation(m_Parent, source, skillID, damage);
|
||||
|
||||
// If this entity has damage reduction, reduce the damage to a minimum of 1
|
||||
if (m_DamageReduction > 0 && damage > 0) {
|
||||
if (damage > m_DamageReduction) {
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include "Entity.h"
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "Implementation.h"
|
||||
#include "Observable.h"
|
||||
|
||||
namespace CppScripts {
|
||||
class Script;
|
||||
@@ -464,8 +464,8 @@ public:
|
||||
// handle hardcode mode drops
|
||||
void DoHardcoreModeDrops(const LWOOBJID source);
|
||||
|
||||
static Implementation<bool, const Entity*> IsEnemyImplentation;
|
||||
static Implementation<bool, const Entity*> IsFriendImplentation;
|
||||
// Damaged entity, offender, skillID, damage
|
||||
static Observable<Entity*, LWOOBJID, uint32_t, uint32_t&> OnDamageCalculation;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@@ -38,6 +38,12 @@
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
|
||||
Observable<InventoryComponent*, Item*> InventoryComponent::OnItemCreated;
|
||||
Observable<InventoryComponent*, Item*> InventoryComponent::OnItemDestroyed;
|
||||
Observable<InventoryComponent*, Item*> InventoryComponent::OnItemEquipped;
|
||||
Observable<InventoryComponent*, Item*> InventoryComponent::OnItemUnequipped;
|
||||
Observable<InventoryComponent*, Item*> InventoryComponent::OnItemLoaded;
|
||||
|
||||
InventoryComponent::InventoryComponent(Entity* parent) : Component(parent) {
|
||||
this->m_Dirty = true;
|
||||
this->m_Equipped = {};
|
||||
@@ -287,6 +293,8 @@ void InventoryComponent::AddItem(
|
||||
}
|
||||
auto* item = new Item(lot, inventory, slot, size, {}, parent, showFlyingLoot, isModMoveAndEquip, subKey, false, lootSourceType);
|
||||
|
||||
OnItemCreated(this, item);
|
||||
|
||||
isModMoveAndEquip = false;
|
||||
}
|
||||
|
||||
@@ -571,6 +579,8 @@ void InventoryComponent::LoadXml(const tinyxml2::XMLDocument& document) {
|
||||
}
|
||||
|
||||
itemElement = itemElement->NextSiblingElement();
|
||||
|
||||
OnItemLoaded(this, item);
|
||||
}
|
||||
|
||||
bag = bag->NextSiblingElement();
|
||||
@@ -849,6 +859,8 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
|
||||
EquipScripts(item);
|
||||
|
||||
OnItemEquipped(this, item);
|
||||
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
@@ -879,6 +891,8 @@ void InventoryComponent::UnEquipItem(Item* item) {
|
||||
|
||||
UnequipScripts(item);
|
||||
|
||||
OnItemUnequipped(this, item);
|
||||
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// Trigger property event
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "eInventoryType.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eLootSourceType.h"
|
||||
#include "Observable.h"
|
||||
|
||||
class Entity;
|
||||
class ItemSet;
|
||||
@@ -374,6 +375,12 @@ public:
|
||||
|
||||
~InventoryComponent() override;
|
||||
|
||||
static Observable<InventoryComponent*, Item*> OnItemCreated;
|
||||
static Observable<InventoryComponent*, Item*> OnItemDestroyed;
|
||||
static Observable<InventoryComponent*, Item*> OnItemEquipped;
|
||||
static Observable<InventoryComponent*, Item*> OnItemUnequipped;
|
||||
static Observable<InventoryComponent*, Item*> OnItemLoaded;
|
||||
|
||||
private:
|
||||
/**
|
||||
* All the inventory this entity possesses
|
||||
|
Reference in New Issue
Block a user