mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
fix(Core/Entities): extend combo point system to all Units (#9816)
- Closes #1140
This commit is contained in:
@@ -169,8 +169,6 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
|
||||
if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()))
|
||||
SetAcceptWhispers(true);
|
||||
|
||||
m_comboPoints = 0;
|
||||
|
||||
m_usedTalentCount = 0;
|
||||
m_questRewardTalentCount = 0;
|
||||
m_extraBonusTalentCount = 0;
|
||||
@@ -391,7 +389,6 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
|
||||
|
||||
// Ours
|
||||
m_NeedToSaveGlyphs = false;
|
||||
m_comboPointGain = 0;
|
||||
m_MountBlockId = 0;
|
||||
m_realDodge = 0.0f;
|
||||
m_realParry = 0.0f;
|
||||
@@ -6202,12 +6199,11 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
if (duel->State == DUEL_STATE_COMPLETED)
|
||||
return;
|
||||
|
||||
Player* opponent = duel->Opponent;
|
||||
duel->State = DUEL_STATE_COMPLETED;
|
||||
Player* opponent = duel->Opponent;
|
||||
duel->State = DUEL_STATE_COMPLETED;
|
||||
opponent->duel->State = DUEL_STATE_COMPLETED;
|
||||
|
||||
LOG_DEBUG("entities.unit", "Player::DuelComplete: Player '%s' (%s), Opponent: '%s' (%s)",
|
||||
GetName().c_str(), GetGUID().ToString().c_str(), opponent->GetName().c_str(), opponent->GetGUID().ToString().c_str());
|
||||
LOG_DEBUG("entities.unit", "Player::DuelComplete: Player '%s' (%s), Opponent: '%s' (%s)", GetName().c_str(), GetGUID().ToString().c_str(), opponent->GetName().c_str(), opponent->GetGUID().ToString().c_str());
|
||||
|
||||
WorldPacket data(SMSG_DUEL_COMPLETE, (1));
|
||||
data << uint8((type != DUEL_INTERRUPTED) ? 1 : 0);
|
||||
@@ -6219,8 +6215,8 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
|
||||
if (type != DUEL_INTERRUPTED)
|
||||
{
|
||||
data.Initialize(SMSG_DUEL_WINNER, (1+20)); // we guess size
|
||||
data << uint8(type == DUEL_WON ? 0 : 1); // 0 = just won; 1 = fled
|
||||
data.Initialize(SMSG_DUEL_WINNER, (1 + 20)); // we guess size
|
||||
data << uint8(type == DUEL_WON ? 0 : 1); // 0 = just won; 1 = fled
|
||||
data << opponent->GetName();
|
||||
data << GetName();
|
||||
SendMessageToSet(&data, true);
|
||||
@@ -6230,45 +6226,45 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DUEL_FLED:
|
||||
// if initiator and opponent are on the same team
|
||||
// or initiator and opponent are not PvP enabled, forcibly stop attacking
|
||||
if (GetTeamId() == opponent->GetTeamId())
|
||||
case DUEL_FLED:
|
||||
// if initiator and opponent are on the same team
|
||||
// or initiator and opponent are not PvP enabled, forcibly stop attacking
|
||||
if (GetTeamId() == opponent->GetTeamId())
|
||||
{
|
||||
AttackStop();
|
||||
opponent->AttackStop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IsPvP())
|
||||
{
|
||||
AttackStop();
|
||||
}
|
||||
if (!opponent->IsPvP())
|
||||
{
|
||||
opponent->AttackStop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IsPvP())
|
||||
{
|
||||
AttackStop();
|
||||
}
|
||||
if (!opponent->IsPvP())
|
||||
{
|
||||
opponent->AttackStop();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DUEL_WON:
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, 1);
|
||||
opponent->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1);
|
||||
}
|
||||
break;
|
||||
case DUEL_WON:
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, 1);
|
||||
opponent->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1);
|
||||
|
||||
// Credit for quest Death's Challenge
|
||||
if (getClass() == CLASS_DEATH_KNIGHT && opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE)
|
||||
{
|
||||
opponent->CastSpell(opponent, 52994, true);
|
||||
}
|
||||
// Credit for quest Death's Challenge
|
||||
if (getClass() == CLASS_DEATH_KNIGHT && opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE)
|
||||
{
|
||||
opponent->CastSpell(opponent, 52994, true);
|
||||
}
|
||||
|
||||
// Honor points after duel (the winner) - ImpConfig
|
||||
if (uint32 amount = sWorld->getIntConfig(CONFIG_HONOR_AFTER_DUEL))
|
||||
{
|
||||
opponent->RewardHonor(nullptr, 1, amount);
|
||||
}
|
||||
// Honor points after duel (the winner) - ImpConfig
|
||||
if (uint32 amount = sWorld->getIntConfig(CONFIG_HONOR_AFTER_DUEL))
|
||||
{
|
||||
opponent->RewardHonor(nullptr, 1, amount);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Victory emote spell
|
||||
@@ -6277,7 +6273,7 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
opponent->CastSpell(opponent, 52852, true);
|
||||
}
|
||||
|
||||
//Remove Duel Flag object
|
||||
// Remove Duel Flag object
|
||||
GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER));
|
||||
if (obj)
|
||||
{
|
||||
@@ -6285,7 +6281,7 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
}
|
||||
|
||||
/* remove auras */
|
||||
AuraApplicationMap &itsAuras = opponent->GetAppliedAuras();
|
||||
AuraApplicationMap& itsAuras = opponent->GetAppliedAuras();
|
||||
for (AuraApplicationMap::iterator i = itsAuras.begin(); i != itsAuras.end();)
|
||||
{
|
||||
Aura const* aura = i->second->GetBase();
|
||||
@@ -6299,7 +6295,7 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
}
|
||||
}
|
||||
|
||||
AuraApplicationMap &myAuras = GetAppliedAuras();
|
||||
AuraApplicationMap& myAuras = GetAppliedAuras();
|
||||
for (AuraApplicationMap::iterator i = myAuras.begin(); i != myAuras.end();)
|
||||
{
|
||||
Aura const* aura = i->second->GetBase();
|
||||
@@ -6310,16 +6306,20 @@ void Player::DuelComplete(DuelCompleteType type)
|
||||
}
|
||||
|
||||
// cleanup combo points
|
||||
if (GetComboTarget() == duel->Opponent->GetGUID())
|
||||
if (GetComboTarget() == duel->Opponent)
|
||||
{
|
||||
ClearComboPoints();
|
||||
else if (GetComboTarget() == duel->Opponent->GetPetGUID())
|
||||
}
|
||||
else if (GetComboTargetGUID() == duel->Opponent->GetPetGUID())
|
||||
{
|
||||
ClearComboPoints();
|
||||
}
|
||||
|
||||
if (duel->Opponent->GetComboTarget() == GetGUID())
|
||||
if (duel->Opponent->GetComboTarget() == this)
|
||||
{
|
||||
duel->Opponent->ClearComboPoints();
|
||||
}
|
||||
else if (duel->Opponent->GetComboTarget() == GetPetGUID())
|
||||
else if (duel->Opponent->GetComboTargetGUID() == GetPetGUID())
|
||||
{
|
||||
duel->Opponent->ClearComboPoints();
|
||||
}
|
||||
@@ -10822,75 +10822,6 @@ void Player::SetSelection(ObjectGuid guid)
|
||||
ArenaSpectator::SendCommand_GUID(FindMap(), GetGUID(), "TRG", guid);
|
||||
}
|
||||
|
||||
void Player::SendComboPoints()
|
||||
{
|
||||
Unit* combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget);
|
||||
if (combotarget)
|
||||
{
|
||||
WorldPacket data;
|
||||
if (m_mover != this)
|
||||
{
|
||||
data.Initialize(SMSG_PET_UPDATE_COMBO_POINTS, m_mover->GetPackGUID().size() + combotarget->GetPackGUID().size() + 1);
|
||||
data << m_mover->GetPackGUID();
|
||||
}
|
||||
else
|
||||
data.Initialize(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size() + 1);
|
||||
data << combotarget->GetPackGUID();
|
||||
data << uint8(m_comboPoints);
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::AddComboPoints(Unit* target, int8 count)
|
||||
{
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
int8* comboPoints = &m_comboPoints;
|
||||
|
||||
// without combo points lost (duration checked in aura)
|
||||
RemoveAurasByType(SPELL_AURA_RETAIN_COMBO_POINTS);
|
||||
|
||||
if (target->GetGUID() == m_comboTarget)
|
||||
*comboPoints += count;
|
||||
else
|
||||
{
|
||||
if (m_comboTarget)
|
||||
if (Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTarget))
|
||||
target2->RemoveComboPointHolder(GetGUID());
|
||||
|
||||
m_comboTarget = target->GetGUID();
|
||||
*comboPoints = count;
|
||||
|
||||
target->AddComboPointHolder(GetGUID());
|
||||
}
|
||||
|
||||
if (*comboPoints > 5)
|
||||
*comboPoints = 5;
|
||||
else if (*comboPoints < 0)
|
||||
*comboPoints = 0;
|
||||
|
||||
SendComboPoints();
|
||||
}
|
||||
|
||||
void Player::ClearComboPoints()
|
||||
{
|
||||
if (!m_comboTarget)
|
||||
return;
|
||||
|
||||
// without combopoints lost (duration checked in aura)
|
||||
RemoveAurasByType(SPELL_AURA_RETAIN_COMBO_POINTS);
|
||||
|
||||
m_comboPoints = 0;
|
||||
|
||||
SendComboPoints();
|
||||
|
||||
if (Unit* target = ObjectAccessor::GetUnit(*this, m_comboTarget))
|
||||
target->RemoveComboPointHolder(GetGUID());
|
||||
|
||||
m_comboTarget.Clear();
|
||||
}
|
||||
|
||||
void Player::SetGroup(Group* group, int8 subgroup)
|
||||
{
|
||||
if (group == nullptr)
|
||||
|
||||
Reference in New Issue
Block a user