Beispiel #1
0
        /// <summary>
        /// Sends SkillComplete to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        public static void SkillComplete(Creature creature, SkillId skillId)
        {
            var packet = new Packet(Op.SkillComplete, creature.EntityId);
            packet.PutUShort((ushort)skillId);

            creature.Client.Send(packet);
        }
Beispiel #2
0
		/// <summary>
		/// Broadcasts RankUp in range of creature.
		/// </summary>
		/// <remarks>
		/// The second parameter is the rank, but doesn't seem to be necessary.
		/// </remarks>
		/// <param name="creature"></param>
		/// <param name="skillId">Excluded if 0</param>
		public static void RankUp(Creature creature, SkillId skillId = 0)
		{
			var packet = new Packet(Op.RankUp, creature.EntityId);
			if (skillId > 0)
				packet.PutUShort((ushort)skillId);
			packet.PutShort(1); // Rank

			creature.Region.Broadcast(packet, creature);
		}
Beispiel #3
0
		/// <summary>
		/// Broadcasts Effect in range of creature, with the given packet id.
		/// </summary>
		/// <remarks>
		/// Parameters have to be casted to the proper type, use carefully!
		/// </remarks>
		/// <param name="id"></param>
		/// <param name="entity"></param>
		/// <param name="effectId"></param>
		/// <param name="parameters"></param>
		public static void Effect(long id, Entity entity, int effectId, params object[] parameters)
		{
			var packet = new Packet(Op.Effect, id);
			packet.PutInt(effectId);
			foreach (var p in parameters)
			{
				if (p is byte) packet.PutByte((byte)p);
				else if (p is bool) packet.PutByte((bool)p);
				else if (p is short) packet.PutShort((short)p);
				else if (p is ushort) packet.PutUShort((ushort)p);
				else if (p is int) packet.PutInt((int)p);
				else if (p is uint) packet.PutUInt((uint)p);
				else if (p is long) packet.PutLong((long)p);
				else if (p is ulong) packet.PutULong((ulong)p);
				else if (p is float) packet.PutFloat((float)p);
				else if (p is string) packet.PutString((string)p);
				else
					throw new Exception("Unsupported effect parameter: " + p.GetType());
			}

			entity.Region.Broadcast(packet, entity);
		}
Beispiel #4
0
        /// <summary>
        /// Sends SkillStop to creature's client or broadcasts it if skill is
        /// of type "BroadcastStartStop".
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skill"></param>
        /// <param name="unkByte"></param>
        public static void SkillStop(Creature creature, Skill skill, byte unkByte)
        {
            var packet = new Packet(Op.SkillStop, creature.EntityId);
            packet.PutUShort((ushort)skill.Info.Id);
            packet.PutByte(unkByte);

            if (skill.Data.Type != SkillType.BroadcastStartStop)
                creature.Client.Send(packet);
            else
                creature.Region.Broadcast(packet, creature);
        }
Beispiel #5
0
		/// <summary>
		/// Sends RemoveKeyword to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="keywordId"></param>
		public static void RemoveKeyword(Creature creature, ushort keywordId)
		{
			var packet = new Packet(Op.RemoveKeyword, creature.EntityId);
			packet.PutUShort(keywordId);

			creature.Client.Send(packet);
		}
Beispiel #6
0
        /// <summary>
        /// Sends ItemAmount to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="item"></param>
        public static void ItemAmount(Creature creature, Item item)
        {
            var packet = new Packet(Op.ItemAmount, creature.EntityId);
            packet.PutLong(item.EntityId);
            packet.PutUShort(item.Info.Amount);
            packet.PutByte(2); // ? (related to the 2 in move item?)

            creature.Client.Send(packet);
        }
