示例#1
0
文件: Mob.cs 项目: slashXXxu/Destiny
        public void Buff(MobStatus buff, short value, MobSkill skill)
        {
            using (Packet oPacket = new Packet(ServerOperationCode.MobStatSet))
            {
                oPacket
                .WriteInt(this.ObjectID)
                .WriteLong()
                .WriteInt()
                .WriteInt((int)buff)
                .WriteShort(value)
                .WriteShort(skill.MapleID)
                .WriteShort(skill.Level)
                .WriteShort(-1)
                .WriteShort(0)     // Delay
                .WriteInt();

                this.Map.Broadcast(oPacket);
            }

            Delay.Execute(() =>
            {
                using (Packet Packet = new Packet(ServerOperationCode.MobStatReset))
                {
                    Packet
                    .WriteInt(this.ObjectID)
                    .WriteLong()
                    .WriteInt()
                    .WriteInt((int)buff)
                    .WriteInt();

                    this.Map.Broadcast(Packet);
                }

                this.Buffs.Remove(buff);
            }, skill.Duration * 1000);
        }
示例#2
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);
            }
        }