예제 #1
0
파일: Npc.cs 프로젝트: xiejiashu/Destiny
        public void Move(Packet iPacket)
        {
            byte action1 = iPacket.ReadByte();
            byte action2 = iPacket.ReadByte();

            Movements movements = null;

            if (iPacket.Remaining > 0)
            {
                movements = Movements.Decode(iPacket);
            }

            using (Packet oPacket = new Packet(ServerOperationCode.NpcMove))
            {
                oPacket
                .WriteInt(this.ObjectID)
                .WriteByte(action1)
                .WriteByte(action2);

                if (movements != null)
                {
                    oPacket.WriteBytes(movements.ToByteArray());
                }

                this.Map.Broadcast(oPacket);
            }
        }
예제 #2
0
        public static void HandleNpcMove(MapleClient client, InPacket iPacket)
        {
            int objectID = iPacket.ReadInt();
            Npc npc;

            try
            {
                npc = client.Character.ControlledNpcs[objectID];
            }
            catch (KeyNotFoundException)
            {
                return;
            }

            byte      a         = iPacket.ReadByte();
            byte      b         = iPacket.ReadByte();
            Movements movements = null;

            using (OutPacket oPacket = new OutPacket(SendOps.NpcMove))
            {
                oPacket
                .WriteInt(npc.ObjectID)
                .WriteByte(a)
                .WriteByte(b);

                if (npc.Data.IsMoving)
                {
                    movements = Movements.Decode(iPacket);

                    movements.Encode(oPacket);
                }

                client.Character.Map.Broadcast(oPacket);
            }
        }
예제 #3
0
        public static void OnMobMove(MapleClient client, InPacket iPacket)
        {
            int objectID = iPacket.ReadInt();

            Mob mob;

            try
            {
                mob = client.Character.ControlledMobs[objectID];
            }
            catch (KeyNotFoundException)
            {
                return;
            }

            short moveAction      = iPacket.ReadShort();
            bool  cheatResult     = (iPacket.ReadByte() & 0xF) != 0;
            byte  centerSplit     = iPacket.ReadByte();
            int   illegalVelocity = iPacket.ReadInt();
            byte  unknown         = iPacket.ReadByte();

            iPacket.ReadInt();

            Movements movements = Movements.Decode(iPacket);

            Movement lastMovement = movements[movements.Count - 1];

            mob.Position = lastMovement.Position;
            mob.Foothold = lastMovement.Foothold;
            mob.Stance   = lastMovement.Stance;

            using (OutPacket oPacket = new OutPacket(SendOps.MobCtrlAck))
            {
                oPacket
                .WriteInt(objectID)
                .WriteShort(moveAction)
                .WriteBool(cheatResult)
                .WriteShort()    // NOTE: Mob mana.
                .WriteByte()     // NOTE: Ability ID.
                .WriteByte();    // NOTE: Ability level.

                client.Send(oPacket);
            }

            using (OutPacket oPacket = new OutPacket(SendOps.MobMove))
            {
                oPacket
                .WriteInt(objectID)
                .WriteBool(cheatResult)
                .WriteByte(centerSplit)
                .WriteInt(illegalVelocity);

                movements.Encode(oPacket);

                client.Character.Map.Broadcast(oPacket, client.Character);
            }
        }
예제 #4
0
        public static void OnMove(MapleClient client, InPacket iPacket)
        {
            Movements movements = Movements.Decode(iPacket);

            // TODO: Validate movements.

            Movement lastMovement = movements[movements.Count - 1];

            client.Character.Position = lastMovement.Position;
            client.Character.Foothold = lastMovement.Foothold;
            client.Character.Stance   = lastMovement.Stance;

            using (OutPacket oPacket = new OutPacket(SendOps.UserMove))
            {
                oPacket.WriteInt(client.Character.ID);
                movements.Encode(oPacket);

                client.Character.Map.Broadcast(oPacket, client.Character);
            }
        }
예제 #5
0
파일: Mob.cs 프로젝트: slashXXxu/Destiny
        public void Move(Packet iPacket)
        {
            short moveAction      = iPacket.ReadShort();
            bool  cheatResult     = (iPacket.ReadByte() & 0xF) != 0;
            byte  centerSplit     = iPacket.ReadByte();
            int   illegalVelocity = iPacket.ReadInt();

            iPacket.Skip(8);
            iPacket.ReadByte();
            iPacket.ReadInt();

            Movements movements = Movements.Decode(iPacket);

            this.Position = movements.Position;
            this.Foothold = movements.Foothold;
            this.Stance   = movements.Stance;

            byte     skillID    = 0;
            byte     skillLevel = 0;
            MobSkill skill      = null;

            if (skill != null)
            {
                if (this.Health * 100 / this.MaxHealth > skill.PercentageLimitHP ||
                    (this.Cooldowns.ContainsKey(skill) && this.Cooldowns[skill].AddSeconds(skill.Cooldown) >= DateTime.Now) ||
                    ((MobSkillName)skill.MapleID) == MobSkillName.Summon && this.Map.Mobs.Count >= 100)
                {
                    skill = null;
                }
            }

            if (skill != null)
            {
                skill.Cast(this);
            }

            using (Packet oPacket = new Packet(ServerOperationCode.MobCtrlAck))
            {
                oPacket
                .WriteInt(this.ObjectID)
                .WriteShort(moveAction)
                .WriteBool(cheatResult)
                .WriteShort((short)this.Mana)
                .WriteByte(skillID)
                .WriteByte(skillLevel);

                this.Controller.Client.Send(oPacket);
            }

            using (Packet oPacket = new Packet(ServerOperationCode.MobMove))
            {
                oPacket
                .WriteInt(this.ObjectID)
                .WriteBool(false)
                .WriteBool(cheatResult)
                .WriteByte(centerSplit)
                .WriteInt(illegalVelocity)
                .WriteBytes(movements.ToByteArray());

                this.Map.Broadcast(oPacket, this.Controller);
            }
        }