diff options
author | megamage <none@none> | 2009-04-19 19:45:54 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-19 19:45:54 -0500 |
commit | 68fd41d2c8990459ca1d82ab82d53cb78d03dd49 (patch) | |
tree | e2a2e20de43f864e4818b45425440bb3517c472f /src/game/Unit.cpp | |
parent | e1806419be36ac8a1b6b1ea377cfba20b36db720 (diff) |
*Fix a bug that pet/charmed cannot AOE neutral creatures.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7b4cb2e1958..e381f41ef13 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -81,6 +81,7 @@ Unit::Unit() : WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) , m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false) , i_AI(NULL), i_disabledAI(NULL), m_removedAurasCount(0), m_Vehicle(NULL) +, m_ControlledByPlayer(false) { m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; @@ -1613,7 +1614,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) // If this is a creature and it attacks from behind it has a probability to daze it's victim if( (damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) && - GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGUID() && !pVictim->HasInArc(M_PI, this) + GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->IsControlledByPlayer() && !pVictim->HasInArc(M_PI, this) && (pVictim->GetTypeId() == TYPEID_PLAYER || !((Creature*)pVictim)->isWorldBoss())) { // -probability is between 0% and 40% @@ -2457,9 +2458,8 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack // mobs can score crushing blows if they're 4 or more levels above victim if (getLevelForTarget(pVictim) >= pVictim->getLevelForTarget(this) + 4 && // can be from by creature (if can) or from controlled player that considered as creature - (GetTypeId()!=TYPEID_PLAYER && !((Creature*)this)->isPet() && - !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH) || - GetTypeId()==TYPEID_PLAYER && GetCharmerOrOwnerGUID())) + !IsControlledByPlayer() && + !(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) { // when their weapon skill is 15 or more above victim's defense skill tmp = victimDefenseSkill; @@ -7835,7 +7835,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) //if(GetTypeId()==TYPEID_UNIT) // ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); - if(GetTypeId()==TYPEID_UNIT) + if(GetTypeId()==TYPEID_UNIT && !IsControlledByPlayer()) { // should not let player enter combat by right clicking target SetInCombatWith(victim); @@ -8060,11 +8060,8 @@ void Unit::SetGuardian(Guardian* guardian, bool apply) if(apply) { - if(!guardian->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) - { - sLog.outCrash("Guardian %u is summoned by %u but it already has a owner", guardian->GetEntry(), GetEntry()); + if(!guardian->SetOwner(this, true)) return; - } m_Controlled.insert(guardian); @@ -8108,11 +8105,8 @@ void Unit::SetGuardian(Guardian* guardian, bool apply) } else { - if(!guardian->RemoveUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) - { - sLog.outCrash("Pet %u is unsummoned by %u but it has another owner", guardian->GetEntry(), GetEntry()); + if(!guardian->SetOwner(this, false)) return; - } m_Controlled.erase(guardian); @@ -8157,7 +8151,11 @@ void Unit::SetCharm(Unit* charm, bool apply) { if(!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) sLog.outCrash("Player %s is trying to charm unit %u, but it already has a charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID()); + + charm->m_ControlledByPlayer = true; } + else + charm->m_ControlledByPlayer = false; if(!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog.outCrash("Unit %u is being charmed, but it already has a charmer %u", charm->GetEntry(), charm->GetCharmerGUID()); @@ -8172,6 +8170,11 @@ void Unit::SetCharm(Unit* charm, bool apply) sLog.outCrash("Player %s is trying to uncharm unit %u, but it has another charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID()); } + if(charm->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(charm->GetOwnerGUID())) + charm->m_ControlledByPlayer = true; + else + charm->m_ControlledByPlayer = false; + if(!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog.outCrash("Unit %u is being uncharmed, but it has another charmer %u", charm->GetEntry(), charm->GetCharmerGUID()); |