本文整理汇总了C++中HostileReference::addThreat方法的典型用法代码示例。如果您正苦于以下问题:C++ HostileReference::addThreat方法的具体用法?C++ HostileReference::addThreat怎么用?C++ HostileReference::addThreat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HostileReference
的用法示例。
在下文中一共展示了HostileReference::addThreat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threatAssist
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 (threat > 0.0f)
{
if (redirectedTarget && redirectedTarget != ref->getTarget() && redirectedTarget->isAlive())
{
float redirectedThreat = threat * redirectedMod;
threat -= redirectedThreat;
if(redirectedTarget == getOwner()) // It is faster to modify the threat durectly if possible
ref->addThreat(float (threat) / size);
else
ref->getSource()->addThreat(redirectedTarget, redirectedThreat);
}
}
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();
}
}
示例2: addThreat
HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat)
{
HostileReference* ref = getReferenceByTarget(pVictim);
if (ref)
ref->addThreat(pThreat);
return ref;
}
示例3: addThreatDirectly
void ThreatManager::addThreatDirectly(Unit* pVictim, float threat)
{
// not to self
if (pVictim == getOwner())
return;
HostileReference* ref = iThreatContainer.addThreat(pVictim, threat);
// Ref is online
if (ref)
iUpdateNeed = true;
// Ref is not in the online refs, search the offline refs next
else
ref = iThreatOfflineContainer.addThreat(pVictim, threat);
if(!ref) // there was no ref => create a new one
{
// threat has to be 0 here
HostileReference* hostileReference = new HostileReference(pVictim, this, 0);
iThreatContainer.addReference(hostileReference);
hostileReference->addThreat(threat); // now we add the real threat
iUpdateNeed = true;
if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster())
hostileReference->setOnlineOfflineState(false); // GM is always offline
}
}
示例4: threatAssist
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();
}
}
示例5: _addThreat
void ThreatManager::_addThreat(Unit* victim, float threat)
{
HostileReference* ref = iThreatContainer.addThreat(victim, threat);
// Ref is not in the online refs, search the offline refs next
if (!ref)
ref = iThreatOfflineContainer.addThreat(victim, threat);
if (!ref) // there was no ref => create a new one
{
// threat has to be 0 here
HostileReference* hostileRef = new HostileReference(victim, this, 0);
iThreatContainer.addReference(hostileRef);
hostileRef->addThreat(threat); // now we add the real threat
if (victim->GetTypeId() == TYPEID_PLAYER && victim->ToPlayer()->isGameMaster())
hostileRef->setOnlineOfflineState(false); // GM is always offline
}
}
示例6: threatAssist
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();
}
}
示例7: addThreat
void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellSchoolMask schoolMask, SpellEntry const *pThreatSpell)
{
//function deals with adding threat and adding players and pets into ThreatList
//mobs, NPCs, guards have ThreatList and HateOfflineList
//players and pets have only InHateListOf
//HateOfflineList is used co contain unattackable victims (in-flight, in-water, GM etc.)
// not to self
if (pVictim == getOwner())
return;
// not to GM
if (!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) )
return;
// not to dead and not for dead
if (!pVictim->isAlive() || !getOwner()->isAlive() )
return;
ASSERT(getOwner()->GetTypeId()== TYPEID_UNIT);
float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, pThreat, crit, schoolMask, pThreatSpell);
HostileReference* ref = iThreatContainer.addThreat(pVictim, threat);
// Ref is online
if (ref)
iUpdateNeed = true;
// Ref is not in the online refs, search the offline refs next
else
ref = iThreatOfflineContainer.addThreat(pVictim, threat);
if (!ref) // there was no ref => create a new one
{
// threat has to be 0 here
HostileReference* hostileReference = new HostileReference(pVictim, this, 0);
iThreatContainer.addReference(hostileReference);
hostileReference->addThreat(threat); // now we add the real threat
iUpdateNeed = true;
if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster())
hostileReference->setOnlineOfflineState(false); // GM is always offline
}
}