Merge remote-tracking branch 'origin/refactoring'
This commit is contained in:
commit
344eb8e31c
8 files changed
+1167
-782
No files matched your search
@@ -863,6 +863,16 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
|
||||
return true;
|
||||
}
|
||||
|
||||
void Creature::InitializeReactState()
|
||||
{
|
||||
if (isTotem() || isTrigger() || GetCreatureType() == CREATURE_TYPE_CRITTER || isSpiritService())
|
||||
SetReactState(REACT_PASSIVE);
|
||||
else
|
||||
SetReactState(REACT_AGGRESSIVE);
|
||||
/*else if (isCivilian())
|
||||
SetReactState(REACT_DEFENSIVE);*/;
|
||||
}
|
||||
|
||||
bool Creature::isCanTrainingOf(Player* player, bool msg) const
|
||||
{
|
||||
if (!isTrainer())
|
||||
@@ -1213,6 +1223,12 @@ float Creature::_GetHealthMod(int32 Rank)
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::LowerPlayerDamageReq(uint32 unDamage)
|
||||
{
|
||||
if (m_PlayerDamageReq)
|
||||
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
|
||||
}
|
||||
|
||||
float Creature::_GetDamageMod(int32 Rank)
|
||||
{
|
||||
switch (Rank) // define rates for each elite rank
|
||||
@@ -1731,6 +1747,23 @@ bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index)
|
||||
return Unit::IsImmunedToSpellEffect(spellInfo, index);
|
||||
}
|
||||
|
||||
bool Creature::isElite() const
|
||||
{
|
||||
if (isPet())
|
||||
return false;
|
||||
|
||||
uint32 rank = GetCreatureTemplate()->rank;
|
||||
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
|
||||
}
|
||||
|
||||
bool Creature::isWorldBoss() const
|
||||
{
|
||||
if (isPet())
|
||||
return false;
|
||||
|
||||
return GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_BOSS;
|
||||
}
|
||||
|
||||
SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
|
||||
{
|
||||
if (!victim)
|
||||
@@ -2218,6 +2251,11 @@ void Creature::SetInCombatWithZone()
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Creature::GetShieldBlockValue() const //dunno mob block value
|
||||
{
|
||||
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
|
||||
}
|
||||
|
||||
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
|
||||
{
|
||||
m_CreatureSpellCooldowns[spell_id] = end_time;
|
||||
@@ -2255,6 +2293,13 @@ bool Creature::HasCategoryCooldown(uint32 spell_id) const
|
||||
return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILLISECONDS)) > time(NULL));
|
||||
}
|
||||
|
||||
uint32 Creature::GetCreatureSpellCooldownDelay(uint32 spellId) const
|
||||
{
|
||||
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId);
|
||||
time_t t = time(NULL);
|
||||
return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0);
|
||||
}
|
||||
|
||||
bool Creature::HasSpellCooldown(uint32 spell_id) const
|
||||
{
|
||||
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
|
||||
@@ -2499,6 +2544,14 @@ void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
|
||||
GetMap()->AddToMap(this);
|
||||
}
|
||||
|
||||
uint32 Creature::GetPetAutoSpellOnPos(uint8 pos) const
|
||||
{
|
||||
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
|
||||
return 0;
|
||||
else
|
||||
return m_charmInfo->GetCharmSpell(pos)->GetAction();
|
||||
}
|
||||
|
||||
void Creature::SetPosition(float x, float y, float z, float o)
|
||||
{
|
||||
// prevent crash when a bad coord is sent by the client
|
||||
|
||||
@@ -474,15 +474,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
void SetReactState(ReactStates st) { m_reactState = st; }
|
||||
ReactStates GetReactState() { return m_reactState; }
|
||||
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
|
||||
void InitializeReactState()
|
||||
{
|
||||
if (isTotem() || isTrigger() || GetCreatureType() == CREATURE_TYPE_CRITTER || isSpiritService())
|
||||
SetReactState(REACT_PASSIVE);
|
||||
else
|
||||
SetReactState(REACT_AGGRESSIVE);
|
||||
/*else if (isCivilian())
|
||||
SetReactState(REACT_DEFENSIVE);*/;
|
||||
}
|
||||
void InitializeReactState();
|
||||
|
||||
/// @todo Rename these properly
|
||||
bool isCanTrainingOf(Player* player, bool msg) const;
|
||||
@@ -491,22 +483,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
bool canCreatureAttack(Unit const* victim, bool force = true) const;
|
||||
bool IsImmunedToSpell(SpellInfo const* spellInfo); //override Unit::IsImmunedToSpell
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; //override Unit::IsImmunedToSpellEffect
|
||||
bool isElite() const
|
||||
{
|
||||
if (isPet())
|
||||
return false;
|
||||
|
||||
uint32 rank = GetCreatureTemplate()->rank;
|
||||
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
|
||||
}
|
||||
|
||||
bool isWorldBoss() const
|
||||
{
|
||||
if (isPet())
|
||||
return false;
|
||||
|
||||
return GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_BOSS;
|
||||
}
|
||||
bool isElite() const;
|
||||
bool isWorldBoss() const;
|
||||
|
||||
bool IsDungeonBoss() const;
|
||||
|
||||
@@ -523,10 +501,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
bool SetDisableGravity(bool disable, bool packetOnly = false);
|
||||
bool SetHover(bool enable);
|
||||
|
||||
uint32 GetShieldBlockValue() const //dunno mob block value
|
||||
{
|
||||
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
|
||||
}
|
||||
uint32 GetShieldBlockValue() const;
|
||||
|
||||
SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
|
||||
void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
|
||||
@@ -536,12 +511,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
void AddCreatureSpellCooldown(uint32 spellid);
|
||||
bool HasSpellCooldown(uint32 spell_id) const;
|
||||
bool HasCategoryCooldown(uint32 spell_id) const;
|
||||
uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const
|
||||
{
|
||||
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId);
|
||||
time_t t = time(NULL);
|
||||
return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0);
|
||||
}
|
||||
uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const;
|
||||
virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs);
|
||||
|
||||
bool HasSpell(uint32 spellID) const;
|
||||
@@ -671,13 +641,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
bool isRegeneratingHealth() { return m_regenHealth; }
|
||||
void setRegeneratingHealth(bool regenHealth) { m_regenHealth = regenHealth; }
|
||||
virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; }
|
||||
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
|
||||
{
|
||||
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
|
||||
return 0;
|
||||
else
|
||||
return m_charmInfo->GetCharmSpell(pos)->GetAction();
|
||||
}
|
||||
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const;
|
||||
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
|
||||
@@ -707,11 +671,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
|
||||
bool IsReputationGainDisabled() { return DisableReputationGain; }
|
||||
bool IsDamageEnoughForLootingAndReward() const { return m_PlayerDamageReq == 0; }
|
||||
void LowerPlayerDamageReq(uint32 unDamage)
|
||||
{
|
||||
if (m_PlayerDamageReq)
|
||||
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
|
||||
}
|
||||
void LowerPlayerDamageReq(uint32 unDamage);
|
||||
void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
|
||||
uint32 m_PlayerDamageReq;
|
||||
|
||||
|
||||
@@ -319,6 +319,44 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const
|
||||
target->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
int32 Object::GetInt32Value(uint16 index) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return m_int32Values[index];
|
||||
}
|
||||
|
||||
uint32 Object::GetUInt32Value(uint16 index) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return m_uint32Values[index];
|
||||
}
|
||||
|
||||
uint64 Object::GetUInt64Value(uint16 index) const
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
|
||||
return *((uint64*)&(m_uint32Values[index]));
|
||||
}
|
||||
|
||||
float Object::GetFloatValue(uint16 index) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return m_floatValues[index];
|
||||
}
|
||||
|
||||
uint8 Object::GetByteValue(uint16 index, uint8 offset) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
ASSERT(offset < 4);
|
||||
return *(((uint8*)&m_uint32Values[index])+offset);
|
||||
}
|
||||
|
||||
uint16 Object::GetUInt16Value(uint16 index, uint8 offset) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
ASSERT(offset < 2);
|
||||
return *(((uint16*)&m_uint32Values[index])+offset);
|
||||
}
|
||||
|
||||
void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
{
|
||||
*data << uint16(flags); // update flags
|
||||
@@ -1076,6 +1114,13 @@ void Object::ApplyModSignedFloatValue(uint16 index, float val, bool apply)
|
||||
SetFloatValue(index, cur);
|
||||
}
|
||||
|
||||
void Object::ApplyPercentModFloatValue(uint16 index, float val, bool apply)
|
||||
{
|
||||
float value = GetFloatValue(index);
|
||||
ApplyPercentModFloatVar(value, val, apply);
|
||||
SetFloatValue(index, value);
|
||||
}
|
||||
|
||||
void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
|
||||
{
|
||||
float cur = GetFloatValue(index);
|
||||
@@ -1125,6 +1170,27 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag)
|
||||
}
|
||||
}
|
||||
|
||||
void Object::ToggleFlag(uint16 index, uint32 flag)
|
||||
{
|
||||
if (HasFlag(index, flag))
|
||||
RemoveFlag(index, flag);
|
||||
else
|
||||
SetFlag(index, flag);
|
||||
}
|
||||
|
||||
bool Object::HasFlag(uint16 index, uint32 flag) const
|
||||
{
|
||||
if (index >= m_valuesCount && !PrintIndexError(index, false))
|
||||
return false;
|
||||
|
||||
return (m_uint32Values[index] & flag) != 0;
|
||||
}
|
||||
|
||||
void Object::ApplyModFlag(uint16 index, uint32 flag, bool apply)
|
||||
{
|
||||
if (apply) SetFlag(index, flag); else RemoveFlag(index, flag);
|
||||
}
|
||||
|
||||
void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
@@ -1171,6 +1237,54 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
|
||||
}
|
||||
}
|
||||
|
||||
void Object::ToggleByteFlag(uint16 index, uint8 offset, uint8 flag)
|
||||
{
|
||||
if (HasByteFlag(index, offset, flag))
|
||||
RemoveByteFlag(index, offset, flag);
|
||||
else
|
||||
SetByteFlag(index, offset, flag);
|
||||
}
|
||||
|
||||
bool Object::HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
ASSERT(offset < 4);
|
||||
return (((uint8*)&m_uint32Values[index])[offset] & flag) != 0;
|
||||
}
|
||||
|
||||
void Object::SetFlag64(uint16 index, uint64 newFlag)
|
||||
{
|
||||
uint64 oldval = GetUInt64Value(index);
|
||||
uint64 newval = oldval | newFlag;
|
||||
SetUInt64Value(index, newval);
|
||||
}
|
||||
|
||||
void Object::RemoveFlag64(uint16 index, uint64 oldFlag)
|
||||
{
|
||||
uint64 oldval = GetUInt64Value(index);
|
||||
uint64 newval = oldval & ~oldFlag;
|
||||
SetUInt64Value(index, newval);
|
||||
}
|
||||
|
||||
void Object::ToggleFlag64(uint16 index, uint64 flag)
|
||||
{
|
||||
if (HasFlag64(index, flag))
|
||||
RemoveFlag64(index, flag);
|
||||
else
|
||||
SetFlag64(index, flag);
|
||||
}
|
||||
|
||||
bool Object::HasFlag64(uint16 index, uint64 flag) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return (GetUInt64Value(index) & flag) != 0;
|
||||
}
|
||||
|
||||
void Object::ApplyModFlag64(uint16 index, uint64 flag, bool apply)
|
||||
{
|
||||
if (apply) SetFlag64(index, flag); else RemoveFlag64(index, flag);
|
||||
}
|
||||
|
||||
bool Object::PrintIndexError(uint32 index, bool set) const
|
||||
{
|
||||
sLog->outError(LOG_FILTER_GENERAL, "Attempt %s non-existed value field: %u (count: %u) for object typeid: %u type mask: %u", (set ? "set value to" : "get value from"), index, m_valuesCount, GetTypeId(), m_objectType);
|
||||
@@ -1329,6 +1443,16 @@ void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
|
||||
m_phaseMask = phaseMask;
|
||||
}
|
||||
|
||||
void WorldObject::RemoveFromWorld()
|
||||
{
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
DestroyForNearbyPlayers();
|
||||
|
||||
Object::RemoveFromWorld();
|
||||
}
|
||||
|
||||
uint32 WorldObject::GetZoneId() const
|
||||
{
|
||||
return GetBaseMap()->GetZoneId(m_positionX, m_positionY, m_positionZ);
|
||||
@@ -1398,6 +1522,80 @@ bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const
|
||||
return IsWithinLOS(ox, oy, oz);
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance(const WorldObject* obj) const
|
||||
{
|
||||
float d = GetExactDist(obj) - GetObjectSize() - obj->GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance(const Position &pos) const
|
||||
{
|
||||
float d = GetExactDist(&pos) - GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance(float x, float y, float z) const
|
||||
{
|
||||
float d = GetExactDist(x, y, z) - GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance2d(const WorldObject* obj) const
|
||||
{
|
||||
float d = GetExactDist2d(obj) - GetObjectSize() - obj->GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance2d(float x, float y) const
|
||||
{
|
||||
float d = GetExactDist2d(x, y) - GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
|
||||
bool WorldObject::IsSelfOrInSameMap(const WorldObject* obj) const
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
return IsInMap(obj);
|
||||
}
|
||||
|
||||
bool WorldObject::IsInMap(const WorldObject* obj) const
|
||||
{
|
||||
if (obj)
|
||||
return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist) const
|
||||
{
|
||||
return IsInDist(x, y, z, dist + GetObjectSize());
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist3d(const Position* pos, float dist) const
|
||||
{
|
||||
return IsInDist(pos, dist + GetObjectSize());
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist2d(float x, float y, float dist) const
|
||||
{
|
||||
return IsInDist2d(x, y, dist + GetObjectSize());
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist2d(const Position* pos, float dist) const
|
||||
{
|
||||
return IsInDist2d(pos, dist + GetObjectSize());
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D /*= true*/) const
|
||||
{
|
||||
return obj && _IsWithinDist(obj, dist2compare, is3D);
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D /*= true*/) const
|
||||
{
|
||||
return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D);
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const
|
||||
{
|
||||
/*float x, y, z;
|
||||
@@ -1629,6 +1827,13 @@ void WorldObject::GetRandomPoint(const Position &pos, float distance, float &ran
|
||||
UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
|
||||
}
|
||||
|
||||
void WorldObject::GetRandomPoint(const Position &srcPos, float distance, Position &pos) const
|
||||
{
|
||||
float x, y, z;
|
||||
GetRandomPoint(srcPos, distance, x, y, z);
|
||||
pos.Relocate(x, y, z, GetOrientation());
|
||||
}
|
||||
|
||||
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
{
|
||||
float new_z = GetBaseMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
@@ -1821,6 +2026,11 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WorldObject::CanNeverSee(WorldObject const* obj) const
|
||||
{
|
||||
return GetMap() != obj->GetMap() || !InSamePhase(obj);
|
||||
}
|
||||
|
||||
bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const
|
||||
{
|
||||
const WorldObject* seer = this;
|
||||
@@ -2364,6 +2574,18 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempS
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang /*= 0*/, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despwtime /*= 0*/) const
|
||||
{
|
||||
if (!x && !y && !z)
|
||||
{
|
||||
GetClosePoint(x, y, z, GetObjectSize());
|
||||
ang = GetOrientation();
|
||||
}
|
||||
Position pos;
|
||||
pos.Relocate(x, y, z, ang);
|
||||
return SummonCreature(id, pos, spwtype, despwtime, 0);
|
||||
}
|
||||
|
||||
GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
|
||||
{
|
||||
if (!IsInWorld())
|
||||
@@ -2695,6 +2917,41 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float
|
||||
*/
|
||||
}
|
||||
|
||||
void WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float distance2d /*= 0*/, float angle /*= 0*/) const
|
||||
{
|
||||
// angle calculated from current orientation
|
||||
GetNearPoint(NULL, x, y, z, size, distance2d, GetOrientation() + angle);
|
||||
}
|
||||
|
||||
void WorldObject::GetNearPosition(Position &pos, float dist, float angle)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
MovePosition(pos, dist, angle);
|
||||
}
|
||||
|
||||
void WorldObject::GetFirstCollisionPosition(Position &pos, float dist, float angle)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
MovePositionToFirstCollision(pos, dist, angle);
|
||||
}
|
||||
|
||||
void WorldObject::GetRandomNearPosition(Position &pos, float radius)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
MovePosition(pos, radius * (float)rand_norm(), (float)rand_norm() * static_cast<float>(2 * M_PI));
|
||||
}
|
||||
|
||||
void WorldObject::GetContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d /*= CONTACT_DISTANCE*/) const
|
||||
{
|
||||
// angle to face `obj` to `this` using distance includes size of `obj`
|
||||
GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
|
||||
}
|
||||
|
||||
float WorldObject::GetObjectSize() const
|
||||
{
|
||||
return (m_valuesCount > UNIT_FIELD_COMBATREACH) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE;
|
||||
}
|
||||
|
||||
void WorldObject::MovePosition(Position &pos, float dist, float angle)
|
||||
{
|
||||
angle += m_orientation;
|
||||
@@ -2816,6 +3073,11 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||
UpdateObjectVisibility();
|
||||
}
|
||||
|
||||
bool WorldObject::InSamePhase(WorldObject const* obj) const
|
||||
{
|
||||
return InSamePhase(obj->GetPhaseMask());
|
||||
}
|
||||
|
||||
void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4+8);
|
||||
|
||||
@@ -150,43 +150,12 @@ class Object
|
||||
|
||||
virtual void DestroyForPlayer(Player* target, bool onDeath = false) const;
|
||||
|
||||
int32 GetInt32Value(uint16 index) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return m_int32Values[index];
|
||||
}
|
||||
|
||||
uint32 GetUInt32Value(uint16 index) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return m_uint32Values[index];
|
||||
}
|
||||
|
||||
uint64 GetUInt64Value(uint16 index) const
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
|
||||
return *((uint64*)&(m_uint32Values[index]));
|
||||
}
|
||||
|
||||
float GetFloatValue(uint16 index) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return m_floatValues[index];
|
||||
}
|
||||
|
||||
uint8 GetByteValue(uint16 index, uint8 offset) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
ASSERT(offset < 4);
|
||||
return *(((uint8*)&m_uint32Values[index])+offset);
|
||||
}
|
||||
|
||||
uint16 GetUInt16Value(uint16 index, uint8 offset) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
ASSERT(offset < 2);
|
||||
return *(((uint16*)&m_uint32Values[index])+offset);
|
||||
}
|
||||
int32 GetInt32Value(uint16 index) const;
|
||||
uint32 GetUInt32Value(uint16 index) const;
|
||||
uint64 GetUInt64Value(uint16 index) const;
|
||||
float GetFloatValue(uint16 index) const;
|
||||
uint8 GetByteValue(uint16 index, uint8 offset) const;
|
||||
uint16 GetUInt16Value(uint16 index, uint8 offset) const;
|
||||
|
||||
void SetInt32Value(uint16 index, int32 value);
|
||||
void SetUInt32Value(uint16 index, uint32 value);
|
||||
@@ -207,88 +176,24 @@ class Object
|
||||
void ApplyModUInt64Value(uint16 index, int32 val, bool apply);
|
||||
void ApplyModPositiveFloatValue(uint16 index, float val, bool apply);
|
||||
void ApplyModSignedFloatValue(uint16 index, float val, bool apply);
|
||||
|
||||
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
|
||||
{
|
||||
float value = GetFloatValue(index);
|
||||
ApplyPercentModFloatVar(value, val, apply);
|
||||
SetFloatValue(index, value);
|
||||
}
|
||||
void ApplyPercentModFloatValue(uint16 index, float val, bool apply);
|
||||
|
||||
void SetFlag(uint16 index, uint32 newFlag);
|
||||
void RemoveFlag(uint16 index, uint32 oldFlag);
|
||||
|
||||
void ToggleFlag(uint16 index, uint32 flag)
|
||||
{
|
||||
if (HasFlag(index, flag))
|
||||
RemoveFlag(index, flag);
|
||||
else
|
||||
SetFlag(index, flag);
|
||||
}
|
||||
|
||||
bool HasFlag(uint16 index, uint32 flag) const
|
||||
{
|
||||
if (index >= m_valuesCount && !PrintIndexError(index, false))
|
||||
return false;
|
||||
|
||||
return (m_uint32Values[index] & flag) != 0;
|
||||
}
|
||||
void ToggleFlag(uint16 index, uint32 flag);
|
||||
bool HasFlag(uint16 index, uint32 flag) const;
|
||||
void ApplyModFlag(uint16 index, uint32 flag, bool apply);
|
||||
|
||||
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag);
|
||||
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag);
|
||||
void ToggleByteFlag(uint16 index, uint8 offset, uint8 flag);
|
||||
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const;
|
||||
|
||||
void ToggleFlag(uint16 index, uint8 offset, uint8 flag)
|
||||
{
|
||||
if (HasByteFlag(index, offset, flag))
|
||||
RemoveByteFlag(index, offset, flag);
|
||||
else
|
||||
SetByteFlag(index, offset, flag);
|
||||
}
|
||||
|
||||
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
ASSERT(offset < 4);
|
||||
return (((uint8*)&m_uint32Values[index])[offset] & flag) != 0;
|
||||
}
|
||||
|
||||
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
|
||||
{
|
||||
if (apply) SetFlag(index, flag); else RemoveFlag(index, flag);
|
||||
}
|
||||
|
||||
void SetFlag64(uint16 index, uint64 newFlag)
|
||||
{
|
||||
uint64 oldval = GetUInt64Value(index);
|
||||
uint64 newval = oldval | newFlag;
|
||||
SetUInt64Value(index, newval);
|
||||
}
|
||||
|
||||
void RemoveFlag64(uint16 index, uint64 oldFlag)
|
||||
{
|
||||
uint64 oldval = GetUInt64Value(index);
|
||||
uint64 newval = oldval & ~oldFlag;
|
||||
SetUInt64Value(index, newval);
|
||||
}
|
||||
|
||||
void ToggleFlag64(uint16 index, uint64 flag)
|
||||
{
|
||||
if (HasFlag64(index, flag))
|
||||
RemoveFlag64(index, flag);
|
||||
else
|
||||
SetFlag64(index, flag);
|
||||
}
|
||||
|
||||
bool HasFlag64(uint16 index, uint64 flag) const
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, false));
|
||||
return (GetUInt64Value(index) & flag) != 0;
|
||||
}
|
||||
|
||||
void ApplyModFlag64(uint16 index, uint64 flag, bool apply)
|
||||
{
|
||||
if (apply) SetFlag64(index, flag); else RemoveFlag64(index, flag);
|
||||
}
|
||||
void SetFlag64(uint16 index, uint64 newFlag);
|
||||
void RemoveFlag64(uint16 index, uint64 oldFlag);
|
||||
void ToggleFlag64(uint16 index, uint64 flag);
|
||||
bool HasFlag64(uint16 index, uint64 flag) const;
|
||||
void ApplyModFlag64(uint16 index, uint64 flag, bool apply);
|
||||
|
||||
void ClearUpdateMask(bool remove);
|
||||
|
||||
@@ -581,68 +486,30 @@ class WorldObject : public Object, public WorldLocation
|
||||
virtual void Update (uint32 /*time_diff*/) { }
|
||||
|
||||
void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
|
||||
|
||||
virtual void RemoveFromWorld()
|
||||
{
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
DestroyForNearbyPlayers();
|
||||
|
||||
Object::RemoveFromWorld();
|
||||
}
|
||||
virtual void RemoveFromWorld();
|
||||
|
||||
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const;
|
||||
void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const;
|
||||
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0) const
|
||||
{
|
||||
// angle calculated from current orientation
|
||||
GetNearPoint(NULL, x, y, z, size, distance2d, GetOrientation() + angle);
|
||||
}
|
||||
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0) const;
|
||||
void MovePosition(Position &pos, float dist, float angle);
|
||||
void GetNearPosition(Position &pos, float dist, float angle)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
MovePosition(pos, dist, angle);
|
||||
}
|
||||
void GetNearPosition(Position &pos, float dist, float angle);
|
||||
void MovePositionToFirstCollision(Position &pos, float dist, float angle);
|
||||
void GetFirstCollisionPosition(Position &pos, float dist, float angle)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
MovePositionToFirstCollision(pos, dist, angle);
|
||||
}
|
||||
void GetRandomNearPosition(Position &pos, float radius)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
MovePosition(pos, radius * (float)rand_norm(), (float)rand_norm() * static_cast<float>(2 * M_PI));
|
||||
}
|
||||
void GetFirstCollisionPosition(Position &pos, float dist, float angle);
|
||||
void GetRandomNearPosition(Position &pos, float radius);
|
||||
void GetContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const;
|
||||
|
||||
void GetContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const
|
||||
{
|
||||
// angle to face `obj` to `this` using distance includes size of `obj`
|
||||
GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
|
||||
}
|
||||
|
||||
float GetObjectSize() const
|
||||
{
|
||||
return (m_valuesCount > UNIT_FIELD_COMBATREACH) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE;
|
||||
}
|
||||
float GetObjectSize() const;
|
||||
void UpdateGroundPositionZ(float x, float y, float &z) const;
|
||||
void UpdateAllowedPositionZ(float x, float y, float &z) const;
|
||||
|
||||
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const;
|
||||
void GetRandomPoint(const Position &srcPos, float distance, Position &pos) const
|
||||
{
|
||||
float x, y, z;
|
||||
GetRandomPoint(srcPos, distance, x, y, z);
|
||||
pos.Relocate(x, y, z, GetOrientation());
|
||||
}
|
||||
void GetRandomPoint(const Position &srcPos, float distance, Position &pos) const;
|
||||
|
||||
uint32 GetInstanceId() const { return m_InstanceId; }
|
||||
|
||||
virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
|
||||
uint32 GetPhaseMask() const { return m_phaseMask; }
|
||||
bool InSamePhase(WorldObject const* obj) const { return InSamePhase(obj->GetPhaseMask()); }
|
||||
bool InSamePhase(WorldObject const* obj) const;
|
||||
bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask); }
|
||||
|
||||
uint32 GetZoneId() const;
|
||||
@@ -656,62 +523,22 @@ class WorldObject : public Object, public WorldLocation
|
||||
|
||||
virtual std::string const& GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return m_name; }
|
||||
|
||||
float GetDistance(const WorldObject* obj) const
|
||||
{
|
||||
float d = GetExactDist(obj) - GetObjectSize() - obj->GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
float GetDistance(const Position &pos) const
|
||||
{
|
||||
float d = GetExactDist(&pos) - GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
float GetDistance(float x, float y, float z) const
|
||||
{
|
||||
float d = GetExactDist(x, y, z) - GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
float GetDistance2d(const WorldObject* obj) const
|
||||
{
|
||||
float d = GetExactDist2d(obj) - GetObjectSize() - obj->GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
float GetDistance2d(float x, float y) const
|
||||
{
|
||||
float d = GetExactDist2d(x, y) - GetObjectSize();
|
||||
return d > 0.0f ? d : 0.0f;
|
||||
}
|
||||
float GetDistance(const WorldObject* obj) const;
|
||||
float GetDistance(const Position &pos) const;
|
||||
float GetDistance(float x, float y, float z) const;
|
||||
float GetDistance2d(const WorldObject* obj) const;
|
||||
float GetDistance2d(float x, float y) const;
|
||||
float GetDistanceZ(const WorldObject* obj) const;
|
||||
|
||||
bool IsSelfOrInSameMap(const WorldObject* obj) const
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
return IsInMap(obj);
|
||||
}
|
||||
bool IsInMap(const WorldObject* obj) const
|
||||
{
|
||||
if (obj)
|
||||
return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap());
|
||||
return false;
|
||||
}
|
||||
bool IsWithinDist3d(float x, float y, float z, float dist) const
|
||||
{ return IsInDist(x, y, z, dist + GetObjectSize()); }
|
||||
bool IsWithinDist3d(const Position* pos, float dist) const
|
||||
{ return IsInDist(pos, dist + GetObjectSize()); }
|
||||
bool IsWithinDist2d(float x, float y, float dist) const
|
||||
{ return IsInDist2d(x, y, dist + GetObjectSize()); }
|
||||
bool IsWithinDist2d(const Position* pos, float dist) const
|
||||
{ return IsInDist2d(pos, dist + GetObjectSize()); }
|
||||
bool IsSelfOrInSameMap(const WorldObject* obj) const;
|
||||
bool IsInMap(const WorldObject* obj) const;
|
||||
bool IsWithinDist3d(float x, float y, float z, float dist) const;
|
||||
bool IsWithinDist3d(const Position* pos, float dist) const;
|
||||
bool IsWithinDist2d(float x, float y, float dist) const;
|
||||
bool IsWithinDist2d(const Position* pos, float dist) const;
|
||||
// use only if you will sure about placing both object at same map
|
||||
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const
|
||||
{
|
||||
return obj && _IsWithinDist(obj, dist2compare, is3D);
|
||||
}
|
||||
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const
|
||||
{
|
||||
return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D);
|
||||
}
|
||||
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const;
|
||||
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const;
|
||||
bool IsWithinLOS(float x, float y, float z) const;
|
||||
bool IsWithinLOSInMap(const WorldObject* obj) const;
|
||||
bool GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D = true) const;
|
||||
@@ -780,17 +607,7 @@ class WorldObject : public Object, public WorldLocation
|
||||
ZoneScript* GetZoneScript() const { return m_zoneScript; }
|
||||
|
||||
TempSummon* SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const;
|
||||
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0)
|
||||
{
|
||||
if (!x && !y && !z)
|
||||
{
|
||||
GetClosePoint(x, y, z, GetObjectSize());
|
||||
ang = GetOrientation();
|
||||
}
|
||||
Position pos;
|
||||
pos.Relocate(x, y, z, ang);
|
||||
return SummonCreature(id, pos, spwtype, despwtime, 0);
|
||||
}
|
||||
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0) const;
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime);
|
||||
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL);
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = NULL);
|
||||
@@ -878,7 +695,7 @@ class WorldObject : public Object, public WorldLocation
|
||||
|
||||
virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const;
|
||||
|
||||
bool CanNeverSee(WorldObject const* obj) const { return GetMap() != obj->GetMap() || !InSamePhase(obj); }
|
||||
bool CanNeverSee(WorldObject const* obj) const;
|
||||
virtual bool CanAlwaysSee(WorldObject const* /*obj*/) const { return false; }
|
||||
bool CanDetect(WorldObject const* obj, bool ignoreStealth) const;
|
||||
bool CanDetectInvisibilityOf(WorldObject const* obj) const;
|
||||
|
||||
@@ -1342,6 +1342,18 @@ void Player::UpdateMirrorTimers()
|
||||
m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags;
|
||||
}
|
||||
|
||||
void Player::StopMirrorTimers()
|
||||
{
|
||||
StopMirrorTimer(FATIGUE_TIMER);
|
||||
StopMirrorTimer(BREATH_TIMER);
|
||||
StopMirrorTimer(FIRE_TIMER);
|
||||
}
|
||||
|
||||
bool Player::IsMirrorTimerActive(MirrorTimerType type)
|
||||
{
|
||||
return m_MirrorTimer[type] == getMaxTimer(type);
|
||||
}
|
||||
|
||||
void Player::HandleDrowning(uint32 time_diff)
|
||||
{
|
||||
if (!m_MirrorTimerFlags)
|
||||
@@ -1873,6 +1885,15 @@ void Player::setDeathState(DeathState s)
|
||||
SetUInt32Value(PLAYER_SELF_RES_SPELL, 0);
|
||||
}
|
||||
|
||||
void Player::InnEnter(time_t time, uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
inn_pos_mapid = mapid;
|
||||
inn_pos_x = x;
|
||||
inn_pos_y = y;
|
||||
inn_pos_z = z;
|
||||
time_inn_enter = time;
|
||||
}
|
||||
|
||||
bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data)
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
@@ -2312,6 +2333,11 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::TeleportTo(WorldLocation const &loc, uint32 options /*= 0*/)
|
||||
{
|
||||
return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options);
|
||||
}
|
||||
|
||||
bool Player::TeleportToBGEntryPoint()
|
||||
{
|
||||
if (m_bgData.joinPos.m_mapId == MAPID_INVALID)
|
||||
@@ -2882,6 +2908,11 @@ bool Player::IsInSameGroupWith(Player const* p) const
|
||||
GetGroup()->SameSubGroup(this, p));
|
||||
}
|
||||
|
||||
bool Player::IsInSameRaidWith(Player const* p) const
|
||||
{
|
||||
return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup());
|
||||
}
|
||||
|
||||
///- If the player is invited, remove him. If the group if then only 1 person, disband the group.
|
||||
/// \todo Shouldn't we also check if there is no other invitees before disbanding the group?
|
||||
void Player::UninviteFromGroup()
|
||||
@@ -7335,6 +7366,16 @@ uint8 Player::GetRankFromDB(uint64 guid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Player::SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
|
||||
{
|
||||
SetArenaTeamInfoField(slot, ARENA_TEAM_ID, ArenaTeamId);
|
||||
SetArenaTeamInfoField(slot, ARENA_TEAM_TYPE, type);
|
||||
}
|
||||
void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
|
||||
{
|
||||
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value);
|
||||
}
|
||||
|
||||
uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ARENA_TEAM_ID_BY_PLAYER_GUID);
|
||||
@@ -10132,6 +10173,14 @@ Item* Player::GetItemByPos(uint8 bag, uint8 slot) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Does additional check for disarmed weapons
|
||||
Item* Player::GetUseableItemByPos(uint8 bag, uint8 slot) const
|
||||
{
|
||||
if (!CanUseAttackType(GetAttackBySlot(slot)))
|
||||
return NULL;
|
||||
return GetItemByPos(bag, slot);
|
||||
}
|
||||
|
||||
Bag* Player::GetBagByPos(uint8 bag) const
|
||||
{
|
||||
if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END)
|
||||
@@ -10496,6 +10545,19 @@ InventoryResult Player::CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
InventoryResult Player::CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count /*= NULL*/) const
|
||||
{
|
||||
return CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count);
|
||||
}
|
||||
|
||||
InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap /*= false*/) const
|
||||
{
|
||||
if (!pItem)
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
uint32 count = pItem->GetCount();
|
||||
return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL);
|
||||
}
|
||||
|
||||
bool Player::HasItemTotemCategory(uint32 TotemCategory) const
|
||||
{
|
||||
Item* pItem;
|
||||
@@ -12415,6 +12477,11 @@ void Player::VisualizeItem(uint8 slot, Item* pItem)
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
}
|
||||
|
||||
Item* Player::BankItem(ItemPosCountVec const& dest, Item* pItem, bool update)
|
||||
{
|
||||
return StoreItem(dest, pItem, update);
|
||||
}
|
||||
|
||||
void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
|
||||
{
|
||||
// note: removeitem does not actually change the item
|
||||
@@ -13565,6 +13632,18 @@ void Player::SendSellError(SellResult msg, Creature* creature, uint64 guid, uint
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
bool Player::IsUseEquipedWeapon(bool mainhand) const
|
||||
{
|
||||
// disarm applied only to mainhand weapon
|
||||
return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED));
|
||||
}
|
||||
|
||||
bool Player::IsTwoHandUsed() const
|
||||
{
|
||||
Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
|
||||
return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
|
||||
}
|
||||
|
||||
void Player::TradeCancel(bool sendback)
|
||||
{
|
||||
if (m_trade)
|
||||
@@ -15897,6 +15976,70 @@ uint16 Player::FindQuestSlot(uint32 quest_id) const
|
||||
return MAX_QUEST_LOG_SIZE;
|
||||
}
|
||||
|
||||
uint32 Player::GetQuestSlotQuestId(uint16 slot) const
|
||||
{
|
||||
return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET);
|
||||
}
|
||||
|
||||
uint32 Player::GetQuestSlotState(uint16 slot) const
|
||||
{
|
||||
return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET);
|
||||
}
|
||||
|
||||
uint16 Player::GetQuestSlotCounter(uint16 slot, uint8 counter) const
|
||||
{
|
||||
return (uint16)(GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET) >> (counter * 16));
|
||||
}
|
||||
|
||||
uint32 Player::GetQuestSlotTime(uint16 slot) const
|
||||
{
|
||||
return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET);
|
||||
}
|
||||
|
||||
void Player::SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer /*= 0*/)
|
||||
{
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET, quest_id);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, 0);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, 0);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET + 1, 0);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer);
|
||||
}
|
||||
|
||||
void Player::SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count)
|
||||
{
|
||||
uint64 val = GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET);
|
||||
val &= ~((uint64)0xFFFF << (counter * 16));
|
||||
val |= ((uint64)count << (counter * 16));
|
||||
SetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, val);
|
||||
}
|
||||
|
||||
void Player::SetQuestSlotState(uint16 slot, uint32 state)
|
||||
{
|
||||
SetFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state);
|
||||
}
|
||||
|
||||
void Player::RemoveQuestSlotState(uint16 slot, uint32 state)
|
||||
{
|
||||
RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state);
|
||||
}
|
||||
|
||||
void Player::SetQuestSlotTimer(uint16 slot, uint32 timer)
|
||||
{
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer);
|
||||
}
|
||||
|
||||
void Player::SwapQuestSlot(uint16 slot1, uint16 slot2)
|
||||
{
|
||||
for (int i = 0; i < MAX_QUEST_OFFSET; ++i)
|
||||
{
|
||||
uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i);
|
||||
uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i);
|
||||
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i, temp2);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i, temp1);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::AreaExploredOrEventHappens(uint32 questId)
|
||||
{
|
||||
if (questId)
|
||||
@@ -18462,6 +18605,12 @@ void Player::BindToInstance()
|
||||
GetSession()->SendCalendarRaidLockout(mapSave, true);
|
||||
}
|
||||
|
||||
void Player::SetPendingBind(uint32 instanceId, uint32 bindTimer)
|
||||
{
|
||||
_pendingBindId = instanceId;
|
||||
_pendingBindTimer = bindTimer;
|
||||
}
|
||||
|
||||
void Player::SendRaidInfo()
|
||||
{
|
||||
uint32 counter = 0;
|
||||
@@ -18663,6 +18812,11 @@ bool Player::CheckInstanceCount(uint32 instanceId) const
|
||||
return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end();
|
||||
}
|
||||
|
||||
void Player::AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
|
||||
{
|
||||
if (_instanceResetTimes.find(instanceId) == _instanceResetTimes.end())
|
||||
_instanceResetTimes.insert(InstanceTimeMap::value_type(instanceId, enterTime + HOUR));
|
||||
}
|
||||
|
||||
bool Player::_LoadHomeBind(PreparedQueryResult result)
|
||||
{
|
||||
@@ -19917,6 +20071,13 @@ void Player::UpdateContestedPvP(uint32 diff)
|
||||
m_contestedPvPTimer -= diff;
|
||||
}
|
||||
|
||||
void Player::ResetContestedPvP()
|
||||
{
|
||||
ClearUnitState(UNIT_STATE_ATTACK_PLAYER);
|
||||
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
|
||||
m_contestedPvPTimer = 0;
|
||||
}
|
||||
|
||||
void Player::UpdatePvPFlag(time_t currTime)
|
||||
{
|
||||
if (!IsPvP())
|
||||
@@ -20152,6 +20313,30 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
|
||||
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->autoReplyMsg.c_str());
|
||||
}
|
||||
|
||||
Item* Player::GetMItem(uint32 id)
|
||||
{
|
||||
ItemMap::const_iterator itr = mMitems.find(id);
|
||||
return itr != mMitems.end() ? itr->second : NULL;
|
||||
}
|
||||
|
||||
void Player::AddMItem(Item* it)
|
||||
{
|
||||
ASSERT(it);
|
||||
//ASSERT deleted, because items can be added before loading
|
||||
mMitems[it->GetGUIDLow()] = it;
|
||||
}
|
||||
|
||||
bool Player::RemoveMItem(uint32 id)
|
||||
{
|
||||
return mMitems.erase(id) ? true : false;
|
||||
}
|
||||
|
||||
void Player::SendOnCancelExpectedVehicleRideAura()
|
||||
{
|
||||
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Player::PetSpellInitialize()
|
||||
{
|
||||
Pet* pet = GetPet();
|
||||
@@ -21400,6 +21585,13 @@ void Player::UpdatePvPState(bool onlyFFA)
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SetPvP(bool state)
|
||||
{
|
||||
Unit::SetPvP(state);
|
||||
for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
||||
(*itr)->SetPvP(state);
|
||||
}
|
||||
|
||||
void Player::UpdatePvP(bool state, bool override)
|
||||
{
|
||||
if (!state || override)
|
||||
@@ -21414,6 +21606,19 @@ void Player::UpdatePvP(bool state, bool override)
|
||||
}
|
||||
}
|
||||
|
||||
bool Player::HasSpellCooldown(uint32 spell_id) const
|
||||
{
|
||||
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
|
||||
return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
|
||||
}
|
||||
|
||||
uint32 Player::GetSpellCooldownDelay(uint32 spell_id) const
|
||||
{
|
||||
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
|
||||
time_t t = time(NULL);
|
||||
return uint32(itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0);
|
||||
}
|
||||
|
||||
void Player::AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell, bool infinityCooldown)
|
||||
{
|
||||
// init cooldown values
|
||||
@@ -21554,6 +21759,16 @@ void Player::UpdatePotionCooldown(Spell* spell)
|
||||
m_lastPotionId = 0;
|
||||
}
|
||||
|
||||
void Player::setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
|
||||
{
|
||||
m_resurrectGUID = guid;
|
||||
m_resurrectMap = mapId;
|
||||
m_resurrectX = X;
|
||||
m_resurrectY = Y;
|
||||
m_resurrectZ = Z;
|
||||
m_resurrectHealth = health;
|
||||
m_resurrectMana = mana;
|
||||
}
|
||||
//slot to be excluded while counting
|
||||
bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot)
|
||||
{
|
||||
@@ -21757,6 +21972,17 @@ void Player::SetBattlegroundEntryPoint()
|
||||
m_bgData.joinPos = WorldLocation(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, 0.0f);
|
||||
}
|
||||
|
||||
void Player::SetBGTeam(uint32 team)
|
||||
{
|
||||
m_bgData.bgTeam = team;
|
||||
SetByteValue(PLAYER_BYTES_3, 3, uint8(team == ALLIANCE ? 1 : 0));
|
||||
}
|
||||
|
||||
uint32 Player::GetBGTeam() const
|
||||
{
|
||||
return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam();
|
||||
}
|
||||
|
||||
void Player::LeaveBattleground(bool teleportToEntryPoint)
|
||||
{
|
||||
if (Battleground* bg = GetBattleground())
|
||||
@@ -21839,6 +22065,11 @@ WorldLocation Player::GetStartPosition() const
|
||||
return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0);
|
||||
}
|
||||
|
||||
bool Player::HaveAtClient(WorldObject const* u) const
|
||||
{
|
||||
return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end();
|
||||
}
|
||||
|
||||
bool Player::IsNeverVisible() const
|
||||
{
|
||||
if (Unit::IsNeverVisible())
|
||||
@@ -22103,6 +22334,25 @@ bool Player::ModifyMoney(int32 amount, bool sendError /*= true*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::HasEnoughMoney(int32 amount) const
|
||||
{
|
||||
if (amount > 0)
|
||||
return (GetMoney() >= (uint32) amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Player::SetMoney(uint32 value)
|
||||
{
|
||||
SetUInt32Value(PLAYER_FIELD_COINAGE, value);
|
||||
MoneyChanged(value);
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED);
|
||||
}
|
||||
|
||||
bool Player::IsQuestRewarded(uint32 quest_id) const
|
||||
{
|
||||
return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end();
|
||||
}
|
||||
|
||||
Unit* Player::GetSelectedUnit() const
|
||||
{
|
||||
if (m_curSelection)
|
||||
@@ -22737,6 +22987,96 @@ Battleground* Player::GetBattleground() const
|
||||
return sBattlegroundMgr->GetBattleground(GetBattlegroundId(), m_bgData.bgTypeID);
|
||||
}
|
||||
|
||||
bool Player::InBattlegroundQueue() const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BattlegroundQueueTypeId Player::GetBattlegroundQueueTypeId(uint32 index) const
|
||||
{
|
||||
return m_bgBattlegroundQueueID[index].bgQueueTypeId;
|
||||
}
|
||||
|
||||
uint32 Player::GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
return i;
|
||||
return PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
|
||||
bool Player::IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
return m_bgBattlegroundQueueID[i].invitedToInstance != 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
return GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
|
||||
void Player::SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
m_bgData.bgInstanceID = val;
|
||||
m_bgData.bgTypeID = bgTypeId;
|
||||
}
|
||||
|
||||
uint32 Player::AddBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
{
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattlegroundQueueID[i].bgQueueTypeId == val)
|
||||
{
|
||||
m_bgBattlegroundQueueID[i].bgQueueTypeId = val;
|
||||
m_bgBattlegroundQueueID[i].invitedToInstance = 0;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
|
||||
bool Player::HasFreeBattlegroundQueueId()
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Player::RemoveBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
{
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == val)
|
||||
{
|
||||
m_bgBattlegroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
|
||||
m_bgBattlegroundQueueID[i].invitedToInstance = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId)
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
m_bgBattlegroundQueueID[i].invitedToInstance = instanceId;
|
||||
}
|
||||
|
||||
bool Player::IsInvitedForBattlegroundInstance(uint32 instanceId) const
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].invitedToInstance == instanceId)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::InArena() const
|
||||
{
|
||||
Battleground* bg = GetBattleground();
|
||||
@@ -22885,6 +23225,15 @@ void Player::UpdateForQuestWorldObjects()
|
||||
GetSession()->SendPacket(&packet);
|
||||
}
|
||||
|
||||
void Player::SetSummonPoint(uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
|
||||
m_summon_mapid = mapid;
|
||||
m_summon_x = x;
|
||||
m_summon_y = y;
|
||||
m_summon_z = z;
|
||||
}
|
||||
|
||||
void Player::SummonIfPossible(bool agree)
|
||||
{
|
||||
if (!agree)
|
||||
@@ -23288,6 +23637,13 @@ void Player::SetClientControl(Unit* target, uint8 allowMove)
|
||||
SetMover(this);
|
||||
}
|
||||
|
||||
void Player::SetMover(Unit* target)
|
||||
{
|
||||
m_mover->m_movedPlayer = NULL;
|
||||
m_mover = target;
|
||||
m_mover->m_movedPlayer = this;
|
||||
}
|
||||
|
||||
void Player::UpdateZoneDependentAuras(uint32 newZone)
|
||||
{
|
||||
// Some spells applied at enter into zone (with subzones), aura removed in UpdateAreaDependentAuras that called always at zone->area update
|
||||
@@ -23788,6 +24144,12 @@ void Player::InitGlyphsForLevel()
|
||||
SetUInt32Value(PLAYER_GLYPHS_ENABLED, value);
|
||||
}
|
||||
|
||||
void Player::SetGlyph(uint8 slot, uint32 glyph)
|
||||
{
|
||||
m_Glyphs[m_activeSpec][slot] = glyph;
|
||||
SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph);
|
||||
}
|
||||
|
||||
bool Player::isTotalImmune()
|
||||
{
|
||||
AuraEffectList const& immune = GetAuraEffectsByType(SPELL_AURA_SCHOOL_IMMUNITY);
|
||||
@@ -23909,6 +24271,22 @@ uint32 Player::GetRuneBaseCooldown(uint8 index)
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
void Player::SetRuneCooldown(uint8 index, uint32 cooldown)
|
||||
{
|
||||
m_runes->runes[index].Cooldown = cooldown;
|
||||
m_runes->SetRuneState(index, (cooldown == 0) ? true : false);
|
||||
}
|
||||
|
||||
void Player::SetRuneConvertAura(uint8 index, AuraEffect const* aura)
|
||||
{
|
||||
m_runes->runes[index].ConvertAura = aura;
|
||||
}
|
||||
|
||||
void Player::AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura)
|
||||
{
|
||||
SetRuneConvertAura(index, aura); ConvertRune(index, newType);
|
||||
}
|
||||
|
||||
void Player::RemoveRunesByAuraEffect(AuraEffect const* aura)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
@@ -24333,6 +24711,12 @@ InventoryResult Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
void Player::SetFallInformation(uint32 time, float z)
|
||||
{
|
||||
m_lastFallTime = time;
|
||||
m_lastFallZ = z;
|
||||
}
|
||||
|
||||
void Player::HandleFall(MovementInfo const& movementInfo)
|
||||
{
|
||||
// calculate total z distance of the fall
|
||||
@@ -24719,6 +25103,11 @@ void Player::ResummonPetTemporaryUnSummonedIfAny()
|
||||
m_temporaryUnsummonedPetNumber = 0;
|
||||
}
|
||||
|
||||
bool Player::IsPetNeedBeTemporaryUnsummoned() const
|
||||
{
|
||||
return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/;
|
||||
}
|
||||
|
||||
bool Player::canSeeSpellClickOn(Creature const* c) const
|
||||
{
|
||||
if (!c->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
|
||||
@@ -25776,6 +26165,39 @@ void Player::SendMovementSetFeatherFall(bool apply)
|
||||
SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
float Player::GetCollisionHeight(bool mounted) const
|
||||
{
|
||||
if (mounted)
|
||||
{
|
||||
CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID));
|
||||
if (!mountDisplayInfo)
|
||||
return GetCollisionHeight(false);
|
||||
|
||||
CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId);
|
||||
if (!mountModelData)
|
||||
return GetCollisionHeight(false);
|
||||
|
||||
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
|
||||
ASSERT(displayInfo);
|
||||
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
|
||||
ASSERT(modelData);
|
||||
|
||||
float scaleMod = GetFloatValue(OBJECT_FIELD_SCALE_X); // 99% sure about this
|
||||
|
||||
return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//! Dismounting case - use basic default model data
|
||||
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
|
||||
ASSERT(displayInfo);
|
||||
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
|
||||
ASSERT(modelData);
|
||||
|
||||
return modelData->CollisionHeight;
|
||||
}
|
||||
}
|
||||
|
||||
Guild* Player::GetGuild()
|
||||
{
|
||||
uint32 guildId = GetGuildId();
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "QuestDef.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Unit.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -1073,20 +1072,10 @@ class Player : public Unit, public GridObject<Player>
|
||||
void RemoveFromWorld();
|
||||
|
||||
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
|
||||
bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
|
||||
{
|
||||
return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options);
|
||||
}
|
||||
bool TeleportTo(WorldLocation const &loc, uint32 options = 0);
|
||||
bool TeleportToBGEntryPoint();
|
||||
|
||||
void SetSummonPoint(uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
|
||||
m_summon_mapid = mapid;
|
||||
m_summon_x = x;
|
||||
m_summon_y = y;
|
||||
m_summon_z = z;
|
||||
}
|
||||
void SetSummonPoint(uint32 mapid, float x, float y, float z);
|
||||
void SummonIfPossible(bool agree);
|
||||
|
||||
bool Create(uint32 guidlow, CharacterCreateInfo* createInfo);
|
||||
@@ -1161,14 +1150,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
void setDeathState(DeathState s); // overwrite Unit::setDeathState
|
||||
|
||||
void InnEnter (time_t time, uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
inn_pos_mapid = mapid;
|
||||
inn_pos_x = x;
|
||||
inn_pos_y = y;
|
||||
inn_pos_z = z;
|
||||
time_inn_enter = time;
|
||||
}
|
||||
void InnEnter(time_t time, uint32 mapid, float x, float y, float z);
|
||||
|
||||
float GetRestBonus() const { return m_rest_bonus; }
|
||||
void SetRestBonus(float rest_bonus_new);
|
||||
@@ -1213,13 +1195,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
Item* GetItemByEntry(uint32 entry) const;
|
||||
Item* GetItemByPos(uint16 pos) const;
|
||||
Item* GetItemByPos(uint8 bag, uint8 slot) const;
|
||||
Item* GetUseableItemByPos(uint8 bag, uint8 slot) const;
|
||||
Bag* GetBagByPos(uint8 slot) const;
|
||||
inline Item* GetUseableItemByPos(uint8 bag, uint8 slot) const //Does additional check for disarmed weapons
|
||||
{
|
||||
if (!CanUseAttackType(GetAttackBySlot(slot)))
|
||||
return NULL;
|
||||
return GetItemByPos(bag, slot);
|
||||
}
|
||||
Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const;
|
||||
Item* GetShield(bool useable = false) const;
|
||||
static uint8 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot
|
||||
@@ -1242,17 +1219,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
|
||||
InventoryResult CanTakeMoreSimilarItems(Item* pItem) const { return CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); }
|
||||
InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return CanTakeMoreSimilarItems(entry, count, NULL); }
|
||||
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL) const
|
||||
{
|
||||
return CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count);
|
||||
}
|
||||
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const
|
||||
{
|
||||
if (!pItem)
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
uint32 count = pItem->GetCount();
|
||||
return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL);
|
||||
}
|
||||
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL) const;
|
||||
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const;
|
||||
InventoryResult CanStoreItems(Item** pItem, int count) const;
|
||||
InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const;
|
||||
InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const;
|
||||
@@ -1292,11 +1260,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void QuickEquipItem(uint16 pos, Item* pItem);
|
||||
void VisualizeItem(uint8 slot, Item* pItem);
|
||||
void SetVisibleItemSlot(uint8 slot, Item* pItem);
|
||||
Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update)
|
||||
{
|
||||
return StoreItem(dest, pItem, update);
|
||||
}
|
||||
Item* BankItem(uint16 pos, Item* pItem, bool update);
|
||||
Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update);
|
||||
void RemoveItem(uint8 bag, uint8 slot, bool update);
|
||||
void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
|
||||
// in trade, auction, guild bank, mail....
|
||||
@@ -1321,16 +1285,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
|
||||
uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
|
||||
uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
|
||||
bool IsUseEquipedWeapon(bool mainhand) const
|
||||
{
|
||||
// disarm applied only to mainhand weapon
|
||||
return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED));
|
||||
}
|
||||
bool IsTwoHandUsed() const
|
||||
{
|
||||
Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
|
||||
return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
|
||||
}
|
||||
bool IsUseEquipedWeapon(bool mainhand) const;
|
||||
bool IsTwoHandUsed() const;
|
||||
void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false);
|
||||
bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
|
||||
bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore);
|
||||
@@ -1434,39 +1390,17 @@ class Player : public Unit, public GridObject<Player>
|
||||
void ResetSeasonalQuestStatus(uint16 event_id);
|
||||
|
||||
uint16 FindQuestSlot(uint32 quest_id) const;
|
||||
uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
|
||||
uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
|
||||
uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const { return (uint16)(GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET) >> (counter * 16)); }
|
||||
uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
|
||||
void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0)
|
||||
{
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET, quest_id);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, 0);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, 0);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET + 1, 0);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer);
|
||||
}
|
||||
void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count)
|
||||
{
|
||||
uint64 val = GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET);
|
||||
val &= ~((uint64)0xFFFF << (counter * 16));
|
||||
val |= ((uint64)count << (counter * 16));
|
||||
SetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, val);
|
||||
}
|
||||
void SetQuestSlotState(uint16 slot, uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); }
|
||||
void RemoveQuestSlotState(uint16 slot, uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); }
|
||||
void SetQuestSlotTimer(uint16 slot, uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer); }
|
||||
void SwapQuestSlot(uint16 slot1, uint16 slot2)
|
||||
{
|
||||
for (int i = 0; i < MAX_QUEST_OFFSET; ++i)
|
||||
{
|
||||
uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i);
|
||||
uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i);
|
||||
uint32 GetQuestSlotQuestId(uint16 slot) const;
|
||||
uint32 GetQuestSlotState(uint16 slot) const;
|
||||
uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const;
|
||||
uint32 GetQuestSlotTime(uint16 slot) const;
|
||||
void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0);
|
||||
void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count);
|
||||
void SetQuestSlotState(uint16 slot, uint32 state);
|
||||
void RemoveQuestSlotState(uint16 slot, uint32 state);
|
||||
void SetQuestSlotTimer(uint16 slot, uint32 timer);
|
||||
void SwapQuestSlot(uint16 slot1, uint16 slot2);
|
||||
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i, temp2);
|
||||
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i, temp1);
|
||||
}
|
||||
}
|
||||
uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
|
||||
void AreaExploredOrEventHappens(uint32 questId);
|
||||
void GroupEventHappens(uint32 questId, WorldObject const* pEventObject);
|
||||
@@ -1557,28 +1491,14 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint32 GetMoney() const { return GetUInt32Value(PLAYER_FIELD_COINAGE); }
|
||||
bool ModifyMoney(int32 amount, bool sendError = true);
|
||||
bool HasEnoughMoney(uint32 amount) const { return (GetMoney() >= amount); }
|
||||
bool HasEnoughMoney(int32 amount) const
|
||||
{
|
||||
if (amount > 0)
|
||||
return (GetMoney() >= (uint32) amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetMoney(uint32 value)
|
||||
{
|
||||
SetUInt32Value(PLAYER_FIELD_COINAGE, value);
|
||||
MoneyChanged(value);
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED);
|
||||
}
|
||||
bool HasEnoughMoney(int32 amount) const;
|
||||
void SetMoney(uint32 value);
|
||||
|
||||
RewardedQuestSet const& getRewardedQuests() const { return m_RewardedQuests; }
|
||||
QuestStatusMap& getQuestStatusMap() { return m_QuestStatus; }
|
||||
|
||||
size_t GetRewardedQuestCount() const { return m_RewardedQuests.size(); }
|
||||
bool IsQuestRewarded(uint32 quest_id) const
|
||||
{
|
||||
return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end();
|
||||
}
|
||||
bool IsQuestRewarded(uint32 quest_id) const;
|
||||
|
||||
uint64 GetSelection() const { return m_curSelection; }
|
||||
Unit* GetSelectedUnit() const;
|
||||
@@ -1619,29 +1539,11 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
ItemMap mMitems; //template defined in objectmgr.cpp
|
||||
|
||||
Item* GetMItem(uint32 id)
|
||||
{
|
||||
ItemMap::const_iterator itr = mMitems.find(id);
|
||||
return itr != mMitems.end() ? itr->second : NULL;
|
||||
}
|
||||
Item* GetMItem(uint32 id);
|
||||
void AddMItem(Item* it);
|
||||
bool RemoveMItem(uint32 id);
|
||||
|
||||
void AddMItem(Item* it)
|
||||
{
|
||||
ASSERT(it);
|
||||
//ASSERT deleted, because items can be added before loading
|
||||
mMitems[it->GetGUIDLow()] = it;
|
||||
}
|
||||
|
||||
bool RemoveMItem(uint32 id)
|
||||
{
|
||||
return mMitems.erase(id) ? true : false;
|
||||
}
|
||||
|
||||
void SendOnCancelExpectedVehicleRideAura()
|
||||
{
|
||||
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
void SendOnCancelExpectedVehicleRideAura();
|
||||
void PetSpellInitialize();
|
||||
void CharmSpellInitialize();
|
||||
void PossessSpellInitialize();
|
||||
@@ -1695,11 +1597,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void InitGlyphsForLevel();
|
||||
void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); }
|
||||
uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); }
|
||||
void SetGlyph(uint8 slot, uint32 glyph)
|
||||
{
|
||||
m_Glyphs[m_activeSpec][slot] = glyph;
|
||||
SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph);
|
||||
}
|
||||
void SetGlyph(uint8 slot, uint32 glyph);
|
||||
uint32 GetGlyph(uint8 slot) { return m_Glyphs[m_activeSpec][slot]; }
|
||||
|
||||
uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); }
|
||||
@@ -1722,17 +1620,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check
|
||||
static uint32 const infinityCooldownDelayCheck = MONTH/2;
|
||||
bool HasSpellCooldown(uint32 spell_id) const
|
||||
{
|
||||
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
|
||||
return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
|
||||
}
|
||||
uint32 GetSpellCooldownDelay(uint32 spell_id) const
|
||||
{
|
||||
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
|
||||
time_t t = time(NULL);
|
||||
return uint32(itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0);
|
||||
}
|
||||
bool HasSpellCooldown(uint32 spell_id) const;
|
||||
uint32 GetSpellCooldownDelay(uint32 spell_id) const;
|
||||
void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false);
|
||||
void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
|
||||
void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true);
|
||||
@@ -1751,29 +1640,14 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
|
||||
void UpdatePotionCooldown(Spell* spell = NULL);
|
||||
|
||||
void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
|
||||
{
|
||||
m_resurrectGUID = guid;
|
||||
m_resurrectMap = mapId;
|
||||
m_resurrectX = X;
|
||||
m_resurrectY = Y;
|
||||
m_resurrectZ = Z;
|
||||
m_resurrectHealth = health;
|
||||
m_resurrectMana = mana;
|
||||
}
|
||||
void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana);
|
||||
void clearResurrectRequestData() { setResurrectRequestData(0, 0, 0.0f, 0.0f, 0.0f, 0, 0); }
|
||||
bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; }
|
||||
bool isRessurectRequested() const { return m_resurrectGUID != 0; }
|
||||
void ResurectUsingRequestData();
|
||||
|
||||
uint8 getCinematic()
|
||||
{
|
||||
return m_cinematic;
|
||||
}
|
||||
void setCinematic(uint8 cine)
|
||||
{
|
||||
m_cinematic = cine;
|
||||
}
|
||||
uint8 getCinematic() { return m_cinematic; }
|
||||
void setCinematic(uint8 cine) { m_cinematic = cine; }
|
||||
|
||||
ActionButton* addActionButton(uint8 button, uint32 action, uint8 type);
|
||||
void removeActionButton(uint8 button);
|
||||
@@ -1784,12 +1658,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
PvPInfo pvpInfo;
|
||||
void UpdatePvPState(bool onlyFFA = false);
|
||||
void SetPvP(bool state)
|
||||
{
|
||||
Unit::SetPvP(state);
|
||||
for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
||||
(*itr)->SetPvP(state);
|
||||
}
|
||||
void SetPvP(bool state);
|
||||
void UpdatePvP(bool state, bool override=false);
|
||||
void UpdateZone(uint32 newZone, uint32 newArea);
|
||||
void UpdateArea(uint32 newArea);
|
||||
@@ -1801,12 +1670,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void UpdatePvPFlag(time_t currTime);
|
||||
void UpdateContestedPvP(uint32 currTime);
|
||||
void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;}
|
||||
void ResetContestedPvP()
|
||||
{
|
||||
ClearUnitState(UNIT_STATE_ATTACK_PLAYER);
|
||||
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
|
||||
m_contestedPvPTimer = 0;
|
||||
}
|
||||
void ResetContestedPvP();
|
||||
|
||||
/** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/
|
||||
DuelInfo* duel;
|
||||
@@ -1817,7 +1681,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
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()); }
|
||||
bool IsInSameRaidWith(Player const* p) const;
|
||||
void UninviteFromGroup();
|
||||
static void RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = NULL);
|
||||
void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); }
|
||||
@@ -1835,15 +1699,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
|
||||
|
||||
// Arena Team
|
||||
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
|
||||
{
|
||||
SetArenaTeamInfoField(slot, ARENA_TEAM_ID, ArenaTeamId);
|
||||
SetArenaTeamInfoField(slot, ARENA_TEAM_TYPE, type);
|
||||
}
|
||||
void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
|
||||
{
|
||||
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value);
|
||||
}
|
||||
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type);
|
||||
void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value);
|
||||
static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
|
||||
static void LeaveAllArenaTeams(uint64 guid);
|
||||
uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); }
|
||||
@@ -1980,13 +1837,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank);
|
||||
|
||||
void UpdateMirrorTimers();
|
||||
void StopMirrorTimers()
|
||||
{
|
||||
StopMirrorTimer(FATIGUE_TIMER);
|
||||
StopMirrorTimer(BREATH_TIMER);
|
||||
StopMirrorTimer(FIRE_TIMER);
|
||||
}
|
||||
bool IsMirrorTimerActive(MirrorTimerType type) { return m_MirrorTimer[type] == getMaxTimer(type); }
|
||||
void StopMirrorTimers();
|
||||
bool IsMirrorTimerActive(MirrorTimerType type);
|
||||
|
||||
void SetMovement(PlayerMovementType pType);
|
||||
|
||||
@@ -2152,93 +2004,24 @@ class Player : public Unit, public GridObject<Player>
|
||||
BattlegroundTypeId GetBattlegroundTypeId() const { return m_bgData.bgTypeID; }
|
||||
Battleground* GetBattleground() const;
|
||||
|
||||
bool InBattlegroundQueue() const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool InBattlegroundQueue() const;
|
||||
|
||||
BattlegroundQueueTypeId GetBattlegroundQueueTypeId(uint32 index) const { return m_bgBattlegroundQueueID[index].bgQueueTypeId; }
|
||||
uint32 GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
return i;
|
||||
return PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
bool IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
return m_bgBattlegroundQueueID[i].invitedToInstance != 0;
|
||||
return false;
|
||||
}
|
||||
bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
return GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
BattlegroundQueueTypeId GetBattlegroundQueueTypeId(uint32 index) const;
|
||||
uint32 GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const;
|
||||
bool IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const;
|
||||
bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const;
|
||||
|
||||
void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
m_bgData.bgInstanceID = val;
|
||||
m_bgData.bgTypeID = bgTypeId;
|
||||
}
|
||||
uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
{
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattlegroundQueueID[i].bgQueueTypeId == val)
|
||||
{
|
||||
m_bgBattlegroundQueueID[i].bgQueueTypeId = val;
|
||||
m_bgBattlegroundQueueID[i].invitedToInstance = 0;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
bool HasFreeBattlegroundQueueId()
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
{
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == val)
|
||||
{
|
||||
m_bgBattlegroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
|
||||
m_bgBattlegroundQueueID[i].invitedToInstance = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId)
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
m_bgBattlegroundQueueID[i].invitedToInstance = instanceId;
|
||||
}
|
||||
bool IsInvitedForBattlegroundInstance(uint32 instanceId) const
|
||||
{
|
||||
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i].invitedToInstance == instanceId)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId);
|
||||
uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val);
|
||||
bool HasFreeBattlegroundQueueId();
|
||||
void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val);
|
||||
void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId);
|
||||
bool IsInvitedForBattlegroundInstance(uint32 instanceId) const;
|
||||
WorldLocation const& GetBattlegroundEntryPoint() const { return m_bgData.joinPos; }
|
||||
void SetBattlegroundEntryPoint();
|
||||
|
||||
void SetBGTeam(uint32 team)
|
||||
{
|
||||
m_bgData.bgTeam = team;
|
||||
SetByteValue(PLAYER_BYTES_3, 3, uint8(team == ALLIANCE ? 1 : 0));
|
||||
}
|
||||
uint32 GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); }
|
||||
void SetBGTeam(uint32 team);
|
||||
uint32 GetBGTeam() const;
|
||||
|
||||
void LeaveBattleground(bool teleportToEntryPoint = true);
|
||||
bool CanJoinToBattleground(Battleground const* bg) const;
|
||||
@@ -2293,23 +2076,14 @@ class Player : public Unit, public GridObject<Player>
|
||||
void UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode);
|
||||
Unit* m_mover;
|
||||
WorldObject* m_seer;
|
||||
void SetFallInformation(uint32 time, float z)
|
||||
{
|
||||
m_lastFallTime = time;
|
||||
m_lastFallZ = z;
|
||||
}
|
||||
void SetFallInformation(uint32 time, float z);
|
||||
void HandleFall(MovementInfo const& movementInfo);
|
||||
|
||||
bool IsKnowHowFlyIn(uint32 mapid, uint32 zone) const;
|
||||
|
||||
void SetClientControl(Unit* target, uint8 allowMove);
|
||||
|
||||
void SetMover(Unit* target)
|
||||
{
|
||||
m_mover->m_movedPlayer = NULL;
|
||||
m_mover = target;
|
||||
m_mover->m_movedPlayer = this;
|
||||
}
|
||||
void SetMover(Unit* target);
|
||||
|
||||
void SetSeer(WorldObject* target) { m_seer = target; }
|
||||
void SetViewpoint(WorldObject* target, bool apply);
|
||||
@@ -2343,7 +2117,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
typedef std::set<uint64> ClientGUIDs;
|
||||
ClientGUIDs m_clientGUIDs;
|
||||
|
||||
bool HaveAtClient(WorldObject const* u) const { return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); }
|
||||
bool HaveAtClient(WorldObject const* u) const;
|
||||
|
||||
bool IsNeverVisible() const;
|
||||
|
||||
@@ -2375,7 +2149,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
|
||||
void UnsummonPetTemporaryIfAny();
|
||||
void ResummonPetTemporaryUnSummonedIfAny();
|
||||
bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; }
|
||||
bool IsPetNeedBeTemporaryUnsummoned() const;
|
||||
|
||||
void SendCinematicStart(uint32 CinematicSequenceId);
|
||||
void SendMovieStart(uint32 MovieId);
|
||||
@@ -2399,7 +2173,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload = false);
|
||||
InstancePlayerBind* BindToInstance(InstanceSave* save, bool permanent, bool load = false);
|
||||
void BindToInstance();
|
||||
void SetPendingBind(uint32 instanceId, uint32 bindTimer) { _pendingBindId = instanceId; _pendingBindTimer = bindTimer; }
|
||||
void SetPendingBind(uint32 instanceId, uint32 bindTimer);
|
||||
bool HasPendingBind() const { return _pendingBindId > 0; }
|
||||
void SendRaidInfo();
|
||||
void SendSavedInstances();
|
||||
@@ -2407,12 +2181,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false);
|
||||
bool CheckInstanceLoginValid();
|
||||
bool CheckInstanceCount(uint32 instanceId) const;
|
||||
|
||||
void AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
|
||||
{
|
||||
if (_instanceResetTimes.find(instanceId) == _instanceResetTimes.end())
|
||||
_instanceResetTimes.insert(InstanceTimeMap::value_type(instanceId, enterTime + HOUR));
|
||||
}
|
||||
void AddInstanceEnterTime(uint32 instanceId, time_t enterTime);
|
||||
|
||||
// last used pet number (for BG's)
|
||||
uint32 GetLastPetNumber() const { return m_lastpetnumber; }
|
||||
@@ -2466,9 +2235,9 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; }
|
||||
void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; }
|
||||
void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
|
||||
void SetRuneCooldown(uint8 index, uint32 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
|
||||
void SetRuneConvertAura(uint8 index, AuraEffect const* aura) { m_runes->runes[index].ConvertAura = aura; }
|
||||
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura) { SetRuneConvertAura(index, aura); ConvertRune(index, newType); }
|
||||
void SetRuneCooldown(uint8 index, uint32 cooldown);
|
||||
void SetRuneConvertAura(uint8 index, AuraEffect const* aura);
|
||||
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura);
|
||||
void RemoveRunesByAuraEffect(AuraEffect const* aura);
|
||||
void RestoreBaseRune(uint8 index);
|
||||
void ConvertRune(uint8 index, RuneType newType);
|
||||
@@ -2516,38 +2285,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }
|
||||
|
||||
//! Return collision height sent to client
|
||||
float GetCollisionHeight(bool mounted)
|
||||
{
|
||||
if (mounted)
|
||||
{
|
||||
CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID));
|
||||
if (!mountDisplayInfo)
|
||||
return GetCollisionHeight(false);
|
||||
|
||||
CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId);
|
||||
if (!mountModelData)
|
||||
return GetCollisionHeight(false);
|
||||
|
||||
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
|
||||
ASSERT(displayInfo);
|
||||
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
|
||||
ASSERT(modelData);
|
||||
|
||||
float scaleMod = GetFloatValue(OBJECT_FIELD_SCALE_X); // 99% sure about this
|
||||
|
||||
return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//! Dismounting case - use basic default model data
|
||||
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
|
||||
ASSERT(displayInfo);
|
||||
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
|
||||
ASSERT(modelData);
|
||||
|
||||
return modelData->CollisionHeight;
|
||||
}
|
||||
}
|
||||
float GetCollisionHeight(bool mounted) const;
|
||||
|
||||
protected:
|
||||
// Gamemaster whisper whitelist
|
||||
@@ -2717,8 +2455,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
int32 m_spellPenetrationItemMod;
|
||||
|
||||
SpellModList m_spellMods[MAX_SPELLMOD];
|
||||
//uint32 m_pad;
|
||||
// Spell* m_spellModTakingSpell; // Spell for which charges are dropped in spell::finish
|
||||
|
||||
EnchantDurationList m_enchantDuration;
|
||||
ItemDurationList m_itemDuration;
|
||||
@@ -2833,12 +2569,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; }
|
||||
bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; }
|
||||
void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
|
||||
|
||||
void ScheduleDelayedOperation(uint32 operation)
|
||||
{
|
||||
if (operation < DELAYED_END)
|
||||
m_DelayedOperations |= operation;
|
||||
}
|
||||
void ScheduleDelayedOperation(uint32 operation) { if (operation < DELAYED_END) m_DelayedOperations |= operation; }
|
||||
|
||||
MapReference m_mapRef;
|
||||
|
||||
|
||||
@@ -442,6 +442,12 @@ void Unit::resetAttackTimer(WeaponAttackType type)
|
||||
m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]);
|
||||
}
|
||||
|
||||
float Unit::GetMeleeReach() const
|
||||
{
|
||||
float reach = m_floatValues[UNIT_FIELD_COMBATREACH];
|
||||
return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH;
|
||||
}
|
||||
|
||||
bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const
|
||||
{
|
||||
if (!obj || !IsInMap(obj) || !InSamePhase(obj))
|
||||
@@ -487,6 +493,26 @@ void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z,
|
||||
, GetAngle(obj) + (attacker_number ? (static_cast<float>(M_PI/2) - static_cast<float>(M_PI) * (float)rand_norm()) * float(attacker_number) / combat_reach * 0.3f : 0));
|
||||
}
|
||||
|
||||
AuraApplication * Unit::GetVisibleAura(uint8 slot) const
|
||||
{
|
||||
VisibleAuraMap::const_iterator itr = m_visibleAuras.find(slot);
|
||||
if (itr != m_visibleAuras.end())
|
||||
return itr->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Unit::SetVisibleAura(uint8 slot, AuraApplication * aur)
|
||||
{
|
||||
m_visibleAuras[slot]=aur;
|
||||
UpdateAuraForGroup(slot);
|
||||
}
|
||||
|
||||
void Unit::RemoveVisibleAura(uint8 slot)
|
||||
{
|
||||
m_visibleAuras.erase(slot);
|
||||
UpdateAuraForGroup(slot);
|
||||
}
|
||||
|
||||
void Unit::UpdateInterruptMask()
|
||||
{
|
||||
m_interruptMask = 0;
|
||||
@@ -2242,6 +2268,17 @@ int32 Unit::GetMechanicResistChance(const SpellInfo* spell)
|
||||
return resist_mech;
|
||||
}
|
||||
|
||||
bool Unit::CanUseAttackType(uint8 attacktype) const
|
||||
{
|
||||
switch (attacktype)
|
||||
{
|
||||
case BASE_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
|
||||
case OFF_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_OFFHAND);
|
||||
case RANGED_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_RANGED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Melee based spells hit result calculations
|
||||
SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spell)
|
||||
{
|
||||
@@ -2582,6 +2619,26 @@ SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spell, bool Ca
|
||||
return SPELL_MISS_NONE;
|
||||
}
|
||||
|
||||
uint32 Unit::GetShieldBlockValue(uint32 soft_cap, uint32 hard_cap) const
|
||||
{
|
||||
uint32 value = GetShieldBlockValue();
|
||||
if (value >= hard_cap)
|
||||
{
|
||||
value = (soft_cap + hard_cap) / 2;
|
||||
}
|
||||
else if (value > soft_cap)
|
||||
{
|
||||
value = soft_cap + ((value - soft_cap) / 2);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint32 Unit::GetUnitMeleeSkill(Unit const* target) const
|
||||
{
|
||||
return (target ? getLevelForTarget(target) : getLevel()) * 5;
|
||||
}
|
||||
|
||||
uint32 Unit::GetDefenseSkillValue(Unit const* target) const
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -4110,6 +4167,11 @@ AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 f
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AuraEffect* Unit::GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
|
||||
{
|
||||
return GetAuraEffect(SPELL_AURA_DUMMY, name, iconId, effIndex);
|
||||
}
|
||||
|
||||
AuraApplication * Unit::GetAuraApplication(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, AuraApplication * except) const
|
||||
{
|
||||
AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId);
|
||||
@@ -4632,6 +4694,45 @@ int32 Unit::GetMaxNegativeAuraModifierByAffectMask(AuraType auratype, SpellInfo
|
||||
return modifier;
|
||||
}
|
||||
|
||||
float Unit::GetResistanceBuffMods(SpellSchools school, bool positive) const
|
||||
{
|
||||
return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school);
|
||||
}
|
||||
|
||||
void Unit::SetResistanceBuffMods(SpellSchools school, bool positive, float val)
|
||||
{
|
||||
SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val);
|
||||
}
|
||||
|
||||
void Unit::ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply)
|
||||
{
|
||||
ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply);
|
||||
}
|
||||
|
||||
void Unit::ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply)
|
||||
{
|
||||
ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply);
|
||||
}
|
||||
|
||||
void Unit::InitStatBuffMods()
|
||||
{
|
||||
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
|
||||
SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0);
|
||||
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
|
||||
SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0);
|
||||
}
|
||||
|
||||
void Unit::ApplyStatBuffMod(Stats stat, float val, bool apply)
|
||||
{
|
||||
ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply);
|
||||
}
|
||||
|
||||
void Unit::ApplyStatPercentBuffMod(Stats stat, float val, bool apply)
|
||||
{
|
||||
ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0+stat, val, apply);
|
||||
ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0+stat, val, apply);
|
||||
}
|
||||
|
||||
void Unit::_RegisterDynObject(DynamicObject* dynObj)
|
||||
{
|
||||
m_dynObj.push_back(dynObj);
|
||||
@@ -8805,6 +8906,27 @@ bool Unit::IsNeutralToAll() const
|
||||
return my_faction->IsNeutralToAll();
|
||||
}
|
||||
|
||||
void Unit::_addAttacker(Unit* pAttacker)
|
||||
{
|
||||
m_attackers.insert(pAttacker);
|
||||
}
|
||||
|
||||
void Unit::_removeAttacker(Unit* pAttacker)
|
||||
{
|
||||
m_attackers.erase(pAttacker);
|
||||
}
|
||||
|
||||
Unit* Unit::getAttackerForHelper() const // If someone wants to help, who to give them
|
||||
{
|
||||
if (getVictim() != NULL)
|
||||
return getVictim();
|
||||
|
||||
if (!m_attackers.empty())
|
||||
return *(m_attackers.begin());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Unit::Attack(Unit* victim, bool meleeAttack)
|
||||
{
|
||||
if (!victim || victim == this)
|
||||
@@ -9195,6 +9317,19 @@ Unit* Unit::GetCharm() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Unit* Unit::GetCharmerOrOwner() const
|
||||
{
|
||||
return GetCharmerGUID() ? GetCharmer() : GetOwner();
|
||||
}
|
||||
|
||||
Unit* Unit::GetCharmerOrOwnerOrSelf() const
|
||||
{
|
||||
if (Unit* u = GetCharmerOrOwner())
|
||||
return u;
|
||||
|
||||
return (Unit*)this;
|
||||
}
|
||||
|
||||
void Unit::SetMinion(Minion *minion, bool apply)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_UNITS, "SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply);
|
||||
@@ -9571,6 +9706,24 @@ void Unit::RemoveAllControlled()
|
||||
sLog->outFatal(LOG_FILTER_UNITS, "Unit %u is not able to release its charm " UI64FMTD, GetEntry(), GetCharmGUID());
|
||||
}
|
||||
|
||||
bool Unit::isPossessedByPlayer() const
|
||||
{
|
||||
return HasUnitState(UNIT_STATE_POSSESSED) && IS_PLAYER_GUID(GetCharmerGUID());
|
||||
}
|
||||
|
||||
bool Unit::isPossessing(Unit* u) const
|
||||
{
|
||||
return u->isPossessed() && GetCharmGUID() == u->GetGUID();
|
||||
}
|
||||
|
||||
bool Unit::isPossessing() const
|
||||
{
|
||||
if (Unit* u = GetCharm())
|
||||
return u->isPossessed();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
|
||||
{
|
||||
Player* player = NULL;
|
||||
@@ -11474,6 +11627,15 @@ void Unit::Dismount()
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::isServiceProvider() const
|
||||
{
|
||||
return HasFlag(UNIT_NPC_FLAGS,
|
||||
UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER |
|
||||
UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER |
|
||||
UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER |
|
||||
UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER);
|
||||
}
|
||||
|
||||
void Unit::SetInCombatWith(Unit* enemy)
|
||||
{
|
||||
Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf();
|
||||
@@ -11939,6 +12101,12 @@ int32 Unit::ModifyPowerPct(Powers power, float pct, bool apply)
|
||||
return ModifyPower(power, (int32)amount - (int32)GetMaxPower(power));
|
||||
}
|
||||
|
||||
uint32 Unit::GetAttackTime(WeaponAttackType att) const
|
||||
{
|
||||
float f_BaseAttackTime = GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att) / m_modAttackSpeedPct[att];
|
||||
return (uint32)f_BaseAttackTime;
|
||||
}
|
||||
|
||||
bool Unit::IsAlwaysVisibleFor(WorldObject const* seer) const
|
||||
{
|
||||
if (WorldObject::IsAlwaysVisibleFor(seer))
|
||||
@@ -11969,6 +12137,11 @@ bool Unit::IsAlwaysDetectableFor(WorldObject const* seer) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::IsVisible() const
|
||||
{
|
||||
return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true;
|
||||
}
|
||||
|
||||
void Unit::SetVisible(bool x)
|
||||
{
|
||||
if (!x)
|
||||
@@ -12878,6 +13051,30 @@ uint32 Unit::GetCreatureType() const
|
||||
return ToCreature()->GetCreatureTemplate()->type;
|
||||
}
|
||||
|
||||
uint32 Unit::GetCreatureTypeMask() const
|
||||
{
|
||||
uint32 creatureType = GetCreatureType();
|
||||
return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0;
|
||||
}
|
||||
|
||||
void Unit::SetShapeshiftForm(ShapeshiftForm form)
|
||||
{
|
||||
SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
|
||||
}
|
||||
|
||||
bool Unit::IsInFeralForm() const
|
||||
{
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
return form == FORM_CAT || form == FORM_BEAR || form == FORM_DIREBEAR;
|
||||
}
|
||||
|
||||
bool Unit::IsInDisallowedMountForm() const
|
||||
{
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
return form != FORM_NONE && form != FORM_BATTLESTANCE && form != FORM_BERSERKERSTANCE && form != FORM_DEFENSIVESTANCE &&
|
||||
form != FORM_SHADOW && form != FORM_STEALTH && form != FORM_UNDEAD;
|
||||
}
|
||||
|
||||
/*#######################################
|
||||
######## ########
|
||||
######## STAT SYSTEM ########
|
||||
@@ -13078,6 +13275,12 @@ float Unit::GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange typ
|
||||
return m_weaponDamage[attType][type];
|
||||
}
|
||||
|
||||
bool Unit::CanFreeMove() const
|
||||
{
|
||||
return !HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT |
|
||||
UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && GetOwnerGUID() == 0;
|
||||
}
|
||||
|
||||
void Unit::SetLevel(uint8 lvl)
|
||||
{
|
||||
SetUInt32Value(UNIT_FIELD_LEVEL, lvl);
|
||||
@@ -14158,6 +14361,18 @@ SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const
|
||||
return SPELL_SCHOOL_MASK_NORMAL;
|
||||
}
|
||||
|
||||
uint64 Unit::GetCharmerOrOwnerGUID() const
|
||||
{
|
||||
return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID();
|
||||
}
|
||||
|
||||
uint64 Unit::GetCharmerOrOwnerOrOwnGUID() const
|
||||
{
|
||||
if (uint64 guid = GetCharmerOrOwnerGUID())
|
||||
return guid;
|
||||
return GetGUID();
|
||||
}
|
||||
|
||||
Player* Unit::GetSpellModOwner() const
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -14576,6 +14791,17 @@ void Unit::UpdateAuraForGroup(uint8 slot)
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::SetCantProc(bool apply)
|
||||
{
|
||||
if (apply)
|
||||
++m_procDeep;
|
||||
else
|
||||
{
|
||||
ASSERT(m_procDeep);
|
||||
--m_procDeep;
|
||||
}
|
||||
}
|
||||
|
||||
float Unit::CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffectType damagetype) const
|
||||
{
|
||||
// Damage over Time spells bonus calculation
|
||||
@@ -15208,6 +15434,15 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
|
||||
}
|
||||
}
|
||||
|
||||
float Unit::GetPositionZMinusOffset() const
|
||||
{
|
||||
float offset = 0.0f;
|
||||
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
|
||||
offset = GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
|
||||
|
||||
return GetPositionZ() - offset;
|
||||
}
|
||||
|
||||
void Unit::SetControlled(bool apply, UnitState state)
|
||||
{
|
||||
if (apply)
|
||||
@@ -15732,6 +15967,11 @@ void Unit::RestoreFaction()
|
||||
}
|
||||
}
|
||||
|
||||
Unit* Unit::GetRedirectThreatTarget()
|
||||
{
|
||||
return _redirectThreadInfo.GetTargetGUID() ? GetUnit(*this, _redirectThreadInfo.GetTargetGUID()) : NULL;
|
||||
}
|
||||
|
||||
bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry)
|
||||
{
|
||||
VehicleEntry const* vehInfo = sVehicleStore.LookupEntry(id);
|
||||
@@ -15760,6 +16000,11 @@ void Unit::RemoveVehicleKit()
|
||||
RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE);
|
||||
}
|
||||
|
||||
bool Unit::IsOnVehicle(const Unit* vehicle) const
|
||||
{
|
||||
return m_vehicle && m_vehicle == vehicle->GetVehicleKit();
|
||||
}
|
||||
|
||||
Unit* Unit::GetVehicleBase() const
|
||||
{
|
||||
return m_vehicle ? m_vehicle->GetBase() : NULL;
|
||||
@@ -15866,6 +16111,22 @@ void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap)
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::IsContestedGuard() const
|
||||
{
|
||||
if (FactionTemplateEntry const* entry = getFactionTemplateEntry())
|
||||
return entry->IsContestedGuardFaction();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Unit::SetPvP(bool state)
|
||||
{
|
||||
if (state)
|
||||
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
|
||||
else
|
||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
|
||||
}
|
||||
|
||||
Aura* Unit::AddAura(uint32 spellId, Unit* target)
|
||||
{
|
||||
if (!target)
|
||||
@@ -16823,6 +17084,11 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
return (relocated || turn);
|
||||
}
|
||||
|
||||
bool Unit::UpdatePosition(const Position &pos, bool teleport)
|
||||
{
|
||||
return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport);
|
||||
}
|
||||
|
||||
//! Only server-side orientation update, does not broadcast to client
|
||||
void Unit::UpdateOrientation(float orientation)
|
||||
{
|
||||
@@ -17245,6 +17511,12 @@ void Unit::SendMovementCanFlyChange()
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
void Unit::SetTarget(uint64 guid)
|
||||
{
|
||||
if (!_focusSpell)
|
||||
SetUInt64Value(UNIT_FIELD_TARGET, guid);
|
||||
}
|
||||
|
||||
void Unit::FocusTarget(Spell const* focusSpell, WorldObject const* target)
|
||||
{
|
||||
// already focused
|
||||
|
||||
@@ -974,8 +974,8 @@ struct RedirectThreatInfo
|
||||
uint64 _targetGUID;
|
||||
uint32 _threatPct;
|
||||
|
||||
uint64 GetTargetGUID() { return _targetGUID; }
|
||||
uint32 GetThreatPct() { return _threatPct; }
|
||||
uint64 GetTargetGUID() const { return _targetGUID; }
|
||||
uint32 GetThreatPct() const { return _threatPct; }
|
||||
|
||||
void Set(uint64 guid, uint32 pct)
|
||||
{
|
||||
@@ -1277,31 +1277,16 @@ class Unit : public WorldObject
|
||||
bool CanDualWield() const { return m_canDualWield; }
|
||||
void SetCanDualWield(bool value) { m_canDualWield = value; }
|
||||
float GetCombatReach() const { return m_floatValues[UNIT_FIELD_COMBATREACH]; }
|
||||
float GetMeleeReach() const { float reach = m_floatValues[UNIT_FIELD_COMBATREACH]; return reach > MIN_MELEE_REACH ? reach : MIN_MELEE_REACH; }
|
||||
float GetMeleeReach() const;
|
||||
bool IsWithinCombatRange(const Unit* obj, float dist2compare) const;
|
||||
bool IsWithinMeleeRange(const Unit* obj, float dist = MELEE_RANGE) const;
|
||||
void GetRandomContactPoint(const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const;
|
||||
uint32 m_extraAttacks;
|
||||
bool m_canDualWield;
|
||||
|
||||
void _addAttacker(Unit* pAttacker) // must be called only from Unit::Attack(Unit*)
|
||||
{
|
||||
m_attackers.insert(pAttacker);
|
||||
}
|
||||
void _removeAttacker(Unit* pAttacker) // must be called only from Unit::AttackStop()
|
||||
{
|
||||
m_attackers.erase(pAttacker);
|
||||
}
|
||||
Unit* getAttackerForHelper() const // If someone wants to help, who to give them
|
||||
{
|
||||
if (getVictim() != NULL)
|
||||
return getVictim();
|
||||
|
||||
if (!m_attackers.empty())
|
||||
return *(m_attackers.begin());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void _addAttacker(Unit* pAttacker); // must be called only from Unit::Attack(Unit*)
|
||||
void _removeAttacker(Unit* pAttacker); // must be called only from Unit::AttackStop()
|
||||
Unit* getAttackerForHelper() const; // If someone wants to help, who to give them
|
||||
bool Attack(Unit* victim, bool meleeAttack);
|
||||
void CastStop(uint32 except_spellid = 0);
|
||||
bool AttackStop();
|
||||
@@ -1320,11 +1305,7 @@ class Unit : public WorldObject
|
||||
void AddUnitState(uint32 f) { m_state |= f; }
|
||||
bool HasUnitState(const uint32 f) const { return (m_state & f); }
|
||||
void ClearUnitState(uint32 f) { m_state &= ~f; }
|
||||
bool CanFreeMove() const
|
||||
{
|
||||
return !HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT |
|
||||
UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && GetOwnerGUID() == 0;
|
||||
}
|
||||
bool CanFreeMove() const;
|
||||
|
||||
uint32 HasUnitTypeMask(uint32 mask) const { return mask & m_unitTypeMask; }
|
||||
void AddUnitTypeMask(uint32 mask) { m_unitTypeMask |= mask; }
|
||||
@@ -1381,12 +1362,7 @@ class Unit : public WorldObject
|
||||
int32 ModifyPower(Powers power, int32 val);
|
||||
int32 ModifyPowerPct(Powers power, float pct, bool apply = true);
|
||||
|
||||
uint32 GetAttackTime(WeaponAttackType att) const
|
||||
{
|
||||
float f_BaseAttackTime = GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att) / m_modAttackSpeedPct[att];
|
||||
return (uint32)f_BaseAttackTime;
|
||||
}
|
||||
|
||||
uint32 GetAttackTime(WeaponAttackType att) const;
|
||||
void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att, val*m_modAttackSpeedPct[att]); }
|
||||
void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply);
|
||||
void ApplyCastTimePercentMod(float val, bool apply);
|
||||
@@ -1409,27 +1385,11 @@ class Unit : public WorldObject
|
||||
bool IsInPartyWith(Unit const* unit) const;
|
||||
bool IsInRaidWith(Unit const* unit) const;
|
||||
void GetPartyMembers(std::list<Unit*> &units);
|
||||
bool IsContestedGuard() const
|
||||
{
|
||||
if (FactionTemplateEntry const* entry = getFactionTemplateEntry())
|
||||
return entry->IsContestedGuardFaction();
|
||||
|
||||
return false;
|
||||
}
|
||||
bool IsContestedGuard() const;
|
||||
bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); }
|
||||
void SetPvP(bool state)
|
||||
{
|
||||
if (state)
|
||||
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
|
||||
else
|
||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
|
||||
}
|
||||
void SetPvP(bool state);
|
||||
uint32 GetCreatureType() const;
|
||||
uint32 GetCreatureTypeMask() const
|
||||
{
|
||||
uint32 creatureType = GetCreatureType();
|
||||
return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0;
|
||||
}
|
||||
uint32 GetCreatureTypeMask() const;
|
||||
|
||||
uint8 getStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1, 0); }
|
||||
bool IsSitState() const;
|
||||
@@ -1496,33 +1456,11 @@ class Unit : public WorldObject
|
||||
float GetUnitMissChance(WeaponAttackType attType) const;
|
||||
float GetUnitCriticalChance(WeaponAttackType attackType, const Unit* victim) const;
|
||||
int32 GetMechanicResistChance(const SpellInfo* spell);
|
||||
bool CanUseAttackType(uint8 attacktype) const
|
||||
{
|
||||
switch (attacktype)
|
||||
{
|
||||
case BASE_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
|
||||
case OFF_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_OFFHAND);
|
||||
case RANGED_ATTACK: return !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_RANGED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool CanUseAttackType(uint8 attacktype) const;
|
||||
|
||||
virtual uint32 GetShieldBlockValue() const =0;
|
||||
uint32 GetShieldBlockValue(uint32 soft_cap, uint32 hard_cap) const
|
||||
{
|
||||
uint32 value = GetShieldBlockValue();
|
||||
if (value >= hard_cap)
|
||||
{
|
||||
value = (soft_cap + hard_cap) / 2;
|
||||
}
|
||||
else if (value > soft_cap)
|
||||
{
|
||||
value = soft_cap + ((value - soft_cap) / 2);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
|
||||
uint32 GetShieldBlockValue(uint32 soft_cap, uint32 hard_cap) const;
|
||||
uint32 GetUnitMeleeSkill(Unit const* target = NULL) const;
|
||||
uint32 GetDefenseSkillValue(Unit const* target = NULL) const;
|
||||
uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const;
|
||||
float GetWeaponProcChance() const;
|
||||
@@ -1545,14 +1483,7 @@ class Unit : public WorldObject
|
||||
bool isTabardDesigner()const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER); }
|
||||
bool isAuctioner() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER); }
|
||||
bool isArmorer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR); }
|
||||
bool isServiceProvider() const
|
||||
{
|
||||
return HasFlag(UNIT_NPC_FLAGS,
|
||||
UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER |
|
||||
UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER |
|
||||
UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER |
|
||||
UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER);
|
||||
}
|
||||
bool isServiceProvider() const;
|
||||
bool isSpiritService() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); }
|
||||
|
||||
bool isInFlight() const { return HasUnitState(UNIT_STATE_IN_FLIGHT); }
|
||||
@@ -1628,7 +1559,7 @@ class Unit : public WorldObject
|
||||
void SendTeleportPacket(Position& pos);
|
||||
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false);
|
||||
// returns true if unit's position really changed
|
||||
bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
|
||||
bool UpdatePosition(const Position &pos, bool teleport = false);
|
||||
void UpdateOrientation(float orientation);
|
||||
void UpdateHeight(float newZ);
|
||||
|
||||
@@ -1692,13 +1623,8 @@ class Unit : public WorldObject
|
||||
uint64 GetCritterGUID() const { return GetUInt64Value(UNIT_FIELD_CRITTER); }
|
||||
|
||||
bool IsControlledByPlayer() const { return m_ControlledByPlayer; }
|
||||
uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
|
||||
uint64 GetCharmerOrOwnerOrOwnGUID() const
|
||||
{
|
||||
if (uint64 guid = GetCharmerOrOwnerGUID())
|
||||
return guid;
|
||||
return GetGUID();
|
||||
}
|
||||
uint64 GetCharmerOrOwnerGUID() const;
|
||||
uint64 GetCharmerOrOwnerOrOwnGUID() const;
|
||||
bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); }
|
||||
|
||||
Player* GetSpellModOwner() const;
|
||||
@@ -1708,14 +1634,8 @@ class Unit : public WorldObject
|
||||
Minion *GetFirstMinion() const;
|
||||
Unit* GetCharmer() const;
|
||||
Unit* GetCharm() const;
|
||||
Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); }
|
||||
Unit* GetCharmerOrOwnerOrSelf() const
|
||||
{
|
||||
if (Unit* u = GetCharmerOrOwner())
|
||||
return u;
|
||||
|
||||
return (Unit*)this;
|
||||
}
|
||||
Unit* GetCharmerOrOwner() const;
|
||||
Unit* GetCharmerOrOwnerOrSelf() const;
|
||||
Player* GetCharmerOrOwnerPlayerOrPlayerItself() const;
|
||||
Player* GetAffectingPlayer() const;
|
||||
|
||||
@@ -1734,15 +1654,9 @@ class Unit : public WorldObject
|
||||
|
||||
bool isCharmed() const { return GetCharmerGUID() != 0; }
|
||||
bool isPossessed() const { return HasUnitState(UNIT_STATE_POSSESSED); }
|
||||
bool isPossessedByPlayer() const { return HasUnitState(UNIT_STATE_POSSESSED) && IS_PLAYER_GUID(GetCharmerGUID()); }
|
||||
bool isPossessing() const
|
||||
{
|
||||
if (Unit* u = GetCharm())
|
||||
return u->isPossessed();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
bool isPossessing(Unit* u) const { return u->isPossessed() && GetCharmGUID() == u->GetGUID(); }
|
||||
bool isPossessedByPlayer() const;
|
||||
bool isPossessing() const;
|
||||
bool isPossessing(Unit* u) const;
|
||||
|
||||
CharmInfo* GetCharmInfo() { return m_charmInfo; }
|
||||
CharmInfo* InitCharmInfo();
|
||||
@@ -1825,7 +1739,7 @@ class Unit : public WorldObject
|
||||
AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, uint64 casterGUID = 0) const;
|
||||
AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; // spell mustn't have familyflags
|
||||
AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID =0);
|
||||
inline AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const { return GetAuraEffect(SPELL_AURA_DUMMY, name, iconId, effIndex);}
|
||||
AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const;
|
||||
|
||||
AuraApplication * GetAuraApplication(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, AuraApplication * except = NULL) const;
|
||||
Aura* GetAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0) const;
|
||||
@@ -1871,21 +1785,13 @@ class Unit : public WorldObject
|
||||
int32 GetMaxPositiveAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const;
|
||||
int32 GetMaxNegativeAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const;
|
||||
|
||||
float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school); }
|
||||
void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val); }
|
||||
void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); }
|
||||
void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); }
|
||||
void InitStatBuffMods()
|
||||
{
|
||||
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0);
|
||||
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0);
|
||||
}
|
||||
void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply); }
|
||||
void ApplyStatPercentBuffMod(Stats stat, float val, bool apply)
|
||||
{
|
||||
ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0+stat, val, apply);
|
||||
ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0+stat, val, apply);
|
||||
}
|
||||
float GetResistanceBuffMods(SpellSchools school, bool positive) const;
|
||||
void SetResistanceBuffMods(SpellSchools school, bool positive, float val);
|
||||
void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply);
|
||||
void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply);
|
||||
void InitStatBuffMods();
|
||||
void ApplyStatBuffMod(Stats stat, float val, bool apply);
|
||||
void ApplyStatPercentBuffMod(Stats stat, float val, bool apply);
|
||||
void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; }
|
||||
void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); }
|
||||
uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
|
||||
@@ -1920,23 +1826,11 @@ class Unit : public WorldObject
|
||||
uint64 m_ObjectSlot[MAX_GAMEOBJECT_SLOT];
|
||||
|
||||
ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, 3)); }
|
||||
void SetShapeshiftForm(ShapeshiftForm form)
|
||||
{
|
||||
SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
|
||||
}
|
||||
void SetShapeshiftForm(ShapeshiftForm form);
|
||||
|
||||
inline bool IsInFeralForm() const
|
||||
{
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
return form == FORM_CAT || form == FORM_BEAR || form == FORM_DIREBEAR;
|
||||
}
|
||||
bool IsInFeralForm() const;
|
||||
|
||||
inline bool IsInDisallowedMountForm() const
|
||||
{
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
return form != FORM_NONE && form != FORM_BATTLESTANCE && form != FORM_BERSERKERSTANCE && form != FORM_DEFENSIVESTANCE &&
|
||||
form != FORM_SHADOW && form != FORM_STEALTH && form != FORM_UNDEAD;
|
||||
}
|
||||
bool IsInDisallowedMountForm() const;
|
||||
|
||||
float m_modMeleeHitChance;
|
||||
float m_modRangedHitChance;
|
||||
@@ -1976,7 +1870,7 @@ class Unit : public WorldObject
|
||||
bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const;
|
||||
|
||||
// Visibility system
|
||||
bool IsVisible() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; }
|
||||
bool IsVisible() const;
|
||||
void SetVisible(bool x);
|
||||
|
||||
// common function for visibility checks for player/creatures with detection code
|
||||
@@ -1999,23 +1893,17 @@ class Unit : public WorldObject
|
||||
HostileRefManager& getHostileRefManager() { return m_HostileRefManager; }
|
||||
|
||||
VisibleAuraMap const* GetVisibleAuras() { return &m_visibleAuras; }
|
||||
AuraApplication * GetVisibleAura(uint8 slot)
|
||||
{
|
||||
VisibleAuraMap::iterator itr = m_visibleAuras.find(slot);
|
||||
if (itr != m_visibleAuras.end())
|
||||
return itr->second;
|
||||
return 0;
|
||||
}
|
||||
void SetVisibleAura(uint8 slot, AuraApplication * aur){ m_visibleAuras[slot]=aur; UpdateAuraForGroup(slot);}
|
||||
void RemoveVisibleAura(uint8 slot){ m_visibleAuras.erase(slot); UpdateAuraForGroup(slot);}
|
||||
AuraApplication * GetVisibleAura(uint8 slot) const;
|
||||
void SetVisibleAura(uint8 slot, AuraApplication * aur);
|
||||
void RemoveVisibleAura(uint8 slot);
|
||||
|
||||
uint32 GetInterruptMask() const { return m_interruptMask; }
|
||||
void AddInterruptMask(uint32 mask) { m_interruptMask |= mask; }
|
||||
void UpdateInterruptMask();
|
||||
|
||||
uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
|
||||
uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
|
||||
void SetDisplayId(uint32 modelId);
|
||||
uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
|
||||
uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
|
||||
void RestoreDisplayId();
|
||||
void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); }
|
||||
void setTransForm(uint32 spellid) { m_transform = spellid;}
|
||||
@@ -2124,14 +2012,7 @@ class Unit : public WorldObject
|
||||
uint16 GetExtraUnitMovementFlags() const { return m_movementInfo.flags2; }
|
||||
void SetExtraUnitMovementFlags(uint16 f) { m_movementInfo.flags2 = f; }
|
||||
|
||||
float GetPositionZMinusOffset() const
|
||||
{
|
||||
float offset = 0.0f;
|
||||
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
|
||||
offset = GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
|
||||
|
||||
return GetPositionZ() - offset;
|
||||
}
|
||||
float GetPositionZMinusOffset() const;
|
||||
|
||||
void SetControlled(bool apply, UnitState state);
|
||||
|
||||
@@ -2157,17 +2038,8 @@ class Unit : public WorldObject
|
||||
void UpdateAuraForGroup(uint8 slot);
|
||||
|
||||
// proc trigger system
|
||||
bool CanProc(){return !m_procDeep;}
|
||||
void SetCantProc(bool apply)
|
||||
{
|
||||
if (apply)
|
||||
++m_procDeep;
|
||||
else
|
||||
{
|
||||
ASSERT(m_procDeep);
|
||||
--m_procDeep;
|
||||
}
|
||||
}
|
||||
bool CanProc() const {return !m_procDeep;}
|
||||
void SetCantProc(bool apply);
|
||||
|
||||
// pet auras
|
||||
typedef std::set<PetAura const*> PetAuraSet;
|
||||
@@ -2182,8 +2054,8 @@ class Unit : public WorldObject
|
||||
void SetRedirectThreat(uint64 guid, uint32 pct) { _redirectThreadInfo.Set(guid, pct); }
|
||||
void ResetRedirectThreat() { SetRedirectThreat(0, 0); }
|
||||
void ModifyRedirectThreat(int32 amount) { _redirectThreadInfo.ModifyThreatPct(amount); }
|
||||
uint32 GetRedirectThreatPercent() { return _redirectThreadInfo.GetThreatPct(); }
|
||||
Unit* GetRedirectThreatTarget() { return _redirectThreadInfo.GetTargetGUID() ? GetUnit(*this, _redirectThreadInfo.GetTargetGUID()) : NULL; }
|
||||
uint32 GetRedirectThreatPercent() const { return _redirectThreadInfo.GetThreatPct(); }
|
||||
Unit* GetRedirectThreatTarget();
|
||||
|
||||
friend class VehicleJoinEvent;
|
||||
bool IsAIEnabled, NeedChangeAI;
|
||||
@@ -2191,7 +2063,7 @@ class Unit : public WorldObject
|
||||
void RemoveVehicleKit();
|
||||
Vehicle* GetVehicleKit()const { return m_vehicleKit; }
|
||||
Vehicle* GetVehicle() const { return m_vehicle; }
|
||||
bool IsOnVehicle(const Unit* vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); }
|
||||
bool IsOnVehicle(const Unit* vehicle) const;
|
||||
Unit* GetVehicleBase() const;
|
||||
Creature* GetVehicleCreatureBase() const;
|
||||
float GetTransOffsetX() const { return m_movementInfo.t_pos.GetPositionX(); }
|
||||
@@ -2236,11 +2108,7 @@ class Unit : public WorldObject
|
||||
TempSummon* ToTempSummon() { if (isSummon()) return reinterpret_cast<TempSummon*>(this); else return NULL; }
|
||||
const TempSummon* ToTempSummon() const { if (isSummon()) return reinterpret_cast<const TempSummon*>(this); else return NULL; }
|
||||
|
||||
void SetTarget(uint64 guid)
|
||||
{
|
||||
if (!_focusSpell)
|
||||
SetUInt64Value(UNIT_FIELD_TARGET, guid);
|
||||
}
|
||||
void SetTarget(uint64 guid);
|
||||
|
||||
// Handling caster facing during spellcast
|
||||
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
|
||||
|
||||
Reference in new issue
Block a user