From cd9f84aae50e9d05bb432a42629965e5eff9222f Mon Sep 17 00:00:00 2001 From: n0n4m3 Date: Sat, 26 Dec 2009 09:43:39 +0100 Subject: Implement expected combat stop with friendly faction. by VladimirMangos --HG-- branch : trunk --- src/game/Unit.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/game/Unit.cpp') 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"); -- cgit v1.2.3