mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 10:37:01 +00:00
[8867] Implement expected combat stop with friendly faction
In case force reaction apply/remove.
This commit is contained in:
parent
670a2dbb4c
commit
e6efe02020
6 changed files with 69 additions and 3 deletions
|
|
@ -107,6 +107,24 @@ void HostileRefManager::deleteReferences()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================
|
||||||
|
// delete one reference, defined by faction
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================
|
//=================================================
|
||||||
// delete one reference, defined by Unit
|
// delete one reference, defined by Unit
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,9 @@ class HostileRefManager : public RefManager<Unit, ThreatManager>
|
||||||
// tell the source to remove them from the list and free the mem
|
// tell the source to remove them from the list and free the mem
|
||||||
void deleteReferences();
|
void deleteReferences();
|
||||||
|
|
||||||
|
// Remove specific faction references
|
||||||
|
void deleteReferencesForFaction(uint32 faction);
|
||||||
|
|
||||||
HostileReference* getFirst() { return ((HostileReference* ) RefManager<Unit, ThreatManager>::getFirst()); }
|
HostileReference* getFirst() { return ((HostileReference* ) RefManager<Unit, ThreatManager>::getFirst()); }
|
||||||
|
|
||||||
void updateThreatTables();
|
void updateThreatTables();
|
||||||
|
|
|
||||||
|
|
@ -3242,10 +3242,14 @@ void Aura::HandleForceReaction(bool apply, bool Real)
|
||||||
Player* player = (Player*)m_target;
|
Player* player = (Player*)m_target;
|
||||||
|
|
||||||
uint32 faction_id = m_modifier.m_miscvalue;
|
uint32 faction_id = m_modifier.m_miscvalue;
|
||||||
uint32 faction_rank = m_modifier.m_amount;
|
ReputationRank faction_rank = ReputationRank(m_modifier.m_amount);
|
||||||
|
|
||||||
player->GetReputationMgr().ApplyForceReaction(faction_id, ReputationRank(faction_rank), apply);
|
player->GetReputationMgr().ApplyForceReaction(faction_id, faction_rank, apply);
|
||||||
player->GetReputationMgr().SendForceReactions();
|
player->GetReputationMgr().SendForceReactions();
|
||||||
|
|
||||||
|
// stop fighting if at apply forced rank friendly or at remove real rank friendly
|
||||||
|
if (apply && faction_rank >= REP_FRIENDLY || !apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY)
|
||||||
|
player->StopAttackFaction(faction_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aura::HandleAuraModSkill(bool apply, bool /*Real*/)
|
void Aura::HandleAuraModSkill(bool apply, bool /*Real*/)
|
||||||
|
|
|
||||||
|
|
@ -12822,3 +12822,43 @@ void Unit::SendThreatRemove(HostileReference* pHostileReference)
|
||||||
data.appendPackGUID(pHostileReference->getUnitGuid());
|
data.appendPackGUID(pHostileReference->getUnitGuid());
|
||||||
SendMessageToSet(&data, false);
|
SendMessageToSet(&data, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::StopAttackFaction(uint32 faction_id)
|
||||||
|
{
|
||||||
|
if (Unit* victim = getVictim())
|
||||||
|
{
|
||||||
|
if (victim->getFactionTemplateEntry()->faction==faction_id)
|
||||||
|
{
|
||||||
|
AttackStop();
|
||||||
|
if (IsNonMeleeSpellCasted(false))
|
||||||
|
InterruptNonMeleeSpells(false);
|
||||||
|
|
||||||
|
// melee and ranged forced attack cancel
|
||||||
|
if (GetTypeId() == TYPEID_PLAYER)
|
||||||
|
((Player*)this)->SendAttackSwingCancelAttack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AttackerSet const& attackers = getAttackers();
|
||||||
|
for(AttackerSet::const_iterator itr = attackers.begin(); itr != attackers.end();)
|
||||||
|
{
|
||||||
|
if ((*itr)->getFactionTemplateEntry()->faction==faction_id)
|
||||||
|
{
|
||||||
|
(*itr)->AttackStop();
|
||||||
|
itr = attackers.begin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
|
||||||
|
getHostileRefManager().deleteReferencesForFaction(faction_id);
|
||||||
|
|
||||||
|
if(Pet* pet = GetPet())
|
||||||
|
pet->StopAttackFaction(faction_id);
|
||||||
|
if(Unit* charm = GetCharm())
|
||||||
|
charm->StopAttackFaction(faction_id);
|
||||||
|
|
||||||
|
for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr)
|
||||||
|
if(Unit* guardian = Unit::GetUnit(*this,*itr))
|
||||||
|
guardian->StopAttackFaction(faction_id);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -929,6 +929,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
Unit* getVictim() const { return m_attacking; }
|
Unit* getVictim() const { return m_attacking; }
|
||||||
void CombatStop(bool includingCast = false);
|
void CombatStop(bool includingCast = false);
|
||||||
void CombatStopWithPets(bool includingCast = false);
|
void CombatStopWithPets(bool includingCast = false);
|
||||||
|
void StopAttackFaction(uint32 faction_id);
|
||||||
Unit* SelectNearbyTarget(Unit* except = NULL) const;
|
Unit* SelectNearbyTarget(Unit* except = NULL) const;
|
||||||
bool hasNegativeAuraWithInterruptFlag(uint32 flag);
|
bool hasNegativeAuraWithInterruptFlag(uint32 flag);
|
||||||
void SendMeleeAttackStop(Unit* victim);
|
void SendMeleeAttackStop(Unit* victim);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8866"
|
#define REVISION_NR "8867"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue