Ejemplo n.º 1
0
        static void WriteCommonMonsterMovePart(MoveSpline move_spline, ref PacketWriter data)
        {
            MoveSplineFlag splineflags = move_spline.splineflags;

            data.WriteUInt8(0);                                       // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
            data.WriteVec3(move_spline.spline.getPoint(move_spline.spline.first()));
            data.WriteUInt32(move_spline.GetId());

            switch (splineflags.Raw() & MoveSplineFlag.eFlags.Mask_Final_Facing)
            {
            case MoveSplineFlag.eFlags.Final_Target:
                data.WriteUInt8(MonsterMoveType.FacingTarget);
                data.WriteUInt64(move_spline.facing.target);
                break;

            case MoveSplineFlag.eFlags.Final_Angle:
                data.WriteUInt8(MonsterMoveType.FacingAngle);
                data.WriteFloat(move_spline.facing.angle);
                break;

            case MoveSplineFlag.eFlags.Final_Point:
                data.WriteUInt8(MonsterMoveType.FacingSpot);
                data.WriteFloat(move_spline.facing.x);
                data.WriteFloat(move_spline.facing.y);
                data.WriteFloat(move_spline.facing.z);
                break;

            default:
                data.WriteUInt8(MonsterMoveType.Normal);
                break;
            }

            // add fake Enter_Cycle flag - needed for client-side cyclic movement (client will erase first spline vertex after first cycle done)
            splineflags.enter_cycle = move_spline.isCyclic();
            data.WriteUInt32(splineflags.Raw() & ~MoveSplineFlag.eFlags.Mask_No_Monster_Move);

            if (splineflags.animation)
            {
                data.WriteUInt8(splineflags.getAnimationId());
                data.WriteInt32(move_spline.effect_start_time);
            }

            data.WriteInt32(move_spline.Duration());

            if (splineflags.parabolic)
            {
                data.WriteFloat(move_spline.vertical_acceleration);
                data.WriteInt32(move_spline.effect_start_time);
            }
        }
Ejemplo n.º 2
0
        public static void WriteCreateData(MoveSpline moveSpline, ref PacketWriter data)
        {
            if (!moveSpline.Finalized())
            {
                MoveSplineFlag splineFlags = moveSpline.splineflags;

                if (splineFlags.final_target)
                {
                    ObjectGuid facingGuid = new ObjectGuid(moveSpline.facing.target);
                    data.WriteByteSeq(facingGuid[3]);
                    data.WriteByteSeq(facingGuid[2]);
                    data.WriteByteSeq(facingGuid[0]);
                    data.WriteByteSeq(facingGuid[5]);
                    data.WriteByteSeq(facingGuid[6]);
                    data.WriteByteSeq(facingGuid[7]);
                    data.WriteByteSeq(facingGuid[4]);
                    data.WriteByteSeq(facingGuid[1]);
                }
                data.WriteInt32(moveSpline.timePassed());
                data.WriteUInt32(moveSpline.Duration());

                if (Convert.ToBoolean(splineFlags.Raw() & MoveSplineFlag.eFlags.Parabolic) && moveSpline.effect_start_time < moveSpline.Duration())
                {
                    data.WriteFloat(moveSpline.vertical_acceleration);
                }

                data.WriteFloat(1.0f);  // splineInfo.duration_mod_next; added in 3.1
                data.WriteFloat(1.0f);  // splineInfo.duration_mod; added in 3.1

                if (splineFlags.final_point)
                {
                    data.WriteFloat(moveSpline.facing.x);
                    data.WriteFloat(moveSpline.facing.y);
                    data.WriteFloat(moveSpline.facing.z);
                }

                if (Convert.ToBoolean(splineFlags.Raw() & (MoveSplineFlag.eFlags.Parabolic | MoveSplineFlag.eFlags.Animation)))
                {
                    data.WriteInt32(moveSpline.effect_start_time);       // added in 3.1
                }
                int nodes = moveSpline.getPath().Length;
                for (var i = 0; i < nodes; ++i)
                {
                    data.WriteFloat(moveSpline.getPath()[i].Z);
                    data.WriteFloat(moveSpline.getPath()[i].X);
                    data.WriteFloat(moveSpline.getPath()[i].Y);
                }

                if (splineFlags.final_angle)
                {
                    data.WriteFloat(moveSpline.facing.angle);
                }
            }

            if (!moveSpline.isCyclic())
            {
                Vector3 dest = moveSpline.FinalDestination();
                data.WriteFloat(dest.Z);
                data.WriteFloat(dest.X);
                data.WriteFloat(dest.Y);
            }
            else
            {
                data.WriteVec3(Vector3.Zero);
            }

            data.WriteUInt32(moveSpline.GetId());
        }