Created
May 29, 2011 14:17
-
-
Save tobmaps/997808 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h | |
index 299f354..02d4c59 100755 | |
--- a/src/server/game/Entities/Player/Player.h | |
+++ b/src/server/game/Entities/Player/Player.h | |
@@ -1761,6 +1761,8 @@ class Player : public Unit, public GridObject<Player> | |
void DuelComplete(DuelCompleteType type); | |
void SendDuelCountdown(uint32 counter); | |
+ bool IsInDuelWith(Player const* p) const { return (duel && duel->opponent == p); } | |
+ | |
bool IsGroupVisibleFor(Player const* p) const; | |
bool IsInSameGroupWith(Player const* p) const; | |
bool IsInSameRaidWith(Player const* p) const { return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); } | |
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp | |
index 89caafa..ac3c34a 100755 | |
--- a/src/server/game/Entities/Unit/Unit.cpp | |
+++ b/src/server/game/Entities/Unit/Unit.cpp | |
@@ -561,9 +561,10 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) | |
return; | |
} | |
- //You don't lose health from damage taken from another player while in a sanctuary | |
+ //You don't lose health from damage taken from another player while in a sanctuary and not dueling with him | |
//You still see it in the combat log though | |
- if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer()) | |
+ if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer() && | |
+ !GetCharmerOrOwnerOrSelf()->ToPlayer()->IsInDuelWith(pVictim->GetCharmerOrOwnerOrSelf()->ToPlayer())) | |
{ | |
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); | |
if (area && area->IsSanctuary()) //sanctuary | |
@@ -1122,16 +1123,6 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss) | |
return; | |
} | |
- //You don't lose health from damage taken from another player while in a sanctuary | |
- //You still see it in the combat log though | |
- if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer()) | |
- { | |
- const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); | |
- | |
- if (area && area->IsSanctuary()) // sanctuary | |
- return; | |
- } | |
- | |
// Call default DealDamage | |
CleanDamage cleanDamage(damageInfo->cleanDamage, damageInfo->absorb, BASE_ATTACK, MELEE_HIT_NORMAL); | |
DealDamage(pVictim, damageInfo->damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SpellSchoolMask(damageInfo->schoolMask), spellProto, durabilityLoss); | |
@@ -1352,17 +1343,8 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) | |
if (!pVictim->isAlive() || pVictim->HasUnitState(UNIT_STAT_IN_FLIGHT) || (pVictim->HasUnitState(UNIT_STAT_ONVEHICLE) && pVictim->GetVehicleBase() != this) || (pVictim->GetTypeId() == TYPEID_UNIT && pVictim->ToCreature()->IsInEvadeMode())) | |
return; | |
- //You don't lose health from damage taken from another player while in a sanctuary | |
- //You still see it in the combat log though | |
- if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer()) | |
- { | |
- const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); | |
- if (area && area->IsSanctuary()) // sanctuary | |
- return; | |
- } | |
- | |
// Hmmmm dont like this emotes client must by self do all animations | |
- if (damageInfo->HitInfo&HITINFO_CRITICALHIT) | |
+ if (damageInfo->HitInfo & HITINFO_CRITICALHIT) | |
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); | |
if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS) | |
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); | |
@@ -9224,7 +9206,7 @@ bool Unit::IsHostileTo(Unit const* unit) const | |
Player const* pTarget = (Player const*)target; | |
// Duel | |
- if (pTester->duel && pTester->duel->opponent == pTarget && pTester->duel->startTime != 0) | |
+ if (pTester->IsInDuelWith(pTarget) && pTester->duel->startTime != 0) | |
return true; | |
// Group | |
@@ -9339,7 +9321,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const | |
Player const* pTarget = (Player const*)target; | |
// Duel | |
- if (pTester->duel && pTester->duel->opponent == target && pTester->duel->startTime != 0) | |
+ if (pTester->IsInDuelWith(pTarget) && pTester->duel->startTime != 0) | |
return false; | |
// Group | |
@@ -12090,7 +12072,7 @@ void Unit::CombatStart(Unit* target, bool initialAggro) | |
Player *me = GetCharmerOrOwnerPlayerOrPlayerItself(); | |
if (me && who->IsPvP() | |
&& (who->GetTypeId() != TYPEID_PLAYER | |
- || !me->duel || me->duel->opponent != who)) | |
+ || !me->IsInDuelWith(who->ToPlayer()))) | |
{ | |
me->UpdatePvP(true); | |
me->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); | |
@@ -14906,7 +14888,7 @@ void Unit::SetContestedPvP(Player *attackedPlayer) | |
{ | |
Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); | |
- if (!player || (attackedPlayer && (attackedPlayer == player || (player->duel && player->duel->opponent == attackedPlayer)))) | |
+ if (!player || (attackedPlayer && (attackedPlayer == player || player->IsInDuelWith(attackedPlayer)))) | |
return; | |
player->SetContestedPvPTimer(30000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment