예제 #1
0
 public AdvertCreatedEvent(
     Guid id,
     CatchType catchType,
     double price,
     Advertiser advertiser,
     string pitch,
     FishingMethod fishingMethod
     ) : base(id)
 {
     CatchType     = catchType;
     Price         = price;
     Advertiser    = advertiser;
     Pitch         = pitch;
     FishingMethod = fishingMethod;
 }
예제 #2
0
 public AdvertUpdatedEvent(
     Guid id,
     CatchType catchType,
     double price,
     Advertiser advertiser,
     string pitch,
     FishingMethod fishingMethod,
     AdvertStatus status
     ) : base(id)
 {
     CatchType     = catchType;
     Price         = price;
     Advertiser    = advertiser;
     Pitch         = pitch;
     FishingMethod = fishingMethod;
     Status        = status;
 }
예제 #3
0
		/// <summary>
		/// Called once ready to pull the fish out.
		/// </summary>
		/// <remarks>
		/// When you catch something just before running out of bait,
		/// and you send MotionCancel2 from Cancel, there's a
		/// visual bug on Aura, where the item keeps flying to you until
		/// you move. This does not happen on NA for unknown reason.
		/// The workaround: Check for cancellation in advance and only
		/// send the real in effect if the skill wasn't canceled.
		/// </remarks>
		/// <param name="creature"></param>
		/// <param name="method">Method used on this try</param>
		/// <param name="success">Success of manual try</param>
		public void OnResponse(Creature creature, FishingMethod method, bool success)
		{
			// Get skill
			var skill = creature.Skills.Get(SkillId.Fishing);
			if (skill == null)
			{
				Log.Error("Fishing.OnResponse: Missing skill.");
				return;
			}

			var rnd = RandomProvider.Get();

			// Update prop state
			creature.Temp.FishingProp.SetState("empty");

			// Get auto success
			if (method == FishingMethod.Auto)
				success = rnd.NextDouble() < skill.RankData.Var3 / 100f;

			// Perfect fishing
			if (ChannelServer.Instance.Conf.World.PerfectFishing)
				success = true;

			// Check fishing ground
			if (creature.Temp.FishingDrop == null)
			{
				Send.ServerMessage(creature, "Error: No items found.");
				Log.Error("Fishing.OnResponse: Failing, no drop found.");
				success = false;
			}

			// Check equipment
			if (!this.CheckEquipment(creature))
			{
				Send.ServerMessage(creature, "Error: Missing equipment.");
				Log.Error("Fishing.OnResponse: Failing, Missing equipment.");
				// TODO: Security violation once we're sure this can't happen
				//   without modding.
				success = false;
			}

			var cancel = false;

			// Reduce durability
			if (creature.RightHand != null)
			{
				creature.Inventory.ReduceDurability(creature.RightHand, 15);

				// Check rod durability
				if (creature.RightHand.Durability == 0)
					cancel = true;
			}

			// Remove bait
			if (creature.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteBait)
			{
				creature.Inventory.Decrement(creature.Magazine);

				// Check if bait was removed because it was empty
				if (creature.Magazine == null)
					cancel = true;
			}

			// Fail
			Item item = null;
			if (!success)
			{
				Send.Notice(creature, Localization.Get("I was hesistating for a bit, and it got away...")); // More responses?
				Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.Fall, true);
			}
			// Success
			else
			{
				var propName = "prop_caught_objbox_01";
				var propSize = 0;
				var size = 0;
				var dropData = creature.Temp.FishingDrop;

				// Create item
				if (dropData.QuestId != 0)
					item = Item.CreateQuestScroll(dropData.QuestId);
				else
					item = new Item(dropData);

				// Check fish
				var fish = AuraData.FishDb.Find(dropData.ItemId);
				if (fish != null)
				{
					propName = fish.PropName;
					propSize = fish.PropSize;

					// Random fish size, unofficial
					if (fish.SizeMin + fish.SizeMax != 0)
					{
						var min = fish.SizeMin;
						var max = fish.SizeMax;

						// Var1 bonus
						min += (int)skill.RankData.Var1;

						// Var4 bonus
						min += (int)Math.Max(0, (item.Data.BaseSize - fish.SizeMin) / 100f * skill.RankData.Var4);

						// Modify min and max, so the size falls into big or
						// small territory.
						var mid = (max - min) / 2;
						if (creature.Temp.CatchSize == CatchSize.BigOne)
							min += mid;
						else
							max -= mid;

						// Cap
						if (max < min) max = min;
						if (min > max) min = max;

						size = Math2.Clamp(fish.SizeMin, fish.SizeMax, rnd.Next(min, max + 1));
						var scale = (1f / item.Data.BaseSize * size);

						item.MetaData1.SetFloat("SCALE", scale);

						// Modify selling price based on scale.
						// The default selling price is 10% of the price.
						// If the scale is 2, double the base size (the
						// "usual" size so to speak), it fetches twice
						// the price. The formula is unofficial, but works.
						item.OptionInfo.SellingPrice = (int)(item.OptionInfo.SellingPrice * scale);
					}
				}

				// Set equipment durability to 0, does not apply to
				// unrepairable items, like Gargoyle Swords.
				// http://wiki.mabinogiworld.com/view/Fishing#Details
				if (item.HasTag("/equip/") && !item.HasTag("/not_repairable/"))
					item.Durability = 0;

				// Drop if inv add failed
				List<Item> changed;
				if (!creature.Inventory.Insert(item, false, out changed))
				{
					item.Drop(creature.Region, creature.GetPosition(), 100, creature, false);

					// Set protection limit to max, since fished items that
					// drop out of the player's overfilled bags should be
					// protected indefinitely.
					item.ProtectionLimit = DateTime.MaxValue;
				}

				var itemEntityId = (changed == null || changed.Count == 0 ? item.EntityId : changed.First().EntityId);

				// Show acquire using the item's entity id if it wasn't added
				// to a stack, or using the stack's id if it was.
				Send.AcquireInfo2(creature, "fishing", itemEntityId);

				// Holding up fish effect
				if (!cancel)
					Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.ReelIn, true, creature.Temp.FishingProp.EntityId, item.Info.Id, size, propName, propSize);
			}

			creature.Temp.FishingDrop = null;

			// Handle training
			this.Training(creature, skill, success, item);

			// Fishing event
			ChannelServer.Instance.Events.OnCreatureFished(creature, item);

			// Cancel
			if (cancel)
			{
				creature.Skills.CancelActiveSkill();
				return;
			}

			// Next round
			this.StartFishing(creature, 6000);
		}
