[8425] Implement SPELL_EFFECT_LEAP_BACK and spell 781

* Move CMSG_MOVE_KNOCK_BACK_ACK (player case) to Unit::KnockBackFrom
* Implement creature case, most at hack way currently :(
  Need information about expected server packet, and possible some disorientation movegen apply at short time.
* In adition of spell 781 implement related creature versions.

* Fixed warnings spawn at reading CMSG_MOVE_KNOCK_BACK_ACK, CMSG_MOVE_HOVER_ACK, CMSG_MOVE_WATER_WALK_ACK.
This commit is contained in:
VladimirMangos 2009-08-27 05:04:55 +04:00
parent 43a4d1505e
commit fdb2842f60
8 changed files with 125 additions and 66 deletions

View file

@ -44,6 +44,7 @@
#include "CellImpl.h"
#include "Path.h"
#include "Traveller.h"
#include "VMapFactory.h"
#include <math.h>
@ -12051,3 +12052,47 @@ void Unit::SetPvP( bool state )
if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i]))
totem->SetPvP(state);
}
void Unit::KnockBackFrom(Unit* target, float horizintalSpeed, float verticalSpeed)
{
float angle = this == target ? GetOrientation() + M_PI : target->GetAngle(this);
float vsin = sin(angle);
float vcos = cos(angle);
// Effect propertly implemented only for players
if(GetTypeId()==TYPEID_PLAYER)
{
WorldPacket data(SMSG_MOVE_KNOCK_BACK, 8+4+4+4+4+4);
data.append(GetPackGUID());
data << uint32(0); // Sequence
data << float(vcos); // x direction
data << float(vsin); // y direction
data << float(horizintalSpeed); // Horizontal speed
data << float(-verticalSpeed); // Z Movement speed (vertical)
((Player*)this)->GetSession()->SendPacket(&data);
}
else
{
float dis = horizintalSpeed;
float ox, oy, oz;
GetPosition(ox, oy, oz);
float fx = ox + dis * vcos;
float fy = oy + dis * vsin;
float fz = oz;
float fx2, fy2, fz2; // getObjectHitPos overwrite last args in any result case
if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), ox,oy,oz+0.5, fx,fy,oz+0.5,fx2,fy2,fz2, -0.5))
{
fx = fx2;
fy = fy2;
fz = fz2;
UpdateGroundPositionZ(fx, fy, fz);
}
//FIXME: this mostly hack, must exist some packet for proper creature move at client side
// with CreatureRelocation at server side
NearTeleportTo(fx, fy, fz, GetOrientation(), this == target);
}
}