コード例 #1
0
ファイル: CombatHandler.cs プロジェクト: ovr/CypherCore
        public static void HandleAttackSwingOpcode(ref PacketReader packet, ref WorldSession session)
        {
            ulong guid = packet.ReadUInt64();

            Log.outDebug("WORLD: Recvd CMSG_ATTACKSWING Message guidlow:{0} guidhigh:{1}", ObjectGuid.GuidLowPart(guid), ObjectGuid.GuidHiPart(guid));

            var pl = session.GetPlayer();

            Unit pEnemy = Cypher.ObjMgr.GetUnit(pl, guid);

            if (pEnemy == null)
            {
                // stop attack state at client
                SendAttackStop(null, pl);
                return;
            }

            //if (!pl.IsValidAttackTarget(pEnemy))
            {
                // stop attack state at client
                //SendAttackStop(pEnemy, pl);
                //return;
            }

            //! Client explicitly checks the following before sending CMSG_ATTACKSWING packet,
            //! so we'll place the same check here. Note that it might be possible to reuse this snippet
            //! in other places as well.
            //if (Vehicle* vehicle = _player->GetVehicle())
            {
                //VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(_player);
                //ASSERT(seat);
                //if (!(seat->m_flags & VEHICLE_SEAT_FLAG_CAN_ATTACK))
                {
                    //SendAttackStop(pEnemy);
                    //return;
                }
            }

            pl.Attack(pEnemy, true);
        }