mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[8858] Implement client inform about creature threat list changes.
Signed-off-by: VladimirMangos <vladimir@getmangos.com> Also small related code cleanups.
This commit is contained in:
parent
29cbdf0a9e
commit
d924406bd8
6 changed files with 114 additions and 18 deletions
|
|
@ -209,6 +209,9 @@ void Unit::Update( uint32 p_time )
|
|||
delete *itr;
|
||||
m_deletedAuras.clear();
|
||||
|
||||
if (CanHaveThreatList())
|
||||
getThreatManager().UpdateForClient(p_time);
|
||||
|
||||
// update combat timer only for players and pets
|
||||
if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet() || ((Creature*)this)->isCharmed()))
|
||||
{
|
||||
|
|
@ -10402,6 +10405,8 @@ void Unit::AddThreat(Unit* pVictim, float threat /*= 0.0f*/, bool crit /*= false
|
|||
|
||||
void Unit::DeleteThreatList()
|
||||
{
|
||||
if(CanHaveThreatList() && !m_ThreatManager.isThreatListEmpty())
|
||||
SendThreatClear();
|
||||
m_ThreatManager.clearReferences();
|
||||
}
|
||||
|
||||
|
|
@ -12763,3 +12768,57 @@ uint32 Unit::GetCombatRatingDamageReduction(CombatRating cr, float rate, float c
|
|||
percent = cap;
|
||||
return uint32 (percent * damage / 100.0f);
|
||||
}
|
||||
|
||||
void Unit::SendThreatUpdate()
|
||||
{
|
||||
if (uint32 count = getThreatManager().getThreatList().size())
|
||||
{
|
||||
sLog.outDebug( "WORLD: Send SMSG_THREAT_UPDATE Message" );
|
||||
WorldPacket data(SMSG_THREAT_UPDATE, 8 + count * 8);
|
||||
data.append(GetPackGUID());
|
||||
data << uint32(count);
|
||||
ThreatList& tlist = getThreatManager().getThreatList();
|
||||
for (ThreatList::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
|
||||
{
|
||||
data.appendPackGUID((*itr)->getUnitGuid());
|
||||
data << uint32((*itr)->getThreat());
|
||||
}
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::SendHighestThreatUpdate(HostileReference* pHostilReference)
|
||||
{
|
||||
if (uint32 count = getThreatManager().getThreatList().size())
|
||||
{
|
||||
sLog.outDebug( "WORLD: Send SMSG_HIGHEST_THREAT_UPDATE Message" );
|
||||
WorldPacket data(SMSG_HIGHEST_THREAT_UPDATE, 8 + 8 + count * 8);
|
||||
data.append(GetPackGUID());
|
||||
data.appendPackGUID(pHostilReference->getUnitGuid());
|
||||
data << uint32(count);
|
||||
ThreatList const& tlist = getThreatManager().getThreatList();
|
||||
for (ThreatList::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
|
||||
{
|
||||
data.appendPackGUID((*itr)->getUnitGuid());
|
||||
data << uint32((*itr)->getThreat());
|
||||
}
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::SendThreatClear()
|
||||
{
|
||||
sLog.outDebug( "WORLD: Send SMSG_THREAT_CLEAR Message" );
|
||||
WorldPacket data(SMSG_THREAT_CLEAR, 8);
|
||||
data.append(GetPackGUID());
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
void Unit::SendThreatRemove(HostileReference* pHostileReference)
|
||||
{
|
||||
sLog.outDebug( "WORLD: Send SMSG_THREAT_REMOVE Message" );
|
||||
WorldPacket data(SMSG_THREAT_REMOVE, 8 + 8);
|
||||
data.append(GetPackGUID());
|
||||
data.appendPackGUID(pHostileReference->getUnitGuid());
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue