*Fix a bug that pet/charmed cannot AOE neutral creatures.
--HG-- branch : trunk
This commit is contained in:
+4
-2
@@ -472,6 +472,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
|
||||
|
||||
m_lastFallTime = 0;
|
||||
m_lastFallZ = 0;
|
||||
|
||||
m_ControlledByPlayer = true;
|
||||
}
|
||||
|
||||
Player::~Player ()
|
||||
@@ -14460,11 +14462,11 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
SetUInt32Value(UNIT_CHANNEL_SPELL,0);
|
||||
|
||||
// clear charm/summon related fields
|
||||
SetUInt64Value(UNIT_FIELD_SUMMONEDBY, 0);
|
||||
SetUInt64Value(UNIT_FIELD_CHARMEDBY, 0);
|
||||
SetUInt64Value(UNIT_FIELD_CHARM, 0);
|
||||
SetUInt64Value(UNIT_FIELD_SUMMON, 0);
|
||||
SetUInt64Value(PLAYER_FARSIGHT, 0);
|
||||
SetCharmerGUID(0);
|
||||
SetOwnerGUID(0);
|
||||
SetCreatorGUID(0);
|
||||
|
||||
// reset some aura modifiers before aura apply
|
||||
|
||||
+1
-1
@@ -671,7 +671,7 @@ namespace Trinity
|
||||
continue;
|
||||
if(!target->isAttackableByAOE())
|
||||
continue;
|
||||
if(i_source->GetTypeId()==TYPEID_PLAYER)
|
||||
if(i_source->IsControlledByPlayer())
|
||||
{
|
||||
if(i_source->IsFriendlyTo(target))
|
||||
continue;
|
||||
|
||||
@@ -5761,7 +5761,7 @@ void Spell::EffectSummonCritter(uint32 i)
|
||||
if(!critter)
|
||||
return;
|
||||
|
||||
critter->SetOwnerGUID(m_caster->GetGUID());
|
||||
critter->SetOwner(m_caster, true);
|
||||
critter->SetCreatorGUID(m_caster->GetGUID());
|
||||
critter->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction());
|
||||
critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
|
||||
@@ -6426,7 +6426,7 @@ void Spell::SummonTotem(uint32 entry, SummonPropertiesEntry const *properties)
|
||||
if(slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT)
|
||||
m_caster->m_SummonSlot[slot] = pTotem->GetGUID();
|
||||
|
||||
pTotem->SetOwner(m_caster->GetGUID());
|
||||
pTotem->SetOwner(m_caster);
|
||||
pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initilized
|
||||
|
||||
int32 duration=GetSpellDuration(m_spellInfo);
|
||||
@@ -6534,7 +6534,7 @@ void Spell::SummonVehicle(uint32 entry, SummonPropertiesEntry const *properties)
|
||||
if(!vehicle)
|
||||
return;
|
||||
|
||||
vehicle->SetOwnerGUID(m_caster->GetGUID());
|
||||
vehicle->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID());
|
||||
vehicle->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
|
||||
|
||||
if(damage)
|
||||
|
||||
@@ -244,8 +244,8 @@ void TempSummon::RemoveFromWorld()
|
||||
}
|
||||
}
|
||||
|
||||
if(GetOwnerGUID())
|
||||
sLog.outError("Unit %u has owner guid when removed from world", GetEntry());
|
||||
//if(GetOwnerGUID())
|
||||
// sLog.outError("Unit %u has owner guid when removed from world", GetEntry());
|
||||
|
||||
Creature::RemoveFromWorld();
|
||||
}
|
||||
@@ -254,6 +254,30 @@ void TempSummon::SaveToDB()
|
||||
{
|
||||
}
|
||||
|
||||
bool TempSummon::SetOwner(Unit *owner, bool apply)
|
||||
{
|
||||
if(apply)
|
||||
{
|
||||
if(!AddUInt64Value(UNIT_FIELD_SUMMONEDBY, owner->GetGUID()))
|
||||
{
|
||||
sLog.outCrash("Unit %u is summoned by %u but it already has a owner", GetEntry(), owner->GetEntry());
|
||||
return false;
|
||||
}
|
||||
if(owner->GetTypeId() == TYPEID_PLAYER)
|
||||
m_ControlledByPlayer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!RemoveUInt64Value(UNIT_FIELD_SUMMONEDBY, owner->GetGUID()))
|
||||
{
|
||||
sLog.outCrash("Unit %u is unsummoned by %u but it has another owner", GetEntry(), owner->GetEntry());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Guardian::Guardian(SummonPropertiesEntry const *properties, Unit *owner) : TempSummon(properties, owner)
|
||||
, m_owner(owner), m_bonusdamage(0)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,8 @@ class TempSummon : public Creature
|
||||
Unit* GetSummoner() const;
|
||||
|
||||
SummonPropertiesEntry const *m_Properties;
|
||||
|
||||
bool SetOwner(Unit *owner, bool apply);
|
||||
private:
|
||||
TempSummonType m_type;
|
||||
uint32 m_timer;
|
||||
|
||||
+5
-8
@@ -142,15 +142,12 @@ void Totem::UnSummon()
|
||||
AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
void Totem::SetOwner(uint64 guid)
|
||||
void Totem::SetOwner(Unit *owner)
|
||||
{
|
||||
SetCreatorGUID(guid);
|
||||
SetOwnerGUID(guid);
|
||||
if (Unit *owner = GetOwner())
|
||||
{
|
||||
this->setFaction(owner->getFaction());
|
||||
this->SetLevel(owner->getLevel());
|
||||
}
|
||||
SetCreatorGUID(owner->GetGUID());
|
||||
TempSummon::SetOwner(owner, true);
|
||||
setFaction(owner->getFaction());
|
||||
SetLevel(owner->getLevel());
|
||||
}
|
||||
|
||||
Unit *Totem::GetOwner()
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ class Totem : public TempSummon
|
||||
TotemType GetTotemType() const { return m_type; }
|
||||
void SetTypeBySummonSpell(SpellEntry const * spellProto);
|
||||
void SetDuration(uint32 dur) { m_duration = dur; }
|
||||
void SetOwner(uint64 guid);
|
||||
void SetOwner(Unit *owner);
|
||||
|
||||
bool UpdateStats(Stats /*stat*/) { return true; }
|
||||
bool UpdateAllStats() { return true; }
|
||||
|
||||
+16
-13
@@ -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());
|
||||
|
||||
|
||||
+3
-1
@@ -1214,7 +1214,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet
|
||||
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); }
|
||||
void SetOwnerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner); }
|
||||
uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); }
|
||||
void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); }
|
||||
uint64 GetGuardianGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); }
|
||||
@@ -1225,6 +1224,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
void SetPetGUID(uint64 guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
|
||||
uint64 GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; }
|
||||
|
||||
bool IsControlledByPlayer() const { return m_ControlledByPlayer; }
|
||||
uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
|
||||
uint64 GetCharmerOrOwnerOrOwnGUID() const
|
||||
{
|
||||
@@ -1624,6 +1624,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
float GetTransOffsetO() const { return m_movementInfo.t_o; }
|
||||
uint32 GetTransTime() const { return m_movementInfo.t_time; }
|
||||
int8 GetTransSeat() const { return m_movementInfo.t_seat; }
|
||||
|
||||
bool m_ControlledByPlayer;
|
||||
protected:
|
||||
explicit Unit ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user