Beispiel #7
0
        /// <summary>
        /// Broadcasts Effect in range of creature.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="instrument"></param>
        /// <param name="compressedMML"></param>
        /// <param name="rndScore"></param>
        public static void SkillUsePlayingInstrument(Creature creature, SkillId skillId, InstrumentType instrument, string compressedMML, int rndScore)
        {
            var packet = new Packet(Op.SkillUse, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutLong(0);
            packet.PutByte(compressedMML != null); // has scroll
            if (compressedMML != null)
                packet.PutString(compressedMML);
            else
                packet.PutInt(rndScore);
            packet.PutByte((byte)instrument);
            packet.PutByte(1);
            packet.PutByte(0);

            creature.Client.Send(packet);
        }
Beispiel #8
0
        /// <summary>
        /// Sends SkillUse to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="part"></param>
        /// <param name="unkByte"></param>
        public static void SkillUseDye(Creature creature, SkillId skillId, int part, byte unkByte)
        {
            var packet = new Packet(Op.SkillUse, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutInt(part);
            packet.PutByte(unkByte);

            creature.Client.Send(packet);
        }
Beispiel #9
0
        /// <summary>
        /// Sends SkillUse to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="entityId"></param>
        /// <param name="unk1"></param>
        /// <param name="unk2"></param>
        public static void SkillUse(Creature creature, SkillId skillId, long entityId, byte unk1, string unk2)
        {
            var packet = new Packet(Op.SkillUse, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutLong(entityId);
            packet.PutByte(unk1);
            packet.PutString(unk2);

            creature.Client.Send(packet);
        }
Beispiel #10
0
        /// <summary>
        /// Sends SkillComplete to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="entityId"></param>
        /// <param name="unkInt"></param>
        /// <param name="unkShort"></param>
        public static void SkillCompleteUnk(Creature creature, SkillId skillId, long entityId, int unkInt, short unkShort)
        {
            var packet = new Packet(Op.SkillCompleteUnk, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutLong(entityId);
            packet.PutInt(unkInt);
            packet.PutShort(unkShort);

            creature.Client.Send(packet);
        }
Beispiel #11
0
        /// <summary>
        /// Sends SharpMind to all creatures in range of user.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="target"></param>
        /// <param name="skillId"></param>
        /// <param name="state"></param>
        public static void SharpMind(Creature user, Creature target, SkillId skillId, SharpMindStatus state)
        {
            var packet = new Packet(Op.SharpMind, target.EntityId);
            packet.PutLong(user.EntityId);
            packet.PutByte(1);
            packet.PutByte(1);
            packet.PutUShort((ushort)skillId);
            packet.PutInt((int)state);

            target.Client.Send(packet);
        }
Beispiel #12
0
        /// <summary>
        /// Sends ResetCooldown to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        public static void ResetCooldown(Creature creature, SkillId skillId)
        {
            var packet = new Packet(Op.ResetCooldown, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutByte(0); // end of list?

            creature.Client.Send(packet);
        }
Beispiel #13
0
        /// <summary>
        /// Sends ProductionSuccessRequestR to creature's client, informing it
        /// about the success rate it requested.
        /// </summary>
        /// <remarks>
        /// This version of the packet is used for Tailoring and Blacksmithing.
        /// </remarks>
        /// <param name="creature"></param>
        /// <param name="skillId">Skill the rate is used for.</param>
        /// <param name="successRate">
        /// Bonus success rate, added to the value calculated by the client,
        /// or the total success rate to use, if totalSuccess is true.
        /// </param>
        /// <param name="totalSuccess">
        /// If true, the client will display the given successRate, if it's false,
        /// it will calculate the default rate itself and add successRate as bonus.
        /// </param>
        public static void ProductionSuccessRequestR(Creature creature, SkillId skillId, float successRate, bool totalSuccess, float unkFloat)
        {
            var gp = new Packet(Op.ProductionSuccessRequestR, creature.EntityId);

            gp.PutByte(1);
            gp.PutUShort((ushort)skillId);
            gp.PutShort(6);
            gp.PutFloat(successRate);
            gp.PutByte(0);
            gp.PutByte(totalSuccess);
            gp.PutFloat(unkFloat);

            creature.Client.Send(gp);
        }
Beispiel #14
0
		/// <summary>
		/// Broadcasts TitleUpdate in creature's range.
		/// </summary>
		/// <param name="creature"></param>
		public static void TitleUpdate(Creature creature)
		{
			var packet = new Packet(Op.TitleUpdate, creature.EntityId);
			packet.PutUShort(creature.Titles.SelectedTitle);
			packet.PutUShort(creature.Titles.SelectedOptionTitle);

			creature.Region.Broadcast(packet, creature);
		}
Beispiel #15
0
		/// <summary>
		/// Sends AddTitle(Knowledge) to creature's client,
		/// depending on state.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="titleId"></param>
		/// <param name="state"></param>
		public static void AddTitle(Creature creature, ushort titleId, TitleState state)
		{
			var op = (state == TitleState.Known ? Op.AddTitleKnowledge : Op.AddTitle);

			var packet = new Packet(op, creature.EntityId);
			packet.PutUShort(titleId);
			packet.PutInt(0);

			creature.Client.Send(packet);
		}
Beispiel #16
0
        /// <summary>
        /// Sends SkillStopSilentCancel to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        public static void SkillStopSilentCancel(Creature creature, SkillId skillId)
        {
            var packet = new Packet(Op.SkillStopSilentCancel, creature.EntityId);
            packet.PutUShort((ushort)skillId);

            creature.Client.Send(packet);
        }
Beispiel #17
0
        /// <summary>
        /// Sends SkillUse to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="dict"></param>
        public static void SkillUse(Creature creature, SkillId skillId, string dict)
        {
            var packet = new Packet(Op.SkillUse, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutString(dict);

            creature.Client.Send(packet);
        }
Beispiel #18
0
        /// <summary>
        /// Sends SkillPrepare to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="castTime">Not always the cast time.</param>
        public static void SkillPrepare(Creature creature, SkillId skillId, int castTime)
        {
            var packet = new Packet(Op.SkillPrepare, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            if (skillId != SkillId.None)
                packet.PutInt(castTime);

            creature.Client.Send(packet);
        }
Beispiel #19
0
        /// <summary>
        /// Sends SkillUse to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="part"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void SkillUseDye(Creature creature, SkillId skillId, int part, short x, short y)
        {
            var packet = new Packet(Op.SkillUse, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutInt(part);
            packet.PutShort(x);
            packet.PutShort(y);

            creature.Client.Send(packet);
        }
Beispiel #20
0
        /// <summary>
        /// Sends SkillPrepareCancellation to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="unkByte"></param>
        public static void SkillPrepareCancellation(Creature creature, SkillId skillId, byte unkByte)
        {
            var packet = new Packet(Op.SkillPrepareCancellation, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutByte(unkByte);

            creature.Client.Send(packet);
        }
Beispiel #21
0
        /// <summary>
        /// Sends SkillUse to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="entityId"></param>
        public static void SkillUseEntity(Creature creature, SkillId skillId, long entityId)
        {
            var packet = new Packet(Op.SkillUse, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutLong(entityId);

            creature.Client.Send(packet);
        }
Beispiel #22
0
        /// <summary>
        /// Sends SkillReady to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="extra"></param>
        public static void SkillReady(Creature creature, SkillId skillId, string extra = "")
        {
            var packet = new Packet(Op.SkillReady, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutString(extra);

            creature.Client.Send(packet);
        }
Beispiel #23
0
        /// <summary>
        /// Sends SkillUse to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="stun"></param>
        /// <param name="unk"></param>
        public static void SkillUseStun(Creature creature, SkillId skillId, int stun, int unk)
        {
            var packet = new Packet(Op.SkillUse, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutInt(stun);
            packet.PutInt(unk);

            creature.Client.Send(packet);
        }
Beispiel #24
0
        /// <summary>
        /// Sends SkillReady to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="unkInt"></param>
        public static void SkillReady(Creature creature, SkillId skillId, int unkInt)
        {
            var packet = new Packet(Op.SkillReady, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutInt(unkInt);

            creature.Client.Send(packet);
        }
Beispiel #25
0
		/// <summary>
		/// Sends SwitchChannelR to creature's client
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="channel">Negative answer if null.</param>
		public static void SwitchChannelR(Creature creature, ChannelInfo channel)
		{
			var packet = new Packet(Op.SwitchChannelR, MabiId.Channel);
			packet.PutByte(channel != null);

			if (channel != null)
			{
				packet.PutString(channel.ServerName);
				packet.PutString(channel.Name);
				packet.PutShort(1); // Channel id
				packet.PutString(channel.Host);
				packet.PutString(channel.Host);
				packet.PutUShort((ushort)channel.Port);
				packet.PutUShort((ushort)(channel.Port + 4));
			}

			creature.Client.Send(packet);
		}
Beispiel #26
0
        /// <summary>
        /// Sends SkillReady to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="itemEntityId"></param>
        /// <param name="dyeEntityId"></param>
        public static void SkillReadyDye(Creature creature, SkillId skillId, long itemEntityId, long dyeEntityId)
        {
            var packet = new Packet(Op.SkillReady, creature.EntityId);
            packet.PutUShort((ushort)skillId);
            packet.PutLong(itemEntityId);
            packet.PutLong(dyeEntityId);

            creature.Client.Send(packet);
        }
Beispiel #27
0
		/// <summary>
		/// Sends CombatUsedSkill to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skillId"></param>
		public static void CombatUsedSkill(Creature creature, SkillId skillId)
		{
			var packet = new Packet(Op.CombatUsedSkill, creature.EntityId);
			packet.PutUShort((ushort)skillId);

			creature.Client.Send(packet);
		}
Beispiel #28
0
        /// <summary>
        /// Sends SkillStackSet to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skillId"></param>
        /// <param name="stacks"></param>
        public static void SkillStackSet(Creature creature, SkillId skillId, int stacks)
        {
            var packet = new Packet(Op.SkillStackSet, creature.EntityId);
            packet.PutByte((byte)stacks);
            packet.PutByte(1);
            packet.PutUShort((ushort)skillId);

            creature.Client.Send(packet);
        }