[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

@ -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);