Core/Auras: If the creature whose model is used for SPELL_AURA_TRANSFORM is a trigger, apply trigger model rules to the creature as well

This commit is contained in:
Shauren
2011-08-28 17:36:02 +02:00
parent 28a8732c8b
commit b94a6f63c5
3 changed files with 73 additions and 59 deletions
+47 -37
View File
@@ -532,7 +532,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
if (index == UNIT_NPC_FLAGS) if (index == UNIT_NPC_FLAGS)
{ {
// remove custom flag before sending // remove custom flag before sending
uint32 appendValue = m_uint32Values[ index ]; uint32 appendValue = m_uint32Values[index];
if (GetTypeId() == TYPEID_UNIT) if (GetTypeId() == TYPEID_UNIT)
{ {
@@ -557,7 +557,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
else if (index >= UNIT_FIELD_BASEATTACKTIME && index <= UNIT_FIELD_RANGEDATTACKTIME) else if (index >= UNIT_FIELD_BASEATTACKTIME && index <= UNIT_FIELD_RANGEDATTACKTIME)
{ {
// convert from float to uint32 and send // convert from float to uint32 and send
*data << uint32(m_floatValues[ index ] < 0 ? 0 : m_floatValues[ index ]); *data << uint32(m_floatValues[index] < 0 ? 0 : m_floatValues[index]);
} }
// there are some float values which may be negative or can't get negative due to other checks // there are some float values which may be negative or can't get negative due to other checks
else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) || else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) ||
@@ -565,22 +565,33 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
(index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) || (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) ||
(index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4)) (index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4))
{ {
*data << uint32(m_floatValues[ index ]); *data << uint32(m_floatValues[index]);
} }
// Gamemasters should be always able to select units - remove not selectable flag // Gamemasters should be always able to select units - remove not selectable flag
else if (index == UNIT_FIELD_FLAGS) else if (index == UNIT_FIELD_FLAGS)
{ {
if (target->isGameMaster()) if (target->isGameMaster())
*data << (m_uint32Values[ index ] & ~UNIT_FLAG_NOT_SELECTABLE); *data << (m_uint32Values[index] & ~UNIT_FLAG_NOT_SELECTABLE);
else else
*data << m_uint32Values[ index ]; *data << m_uint32Values[index];
} }
// use modelid_a if not gm, _h if gm for CREATURE_FLAG_EXTRA_TRIGGER creatures // use modelid_a if not gm, _h if gm for CREATURE_FLAG_EXTRA_TRIGGER creatures
else if (index == UNIT_FIELD_DISPLAYID) else if (index == UNIT_FIELD_DISPLAYID)
{ {
if (GetTypeId() == TYPEID_UNIT) if (GetTypeId() == TYPEID_UNIT)
{ {
const CreatureTemplate* cinfo = this->ToCreature()->GetCreatureInfo(); CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo();
// this also applies for transform auras
if (SpellInfo const* transform = sSpellMgr->GetSpellInfo(ToUnit()->getTransForm()))
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (transform->Effects[i].IsAura(SPELL_AURA_TRANSFORM))
if (CreatureTemplate const* transformInfo = sObjectMgr->GetCreatureTemplate(transform->Effects[i].MiscValue))
{
cinfo = transformInfo;
break;
}
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
{ {
if (target->isGameMaster()) if (target->isGameMaster())
@@ -599,10 +610,10 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
} }
} }
else else
*data << m_uint32Values[ index ]; *data << m_uint32Values[index];
} }
else else
*data << m_uint32Values[ index ]; *data << m_uint32Values[index];
} }
// hide lootable animation for unallowed players // hide lootable animation for unallowed players
else if (index == UNIT_DYNAMIC_FLAGS) else if (index == UNIT_DYNAMIC_FLAGS)
@@ -615,7 +626,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
{ {
if (creature->isTappedBy(target)) if (creature->isTappedBy(target))
{ {
dynamicFlags |= (UNIT_DYNFLAG_TAPPED|UNIT_DYNFLAG_TAPPED_BY_PLAYER); dynamicFlags |= (UNIT_DYNFLAG_TAPPED | UNIT_DYNFLAG_TAPPED_BY_PLAYER);
} }
else else
{ {
@@ -638,17 +649,17 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
// FG: pretend that OTHER players in own group are friendly ("blue") // FG: pretend that OTHER players in own group are friendly ("blue")
else if (index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE) else if (index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE)
{ {
if (((Unit*)this)->IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && ((Unit*)this)->IsInRaidWith(target)) Unit const* unit = ToUnit();
if (unit->IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && unit->IsInRaidWith(target))
{ {
FactionTemplateEntry const *ft1, *ft2; FactionTemplateEntry const* ft1 = unit->getFactionTemplateEntry();
ft1 = ((Unit*)this)->getFactionTemplateEntry(); FactionTemplateEntry const* ft2 = target->getFactionTemplateEntry();
ft2 = target->getFactionTemplateEntry();
if (ft1 && ft2 && !ft1->IsFriendlyTo(*ft2)) if (ft1 && ft2 && !ft1->IsFriendlyTo(*ft2))
{ {
if (index == UNIT_FIELD_BYTES_2) if (index == UNIT_FIELD_BYTES_2)
{ {
// Allow targetting opposite faction in party when enabled in config // Allow targetting opposite faction in party when enabled in config
*data << (m_uint32Values[ index ] & ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8)); // this flag is at uint8 offset 1 !! *data << (m_uint32Values[index] & ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8)); // this flag is at uint8 offset 1 !!
} }
else else
{ {
@@ -658,15 +669,15 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
} }
} }
else else
*data << m_uint32Values[ index ]; *data << m_uint32Values[index];
} }
else else
*data << m_uint32Values[ index ]; *data << m_uint32Values[index];
} }
else else
{ {
// send in current format (float as float, uint32 as uint32) // send in current format (float as float, uint32 as uint32)
*data << m_uint32Values[ index ]; *data << m_uint32Values[index];
} }
} }
} }
@@ -682,7 +693,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
{ {
if (IsActivateToQuest) if (IsActivateToQuest)
{ {
switch(((GameObject*)this)->GetGoType()) switch (ToGameObject()->GetGoType())
{ {
case GAMEOBJECT_TYPE_CHEST: case GAMEOBJECT_TYPE_CHEST:
if (target->isGameMaster()) if (target->isGameMaster())
@@ -720,7 +731,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
} }
} }
else else
*data << m_uint32Values[ index ]; // other cases *data << m_uint32Values[index]; // other cases
} }
} }
} }
@@ -731,7 +742,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
if (updateMask->GetBit(index)) if (updateMask->GetBit(index))
{ {
// send in current format (float as float, uint32 as uint32) // send in current format (float as float, uint32 as uint32)
*data << m_uint32Values[ index ]; *data << m_uint32Values[index];
} }
} }
} }
@@ -749,7 +760,7 @@ void Object::ClearUpdateMask(bool remove)
} }
} }
void Object::BuildFieldsUpdate(Player *pl, UpdateDataMapType &data_map) const void Object::BuildFieldsUpdate(Player* pl, UpdateDataMapType& data_map) const
{ {
UpdateDataMapType::iterator iter = data_map.find(pl); UpdateDataMapType::iterator iter = data_map.find(pl);
@@ -777,7 +788,7 @@ void Object::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 cou
m_uint32Values[startOffset + index] = atol(tokens[index]); m_uint32Values[startOffset + index] = atol(tokens[index]);
} }
void Object::_SetUpdateBits(UpdateMask *updateMask, Player* /*target*/) const void Object::_SetUpdateBits(UpdateMask* updateMask, Player* /*target*/) const
{ {
uint32 *value = m_uint32Values; uint32 *value = m_uint32Values;
uint32 *mirror = m_uint32Values_mirror; uint32 *mirror = m_uint32Values_mirror;
@@ -789,9 +800,9 @@ void Object::_SetUpdateBits(UpdateMask *updateMask, Player* /*target*/) const
} }
} }
void Object::_SetCreateBits(UpdateMask *updateMask, Player* /*target*/) const void Object::_SetCreateBits(UpdateMask* updateMask, Player* /*target*/) const
{ {
uint32 *value = m_uint32Values; uint32* value = m_uint32Values;
for (uint16 index = 0; index < m_valuesCount; ++index, ++value) for (uint16 index = 0; index < m_valuesCount; ++index, ++value)
{ {
@@ -845,7 +856,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value)
m_uint32Values[ index ] = value; m_uint32Values[ index ] = value;
} }
void Object::SetUInt64Value(uint16 index, const uint64 value) void Object::SetUInt64Value(uint16 index, uint64 const value)
{ {
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (*((uint64*)&(m_uint32Values[ index ])) != value) if (*((uint64*)&(m_uint32Values[ index ])) != value)
@@ -864,7 +875,7 @@ void Object::SetUInt64Value(uint16 index, const uint64 value)
} }
} }
bool Object::AddUInt64Value(uint16 index, const uint64 value) bool Object::AddUInt64Value(uint16 index, uint64 const value)
{ {
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , true)); ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , true));
if (value && !*((uint64*)&(m_uint32Values[index]))) if (value && !*((uint64*)&(m_uint32Values[index])))
@@ -901,8 +912,10 @@ bool Object::RemoveUInt64Value(uint16 index, const uint64 value)
m_objectUpdated = true; m_objectUpdated = true;
} }
} }
return true; return true;
} }
return false; return false;
} }
@@ -1127,7 +1140,7 @@ bool Object::PrintIndexError(uint32 index, bool set) const
return false; return false;
} }
bool Position::HasInLine(const Unit* const target, float distance, float width) const bool Position::HasInLine(Unit const* target, float distance, float width) const
{ {
if (!HasInArc(M_PI, target) || !target->IsWithinDist3d(m_positionX, m_positionY, m_positionZ, distance)) if (!HasInArc(M_PI, target) || !target->IsWithinDist3d(m_positionX, m_positionY, m_positionZ, distance))
return false; return false;
@@ -1143,14 +1156,14 @@ std::string Position::ToString() const
return sstr.str(); return sstr.str();
} }
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer) ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
{ {
float x, y, z, o; float x, y, z, o;
buf >> x >> y >> z >> o; buf >> x >> y >> z >> o;
streamer.m_pos->Relocate(x, y, z, o); streamer.m_pos->Relocate(x, y, z, o);
return buf; return buf;
} }
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer) ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
{ {
float x, y, z; float x, y, z;
streamer.m_pos->GetPosition(x, y, z); streamer.m_pos->GetPosition(x, y, z);
@@ -1158,7 +1171,7 @@ ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & s
return buf; return buf;
} }
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer) ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
{ {
float x, y, z; float x, y, z;
buf >> x >> y >> z; buf >> x >> y >> z;
@@ -1166,7 +1179,7 @@ ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & st
return buf; return buf;
} }
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer) ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
{ {
float x, y, z, o; float x, y, z, o;
streamer.m_pos->GetPosition(x, y, z, o); streamer.m_pos->GetPosition(x, y, z, o);
@@ -1192,19 +1205,16 @@ void MovementInfo::OutDebug()
if (flags2 & MOVEMENTFLAG2_INTERPOLATED_MOVEMENT) if (flags2 & MOVEMENTFLAG2_INTERPOLATED_MOVEMENT)
sLog->outString("time2: %u", t_time2); sLog->outString("time2: %u", t_time2);
} }
if ((flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (flags2 & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING)) if ((flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (flags2 & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
{
sLog->outString("pitch: %f", pitch); sLog->outString("pitch: %f", pitch);
}
sLog->outString("fallTime: %u", fallTime); sLog->outString("fallTime: %u", fallTime);
if (flags & MOVEMENTFLAG_JUMPING) if (flags & MOVEMENTFLAG_JUMPING)
{
sLog->outString("j_zspeed: %f j_sinAngle: %f j_cosAngle: %f j_xyspeed: %f", j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed); sLog->outString("j_zspeed: %f j_sinAngle: %f j_cosAngle: %f j_xyspeed: %f", j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed);
}
if (flags & MOVEMENTFLAG_SPLINE_ELEVATION) if (flags & MOVEMENTFLAG_SPLINE_ELEVATION)
{
sLog->outString("splineElevation: %f", splineElevation); sLog->outString("splineElevation: %f", splineElevation);
}
} }
WorldObject::WorldObject(): WorldLocation(), WorldObject::WorldObject(): WorldLocation(),
+19 -19
View File
@@ -172,54 +172,54 @@ class Object
int32 GetInt32Value(uint16 index) const int32 GetInt32Value(uint16 index) const
{ {
ASSERT(index < m_valuesCount || PrintIndexError(index , false)); ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return m_int32Values[ index ]; return m_int32Values[index];
} }
uint32 GetUInt32Value(uint16 index) const uint32 GetUInt32Value(uint16 index) const
{ {
ASSERT(index < m_valuesCount || PrintIndexError(index , false)); ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return m_uint32Values[ index ]; return m_uint32Values[index];
} }
uint64 GetUInt64Value(uint16 index) const uint64 GetUInt64Value(uint16 index) const
{ {
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , false)); ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , false));
return *((uint64*)&(m_uint32Values[ index ])); return *((uint64*)&(m_uint32Values[index]));
} }
float GetFloatValue(uint16 index) const float GetFloatValue(uint16 index) const
{ {
ASSERT(index < m_valuesCount || PrintIndexError(index , false)); ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return m_floatValues[ index ]; return m_floatValues[index];
} }
uint8 GetByteValue(uint16 index, uint8 offset) const uint8 GetByteValue(uint16 index, uint8 offset) const
{ {
ASSERT(index < m_valuesCount || PrintIndexError(index , false)); ASSERT(index < m_valuesCount || PrintIndexError(index , false));
ASSERT(offset < 4); ASSERT(offset < 4);
return *(((uint8*)&m_uint32Values[ index ])+offset); return *(((uint8*)&m_uint32Values[index])+offset);
} }
uint16 GetUInt16Value(uint16 index, uint8 offset) const uint16 GetUInt16Value(uint16 index, uint8 offset) const
{ {
ASSERT(index < m_valuesCount || PrintIndexError(index , false)); ASSERT(index < m_valuesCount || PrintIndexError(index , false));
ASSERT(offset < 2); ASSERT(offset < 2);
return *(((uint16*)&m_uint32Values[ index ])+offset); return *(((uint16*)&m_uint32Values[index])+offset);
} }
void SetInt32Value(uint16 index, int32 value); void SetInt32Value(uint16 index, int32 value);
void SetUInt32Value(uint16 index, uint32 value); void SetUInt32Value(uint16 index, uint32 value);
void UpdateUInt32Value(uint16 index, uint32 value); void UpdateUInt32Value(uint16 index, uint32 value);
void SetUInt64Value(uint16 index, const uint64 value); void SetUInt64Value(uint16 index, uint64 const value);
void SetFloatValue(uint16 index, float value); void SetFloatValue(uint16 index, float value);
void SetByteValue(uint16 index, uint8 offset, uint8 value); void SetByteValue(uint16 index, uint8 offset, uint8 value);
void SetUInt16Value(uint16 index, uint8 offset, uint16 value); void SetUInt16Value(uint16 index, uint8 offset, uint16 value);
void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index, offset, (uint16)value); } void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index, offset, (uint16)value); }
void SetStatFloatValue(uint16 index, float value); void SetStatFloatValue(uint16 index, float value);
void SetStatInt32Value(uint16 index, int32 value); void SetStatInt32Value(uint16 index, int32 value);
bool AddUInt64Value(uint16 index, const uint64 value); bool AddUInt64Value(uint16 index, uint64 const value);
bool RemoveUInt64Value(uint16 index, const uint64 value); bool RemoveUInt64Value(uint16 index, uint64 const value);
void ApplyModUInt32Value(uint16 index, int32 val, bool apply); void ApplyModUInt32Value(uint16 index, int32 val, bool apply);
void ApplyModInt32Value(uint16 index, int32 val, bool apply); void ApplyModInt32Value(uint16 index, int32 val, bool apply);
@@ -248,7 +248,7 @@ class Object
bool HasFlag(uint16 index, uint32 flag) const bool HasFlag(uint16 index, uint32 flag) const
{ {
if (index >= m_valuesCount && !PrintIndexError(index , false)) return false; if (index >= m_valuesCount && !PrintIndexError(index , false)) return false;
return (m_uint32Values[ index ] & flag) != 0; return (m_uint32Values[index] & flag) != 0;
} }
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag); void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag);
@@ -471,13 +471,13 @@ struct Position
bool IsInDist(const Position *pos, float dist) const bool IsInDist(const Position *pos, float dist) const
{ return GetExactDistSq(pos) < dist * dist; } { return GetExactDistSq(pos) < dist * dist; }
bool HasInArc(float arcangle, const Position *pos) const; bool HasInArc(float arcangle, const Position *pos) const;
bool HasInLine(const Unit* target, float distance, float width) const; bool HasInLine(Unit const* target, float distance, float width) const;
std::string ToString() const; std::string ToString() const;
}; };
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer); ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer);
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer); ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer); ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer); ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer);
struct MovementInfo struct MovementInfo
{ {
+7 -3
View File
@@ -21157,19 +21157,23 @@ void Player::UpdateTriggerVisibility()
if (m_clientGUIDs.empty()) if (m_clientGUIDs.empty())
return; return;
if (!IsInWorld())
return;
UpdateData udata; UpdateData udata;
WorldPacket packet; WorldPacket packet;
for (ClientGUIDs::iterator itr=m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) for (ClientGUIDs::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr)
{ {
if (IS_CREATURE_GUID(*itr)) if (IS_CREATURE_GUID(*itr))
{ {
Creature *obj = IsInWorld() ? GetMap()->GetCreature(*itr) : NULL; Creature *obj = GetMap()->GetCreature(*itr);
if (!obj || !obj->isTrigger()) if (!obj || !(obj->isTrigger() || obj->HasAuraType(SPELL_AURA_TRANSFORM))) // can transform into triggers
continue; continue;
obj->BuildCreateUpdateBlockForPlayer(&udata, this); obj->BuildCreateUpdateBlockForPlayer(&udata, this);
} }
} }
udata.BuildPacket(&packet); udata.BuildPacket(&packet);
GetSession()->SendPacket(&packet); GetSession()->SendPacket(&packet);
} }