diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 21 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 3 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index e9f27465f38..b91796f9b8a 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -762,7 +762,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons return 0; // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if (victim->ToPlayer()->duel->opponent == attacker || victim->ToPlayer()->duel->opponent->GetGUID() == attacker->GetOwnerGUID()) + if (victim->ToPlayer()->duel->opponent == attacker->GetControllingPlayer()) damage = health - 1; duel_hasEnded = true; @@ -777,7 +777,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons return 0; // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if (victimRider->duel->opponent == attacker || victimRider->duel->opponent->GetGUID() == attacker->GetCharmerGUID()) + if (victimRider->duel->opponent == attacker->GetControllingPlayer()) damage = health - 1; duel_wasMounted = true; @@ -5779,6 +5779,18 @@ void Unit::SetOwnerGUID(ObjectGuid owner) RemoveFieldNotifyFlag(UF_FLAG_OWNER); } +Player* Unit::GetControllingPlayer() const +{ + if (ObjectGuid guid = GetCharmerOrOwnerGUID()) + { + if (Unit* master = ObjectAccessor::GetUnit(*this, guid)) + return master->GetControllingPlayer(); + return nullptr; + } + else + return const_cast<Player*>(ToPlayer()); +} + Unit* Unit::GetCharmer() const { if (ObjectGuid charmerGUID = GetCharmerGUID()) @@ -10117,11 +10129,6 @@ void Unit::TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProc SetCantProc(false); } -ObjectGuid Unit::GetCharmerOrOwnerGUID() const -{ - return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); -} - ///----------Pet responses methods----------------- void Unit::SendPetActionFeedback(uint8 msg) { diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 774ba7d5c46..ad11d9708cc 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1153,7 +1153,8 @@ class TC_GAME_API Unit : public WorldObject ObjectGuid GetCritterGUID() const { return GetGuidValue(UNIT_FIELD_CRITTER); } bool IsControlledByPlayer() const { return m_ControlledByPlayer; } - ObjectGuid GetCharmerOrOwnerGUID() const override; + Player* GetControllingPlayer() const; + ObjectGuid GetCharmerOrOwnerGUID() const override { return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID(); } bool IsCharmedOwnedByPlayerOrPlayer() const { return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); } Guardian* GetGuardianPet() const; |