예제 #4
0
        /// <summary>
        /// Called once ready to pull the fish out.
        /// </summary>
        /// <remarks>
        /// When you catch something just before running out of bait,
        /// and you send MotionCancel2 from Cancel, there's a
        /// visual bug on Aura, where the item keeps flying to you until
        /// you move. This does not happen on NA for unknown reason.
        /// The workaround: Check for cancellation in advance and only
        /// send the real in effect if the skill wasn't canceled.
        /// </remarks>
        /// <param name="creature"></param>
        /// <param name="method">Method used on this try</param>
        /// <param name="success">Success of manual try</param>
        public void OnResponse(Creature creature, FishingMethod method, bool success)
        {
            // Get skill
            var skill = creature.Skills.Get(SkillId.Fishing);

            if (skill == null)
            {
                Log.Error("Fishing.OnResponse: Missing skill.");
                return;
            }

            var rnd = RandomProvider.Get();

            // Update prop state
            creature.Temp.FishingProp.SetState("empty");

            // Get auto success
            if (method == FishingMethod.Auto)
            {
                success = rnd.NextDouble() < skill.RankData.Var3 / 100f;
            }

            // Perfect fishing
            if (ChannelServer.Instance.Conf.World.PerfectFishing)
            {
                success = true;
            }

            // Check fishing ground
            if (creature.Temp.FishingDrop == null)
            {
                Send.ServerMessage(creature, "Error: No items found.");
                Log.Error("Fishing.OnResponse: Failing, no drop found.");
                success = false;
            }

            // Check equipment
            if (!this.CheckEquipment(creature))
            {
                Send.ServerMessage(creature, "Error: Missing equipment.");
                Log.Error("Fishing.OnResponse: Failing, Missing equipment.");
                // TODO: Security violation once we're sure this can't happen
                //   without modding.
                success = false;
            }

            var cancel = false;

            // Reduce durability
            if (creature.RightHand != null)
            {
                creature.Inventory.ReduceDurability(creature.RightHand, 15);

                // Check rod durability
                if (creature.RightHand.Durability == 0)
                {
                    cancel = true;
                }
            }

            // Remove bait
            if (creature.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteBait)
            {
                creature.Inventory.Decrement(creature.Magazine);

                // Check if bait was removed because it was empty
                if (creature.Magazine == null)
                {
                    cancel = true;
                }
            }

            // Fail
            Item item = null;

            if (!success)
            {
                Send.Notice(creature, Localization.Get("I was hesistating for a bit, and it got away..."));                 // More responses?
                Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.Fall, true);
            }
            // Success
            else
            {
                var propName = "prop_caught_objbox_01";
                var propSize = 0;
                var size     = 0;
                var dropData = creature.Temp.FishingDrop;

                // Create item
                if (dropData.QuestId != 0)
                {
                    item = Item.CreateQuestScroll(dropData.QuestId);
                }
                else
                {
                    item = new Item(dropData);
                }

                // Check fish
                var fish = AuraData.FishDb.Find(dropData.ItemId);
                if (fish != null)
                {
                    propName = fish.PropName;
                    propSize = fish.PropSize;

                    // Random fish size, unofficial
                    if (fish.SizeMin + fish.SizeMax != 0)
                    {
                        var min = fish.SizeMin;
                        var max = fish.SizeMax;

                        // Var1 bonus
                        min += (int)skill.RankData.Var1;

                        // Var4 bonus
                        min += (int)Math.Max(0, (item.Data.BaseSize - fish.SizeMin) / 100f * skill.RankData.Var4);

                        // Modify min and max, so the size falls into big or
                        // small territory.
                        var mid = (max - min) / 2;
                        if (creature.Temp.CatchSize == CatchSize.BigOne)
                        {
                            min += mid;
                        }
                        else
                        {
                            max -= mid;
                        }

                        // Cap
                        if (max < min)
                        {
                            max = min;
                        }
                        if (min > max)
                        {
                            min = max;
                        }

                        size = Math2.Clamp(fish.SizeMin, fish.SizeMax, rnd.Next(min, max + 1));
                        var scale = (1f / item.Data.BaseSize * size);

                        item.MetaData1.SetFloat("SCALE", scale);
                    }
                }

                // Set equipment durability to 0, does not apply to
                // unrepairable items, like Gargoyle Swords.
                // http://wiki.mabinogiworld.com/view/Fishing#Details
                if (item.HasTag("/equip/") && !item.HasTag("/not_repairable/"))
                {
                    item.Durability = 0;
                }

                // Drop if inv add failed
                List <Item> changed;
                if (!creature.Inventory.Insert(item, false, out changed))
                {
                    item.Drop(creature.Region, creature.GetPosition(), 100, creature, false);
                }

                var itemEntityId = (changed == null || changed.Count == 0 ? item.EntityId : changed.First().EntityId);

                // Show acquire using the item's entity id if it wasn't added
                // to a stack, or using the stack's id if it was.
                Send.AcquireInfo2(creature, "fishing", itemEntityId);

                // Holding up fish effect
                if (!cancel)
                {
                    Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.ReelIn, true, creature.Temp.FishingProp.EntityId, item.Info.Id, size, propName, propSize);
                }
            }

            creature.Temp.FishingDrop = null;

            // Handle training
            this.Training(creature, skill, success, item);

            // Fishing event
            ChannelServer.Instance.Events.OnCreatureFished(creature, item);

            // Cancel
            if (cancel)
            {
                creature.Skills.CancelActiveSkill();
                return;
            }

            // Next round
            this.StartFishing(creature, 6000);
        }
