Ejemplo n.º 1
0
        public void Buff(MobStatus buff, short value, MobSkill skill)
        {
            using (Packet outPacket = new Packet(MapleServerOperationCode.ApplyMonsterStatus))
            {
                outPacket.WriteInt(this.ObjectID);
                outPacket.WriteInt((int)buff);
                outPacket.WriteShort(value);
                outPacket.WriteShort(skill.MapleID);
                outPacket.WriteShort(skill.Level);
                outPacket.WriteShort();
                outPacket.WriteShort(0); // Delay
                outPacket.WriteByte(1);

                this.Map.Broadcast(outPacket);
            }

            Delay.Execute(skill.Duration * 1000, () =>
            {
                using (Packet outPacket = new Packet(MapleServerOperationCode.CancelMonsterStatus))
                {
                    outPacket.WriteInt(this.ObjectID);
                    outPacket.WriteInt((int)buff);
                    outPacket.WriteShort(value);
                    outPacket.WriteByte(1);

                    this.Map.Broadcast(outPacket);
                }

                this.Buffs.Remove(buff);
            });
        }
Ejemplo n.º 2
0
        public void Move(Packet inPacket)
        {
            short movementId = inPacket.ReadShort();

            bool  useSkill      = (inPacket.ReadByte() & 0xF) != 0;
            int   skillUnknown1 = inPacket.ReadByte() & 0xFF;
            byte  skillId       = inPacket.ReadByte();
            byte  skillLevel    = inPacket.ReadByte();
            short delay         = inPacket.ReadShort();
            Point startPosition = null;

            if (inPacket.ReadBool())
            {
                startPosition = new Point(inPacket.ReadShort(), inPacket.ReadShort());
            }

            inPacket.Skip(27);
            Movements movements = Movements.Parse(inPacket.ReadBytes());
            MobSkill  skill     = null;

            if (useSkill && this.Skills.Count > 0)
            {
                skill = this.Skills.Random;
            }
            else if ((skillId >= 100 && skillId <= 200) && this.Skills.Contains(skillId, skillLevel)) // TODO: Is this necessary?
            {
                skill = this.Skills[skillId];
            }

            if (skill != null)
            {
                if (this.CurrentHP * 100 / this.MaxHP > 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 outPacket = new Packet(MapleServerOperationCode.MoveMonsterResponse))
            {
                outPacket.WriteInt(this.ObjectID);
                outPacket.WriteShort(movementId);
                outPacket.WriteBool(useSkill);
                outPacket.WriteShort((short)this.CurrentMP);
                outPacket.WriteByte((byte)(skill == null ? 0 : skill.MapleID));
                outPacket.WriteByte((byte)(skill == null ? 0 : skill.Level));
                outPacket.WriteInt();

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

            using (Packet outPacket = new Packet(MapleServerOperationCode.MoveMonster))
            {
                outPacket.WriteInt(this.ObjectID);
                outPacket.WriteShort();
                outPacket.WriteBool(useSkill);
                outPacket.WriteByte((byte)skillUnknown1);
                outPacket.WriteByte(skillId);
                outPacket.WriteByte(skillLevel);
                outPacket.WriteShort(delay);
                outPacket.WriteShort();

                if (startPosition != null)
                {
                    outPacket.WriteShort(startPosition.X);
                    outPacket.WriteShort(startPosition.Y);
                }

                outPacket.WriteShort(this.Position.X);
                outPacket.WriteShort(this.Position.Y);
                outPacket.WriteInt();
                outPacket.WriteBytes(movements.ToByteArray());

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

            foreach (Movement movement in movements) // TODO: Inheritable. Moves, has stance... AnimatedMapleMap? F**k I hate inheritance.
            {
                if (movement is AbsoluteMovement)
                {
                    this.Position = ((AbsoluteMovement)movement).Position;
                }

                if (!(movement is EquipmentMovement))
                {
                    this.Stance = movement.NewStance;
                }
            }
        }