mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-14 20:28:21 +00:00
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.
This commit is contained in:
parent
5225c86d65
commit
a67ef6336f
@ -1357,17 +1357,11 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
||||
}
|
||||
|
||||
if (!other->GetIsDead()) {
|
||||
auto* combat = GetComponent<BaseCombatAIComponent>();
|
||||
|
||||
if (combat != nullptr) {
|
||||
if (GetComponent<BaseCombatAIComponent>() != nullptr) {
|
||||
const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity);
|
||||
|
||||
if (index != m_TargetsInPhantom.end()) return;
|
||||
|
||||
const auto valid = combat->IsEnemy(otherEntity);
|
||||
|
||||
if (!valid) return;
|
||||
|
||||
m_TargetsInPhantom.push_back(otherEntity);
|
||||
}
|
||||
}
|
||||
@ -1992,25 +1986,25 @@ void Entity::SetNetworkId(const uint16_t id) {
|
||||
m_NetworkID = id;
|
||||
}
|
||||
|
||||
std::vector<LWOOBJID>& Entity::GetTargetsInPhantom() {
|
||||
std::vector<LWOOBJID> valid;
|
||||
|
||||
std::vector<LWOOBJID> Entity::GetTargetsInPhantom() {
|
||||
// Clean up invalid targets, like disconnected players
|
||||
for (auto i = 0u; i < m_TargetsInPhantom.size(); ++i) {
|
||||
const auto id = m_TargetsInPhantom.at(i);
|
||||
|
||||
auto* entity = Game::entityManager->GetEntity(id);
|
||||
|
||||
if (entity == nullptr) {
|
||||
for (auto i = 0u; i < m_TargetsInPhantom.size(); ) {
|
||||
if (Game::entityManager->GetEntity(m_TargetsInPhantom.at(i))) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
valid.push_back(id);
|
||||
m_TargetsInPhantom.erase(m_TargetsInPhantom.begin() + i);
|
||||
}
|
||||
|
||||
m_TargetsInPhantom = valid;
|
||||
std::vector<LWOOBJID> enemies;
|
||||
for (const auto id : m_TargetsInPhantom) {
|
||||
auto* combat = GetComponent<BaseCombatAIComponent>();
|
||||
if (!combat || !combat->IsEnemy(id)) continue;
|
||||
|
||||
return m_TargetsInPhantom;
|
||||
enemies.push_back(id);
|
||||
}
|
||||
|
||||
return enemies;
|
||||
}
|
||||
|
||||
void Entity::SendNetworkVar(const std::string& data, const SystemAddress& sysAddr) {
|
||||
|
@ -293,7 +293,7 @@ public:
|
||||
/*
|
||||
* Collision
|
||||
*/
|
||||
std::vector<LWOOBJID>& GetTargetsInPhantom();
|
||||
std::vector<LWOOBJID> GetTargetsInPhantom();
|
||||
|
||||
Entity* GetScheduledKiller() { return m_ScheduleKiller; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user