예제 #5
0
		/// <summary>
		/// Called once ready to pull the fish out.
		/// </summary>
		/// <remarks>
		/// When you catch something just before running out of bait,
		/// and you send MotionCancel2 from Cancel, there's a
		/// visual bug on Aura, where the item keeps flying to you until
		/// you move. This does not happen on NA for unknown reason.
		/// The workaround: Check for cancellation in advance and only
		/// send the real in effect if the skill wasn't canceled.
		/// </remarks>
		/// <param name="creature"></param>
		/// <param name="method">Method used on this try</param>
		/// <param name="success">Success of manual try</param>
		public void OnResponse(Creature creature, FishingMethod method, bool success)
		{
			// Get skill
			var skill = creature.Skills.Get(SkillId.Fishing);
			if (skill == null)
			{
				Log.Error("Fishing.OnResponse: Missing skill.");
				return;
			}

			var rnd = RandomProvider.Get();

			// Update prop state
			// TODO: update prop state method
			creature.Temp.FishingProp.SetState("empty");

			// Get auto success
			if (method == FishingMethod.Auto)
				success = rnd.NextDouble() < skill.RankData.Var3 / 100f;

			// Perfect fishing
			if (ChannelServer.Instance.Conf.World.PerfectFishing)
				success = true;

			// Check fishing ground
			if (creature.Temp.FishingDrop == null)
			{
				Send.ServerMessage(creature, "Error: No items found.");
				Log.Error("Fishing.OnResponse: Failing, no drop found.");
				success = false;
			}

			// Check equipment
			if (!this.CheckEquipment(creature))
			{
				Send.ServerMessage(creature, "Error: Missing equipment.");
				Log.Error("Fishing.OnResponse: Failing, Missing equipment.");
				// TODO: Security violation once we're sure this can't happen
				//   without modding.
				success = false;
			}

			var cancel = false;

			// Reduce durability
			if (creature.RightHand != null && !ChannelServer.Instance.Conf.World.NoDurabilityLoss)
			{
				var reduce = 15;

				// Half dura loss if blessed
				if (creature.RightHand.IsBlessed)
					reduce = Math.Max(1, reduce / 2);

				creature.RightHand.Durability -= reduce;
				Send.ItemDurabilityUpdate(creature, creature.RightHand);

				// Check rod durability
				if (creature.RightHand.Durability == 0)
					cancel = true;
			}

			// Remove bait
			if (creature.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteBait)
			{
				creature.Inventory.Decrement(creature.Magazine);

				// Check if bait was removed because it was empty
				if (creature.Magazine == null)
					cancel = true;
			}

			// Fail
			Item item = null;
			if (!success)
			{
				Send.Notice(creature, Localization.Get("I was hesistating for a bit, and it got away...")); // More responses?
				Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.Fall, true);
			}
			// Success
			else
			{
				var propName = "prop_caught_objbox_01";
				var propSize = 0;
				var size = 0;

				// Create item
				item = new Item(creature.Temp.FishingDrop);

				// Check fish
				var fish = AuraData.FishDb.Find(creature.Temp.FishingDrop.ItemId);
				if (fish != null)
				{
					propName = fish.PropName;
					propSize = fish.PropSize;

					// Random fish size, unofficial
					if (fish.SizeMin + fish.SizeMax != 0)
					{
						var min = fish.SizeMin + (int)Math.Max(0, (item.Data.BaseSize - fish.SizeMin) / 100f * skill.RankData.Var4);
						var max = fish.SizeMax;

						size = Math2.Clamp(fish.SizeMin, fish.SizeMax, rnd.Next(min, max + 1) + (int)skill.RankData.Var1);
						var scale = (1f / item.Data.BaseSize * size);

						item.MetaData1.SetFloat("SCALE", scale);
					}
				}

				// Set equipment durability
				if (item.HasTag("/equip/") && item.OptionInfo.DurabilityMax >= 1)
					item.Durability = 0;

				// Drop if inv add failed
				List<Item> changed;
				if (!creature.Inventory.Insert(item, false, out changed))
					item.Drop(creature.Region, creature.GetPosition().GetRandomInRange(100, rnd));

				var itemEntityId = (changed == null || changed.Count == 0 ? item.EntityId : changed.First().EntityId);

				// Show acquire using the item's entity id if it wasn't added
				// to a stack, or using the stack's id if it was.
				Send.AcquireInfo2(creature, "fishing", itemEntityId);

				// Holding up fish effect
				if (!cancel)
					Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.ReelIn, true, creature.Temp.FishingProp.EntityId, item.Info.Id, size, propName, propSize);
			}

			creature.Temp.FishingDrop = null;

			// Handle training
			this.Training(creature, skill, success, item);

			// Cancel
			if (cancel)
			{
				creature.Skills.CancelActiveSkill();
				return;
			}

			// Next round
			this.StartFishing(creature, 6000);
		}
