diff options
author | n0n4m3 <none@none> | 2009-12-26 09:43:39 +0100 |
---|---|---|
committer | n0n4m3 <none@none> | 2009-12-26 09:43:39 +0100 |
commit | cd9f84aae50e9d05bb432a42629965e5eff9222f (patch) | |
tree | 7b88af77b396c262df03c0b79f4fd02b958398c7 /src/game/Unit.cpp | |
parent | 3796af3658a6c70ce0209ede98dea2b5b326ed8f (diff) |
Implement expected combat stop with friendly faction. by VladimirMangos
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7ea832d2477..24cd4a71b16 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -15751,6 +15751,40 @@ void Unit::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ModifyPower(POWER_RAGE, uint32(addRage*10)); } +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; + } + + getHostilRefManager().deleteReferencesForFaction(faction_id); + + for(ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) + (*itr)->StopAttackFaction(faction_id); +} + void Unit::OutDebugInfo() const { sLog.outError("Unit::OutDebugInfo"); |