Example #1
0
        /// <summary>
        /// Sends BlacksmithingMiniGame to creature's client, which starts
        /// the Blacksmithing mini-game.
        /// </summary>
        /// <remarks>
        /// The position of the dots is relative to the upper left of the
        /// field. They land exactly on those spots after "wavering" for a
        /// moment. This wavering is randomized on the client side and
        /// doesn't affect anything.
        /// 
        /// The time bar is always the same, but the time it takes to fill
        /// up changes based on the "time displacement". The lower the value,
        /// the longer it takes to fill up. Using values that are too high
        /// or too low mess up the calculations and cause confusing results.
        /// The official range seems to be between ~0.81 and ~0.98.
        /// </remarks>
        /// <param name="creature"></param>
        /// <param name="prop"></param>
        /// <param name="item"></param>
        /// <param name="dots"></param>
        /// <param name="deviation"></param>
        public static void BlacksmithingMiniGame(Creature creature, Prop prop, Item item, List<BlacksmithDot> dots, int deviation)
        {
            if (dots == null || dots.Count != 5)
                throw new ArgumentException("5 dots required.");

            var packet = new Packet(Op.BlacksmithingMiniGame, creature.EntityId);

            // Untested if this is actually the deviation/cursor size,
            // but Tailoring does something very similar. Just like with
            // Tailoring, wrong values cause failed games.
            packet.PutShort((short)deviation);

            foreach (var dot in dots)
            {
                packet.PutShort((short)dot.X);
                packet.PutShort((short)dot.Y);
                packet.PutFloat(dot.TimeDisplacement);
                packet.PutShort((short)dot.Deviation);
            }

            packet.PutLong(prop.EntityId);
            packet.PutInt(0);
            packet.PutLong(item.EntityId);
            packet.PutInt(0);

            creature.Client.Send(packet);
        }
Example #2
0
		/// <summary>
		/// Sends Disappear to creature's client.
		/// </summary>
		/// <remarks>
		/// Should this be broadcasted? What does it even do? TODO.
		/// </remarks>
		/// <param name="creature"></param>
		public static void Disappear(Creature creature)
		{
			var packet = new Packet(Op.Disappear, MabiId.Channel);
			packet.PutLong(creature.EntityId);

			creature.Client.Send(packet);
		}
Example #3
0
        /// <summary>
        /// Sends DestroyExpiredItemsR to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="success"></param>
        public static void DestroyExpiredItemsR(Creature creature, bool success)
        {
            var packet = new Packet(Op.DestroyExpiredItemsR, creature.EntityId);
            packet.PutByte(success);

            creature.Client.Send(packet);
        }
Example #4
0
		/// <summary>
		/// Sends TouchPropR to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		public static void TouchPropR(Creature creature)
		{
			var packet = new Packet(Op.TouchPropR, creature.EntityId);
			packet.PutByte(true);

			creature.Client.Send(packet);
		}
Example #5
0
		/// <summary>
		/// Sends MailsRequestR to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		public static void MailsRequestR(Creature creature)
		{
			var packet = new Packet(Op.MailsRequestR, creature.EntityId);
			// ...

			creature.Client.Send(packet);
		}
Example #6
0
		/// <summary>
		/// Sends RequestRebirthR to creature's client.
		/// </summary>
		/// <param name="vehicle"></param>
		public static void RequestRebirthR(Creature creature, bool success)
		{
			var packet = new Packet(Op.RequestRebirthR, MabiId.Login);
			packet.PutByte(success);

			creature.Client.Send(packet);
		}
Example #7
0
		/// <summary>
		/// Prepares skill, skips right to used.
		/// </summary>
		/// <remarks>
		/// Doesn't check anything, like what you can gather with what,
		/// because at this point there's no chance for abuse.
		/// </remarks>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var entityId = packet.GetLong();
			var collectId = packet.GetInt();

			// You shall stop
			creature.StopMove();
			var creaturePosition = creature.GetPosition();

			// Get target (either prop or creature)
			var targetEntity = this.GetTargetEntity(creature.Region, entityId);
			if (targetEntity != null)
				creature.Temp.GatheringTargetPosition = targetEntity.GetPosition();

			// Check distance
			if (!creaturePosition.InRange(creature.Temp.GatheringTargetPosition, MaxDistance))
			{
				Send.Notice(creature, Localization.Get("Your arms are too short to reach that from here."));
				return false;
			}

			// ? (sets creatures position on the client side)
			Send.CollectAnimation(creature, entityId, collectId, creaturePosition);

			// Use
			Send.SkillUse(creature, skill.Info.Id, entityId, collectId);
			skill.State = SkillState.Used;

			return true;
		}
Example #8
0
		/// <summary>
		/// Prepares skill, goes straight to use to skip readying and using it.
		/// </summary>
		/// <remarks>
		/// The client will take a moment to send the Complete packet,
		/// as if it would cast the skill first.
		/// </remarks>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			Send.SkillUse(creature, skill.Info.Id, 0);
			skill.State = SkillState.Used;

			return true;
		}
Example #9
0
		/// <summary>
		/// Completes skill, dropping a cobweb.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		public void Complete(Creature creature, Skill skill, Packet packet)
		{
			var cobweb = new Item(ItemId);
			cobweb.Drop(creature.Region, creature.GetPosition(), 200, creature, true);

			Send.SkillComplete(creature, skill.Info.Id);
		}
Example #10
0
        /// <summary>
        /// Broadcasts CancelMotion in creature's region.
        /// </summary>
        /// <param name="creature"></param>
        public static void CancelMotion(Creature creature)
        {
            var cancelPacket = new Packet(Op.CancelMotion, creature.EntityId);
            cancelPacket.PutByte(0);

            creature.Region.Broadcast(cancelPacket, creature);
        }
Example #11
0
        /// <summary>
        /// Sends ChannelDisconnectR to client.
        /// </summary>
        /// <param name="client"></param>
        public static void ChannelDisconnectR(ChannelClient client)
        {
            var packet = new Packet(Op.DisconnectRequestR, MabiId.Channel);
            packet.PutByte(0);

            client.Send(packet);
        }
Example #12
0
		public void Complete(Creature creature, Skill skill, Packet packet)
		{
			var str = packet.GetString();
			var dict = new MabiDictionary(str);

			var hwEntityId = dict.GetLong("ITEMID");
			if (hwEntityId == 0)
				goto L_End;

			var hw = creature.Inventory.GetItemSafe(hwEntityId);
			if (!hw.HasTag("/large_blessing_potion/"))
				goto L_End;

			// TODO: Check loading time

			var items = creature.Inventory.GetEquipment();
			foreach (var item in items)
			{
				var blessable = (item.HasTag("/equip/") && !item.HasTag("/not_bless/"));

				if (blessable)
					item.OptionInfo.Flags |= ItemFlags.Blessed;
			}

			creature.Inventory.Decrement(hw, 1);
			Send.ItemBlessed(creature, items);

		L_End:
			Send.UseMotion(creature, 14, 0);
			Send.SkillComplete(creature, skill.Info.Id, str);
		}
Example #13
0
		/// <summary>
		/// Completes skill, warping to destination.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		public void Complete(Creature creature, Skill skill, Packet packet)
		{
			var destination = (Continent)packet.GetByte();

			int regionId, x, y;
			switch (destination)
			{
				case Continent.Uladh:
					if (creature.Keywords.Has("portal_dunbarton"))
					{
						regionId = 14; x = 41598; y = 36010; // Dun
					}
					else
					{
						regionId = 1; x = 12789; y = 38399; // Tir
					}
					break;
				case Continent.Iria:
					regionId = 3001; x = 164837; y = 170144; // Qilla
					break;
				case Continent.Belvast:
					regionId = 4005; x = 41760; y = 26924; // Belvast
					break;
				default:
					Send.Notice(creature, "Unknown destination.");
					Send.SkillCancel(creature);
					return;
			}

			creature.Warp(regionId, x, y);

			Send.SkillComplete(creature, skill.Info.Id, (byte)destination);
		}
Example #14
0
		protected override byte[] BuildPacket(Packet packet)
		{
			var packetSize = packet.GetSize();

			// Calculate header size
			var headerSize = 3;
			int n = packetSize;
			do { headerSize++; n >>= 7; } while (n != 0);

			// Write header
			var result = new byte[headerSize + packetSize];
			result[0] = 0x55;
			result[1] = 0x12;
			result[2] = 0x00;

			// Length
			var ptr = 3;
			n = packetSize;
			do
			{
				result[ptr++] = (byte)(n > 0x7F ? (0x80 | (n & 0xFF)) : n & 0xFF);
				n >>= 7;
			}
			while (n != 0);

			// Write packet
			packet.Build(ref result, ptr);

			return result;
		}
Example #15
0
        /// <summary>
        ///  Sends NewQuest to creature's client.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="quest"></param>
        public static void NewQuest(Creature character, Quest quest)
        {
            var packet = new Packet(Op.NewQuest, character.EntityId);
            packet.AddQuest(quest);

            character.Client.Send(packet);
        }
Example #16
0
		/// <summary>
		/// Sends PetUnregister to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="pet"></param>
		public static void PetUnregister(Creature creature, Creature pet)
		{
			var packet = new Packet(Op.PetUnregister, creature.EntityId);
			packet.PutLong(pet.EntityId);

			creature.Client.Send(packet);
		}
