mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 02:08:20 +00:00
fix: faction changes not allowing updated targets (#1437)
* fix faction change issue fixes an issue where enemies who would have their faction changed would not change aggro targets. Tested that stromling mechs and ronin/horsemen in forbidden valley still aggro on spawn as expected. * use erase remove if
This commit is contained in:
parent
54ded62757
commit
2f247b1fc9
@ -1357,17 +1357,11 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!other->GetIsDead()) {
|
if (!other->GetIsDead()) {
|
||||||
auto* combat = GetComponent<BaseCombatAIComponent>();
|
if (GetComponent<BaseCombatAIComponent>() != nullptr) {
|
||||||
|
|
||||||
if (combat != nullptr) {
|
|
||||||
const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity);
|
const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity);
|
||||||
|
|
||||||
if (index != m_TargetsInPhantom.end()) return;
|
if (index != m_TargetsInPhantom.end()) return;
|
||||||
|
|
||||||
const auto valid = combat->IsEnemy(otherEntity);
|
|
||||||
|
|
||||||
if (!valid) return;
|
|
||||||
|
|
||||||
m_TargetsInPhantom.push_back(otherEntity);
|
m_TargetsInPhantom.push_back(otherEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1992,25 +1986,21 @@ void Entity::SetNetworkId(const uint16_t id) {
|
|||||||
m_NetworkID = id;
|
m_NetworkID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<LWOOBJID>& Entity::GetTargetsInPhantom() {
|
std::vector<LWOOBJID> Entity::GetTargetsInPhantom() {
|
||||||
std::vector<LWOOBJID> valid;
|
|
||||||
|
|
||||||
// Clean up invalid targets, like disconnected players
|
// Clean up invalid targets, like disconnected players
|
||||||
for (auto i = 0u; i < m_TargetsInPhantom.size(); ++i) {
|
m_TargetsInPhantom.erase(std::remove_if(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), [](const LWOOBJID id) {
|
||||||
const auto id = m_TargetsInPhantom.at(i);
|
return !Game::entityManager->GetEntity(id);
|
||||||
|
}), m_TargetsInPhantom.end());
|
||||||
|
|
||||||
auto* entity = Game::entityManager->GetEntity(id);
|
std::vector<LWOOBJID> enemies;
|
||||||
|
for (const auto id : m_TargetsInPhantom) {
|
||||||
|
auto* combat = GetComponent<BaseCombatAIComponent>();
|
||||||
|
if (!combat || !combat->IsEnemy(id)) continue;
|
||||||
|
|
||||||
if (entity == nullptr) {
|
enemies.push_back(id);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
valid.push_back(id);
|
return enemies;
|
||||||
}
|
|
||||||
|
|
||||||
m_TargetsInPhantom = valid;
|
|
||||||
|
|
||||||
return m_TargetsInPhantom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SendNetworkVar(const std::string& data, const SystemAddress& sysAddr) {
|
void Entity::SendNetworkVar(const std::string& data, const SystemAddress& sysAddr) {
|
||||||
|
@ -293,7 +293,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Collision
|
* Collision
|
||||||
*/
|
*/
|
||||||
std::vector<LWOOBJID>& GetTargetsInPhantom();
|
std::vector<LWOOBJID> GetTargetsInPhantom();
|
||||||
|
|
||||||
Entity* GetScheduledKiller() { return m_ScheduleKiller; }
|
Entity* GetScheduledKiller() { return m_ScheduleKiller; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user