[12111] Add Unit::KnockBackWithAngle function

Also wrap up the packet sending for a knockbacked player to WorldSession::SendKnockBack

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Reamer 2012-08-23 13:01:29 +02:00 committed by Antz
parent 68fe5fb4b0
commit e90caf7349
5 changed files with 25 additions and 11 deletions

View file

@ -447,6 +447,21 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket& recv_data)
mover->SendMessageToSetExcept(&data, _player);
}
void WorldSession::SendKnockBack(float angle, float horizontalSpeed, float verticalSpeed)
{
float vsin = sin(angle);
float vcos = cos(angle);
WorldPacket data(SMSG_MOVE_KNOCK_BACK, 9 + 4 + 4 + 4 + 4 + 4);
data << GetPlayer()->GetPackGUID();
data << uint32(0); // Sequence
data << float(vcos); // x direction
data << float(vsin); // y direction
data << float(horizontalSpeed); // Horizontal speed
data << float(-verticalSpeed); // Z Movement speed (vertical)
SendPacket(&data);
}
void WorldSession::HandleMoveHoverAck(WorldPacket& recv_data)
{
DEBUG_LOG("CMSG_MOVE_HOVER_ACK");

View file

@ -11235,22 +11235,19 @@ void Unit::SetFFAPvP(bool state)
void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpeed)
{
float angle = this == target ? GetOrientation() + M_PI_F : target->GetAngle(this);
float vsin = sin(angle);
float vcos = cos(angle);
KnockBackWithAngle(angle, horizontalSpeed, verticalSpeed);
}
void Unit::KnockBackWithAngle(float angle, float horizontalSpeed, float verticalSpeed)
{
if (GetTypeId() == TYPEID_PLAYER)
{
WorldPacket data(SMSG_MOVE_KNOCK_BACK, 9 + 4 + 4 + 4 + 4 + 4);
data << GetPackGUID();
data << uint32(0); // Sequence
data << float(vcos); // x direction
data << float(vsin); // y direction
data << float(horizontalSpeed); // Horizontal speed
data << float(-verticalSpeed); // Z Movement speed (vertical)
((Player*)this)->GetSession()->SendPacket(&data);
((Player*)this)->GetSession()->SendKnockBack(angle, horizontalSpeed, verticalSpeed);
}
else
{
float vsin = sin(angle);
float vcos = cos(angle);
float moveTimeHalf = verticalSpeed / Movement::gravity;
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -verticalSpeed);

View file

@ -1892,6 +1892,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void SetSpeedRate(UnitMoveType mtype, float rate, bool forced = false);
void KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpeed);
void KnockBackWithAngle(float angle, float horizontalSpeed, float verticalSpeed);
void _RemoveAllAuraMods();
void _ApplyAllAuraMods();

View file

@ -442,6 +442,7 @@ class MANGOS_DLL_SPEC WorldSession
// Knockback
void HandleMoveKnockBackAck(WorldPacket& recvPacket);
void SendKnockBack(float angle, float horizontalSpeed, float verticalSpeed);
void HandleMoveTeleportAckOpcode(WorldPacket& recvPacket);
void HandleForceSpeedChangeAckOpcodes(WorldPacket& recv_data);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12110"
#define REVISION_NR "12111"
#endif // __REVISION_NR_H__