void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent) { threatRefStatusChangeEvent->setThreatManager(this); // now we can set the threat manager HostileReference* hostileReference = threatRefStatusChangeEvent->getReference(); switch(threatRefStatusChangeEvent->getType()) { case UEV_THREAT_REF_THREAT_CHANGE: if((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue()<0.0f) || (getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue()>0.0f)) setDirty(true); // the order in the threat list might have changed break; case UEV_THREAT_REF_ONLINE_STATUS: if(!hostileReference->isOnline()) { if (hostileReference == getCurrentVictim()) { setCurrentVictim(NULL); setDirty(true); } if (getOwner() && getOwner()->IsInWorld()) if (Unit* target = ObjectAccessor::GetUnit(*getOwner(), hostileReference->getUnitGuid())) if (getOwner()->IsInMap(target)) getOwner()->SendThreatRemove(hostileReference); iThreatContainer.remove(hostileReference); iUpdateNeed = true; iThreatOfflineContainer.addReference(hostileReference); } else { if(getCurrentVictim() && hostileReference->getThreat() > (1.1f * getCurrentVictim()->getThreat())) setDirty(true); iThreatContainer.addReference(hostileReference); iUpdateNeed = true; iThreatOfflineContainer.remove(hostileReference); } break; case UEV_THREAT_REF_REMOVE_FROM_LIST: if (hostileReference == getCurrentVictim()) { setCurrentVictim(NULL); setDirty(true); } if(hostileReference->isOnline()) { if (getOwner() && getOwner()->IsInWorld()) if (Unit* target = ObjectAccessor::GetUnit(*getOwner(), hostileReference->getUnitGuid())) if (getOwner()->IsInMap(target)) getOwner()->SendThreatRemove(hostileReference); iThreatContainer.remove(hostileReference); iUpdateNeed = true; } else iThreatOfflineContainer.remove(hostileReference); break; } }
void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent) { threatRefStatusChangeEvent->setThreatManager(this); // now we can set the threat manager HostileReference* hostileReference = threatRefStatusChangeEvent->getReference(); switch (threatRefStatusChangeEvent->getType()) { case UEV_THREAT_REF_THREAT_CHANGE: if ((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue() < 0.0f) || (getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue() > 0.0f)) { setDirty(true); // the order in the threat list might have changed } break; case UEV_THREAT_REF_ONLINE_STATUS: if (!hostileReference->isOnline()) { if (hostileReference == getCurrentVictim()) { setCurrentVictim(NULL); setDirty(true); } iThreatContainer.remove(hostileReference); iThreatOfflineContainer.addReference(hostileReference); } else { if (getCurrentVictim() && hostileReference->getThreat() > (1.1f * getCurrentVictim()->getThreat())) { setDirty(true); } iThreatContainer.addReference(hostileReference); iThreatOfflineContainer.remove(hostileReference); } break; case UEV_THREAT_REF_REMOVE_FROM_LIST: if (hostileReference == getCurrentVictim()) { setCurrentVictim(NULL); setDirty(true); } if (hostileReference->isOnline()) { iThreatContainer.remove(hostileReference); } else { iThreatOfflineContainer.remove(hostileReference); } break; } }