Example #17
0
        /// <summary>
        /// Broadcasts PartySetActiveQuest in party.
        /// </summary>
        /// <param name="party"></param>
        /// <param name="uniqueQuestId"></param>
        public static void PartySetActiveQuest(Party party, long uniqueQuestId)
        {
            var packet = new Packet(Op.PartySetActiveQuest, 0);
            packet.PutLong(uniqueQuestId);

            party.Broadcast(packet, true);
        }
Example #18
0
		/// <summary>
		/// Sends TelePetR to pet's client.
		/// </summary>
		/// <param name="pet"></param>
		/// <param name="success"></param>
		public static void TelePetR(Creature pet, bool success)
		{
			var packet = new Packet(Op.TelePetR, pet.EntityId);
			packet.PutByte(success);

			pet.Client.Send(packet);
		}
Example #19
0
		/// <summary>
		/// Sends EnterRebirthR to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		public static void EnterRebirthR(Creature creature)
		{
			var packet = new Packet(Op.EnterRebirthR, creature.EntityId);
			packet.PutByte(0);

			creature.Client.Send(packet);
		}
Example #20
0
        /// <summary>
        /// Sends Internal.ServerIdentify to login server.
        /// </summary>
        public static void Internal_ServerIdentify()
        {
            var packet = new Packet(Op.Internal.ServerIdentify, 0);
            packet.PutString(Password.Hash(ChannelServer.Instance.Conf.Internal.Password));

            ChannelServer.Instance.LoginServer.Send(packet);
        }
		/// <summary>
		/// Readies the skill.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		/// <returns></returns>
		public override bool Ready(Creature creature, Skill skill, Packet packet)
		{
			Send.Effect(creature, 5, (byte)0);
			Send.SkillReady(creature, skill.Info.Id);

			return true;
		}
Example #22
0
        /// <summary>
        /// Sends PetUnmountR to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="success"></param>
        public static void PetUnmountR(Creature creature, bool success)
        {
            var packet = new Packet(Op.PetUnmountR, creature.EntityId);
            packet.PutByte(success);

            creature.Client.Send(packet);
        }
Example #23
0
		/// <summary>
		/// Broadcasts prop update in its region.
		/// </summary>
		/// <param name="prop"></param>
		public static void PropUpdate(Prop prop)
		{
			var packet = new Packet(Op.PropUpdate, prop.EntityId);
			packet.AddPropUpdateInfo(prop);

			prop.Region.Broadcast(packet);
		}
Example #24
0
		/// <summary>
		/// Broadcasts PropDisappears in prop's region.
		/// </summary>
		/// <param name="prop"></param>
		public static void PropDisappears(Prop prop)
		{
			var packet = new Packet(Op.PropDisappears, MabiId.Broadcast);
			packet.PutLong(prop.EntityId);

			prop.Region.Broadcast(packet, prop, false);
		}
Example #25
0
		/// <summary>
		/// Sends SosButtonRequestR to creature's client.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="enabled"></param>
		public static void SosButtonRequestR(Creature creature, bool enabled)
		{
			var packet = new Packet(Op.SosButtonRequestR, creature.EntityId);
			packet.PutByte(enabled);

			creature.Client.Send(packet);
		}
Example #26
0
        /// <summary>
        /// Sends QuestClear to creature's client.
        /// </summary>
        /// <remarks>
        /// Removes quest from quest log.
        /// </remarks>
        /// <param name="creature"></param>
        /// <param name="questId"></param>
        public static void QuestClear(Creature creature, long questId)
        {
            var packet = new Packet(Op.QuestClear, creature.EntityId);
            packet.PutLong(questId);

            creature.Client.Send(packet);
        }
Example #27
0
        /// <summary>
        /// Sends BurnItemR to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="success"></param>
        public static void BurnItemR(Creature creature, bool success)
        {
            var packet = new Packet(Op.BurnItemR, creature.EntityId);
            packet.PutByte(success);

            creature.Client.Send(packet);
        }
Example #28
0
        /// <summary>
        /// Sends CompleteQuestR to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="success"></param>
        public static void GiveUpQuestR(Creature creature, bool success)
        {
            var packet = new Packet(Op.GiveUpQuestR, creature.EntityId);
            packet.PutByte(success);

            creature.Client.Send(packet);
        }
Example #29
0
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			Send.SkillFlashEffect(creature);
			Send.SkillPrepare(creature, skill.Info.Id, skill.GetCastTime());

			return true;
		}
Example #30
0
        /// <summary>
        /// Sends GmcpInvisibilityR to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="success"></param>
        public static void GmcpInvisibilityR(Creature creature, bool success)
        {
            var packet = new Packet(Op.GmcpInvisibilityR, creature.EntityId);
            packet.PutByte(success);

            creature.Client.Send(packet);
        }