*Update movement enums - thanks to Zor for info.

*Add functions for position data streaming.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-08-04 14:39:45 +02:00
parent 850868c8a3
commit 6353e7dd8c
60 changed files with 428 additions and 366 deletions
@@ -318,10 +318,10 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId)
{
sLog.outDebug("TSCR: EscortAI has returned to original position before combat");
if (m_bIsRunning && me->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
else if (!m_bIsRunning && !me->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
if (m_bIsRunning && me->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
else if (!m_bIsRunning && !me->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
RemoveEscortState(STATE_ESCORT_RETURNING);
@@ -413,14 +413,14 @@ void npc_escortAI::SetRun(bool bRun)
if (bRun)
{
if (!m_bIsRunning)
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
else
sLog.outDebug("TSCR: EscortAI attempt to set run mode, but is already running.");
}
else
{
if (m_bIsRunning)
me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
else
sLog.outDebug("TSCR: EscortAI attempt to set walk mode, but is already walking.");
}
@@ -487,9 +487,9 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID,
//Set initial speed
if (m_bIsRunning)
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
else
me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
AddEscortState(STATE_ESCORT_ESCORTING);
}
@@ -420,7 +420,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data)
// TODO: In fact monster move flags should be set - not movement flags.
if (cInfo->InhabitType & INHABIT_AIR)
AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING);
AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING);
if (cInfo->InhabitType & INHABIT_WATER)
AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
@@ -784,7 +784,7 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry,
if (GetCreatureInfo()->InhabitType & INHABIT_AIR)
{
if (GetDefaultMovementType() == IDLE_MOTION_TYPE)
AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE);
AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY);
else
SetFlying(true);
}
@@ -1515,9 +1515,9 @@ void Creature::setDeathState(DeathState s)
SetLootRecipient(NULL);
ResetPlayerDamageReq();
CreatureInfo const *cinfo = GetCreatureInfo();
AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
if (GetCreatureInfo()->InhabitType & INHABIT_AIR)
AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING);
AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING);
if (GetCreatureInfo()->InhabitType & INHABIT_WATER)
AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
@@ -246,7 +246,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z)
if (member->IsWithinDist(m_leader, dist + MAX_DESYNC))
member->SetUnitMovementFlags(m_leader->GetUnitMovementFlags());
else
member->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
member->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
member->GetMotionMaster()->MovePoint(0, dx, dy, dz);
member->SetHomePosition(dx, dy, dz, pathangle);
+35 -4
View File
@@ -301,7 +301,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const
FlightPathMovementGenerator *fmg = (FlightPathMovementGenerator*)(player->GetMotionMaster()->top());
uint32 flags3 = MOVEFLAG_GLIDE;
uint32 flags3 = SPLINEFLAG_GLIDE;
*data << uint32(flags3); // splines flag?
@@ -1144,6 +1144,37 @@ bool Position::HasInLine(const Unit * const target, float distance, float width)
return abs(sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width;
}
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer)
{
float x, y, z, o;
buf >> x >> y >> z >> o;
streamer.m_pos->Relocate(x, y, z, o);
return buf;
}
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer)
{
float x, y, z;
streamer.m_pos->GetPosition(x, y, z);
buf << x << y << z;
return buf;
}
ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer)
{
float x, y, z;
buf >> x >> y >> z;
streamer.m_pos->Relocate(x, y, z);
return buf;
}
ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer)
{
float x, y, z, o;
streamer.m_pos->GetPosition(x, y, z, o);
buf << x << y << z << o;
return buf;
}
WorldObject::WorldObject()
: WorldLocation(), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_currMap(NULL)
, m_zoneScript(NULL)
@@ -1241,12 +1272,12 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUIDLow() == m_transport->GetGUIDLow())
{
float dtx = m_movementInfo.t_x - obj->m_movementInfo.t_x;
float dty = m_movementInfo.t_y - obj->m_movementInfo.t_y;
float dtx = m_movementInfo.t_pos.m_positionX - obj->m_movementInfo.t_pos.m_positionX;
float dty = m_movementInfo.t_pos.m_positionY - obj->m_movementInfo.t_pos.m_positionY;
float disttsq = dtx * dtx + dty * dty;
if (is3D)
{
float dtz = m_movementInfo.t_z - obj->m_movementInfo.t_z;
float dtz = m_movementInfo.t_pos.m_positionZ - obj->m_movementInfo.t_pos.m_positionZ;
disttsq += dtz * dtz;
}
return disttsq < (maxdist * maxdist);
+66 -36
View File
@@ -117,44 +117,9 @@ class ZoneScript;
class Unit;
class Transport;
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
struct MovementInfo
{
// common
uint64 guid;
uint32 flags;
uint16 unk1;
uint32 time;
float x, y, z, o;
// transport
uint64 t_guid;
float t_x, t_y, t_z, t_o;
uint32 t_time;
int8 t_seat;
// swimming and unknown
float s_pitch;
// last fall time
uint32 fallTime;
// jumping
float j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed;
// spline
float u_unk1;
MovementInfo()
{
flags = 0;
time = t_time = fallTime = 0;
unk1 = 0;
x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_zspeed = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f;
t_guid = 0;
}
uint32 GetMovementFlags() { return flags; }
void AddMovementFlag(uint32 flag) { flags |= flag; }
bool HasMovementFlag(uint32 flag) const { return flags & flag; }
};
class Object
{
public:
@@ -405,6 +370,18 @@ class Object
struct Position
{
struct PositionXYZStreamer
{
explicit PositionXYZStreamer(Position& pos) : m_pos(&pos) {}
Position* m_pos;
};
struct PositionXYZOStreamer
{
explicit PositionXYZOStreamer(Position& pos) : m_pos(&pos) {}
Position* m_pos;
};
float m_positionX;
float m_positionY;
float m_positionZ;
@@ -440,6 +417,15 @@ struct Position
pos->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation);
}
Position::PositionXYZStreamer PositionXYZStream()
{
return Position::PositionXYZStreamer(*this);
}
Position::PositionXYZOStreamer PositionXYZOStream()
{
return Position::PositionXYZOStreamer(*this);
}
bool IsPositionValid() const;
float GetExactDist2dSq(float x, float y) const
@@ -477,6 +463,50 @@ struct Position
bool HasInArc(float arcangle, const Position *pos) const;
bool HasInLine(const Unit *target, float distance, float width) const;
};
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::PositionXYZOStreamer const & streamer);
struct MovementInfo
{
// common
uint64 guid;
uint32 flags;
uint16 flags2;
Position pos;
uint32 time;
// transport
uint64 t_guid;
Position t_pos;
uint32 t_time;
uint32 t_time2;
int8 t_seat;
// swimming/flying
float pitch;
// falling
uint32 fallTime;
// jumping
float j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed;
// spline
float splineElevation;
MovementInfo()
{
guid = 0;
flags = 0;
flags2 = 0;
time = t_time = fallTime = 0;
splineElevation = 0;
pitch = j_zspeed = j_sinAngle = j_cosAngle = j_xyspeed = 0.0f;
t_guid = 0;
t_seat = -1;
}
uint32 GetMovementFlags() { return flags; }
void AddMovementFlag(uint32 flag) { flags |= flag; }
bool HasMovementFlag(uint32 flag) const { return flags & flag; }
};
#define MAPID_INVALID 0xFFFFFFFF
+22 -28
View File
@@ -1851,10 +1851,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
{
m_transport->RemovePassenger(this);
m_transport = NULL;
m_movementInfo.t_x = 0.0f;
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
m_movementInfo.t_pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
m_movementInfo.t_time = 0;
m_movementInfo.t_seat = -1;
}
@@ -1990,7 +1987,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
data.Initialize(SMSG_NEW_WORLD, (20));
if (m_transport)
data << (uint32)mapid << m_movementInfo.t_x << m_movementInfo.t_y << m_movementInfo.t_z << m_movementInfo.t_o;
data << (uint32)mapid << m_movementInfo.t_pos.PositionXYZOStream();
else
data << (uint32)mapid << (float)x << (float)y << (float)z << (float)orientation;
@@ -2010,10 +2007,10 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (m_transport)
{
final_x += m_movementInfo.t_x;
final_y += m_movementInfo.t_y;
final_z += m_movementInfo.t_z;
final_o += m_movementInfo.t_o;
final_x += m_movementInfo.t_pos.GetPositionX();
final_y += m_movementInfo.t_pos.GetPositionY();
final_z += m_movementInfo.t_pos.GetPositionZ();
final_o += m_movementInfo.t_pos.GetOrientation();
}
m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
@@ -16057,20 +16054,17 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
instanceId = 0;
m_movementInfo.t_guid = MAKE_NEW_GUID(transGUID, 0, HIGHGUID_TRANSPORT);
m_movementInfo.t_x = fields[26].GetFloat();
m_movementInfo.t_y = fields[27].GetFloat();
m_movementInfo.t_z = fields[28].GetFloat();
m_movementInfo.t_o = fields[29].GetFloat();
m_movementInfo.t_pos.Relocate(fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat());
if (!Trinity::IsValidMapCoord(
GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y,
GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o) ||
GetPositionX()+m_movementInfo.t_pos.m_positionX,GetPositionY()+m_movementInfo.t_pos.m_positionY,
GetPositionZ()+m_movementInfo.t_pos.m_positionZ,GetOrientation()+m_movementInfo.t_pos.m_orientation) ||
// transport size limited
m_movementInfo.t_x > 250 || m_movementInfo.t_y > 250 || m_movementInfo.t_z > 250)
m_movementInfo.t_pos.m_positionX > 250 || m_movementInfo.t_pos.m_positionY > 250 || m_movementInfo.t_pos.m_positionZ > 250)
{
sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",
guid,GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y,
GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o);
guid,GetPositionX()+m_movementInfo.t_pos.m_positionX,GetPositionY()+m_movementInfo.t_pos.m_positionY,
GetPositionZ()+m_movementInfo.t_pos.m_positionZ,GetOrientation()+m_movementInfo.t_pos.m_orientation);
RelocateToHomebind();
}
@@ -17675,10 +17669,10 @@ void Player::SaveToDB()
ss << m_resetTalentsCost << ", ";
ss << (uint64)m_resetTalentsTime << ", ";
ss << finiteAlways(m_movementInfo.t_x) << ", ";
ss << finiteAlways(m_movementInfo.t_y) << ", ";
ss << finiteAlways(m_movementInfo.t_z) << ", ";
ss << finiteAlways(m_movementInfo.t_o) << ", ";
ss << finiteAlways(m_movementInfo.t_pos.GetPositionX()) << ", ";
ss << finiteAlways(m_movementInfo.t_pos.GetPositionY()) << ", ";
ss << finiteAlways(m_movementInfo.t_pos.GetPositionZ()) << ", ";
ss << finiteAlways(m_movementInfo.t_pos.GetOrientation()) << ", ";
if (m_transport)
ss << m_transport->GetGUIDLow();
else
@@ -22845,7 +22839,7 @@ uint8 Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 except_sl
void Player::HandleFall(MovementInfo const& movementInfo)
{
// calculate total z distance of the fall
float z_diff = m_lastFallZ - movementInfo.z;
float z_diff = m_lastFallZ - movementInfo.pos.GetPositionZ();
//sLog.outDebug("zDiff = %f", z_diff);
//Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
@@ -22863,8 +22857,8 @@ void Player::HandleFall(MovementInfo const& movementInfo)
{
uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL));
float height = movementInfo.z;
UpdateGroundPositionZ(movementInfo.x,movementInfo.y,height);
float height = movementInfo.t_pos.m_positionZ;
UpdateGroundPositionZ(movementInfo.pos.m_positionX,movementInfo.pos.m_positionY,height);
if (damage > 0)
{
@@ -22885,7 +22879,7 @@ void Player::HandleFall(MovementInfo const& movementInfo)
}
//Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction
DEBUG_LOG("FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d" , movementInfo.z, height, GetPositionZ(), movementInfo.fallTime, height, damage, safe_fall);
DEBUG_LOG("FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d" , movementInfo.pos.GetPositionZ(), height, GetPositionZ(), movementInfo.fallTime, height, damage, safe_fall);
}
}
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LANDING); // No fly zone - Parachute
@@ -23165,8 +23159,8 @@ void Player::UpdateKnownCurrencies(uint32 itemId, bool apply)
void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode)
{
if (m_lastFallTime >= minfo.fallTime || m_lastFallZ <= minfo.z || opcode == MSG_MOVE_FALL_LAND)
SetFallInformation(minfo.fallTime, minfo.z);
if (m_lastFallTime >= minfo.fallTime || m_lastFallZ <= minfo.pos.GetPositionZ() || opcode == MSG_MOVE_FALL_LAND)
SetFallInformation(minfo.fallTime, minfo.pos.GetPositionZ());
}
void Player::UnsummonPetTemporaryIfAny()
@@ -644,17 +644,14 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y,
pCreature->SetTransport(this);
pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
pCreature->m_movementInfo.guid = GetGUID();
pCreature->m_movementInfo.t_x = x;
pCreature->m_movementInfo.t_y = y;
pCreature->m_movementInfo.t_z = z;
pCreature->m_movementInfo.t_o = o;
pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o);
pCreature->setActive(true);
if (anim > 0)
pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE,anim);
pCreature->Relocate(
GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + 3.14159f)),
GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + M_PI)),
GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
z + GetPositionZ() ,
o + GetOrientation());
@@ -684,10 +681,10 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y,
void Transport::UpdatePosition(MovementInfo* mi)
{
float transport_o = mi->o - mi->t_o;
float transport_x = mi->x - (mi->t_x*cos(transport_o) - mi->t_y*sin(transport_o));
float transport_y = mi->y - (mi->t_y*cos(transport_o) + mi->t_x*sin(transport_o));
float transport_z = mi->z - mi->t_z;
float transport_o = mi->pos.m_orientation - mi->t_pos.m_orientation;
float transport_x = mi->pos.m_positionX - (mi->t_pos.m_positionX * cos(transport_o) - mi->t_pos.m_positionY*sin(transport_o));
float transport_y = mi->pos.m_positionY - (mi->t_pos.m_positionY * cos(transport_o) + mi->t_pos.m_positionX*sin(transport_o));
float transport_z = mi->pos.m_positionZ - mi->t_pos.m_positionZ;
Relocate(transport_x,transport_y,transport_z,transport_o);
UpdateNPCPositions();
@@ -707,10 +704,10 @@ void Transport::UpdateNPCPositions()
if (Creature* npc = Creature::GetCreature(*this, guid))
{
float x, y, z, o;
o = GetOrientation() + npc->m_movementInfo.t_o;
x = GetPositionX() + (npc->m_movementInfo.t_x * cos(GetOrientation()) + npc->m_movementInfo.t_y * sin(GetOrientation() + 3.14159f));
y = GetPositionY() + (npc->m_movementInfo.t_y * cos(GetOrientation()) + npc->m_movementInfo.t_x * sin(GetOrientation()));
z = GetPositionZ() + npc->m_movementInfo.t_z;
o = GetOrientation() + npc->m_movementInfo.t_pos.m_orientation;
x = GetPositionX() + (npc->m_movementInfo.t_pos.m_positionX * cos(GetOrientation()) + npc->m_movementInfo.t_pos.m_positionY * sin(GetOrientation() + M_PI));
y = GetPositionY() + (npc->m_movementInfo.t_pos.m_positionY * cos(GetOrientation()) + npc->m_movementInfo.t_pos.m_positionX * sin(GetOrientation()));
z = GetPositionZ() + npc->m_movementInfo.t_pos.m_positionZ;
npc->SetPosition(x, y, z,o);
npc->SetHomePosition(x,y,z,o);
}
+16 -32
View File
@@ -326,7 +326,7 @@ void Unit::SendMonsterStop(bool on_death)
if (on_death == true)
{
data << uint8(0);
data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? MOVEFLAG_FLY : MOVEFLAG_WALK);
data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING);
data << uint32(0); // Time in between points
data << uint32(1); // 1 single waypoint
data << GetPositionX() << GetPositionY() << GetPositionZ();
@@ -349,7 +349,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 T
data << getMSTime();
data << uint8(0);
data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? MOVEFLAG_FLY : MOVEFLAG_WALK);
data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING);
data << Time; // Time in between points
data << uint32(1); // 1 single waypoint
data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B
@@ -374,7 +374,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M
data << uint8(0);
data << MoveFlags;
if (MoveFlags & MOVEFLAG_JUMP)
if (MoveFlags & SPLINEFLAG_TRAJECTORY)
{
data << time;
data << speedZ;
@@ -452,7 +452,7 @@ void Unit::SendMonsterMoveTransport(Unit *vehicleOwner)
data << uint32(getMSTime());
data << uint8(4);
data << GetTransOffsetO();
data << uint32(MOVEFLAG_ENTER_TRANSPORT);
data << uint32(SPLINEFLAG_TRANSPORT);
data << uint32(0);// move time
data << uint32(0);//GetTransOffsetX();
data << uint32(0);//GetTransOffsetY();
@@ -9752,9 +9752,9 @@ void Unit::SetCharm(Unit* charm, bool apply)
if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
sLog.outCrash("Unit %u is being charmed, but it already has a charmer %u", charm->GetEntry(), charm->GetCharmerGUID());
if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
{
charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
charm->SendMovementFlagUpdate();
}
@@ -16411,10 +16411,7 @@ void Unit::ExitVehicle()
SetControlled(false, UNIT_STAT_ROOT);
RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
m_movementInfo.t_x = 0;
m_movementInfo.t_y = 0;
m_movementInfo.t_z = 0;
m_movementInfo.t_o = 0;
m_movementInfo.t_pos.Relocate(0, 0, 0, 0);
m_movementInfo.t_time = 0;
m_movementInfo.t_seat = 0;
@@ -16446,17 +16443,17 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
break;
case TYPEID_PLAYER:
// remove unknown, unused etc flags for now
const_cast<Unit*>(this)->RemoveUnitMovementFlag(MOVEMENTFLAG_SPLINE2);
const_cast<Unit*>(this)->RemoveUnitMovementFlag(MOVEMENTFLAG_SPLINE_ENABLED);
if (isInFlight())
{
WPAssert(const_cast<Unit*>(this)->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE);
const_cast<Unit*>(this)->AddUnitMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE2);
const_cast<Unit*>(this)->AddUnitMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE_ENABLED);
}
break;
}
*data << uint32(GetUnitMovementFlags()); // movement flags
*data << uint16(m_movementInfo.unk1); // 2.3.0
*data << uint16(m_movementInfo.flags2); // 2.3.0
*data << uint32(getMSTime()); // time
*data << GetPositionX();
*data << GetPositionY();
@@ -16485,8 +16482,8 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
// 0x02200000
if ((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING))
|| (m_movementInfo.unk1 & 0x20))
*data << (float)m_movementInfo.s_pitch;
|| (m_movementInfo.flags2 & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
*data << (float)m_movementInfo.pitch;
*data << (uint32)m_movementInfo.fallTime;
@@ -16500,8 +16497,8 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
}
// 0x04000000
if (GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE)
*data << (float)m_movementInfo.u_unk1;
if (GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE_ELEVATION)
*data << (float)m_movementInfo.splineElevation;
/*if (GetTypeId() == TYPEID_PLAYER)
{
@@ -16510,30 +16507,17 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
}*/
}
void Unit::OutMovementInfo() const
{
sLog.outString("MovementInfo for %u: Flag %u, Unk1 %u, Time %u, Pos %f %f %f %f, Fall %u", GetEntry(), m_movementInfo.flags, (uint32)m_movementInfo.unk1, m_movementInfo.time, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), m_movementInfo.fallTime);
if (m_movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
sLog.outString("Transport: GUID " UI64FMTD ", Pos %f %f %f %f, Time %u, Seat %d", m_movementInfo.t_guid, m_movementInfo.t_x, m_movementInfo.t_y, m_movementInfo.t_z, m_movementInfo.t_o, m_movementInfo.t_time, (int32)m_movementInfo.t_seat);
if ((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20))
sLog.outString("Pitch: %f", m_movementInfo.s_pitch);
if (m_movementInfo.flags & MOVEMENTFLAG_JUMPING)
sLog.outString("Jump: speedz %f, sin %f, cos %f, speedxy %f", m_movementInfo.j_zspeed, m_movementInfo.j_sinAngle, m_movementInfo.j_cosAngle, m_movementInfo.j_xyspeed);
if (m_movementInfo.flags & MOVEMENTFLAG_SPLINE)
sLog.outString("Spline: %f", m_movementInfo.u_unk1);
}
void Unit::SetFlying(bool apply)
{
if (apply)
{
SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING);
AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING);
}
else
{
RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
RemoveUnitMovementFlag(MOVEMENTFLAG_FLY_MODE | MOVEMENTFLAG_FLYING);
RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING);
}
}
+117 -81
View File
@@ -636,91 +636,128 @@ enum NPCFlags
UNIT_NPC_FLAG_OUTDOORPVP = 0x20000000, // custom flag for outdoor pvp creatures
};
enum MoveFlags
{
MOVEFLAG_JUMP = 0x00000800,
MOVEFLAG_WALK = 0x00001000,
MOVEFLAG_FLY = 0x00002000,
MOVEFLAG_GLIDE = 0x00003000, // dragon
MOVEFLAG_ENTER_TRANSPORT = 0x00800000,
};
enum MovementFlags
{
MOVEMENTFLAG_NONE = 0x00000000,
MOVEMENTFLAG_FORWARD = 0x00000001,
MOVEMENTFLAG_BACKWARD = 0x00000002,
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
MOVEMENTFLAG_LEFT = 0x00000010,
MOVEMENTFLAG_RIGHT = 0x00000020,
MOVEMENTFLAG_PITCH_UP = 0x00000040,
MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking
MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures
MOVEMENTFLAG_LEVITATING = 0x00000400,
MOVEMENTFLAG_ROOT = 0x00000800,
MOVEMENTFLAG_JUMPING = 0x00001000,
MOVEMENTFLAG_FALL_DAMAGE = 0x00002000, // newZ < oldZ
MOVEMENTFLAG_FALLING = 0x00004000,
// 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
MOVEMENTFLAG_ASCEND = 0x00400000, // press "space" when flying
MOVEMENTFLAG_CAN_FLY = 0x00800000,
MOVEMENTFLAG_FLY_MODE = 0x01000000, // can fly
MOVEMENTFLAG_FLYING = 0x02000000, // hover
MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths
MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths
MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water
MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
MOVEMENTFLAG_HOVER = 0x40000000, // hover, cannot jump
MOVEMENTFLAG_NONE = 0x00000000,
MOVEMENTFLAG_FORWARD = 0x00000001,
MOVEMENTFLAG_BACKWARD = 0x00000002,
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
MOVEMENTFLAG_LEFT = 0x00000010,
MOVEMENTFLAG_RIGHT = 0x00000020,
MOVEMENTFLAG_PITCH_UP = 0x00000040,
MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
MOVEMENTFLAG_WALKING = 0x00000100, // Walking
MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures
MOVEMENTFLAG_LEVITATING = 0x00000400,
MOVEMENTFLAG_ROOT = 0x00000800,
MOVEMENTFLAG_JUMPING = 0x00001000,
MOVEMENTFLAG_FALLING = 0x00002000, // damage dealt on that type of falling
MOVEMENTFLAG_PENDING_STOP = 0x00004000,
MOVEMENTFLAG_PENDING_STRAFE_STOP = 0x00008000,
MOVEMENTFLAG_PENDING_FORWARD = 0x00010000,
MOVEMENTFLAG_PENDING_BACKWARD = 0x00020000,
MOVEMENTFLAG_PENDING_STRAFE_LEFT = 0x00040000,
MOVEMENTFLAG_PENDING_STRAFE_RIGHT = 0x00080000,
MOVEMENTFLAG_PENDING_ROOT = 0x00100000,
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
MOVEMENTFLAG_ASCENDING = 0x00400000, // press "space" when flying
MOVEMENTFLAG_DESCENDING = 0x00800000,
MOVEMENTFLAG_CAN_FLY = 0x01000000, // can fly
MOVEMENTFLAG_FLYING = 0x02000000, // hover
MOVEMENTFLAG_SPLINE_ELEVATION = 0x04000000, // used for flight paths
MOVEMENTFLAG_SPLINE_ENABLED = 0x08000000, // used for flight paths
MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water
MOVEMENTFLAG_FALLING_SLOW = 0x20000000, // active rogue safe fall spell (passive)
MOVEMENTFLAG_HOVER = 0x40000000, // hover, cannot jump
MOVEMENTFLAG_MOVING =
MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FALL_DAMAGE|
MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_ASCEND |
MOVEMENTFLAG_SPLINE,
MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_JUMPING
|MOVEMENTFLAG_FALLING|MOVEMENTFLAG_ASCENDING| MOVEMENTFLAG_SPLINE_ELEVATION,
MOVEMENTFLAG_TURNING =
MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT,
};
/*
enum MonsterMovementFlags
enum MovementFlags2
{
MONSTER_MOVE_NONE = 0x00000000,
MONSTER_MOVE_FORWARD = 0x00000001,
MONSTER_MOVE_BACKWARD = 0x00000002,
MONSTER_MOVE_STRAFE_LEFT = 0x00000004,
MONSTER_MOVE_STRAFE_RIGHT = 0x00000008,
MONSTER_MOVE_LEFT = 0x00000010, // turn
MONSTER_MOVE_RIGHT = 0x00000020, // turn
MONSTER_MOVE_PITCH_UP = 0x00000040,
MONSTER_MOVE_PITCH_DOWN = 0x00000080,
MONSTER_MOVE_TELEPORT = 0x00000100,
MONSTER_MOVE_TELEPORT2 = 0x00000200,
MONSTER_MOVE_LEVITATING = 0x00000400,
MONSTER_MOVE_UNK1 = 0x00000800, // float+uint32
MONSTER_MOVE_WALK = 0x00001000, // run2?
MONSTER_MOVE_SPLINE = 0x00002000, // spline n*(float x,y,z)
// 0x4000, 0x8000, 0x10000, 0x20000 run
MONSTER_MOVE_SPLINE2 = 0x00040000, // spline n*(float x,y,z)
MONSTER_MOVE_UNK2 = 0x00080000, // used for flying mobs
MONSTER_MOVE_UNK3 = 0x00100000, // used for flying mobs
MONSTER_MOVE_UNK4 = 0x00200000, // uint8+uint32
MONSTER_MOVE_UNK5 = 0x00400000, // run in place, then teleport to final point
MONSTER_MOVE_UNK6 = 0x00800000, // teleport
MONSTER_MOVE_UNK7 = 0x01000000, // run
MONSTER_MOVE_FLY = 0x02000000, // swimming/flying (depends on mob?)
MONSTER_MOVE_UNK9 = 0x04000000, // run
MONSTER_MOVE_UNK10 = 0x08000000, // run
MONSTER_MOVE_UNK11 = 0x10000000, // run
MONSTER_MOVE_UNK12 = 0x20000000, // run
MONSTER_MOVE_UNK13 = 0x40000000, // levitating
MOVEMENTFLAG2_NONE = 0x00000000,
MOVEMENTFLAG2_UNK1 = 0x00000001,
MOVEMENTFLAG2_UNK2 = 0x00000002,
MOVEMENTFLAG2_UNK3 = 0x00000004,
MOVEMENTFLAG2_FULL_SPEED_TURNING = 0x00000008,
MOVEMENTFLAG2_FULL_SPEED_PITCHING = 0x00000010,
MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING = 0x00000020,
MOVEMENTFLAG2_UNK7 = 0x00000040,
MOVEMENTFLAG2_UNK8 = 0x00000080,
MOVEMENTFLAG2_UNK9 = 0x00000100,
MOVEMENTFLAG2_UNK10 = 0x00000200,
MOVEMENTFLAG2_INTERPOLATED_MOVEMENT = 0x00000400,
MOVEMENTFLAG2_INTERPOLATED_TURNING = 0x00000800,
MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00001000,
MOVEMENTFLAG2_UNK14 = 0x00002000,
MOVEMENTFLAG2_UNK15 = 0x00004000,
MOVEMENTFLAG2_UNK16 = 0x00008000,
// masks
MONSTER_MOVE_SPLINE_FLY = 0x00003000, // fly by points
// player only?
MOVEMENTFLAG2_INTERPOLATED =
MOVEMENTFLAG2_INTERPOLATED_MOVEMENT |
MOVEMENTFLAG2_INTERPOLATED_TURNING |
MOVEMENTFLAG2_INTERPOLATED_PITCHING
};
enum SplineFlags
{
SPLINEFLAG_NONE = 0x00000000,
SPLINEFLAG_FORWARD = 0x00000001,
SPLINEFLAG_BACKWARD = 0x00000002,
SPLINEFLAG_STRAFE_LEFT = 0x00000004,
SPLINEFLAG_STRAFE_RIGHT = 0x00000008,
SPLINEFLAG_LEFT = 0x00000010,
SPLINEFLAG_RIGHT = 0x00000020,
SPLINEFLAG_PITCH_UP = 0x00000040,
SPLINEFLAG_PITCH_DOWN = 0x00000080,
SPLINEFLAG_DONE = 0x00000100,
SPLINEFLAG_FALLING = 0x00000200,
SPLINEFLAG_NO_SPLINE = 0x00000400,
SPLINEFLAG_TRAJECTORY = 0x00000800,
SPLINEFLAG_WALKING = 0x00001000,
SPLINEFLAG_FLYING = 0x00002000,
SPLINEFLAG_KNOCKBACK = 0x00004000,
SPLINEFLAG_FINAL_POINT = 0x00008000,
SPLINEFLAG_FINAL_TARGET = 0x00010000,
SPLINEFLAG_FINAL_FACING = 0x00020000,
SPLINEFLAG_CATMULL_ROM = 0x00040000,
SPLINEFLAG_UNKNOWN20 = 0x00080000,
SPLINEFLAG_UNKNOWN21 = 0x00100000,
SPLINEFLAG_UNKNOWN22 = 0x00200000,
SPLINEFLAG_UNKNOWN23 = 0x00400000,
SPLINEFLAG_TRANSPORT = 0x00800000,
SPLINEFLAG_UNKNOWN25 = 0x01000000,
SPLINEFLAG_UNKNOWN26 = 0x02000000,
SPLINEFLAG_UNKNOWN27 = 0x04000000,
SPLINEFLAG_UNKNOWN28 = 0x08000000,
SPLINEFLAG_UNKNOWN29 = 0x10000000,
SPLINEFLAG_ANIMATION = 0x20000000,
SPLINEFLAG_UNKNOWN31 = 0x40000000,
SPLINEFLAG_UNKNOWN32 = 0x80000000,
SPLINEFLAG_GLIDE = SPLINEFLAG_WALKING | SPLINEFLAG_FLYING,
};
enum SplineMode
{
SPLINEMODE_LINEAR = 0,
SPLINEMODE_CATMULL_ROM = 1,
SPLINEMODE_BEZIER3 = 2
};
enum SplineType
{
SPLINETYPE_NORMAL = 0,
SPLINETYPE_STOP = 1,
SPLINETYPE_FACING_SPOT = 2,
SPLINETYPE_FACING_TARGET = 3,
SPLINETYPE_FACING_ANGLE = 4
};
*/
enum UnitTypeMask
{
@@ -1424,7 +1461,6 @@ class Unit : public WorldObject
void SendThreatListUpdate();
void BuildHeartBeatMsg(WorldPacket *data) const;
void OutMovementInfo() const;
bool isAlive() const { return (m_deathState == ALIVE); };
bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); };
@@ -1913,10 +1949,10 @@ class Unit : public WorldObject
bool IsOnVehicle(const Unit *vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); }
Unit *GetVehicleBase() const;
Creature *GetVehicleCreatureBase() const;
float GetTransOffsetX() const { return m_movementInfo.t_x; }
float GetTransOffsetY() const { return m_movementInfo.t_y; }
float GetTransOffsetZ() const { return m_movementInfo.t_z; }
float GetTransOffsetO() const { return m_movementInfo.t_o; }
float GetTransOffsetX() const { return m_movementInfo.t_pos.GetPositionX(); }
float GetTransOffsetY() const { return m_movementInfo.t_pos.GetPositionY(); }
float GetTransOffsetZ() const { return m_movementInfo.t_pos.GetPositionZ(); }
float GetTransOffsetO() const { return m_movementInfo.t_pos.GetOrientation(); }
uint32 GetTransTime() const { return m_movementInfo.t_time; }
int8 GetTransSeat() const { return m_movementInfo.t_seat; }
@@ -1932,7 +1968,7 @@ class Unit : public WorldObject
bool isMoving() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MOVING); }
bool isTurning() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_TURNING); }
bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLY_MODE); }
bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }
bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); }
void SetFlying(bool apply);
@@ -2111,7 +2147,7 @@ inline void Unit::SendMonsterMoveByPath(Path<Elem,Node> const& path, uint32 star
data << GetPositionZ();
data << uint32(getMSTime());
data << uint8(0);
data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight()) ? (MOVEFLAG_FLY|MOVEFLAG_WALK) : MOVEFLAG_WALK);
data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight()) ? (SPLINEFLAG_FLYING|SPLINEFLAG_WALKING) : SPLINEFLAG_WALKING);
data << uint32(traveltime);
data << uint32(pathSize);
+8 -8
View File
@@ -291,10 +291,10 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
VehicleSeatEntry const *veSeat = seat->second.seatInfo;
unit->m_movementInfo.t_x = veSeat->m_attachmentOffsetX;
unit->m_movementInfo.t_y = veSeat->m_attachmentOffsetY;
unit->m_movementInfo.t_z = veSeat->m_attachmentOffsetZ;
unit->m_movementInfo.t_o = 0;
unit->m_movementInfo.t_pos.m_positionX = veSeat->m_attachmentOffsetX;
unit->m_movementInfo.t_pos.m_positionY = veSeat->m_attachmentOffsetY;
unit->m_movementInfo.t_pos.m_positionZ = veSeat->m_attachmentOffsetZ;
unit->m_movementInfo.t_pos.m_orientation = 0;
unit->m_movementInfo.t_time = 0; // 1 for player
unit->m_movementInfo.t_seat = seat->first;
@@ -378,10 +378,10 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang)
for (SeatMap::const_iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
if (Unit *passenger = itr->second.passenger)
{
float px = x + passenger->m_movementInfo.t_x;
float py = y + passenger->m_movementInfo.t_y;
float pz = z + passenger->m_movementInfo.t_z;
float po = ang + passenger->m_movementInfo.t_o;
float px = x + passenger->m_movementInfo.t_pos.m_positionX;
float py = y + passenger->m_movementInfo.t_pos.m_positionY;
float pz = z + passenger->m_movementInfo.t_pos.m_positionZ;
float po = ang + passenger->m_movementInfo.t_pos.m_orientation;
passenger->SetPosition(px, py, pz, po);
}
+1 -1
View File
@@ -324,7 +324,7 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ)
void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ)
{
uint32 moveFlag = MOVEFLAG_JUMP | MOVEFLAG_WALK;
uint32 moveFlag = SPLINEFLAG_TRAJECTORY | SPLINEFLAG_WALKING;
uint32 time = speedZ * 100;
i_owner->addUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING);
@@ -91,7 +91,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
unit.CastStop();
unit.StopMoving();
unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
unit.addUnitState(UNIT_STAT_CONFUSED);
}
@@ -307,7 +307,7 @@ FleeingMovementGenerator<T>::Initialize(T &owner)
owner.addUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
owner.SetUInt64Value(UNIT_FIELD_TARGET, 0);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
if (Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
{
@@ -30,7 +30,7 @@ HomeMovementGenerator<Creature>::Initialize(Creature & owner)
{
float x, y, z;
owner.GetHomePosition(x, y, z, ori);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
owner.addUnitState(UNIT_STAT_EVADE);
_setTargetLocation(owner);
}
@@ -67,7 +67,7 @@ HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32& time_diff
if (time_diff > i_travel_timer)
{
owner.AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
owner.AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
// restore orientation of not moving creature at returning to home
if (owner.GetDefaultMovementType() == IDLE_MOTION_TYPE)
@@ -128,7 +128,7 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
else
{
i_nextMoveTime.Reset(urand(500+i_destinationHolder.GetTotalTravelTime(),5000+i_destinationHolder.GetTotalTravelTime()));
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
}
//Call for creature group update
@@ -149,7 +149,7 @@ RandomMovementGenerator<Creature>::Initialize(Creature &creature)
wander_distance = creature.GetRespawnRadius();
if (irand(0,RUNNING_CHANCE_RANDOMMV) > 0)
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
_setRandomLocation(creature);
}
@@ -190,12 +190,12 @@ RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff
if (i_nextMoveTime.Passed())
{
if (irand(0,RUNNING_CHANCE_RANDOMMV) > 0)
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
_setRandomLocation(creature);
}
else if (creature.isPet() && creature.GetOwner() && !creature.IsWithinDist(creature.GetOwner(),PET_FOLLOW_DIST+2.5f))
{
creature.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
creature.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
_setRandomLocation(creature);
}
}
@@ -154,7 +154,7 @@ void
TargetedMovementGenerator<T>::Initialize(T &owner)
{
if (owner.isInCombat())
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
_setTargetLocation(owner);
}
@@ -80,8 +80,8 @@ void WaypointMovementGenerator<Player>::Reset(Player & /*unit*/){}
template<>
void WaypointMovementGenerator<Creature>::InitTraveller(Creature &unit, const WaypointData &node)
{
node.run ? unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE):
unit.AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
node.run ? unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING):
unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
unit.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
unit.SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
+3 -3
View File
@@ -77,7 +77,7 @@ inline float Traveller<Creature>::Speed()
{
if (i_traveller.hasUnitState(UNIT_STAT_CHARGING))
return i_traveller.m_TempSpeed;
else if (i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
else if (i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
return i_traveller.GetSpeed(MOVE_WALK);
else if (i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING))
return i_traveller.GetSpeed(MOVE_FLIGHT);
@@ -120,7 +120,7 @@ inline float Traveller<Player>::Speed()
else if (i_traveller.isInFlight())
return PLAYER_FLIGHT_SPEED;
else
return i_traveller.GetSpeed(i_traveller.m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALK_MODE) ? MOVE_WALK : MOVE_RUN);
return i_traveller.GetSpeed(i_traveller.m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING) ? MOVE_WALK : MOVE_RUN);
}
template<>
@@ -145,7 +145,7 @@ inline void Traveller<Player>::Relocation(float x, float y, float z, float orien
template<>
inline void Traveller<Player>::MoveTo(float x, float y, float z, uint32 t)
{
//Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags
//Only send MOVEMENTFLAG_WALKING, client has strange issues with other move flags
i_traveller.SendMonsterMove(x, y, z, t);
}
@@ -280,7 +280,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
/* return;
}*/
if (!Trinity::IsValidMapCoord(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o))
if (!movementInfo.pos.IsPositionValid())
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
@@ -291,14 +291,14 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
{
// transports size limited
// (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
if (movementInfo.t_x > 50 || movementInfo.t_y > 50 || movementInfo.t_z > 50)
if (movementInfo.t_pos.GetPositionX() > 50 || movementInfo.t_pos.GetPositionY() > 50 || movementInfo.t_pos.GetPositionZ() > 50)
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
if (!Trinity::IsValidMapCoord(movementInfo.x+movementInfo.t_x, movementInfo.y + movementInfo.t_y,
movementInfo.z + movementInfo.t_z, movementInfo.o + movementInfo.t_o))
if (!Trinity::IsValidMapCoord(movementInfo.pos.GetPositionX() + movementInfo.t_pos.GetPositionX(), movementInfo.pos.GetPositionY() + movementInfo.t_pos.GetPositionY(),
movementInfo.pos.GetPositionZ() + movementInfo.t_pos.GetPositionZ(), movementInfo.pos.GetOrientation() + movementInfo.t_pos.GetOrientation()))
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
@@ -330,10 +330,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
{
plMover->m_transport->RemovePassenger(plMover);
plMover->m_transport = NULL;
movementInfo.t_x = 0.0f;
movementInfo.t_y = 0.0f;
movementInfo.t_z = 0.0f;
movementInfo.t_o = 0.0f;
movementInfo.t_pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
movementInfo.t_time = 0;
movementInfo.t_seat = -1;
}
@@ -345,7 +342,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
if (plMover && ((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != plMover->IsInWater())
{
// now client not include swimming flag in case jumping under water
plMover->SetInWater(!plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z));
plMover->SetInWater(!plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()));
}
/*----------------------*/
@@ -362,17 +359,17 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
// this is almost never true (not sure why it is sometimes, but it is), normally use mover->IsVehicle()
if (mover->GetVehicle())
{
mover->SetOrientation(movementInfo.o);
mover->SetOrientation(movementInfo.pos.GetOrientation());
return;
}
mover->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
mover->Relocate(movementInfo.pos);
if (plMover) // nothing is charmed, or player charmed
{
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
if (movementInfo.z < -500.0f)
if (movementInfo.pos.GetPositionZ() < -500.0f)
{
if (plMover->InBattleGround()
&& plMover->GetBattleGround()
+22 -29
View File
@@ -712,33 +712,32 @@ void WorldSession::SaveTutorialsData()
void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
{
data >> mi->flags;
data >> mi->unk1;
data >> mi->flags2;
data >> mi->time;
data >> mi->x;
data >> mi->y;
data >> mi->z;
data >> mi->o;
data >> mi->pos.PositionXYZOStream();
if (mi->flags & MOVEMENTFLAG_ONTRANSPORT)
{
if (!data.readPackGUID(mi->t_guid))
return;
data >> mi->t_x;
data >> mi->t_y;
data >> mi->t_z;
data >> mi->t_o;
data >> mi->t_pos.PositionXYZOStream();
data >> mi->t_time;
data >> mi->t_seat;
if(mi->x != mi->t_x)
if (mi->flags2 & MOVEMENTFLAG2_INTERPOLATED_MOVEMENT)
{
data >> mi->t_time2;
}
if(mi->pos.m_positionX != mi->t_pos.m_positionX)
if(GetPlayer()->GetTransport())
GetPlayer()->GetTransport()->UpdatePosition(mi);
}
if ((mi->flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (mi->unk1 & 0x20))
if ((mi->flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (mi->flags2 & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
{
data >> mi->s_pitch;
data >> mi->pitch;
}
data >> mi->fallTime;
@@ -751,9 +750,9 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
data >> mi->j_xyspeed;
}
if (mi->flags & MOVEMENTFLAG_SPLINE)
if (mi->flags & MOVEMENTFLAG_SPLINE_ELEVATION)
{
data >> mi->u_unk1;
data >> mi->splineElevation;
}
}
@@ -762,28 +761,22 @@ void WorldSession::WriteMovementInfo(WorldPacket *data, MovementInfo *mi)
data->appendPackGUID(mi->guid);
*data << mi->flags;
*data << mi->unk1;
*data << mi->flags2;
*data << mi->time;
*data << mi->x;
*data << mi->y;
*data << mi->z;
*data << mi->o;
*data << mi->pos.PositionXYZOStream();
if (mi->HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
data->appendPackGUID(mi->t_guid);
*data << mi->t_x;
*data << mi->t_y;
*data << mi->t_z;
*data << mi->t_o;
*data << mi->t_time;
*data << mi->t_seat;
*data << mi->t_pos.PositionXYZOStream();
*data << mi->t_time;
*data << mi->t_seat;
}
if ((mi->HasMovementFlag(MovementFlags(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING))) || (mi->unk1 & 0x20))
if ((mi->HasMovementFlag(MovementFlags(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING))) || (mi->flags & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
{
*data << mi->s_pitch;
*data << mi->pitch;
}
*data << mi->fallTime;
@@ -796,9 +789,9 @@ void WorldSession::WriteMovementInfo(WorldPacket *data, MovementInfo *mi)
*data << mi->j_xyspeed;
}
if (mi->HasMovementFlag(MOVEMENTFLAG_SPLINE))
if (mi->HasMovementFlag(MOVEMENTFLAG_SPLINE_ELEVATION))
{
*data << mi->u_unk1;
*data << mi->splineElevation;
}
}