예제 #6
0
파일: Fishing.cs 프로젝트: Vinna/aura
        /// <summary>
        /// Called once ready to pull the fish out.
        /// </summary>
        /// <remarks>
        /// When you catch something just before running out of bait,
        /// and you send MotionCancel2 from Cancel, there's a
        /// visual bug on Aura, where the item keeps flying to you until
        /// you move. This does not happen on NA for unknown reason.
        /// The workaround: Check for cancellation in advance and only
        /// send the real in effect if the skill wasn't canceled.
        /// </remarks>
        /// <param name="creature"></param>
        /// <param name="method">Method used on this try</param>
        /// <param name="success">Success of manual try</param>
        public void OnResponse(Creature creature, FishingMethod method, bool success)
        {
            // Get skill
            var skill = creature.Skills.Get(SkillId.Fishing);

            if (skill == null)
            {
                Log.Error("Fishing.OnResponse: Missing skill.");
                return;
            }

            var rnd = RandomProvider.Get();

            // Update prop state
            // TODO: update prop state method
            creature.Temp.FishingProp.SetState("empty");

            // Get auto success
            if (method == FishingMethod.Auto)
            {
                success = rnd.NextDouble() < skill.RankData.Var3 / 100f;
            }

            // Perfect fishing
            if (ChannelServer.Instance.Conf.World.PerfectFishing)
            {
                success = true;
            }

            // Check fishing ground
            if (creature.Temp.FishingDrop == null)
            {
                Send.ServerMessage(creature, "Error: No items found.");
                Log.Error("Fishing.OnResponse: Failing, no drop found.");
                success = false;
            }

            // Check equipment
            if (!this.CheckEquipment(creature))
            {
                Send.ServerMessage(creature, "Error: Missing equipment.");
                Log.Error("Fishing.OnResponse: Failing, Missing equipment.");
                // TODO: Security violation once we're sure this can't happen
                //   without modding.
                success = false;
            }

            var cancel = false;

            // Reduce durability
            if (creature.RightHand != null && !ChannelServer.Instance.Conf.World.NoDurabilityLoss)
            {
                var reduce = 15;

                // Half dura loss if blessed
                if (creature.RightHand.IsBlessed)
                {
                    reduce = Math.Max(1, reduce / 2);
                }

                creature.RightHand.Durability -= reduce;
                Send.ItemDurabilityUpdate(creature, creature.RightHand);

                // Check rod durability
                if (creature.RightHand.Durability == 0)
                {
                    cancel = true;
                }
            }

            // Remove bait
            if (creature.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteBait)
            {
                creature.Inventory.Decrement(creature.Magazine);

                // Check if bait was removed because it was empty
                if (creature.Magazine == null)
                {
                    cancel = true;
                }
            }

            // Fail
            Item item = null;

            if (!success)
            {
                Send.Notice(creature, Localization.Get("I was hesistating for a bit, and it got away..."));                 // More responses?
                Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.Fall, true);
            }
            // Success
            else
            {
                var propName = "prop_caught_objbox_01";
                var propSize = 0;
                var size     = 0;

                // Create item
                item = new Item(creature.Temp.FishingDrop);

                // Check fish
                var fish = AuraData.FishDb.Find(creature.Temp.FishingDrop.ItemId);
                if (fish != null)
                {
                    propName = fish.PropName;
                    propSize = fish.PropSize;

                    // Random fish size, unofficial
                    if (fish.SizeMin + fish.SizeMax != 0)
                    {
                        var min = fish.SizeMin + (int)Math.Max(0, (item.Data.BaseSize - fish.SizeMin) / 100f * skill.RankData.Var4);
                        var max = fish.SizeMax;

                        size = Math2.Clamp(fish.SizeMin, fish.SizeMax, rnd.Next(min, max + 1) + (int)skill.RankData.Var1);
                        var scale = (1f / item.Data.BaseSize * size);

                        item.MetaData1.SetFloat("SCALE", scale);
                    }
                }

                // Set equipment durability
                if (item.HasTag("/equip/") && item.OptionInfo.DurabilityMax >= 1)
                {
                    item.Durability = 0;
                }

                // Drop if inv add failed
                List <Item> changed;
                if (!creature.Inventory.Insert(item, false, out changed))
                {
                    item.Drop(creature.Region, creature.GetPosition().GetRandomInRange(100, rnd), creature, false);
                }

                var itemEntityId = (changed == null || changed.Count == 0 ? item.EntityId : changed.First().EntityId);

                // Show acquire using the item's entity id if it wasn't added
                // to a stack, or using the stack's id if it was.
                Send.AcquireInfo2(creature, "fishing", itemEntityId);

                // Holding up fish effect
                if (!cancel)
                {
                    Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.ReelIn, true, creature.Temp.FishingProp.EntityId, item.Info.Id, size, propName, propSize);
                }
            }

            creature.Temp.FishingDrop = null;

            // Handle training
            this.Training(creature, skill, success, item);

            // Cancel
            if (cancel)
            {
                creature.Skills.CancelActiveSkill();
                return;
            }

            // Next round
            this.StartFishing(creature, 6000);
        }