mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
refactor: re-write AOE, add FilterTargets, Update TacArc Reading (#1035)
* Re-write AOE behavior for new filter targets Update Tacarc to use new filter targets Added dev commands for skill and attack debugging * Get all entities by detroyable rather than controllable physics Since destroyables are what can be hit * Re-work filter targets to be 100% live accurate reduce memory usage by only using one vector and removing invalid entries get entities in the proximity rather than all entities with des comps in the instance, as was done in live * remove debuging longs and remove oopsie * address feedback * make log more useful * make filter more flat * Add some more checks to filter targets add pvp checks to isenemy * fix typing * Add filter target to TacArc and update filter target * fix double declaration * Some debugging logs * Update TacArc reading * make log clearer * logs * Update TacArcBehavior.cpp * banana * fix max targets * remove extreanous parenthesesuuesdsds * make behavior slot use a real type --------- Co-authored-by: David Markowitz <EmosewaMC@gmail.com>
This commit is contained in:
@@ -363,9 +363,10 @@ void DestroyableComponent::SetIsShielded(bool value) {
|
||||
|
||||
void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignoreChecks) {
|
||||
// Ignore factionID -1
|
||||
if (factionID == -1 && !ignoreChecks) {
|
||||
return;
|
||||
}
|
||||
if (factionID == -1 && !ignoreChecks) return;
|
||||
|
||||
// if we already have that faction, don't add it again
|
||||
if (std::find(m_FactionIDs.begin(), m_FactionIDs.end(), factionID) != m_FactionIDs.end()) return;
|
||||
|
||||
m_FactionIDs.push_back(factionID);
|
||||
m_DirtyHealth = true;
|
||||
@@ -407,6 +408,14 @@ void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignore
|
||||
}
|
||||
|
||||
bool DestroyableComponent::IsEnemy(const Entity* other) const {
|
||||
if (m_Parent->IsPlayer() && other->IsPlayer()){
|
||||
auto* thisCharacterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
if (!thisCharacterComponent) return false;
|
||||
auto* otherCharacterComponent = other->GetComponent<CharacterComponent>();
|
||||
if (!otherCharacterComponent) return false;
|
||||
if (thisCharacterComponent->GetPvpEnabled() && otherCharacterComponent->GetPvpEnabled()) return true;
|
||||
return false;
|
||||
}
|
||||
const auto* otherDestroyableComponent = other->GetComponent<DestroyableComponent>();
|
||||
if (otherDestroyableComponent != nullptr) {
|
||||
for (const auto enemyFaction : m_EnemyFactionIDs) {
|
||||
@@ -485,43 +494,6 @@ Entity* DestroyableComponent::GetKiller() const {
|
||||
return Game::entityManager->GetEntity(m_KillerID);
|
||||
}
|
||||
|
||||
bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignoreFactions, const bool targetEnemy, const bool targetFriend) const {
|
||||
auto* targetEntity = Game::entityManager->GetEntity(target);
|
||||
|
||||
if (targetEntity == nullptr) {
|
||||
Game::logger->Log("DestroyableComponent", "Invalid entity for checking validity (%llu)!", target);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* targetDestroyable = targetEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (targetDestroyable == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* targetQuickbuild = targetEntity->GetComponent<RebuildComponent>();
|
||||
|
||||
if (targetQuickbuild != nullptr) {
|
||||
const auto state = targetQuickbuild->GetState();
|
||||
|
||||
if (state != eRebuildState::COMPLETED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreFactions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get if the target entity is an enemy and friend
|
||||
bool isEnemy = IsEnemy(targetEntity);
|
||||
bool isFriend = IsFriend(targetEntity);
|
||||
|
||||
// Return true if the target type matches what we are targeting
|
||||
return (isEnemy && targetEnemy) || (isFriend && targetFriend);
|
||||
}
|
||||
|
||||
|
||||
void DestroyableComponent::Heal(const uint32_t health) {
|
||||
auto current = static_cast<uint32_t>(GetHealth());
|
||||
const auto max = static_cast<uint32_t>(GetMaxHealth());
|
||||
|
@@ -371,14 +371,6 @@ public:
|
||||
*/
|
||||
Entity* GetKiller() const;
|
||||
|
||||
/**
|
||||
* Checks if the target ID is a valid enemy of this entity
|
||||
* @param target the target ID to check for
|
||||
* @param ignoreFactions whether or not check for the factions, e.g. just return true if the entity cannot be smashed
|
||||
* @return if the target ID is a valid enemy
|
||||
*/
|
||||
bool CheckValidity(LWOOBJID target, bool ignoreFactions = false, bool targetEnemy = true, bool targetFriend = false) const;
|
||||
|
||||
/**
|
||||
* Attempt to damage this entity, handles everything from health and armor to absorption, immunity and callbacks.
|
||||
* @param damage the damage to attempt to apply
|
||||
|
@@ -1158,19 +1158,7 @@ void InventoryComponent::AddItemSkills(const LOT lot) {
|
||||
|
||||
const auto skill = FindSkill(lot);
|
||||
|
||||
if (skill == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (index != m_Skills.end()) {
|
||||
const auto old = index->second;
|
||||
|
||||
GameMessages::SendRemoveSkill(m_Parent, old);
|
||||
}
|
||||
|
||||
GameMessages::SendAddSkill(m_Parent, skill, static_cast<int>(slot));
|
||||
|
||||
m_Skills.insert_or_assign(slot, skill);
|
||||
SetSkill(slot, skill);
|
||||
}
|
||||
|
||||
void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
@@ -1197,7 +1185,7 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
if (slot == BehaviorSlot::Primary) {
|
||||
m_Skills.insert_or_assign(BehaviorSlot::Primary, 1);
|
||||
|
||||
GameMessages::SendAddSkill(m_Parent, 1, static_cast<int>(BehaviorSlot::Primary));
|
||||
GameMessages::SendAddSkill(m_Parent, 1, BehaviorSlot::Primary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1627,3 +1615,29 @@ void InventoryComponent::UpdatePetXml(tinyxml2::XMLDocument* document) {
|
||||
petInventoryElement->LinkEndChild(petElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool InventoryComponent::SetSkill(int32_t slot, uint32_t skillId){
|
||||
BehaviorSlot behaviorSlot = BehaviorSlot::Invalid;
|
||||
if (slot == 1 ) behaviorSlot = BehaviorSlot::Primary;
|
||||
else if (slot == 2 ) behaviorSlot = BehaviorSlot::Offhand;
|
||||
else if (slot == 3 ) behaviorSlot = BehaviorSlot::Neck;
|
||||
else if (slot == 4 ) behaviorSlot = BehaviorSlot::Head;
|
||||
else if (slot == 5 ) behaviorSlot = BehaviorSlot::Consumable;
|
||||
else return false;
|
||||
return SetSkill(behaviorSlot, skillId);
|
||||
}
|
||||
|
||||
bool InventoryComponent::SetSkill(BehaviorSlot slot, uint32_t skillId){
|
||||
if (skillId == 0) return false;
|
||||
const auto index = m_Skills.find(slot);
|
||||
if (index != m_Skills.end()) {
|
||||
const auto old = index->second;
|
||||
GameMessages::SendRemoveSkill(m_Parent, old);
|
||||
}
|
||||
|
||||
GameMessages::SendAddSkill(m_Parent, skillId, slot);
|
||||
m_Skills.insert_or_assign(slot, skillId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -367,6 +367,11 @@ public:
|
||||
*/
|
||||
void UnequipScripts(Item* unequippedItem);
|
||||
|
||||
std::map<BehaviorSlot, uint32_t> GetSkills(){ return m_Skills; };
|
||||
|
||||
bool SetSkill(int slot, uint32_t skillId);
|
||||
bool SetSkill(BehaviorSlot slot, uint32_t skillId);
|
||||
|
||||
~InventoryComponent() override;
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user