void HostileRefManager::deleteReferences() { HostileReference* ref = getFirst(); while (ref) { HostileReference* nextRef = ref->next(); ref->removeReference(); delete ref; ref = nextRef; } }
void HostileRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) { uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not devide threat float threat = pThreat/size; HostileReference* ref = getFirst(); while (ref) { ref->getSource()->addThreat(pVictim, threat, false, (pThreatSpell ? GetSpellSchoolMask(pThreatSpell) : SPELL_SCHOOL_MASK_NORMAL), pThreatSpell); ref = ref->next(); } }
void HostileRefManager::setOnlineOfflineState(bool pIsOnline) { HostileReference* ref; ref = getFirst(); while(ref != NULL) { if(iOwner->GetMapId() == ref->getSource()->getOwner()->GetMapId()) ref->setOnlineOfflineState(pIsOnline); ref = ref->next(); } }
void HostileRefManager::threatAssist(Unit* victim, float baseThreat, SpellInfo const* threatSpell) { HostileReference* ref = getFirst(); float threat = ThreatCalcHelper::calcThreat(victim, iOwner, baseThreat, (threatSpell ? threatSpell->GetSchoolMask() : SPELL_SCHOOL_MASK_NORMAL), threatSpell); threat /= getSize(); while (ref) { if (ThreatCalcHelper::isValidProcess(victim, ref->getSource()->getOwner(), threatSpell)) ref->getSource()->doAddThreat(victim, threat); ref = ref->next(); } }
void HostileRefManager::deleteReferencesForFaction(uint32 faction) { HostileReference* ref = getFirst(); while(ref) { HostileReference* nextRef = ref->next(); if(ref->getSource()->getOwner()->getFactionTemplateEntry()->faction == faction) { ref->removeReference(); delete ref; } ref = nextRef; } }
void HostileRefManager::setOnlineOfflineState(Unit *pCreature,bool pIsOnline) { HostileReference* ref = getFirst(); while(ref) { HostileReference* nextRef = ref->next(); if(ref->getSource()->getOwner() == pCreature) { ref->setOnlineOfflineState(pIsOnline); break; } ref = nextRef; } }
void HostileRefManager::deleteReference(Unit *pCreature) { HostileReference* ref = getFirst(); while(ref) { HostileReference* nextRef = ref->next(); if(ref->getSource()->getOwner() == pCreature) { ref->removeReference(); delete ref; break; } ref = nextRef; } }
void HostileRefManager::threatAssist(Unit *pVictim, float fThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) { HostileReference* ref; float size = pSingleTarget ? 1.0f : getSize(); // if pSingleTarget do not divide threat ref = getFirst(); while (ref != NULL) { float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, fThreat, (pThreatSpell ? GetSpellSchoolMask(pThreatSpell) : SPELL_SCHOOL_MASK_NORMAL), pThreatSpell); if (pVictim == getOwner()) ref->addThreat(threat / size); // It is faster to modify the threat durectly if possible else ref->getSource()->addThreat(pVictim, threat / size); ref = ref->next(); } }
void HostileRefManager::deleteReferencesOutOfRange(float range) { HostileReference* ref = getFirst(); range = range*range; while (ref) { HostileReference* nextRef = ref->next(); Unit* owner = ref->GetSource()->GetOwner(); if (!owner->isActiveObject() && owner->GetExactDist2dSq(GetOwner()) > range) { ref->removeReference(); delete ref; } ref = nextRef; } }
void HostileRefManager::addTempThreat(float threat, bool apply) { HostileReference* ref = getFirst(); while (ref) { if (apply) { if (ref->getTempThreatModifier() == 0.0f) ref->addTempThreat(threat); } else ref->resetTempThreat(); ref = ref->next(); } }
void AttackersValue::AddAttackersOf(Unit* unit, set<Unit*>& targets) { HostileRefManager& refManager = unit->getHostileRefManager(); HostileReference *ref = refManager.getFirst(); if (!ref) return; while( ref ) { ThreatManager *threatManager = ref->GetSource(); Unit *attacker = threatManager->GetOwner(); Unit *victim = attacker->GetVictim(); if (victim == unit) targets.insert(attacker); ref = ref->next(); } }
void HostileRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) { float redirectedMod = pVictim->getHostileRefManager().GetThreatRedirectionMod(); Unit* redirectedTarget = redirectedMod ? pVictim->getHostileRefManager().GetThreatRedirectionTarget() : NULL; uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not devide threat HostileReference* ref = getFirst(); while(ref != NULL) { float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, pThreat, false, (pThreatSpell ? GetSpellSchoolMask(pThreatSpell) : SPELL_SCHOOL_MASK_NORMAL), pThreatSpell); if(pVictim == getOwner()) ref->addThreat(float (threat) / size); // It is faster to modify the threat durectly if possible else ref->getSource()->addThreat(pVictim, float (threat) / size); ref = ref->next(); } }
void HostileRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) { if (iOwner->hasUnitState(UNIT_STAT_IGNORE_ATTACKERS)) return; HostileReference* ref; uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not divide threat ref = getFirst(); while (ref != NULL) { float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, pThreat, (pThreatSpell ? SpellMgr::GetSpellSchoolMask(pThreatSpell) : SPELL_SCHOOL_MASK_NORMAL), pThreatSpell); if (pVictim == getOwner()) ref->addThreat(float (threat) / size); // It is faster to modify the threat directly if possible else ref->getSource()->addThreat(pVictim, float (threat) / size); ref = ref->next(); } }
void RandomPlayerbotMgr::Refresh(Player* bot) { if (bot->isDead()) { bot->ResurrectPlayer(1.0f); bot->SpawnCorpseBones(); bot->SaveToDB(); bot->GetPlayerbotAI()->ResetStrategies(); } bot->GetPlayerbotAI()->Reset(); HostileReference *ref = bot->getHostileRefManager().getFirst(); while( ref ) { ThreatManager *threatManager = ref->GetSource(); Unit *unit = threatManager->GetOwner(); float threat = ref->getThreat(); unit->RemoveAllAttackers(); unit->ClearInCombat(); ref = ref->next(); } bot->RemoveAllAttackers(); bot->ClearInCombat(); bot->DurabilityRepairAll(false, 1.0f, false); bot->SetFullHealth(); bot->SetPvP(true); if (bot->GetMaxPower(POWER_MANA) > 0) bot->SetPower(POWER_MANA, bot->GetMaxPower(POWER_MANA)); if (bot->GetMaxPower(POWER_ENERGY) > 0) bot->SetPower(POWER_ENERGY, bot->GetMaxPower(POWER_ENERGY)); }
void RandomPlayerbotMgr::Refresh(Player* bot) { if (bot->IsDead()) { PlayerbotChatHandler ch(bot); ch.revive(*bot); bot->GetPlayerbotAI()->ResetStrategies(); } bot->GetPlayerbotAI()->Reset(); HostileReference *ref = bot->GetHostileRefManager().getFirst(); while( ref ) { ThreatManager *threatManager = ref->getSource(); Unit *unit = threatManager->getOwner(); float threat = ref->getThreat(); unit->RemoveAllAttackers(); unit->ClearInCombat(); ref = ref->next(); } bot->RemoveAllAttackers(); bot->ClearInCombat(); bot->DurabilityRepairAll(false, 1.0f); bot->SetHealthPercent(100); bot->SetPvP(true); if (bot->GetMaxPower(POWER_MANA) > 0) bot->SetPower(POWER_MANA, bot->GetMaxPower(POWER_MANA)); if (bot->GetMaxPower(POWER_ENERGY) > 0) bot->SetPower(POWER_ENERGY, bot->GetMaxPower(POWER_ENERGY)); }
void InitializeAI() { CasterAI::InitializeAI(); Unit* owner = me->GetOwner(); if (!owner) return; // Clone Me! owner->CastSpell(me, SPELL_MAGE_CLONE_ME, true); // xinef: Glyph of Mirror Image (4th copy) float angle = 0.0f; switch (me->GetUInt32Value(UNIT_CREATED_BY_SPELL)) { case SPELL_SUMMON_MIRROR_IMAGE1: angle = 0.5f * M_PI; break; case SPELL_SUMMON_MIRROR_IMAGE2: angle = M_PI; break; case SPELL_SUMMON_MIRROR_IMAGE3: angle = 1.5f * M_PI; break; } ((Minion*)me)->SetFollowAngle(angle); if (owner->IsInCombat()) me->NearTeleportTo(me->GetPositionX() + cos(angle)*dist, me->GetPositionY() + sin(angle)*dist, me->GetPositionZ(), me->GetOrientation(), false, false, false, false); else me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE); me->SetReactState(REACT_DEFENSIVE); // Xinef: Inherit Master's Threat List (not yet implemented) //owner->CastSpell((Unit*)NULL, SPELL_MAGE_MASTERS_THREAT_LIST, true); HostileReference* ref = owner->getHostileRefManager().getFirst(); while (ref) { if (Unit* unit = ref->GetSource()->GetOwner()) unit->AddThreat(me, ref->getThreat() - ref->getTempThreatModifier()); ref = ref->next(); } _ebonGargoyleGUID = 0; // Xinef: copy caster auras Unit::VisibleAuraMap const* visibleAuraMap = owner->GetVisibleAuras(); for (Unit::VisibleAuraMap::const_iterator itr = visibleAuraMap->begin(); itr != visibleAuraMap->end(); ++itr) if (Aura* visAura = itr->second->GetBase()) { // Ebon Gargoyle if (visAura->GetId() == 49206 && me->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SPELL_SUMMON_MIRROR_IMAGE1) { if (Unit* gargoyle = visAura->GetCaster()) _ebonGargoyleGUID = gargoyle->GetGUID(); continue; } SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(visAura->GetId()); if (bounds.first != bounds.second) continue; std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(visAura->GetId() + SPELL_LINK_AURA); if (!spellTriggered || !spellTriggered->empty()) continue; if (Aura* newAura = me->AddAura(visAura->GetId(), me)) newAura->SetDuration(visAura->GetDuration()); } me->m_Events.AddEvent(new DeathEvent(*me), me->m_Events.CalculateTime(29500)); }
void HostileRefManager::addThreatPercent(int32 pValue) { for (HostileReference* ref = getFirst(); ref != NULL; ref = ref->next()) ref->addThreatPercent(pValue); }
void HostileRefManager::setOnlineOfflineState(bool pIsOnline) { for (HostileReference* ref = getFirst(); ref != NULL; ref = ref->next()) ref->setOnlineOfflineState(pIsOnline); }
void HostileRefManager::updateThreatTables() { for (HostileReference* ref = getFirst(); ref != NULL; ref = ref->next()) ref->updateOnlineStatus(); }