示例#1
0
        public override Type GetResourceType(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource)
        {
            Type type = FishInfo.GetSpecialItem(from, tool, loc, false);

            if (type == null)
                type = base.GetResourceType(from, tool, def, map, loc, resource);

            return type;
        }
示例#2
0
        public override void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            //Lava fishing needs to have its own set of rules.
            if (IsLavaHarvest(tool, toHarvest))
            {
                from.EndAction(locked);

                if (!CheckHarvest(from, tool))
                {
                    return;
                }

                int     tileID;
                Map     map;
                Point3D loc;

                if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }
                else if (!def.Validate(tileID) && !def.ValidateSpecial(tileID))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }

                if (!CheckRange(from, tool, def, map, loc, true))
                {
                    return;
                }
                else if (!CheckResources(from, tool, def, map, loc, true))
                {
                    return;
                }
                else if (!CheckHarvest(from, tool, def, toHarvest))
                {
                    return;
                }

                HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

                if (bank == null)
                {
                    return;
                }

                HarvestVein vein = bank.Vein;

                if (vein == null)
                {
                    return;
                }

                Type type = null;

                HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, vein.PrimaryResource, vein.FallbackResource);

                if (from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
                {
                    //Special eye candy item
                    type = GetSpecialLavaItem(from, tool, map, loc, toHarvest);

                    //Special fish
                    if (type == null)
                    {
                        type = FishInfo.GetSpecialItem(from, tool, loc, IsLavaHarvest(tool, tileID));
                    }

                    if (type != null)
                    {
                        Item item = Construct(type, from, tool);

                        if (item == null)
                        {
                            type = null;
                        }
                        else
                        {
                            if (from.AccessLevel == AccessLevel.Player)
                            {
                                bank.Consume(Convert.ToInt32(map != null && map.Rules == MapRules.FeluccaRules ? Math.Ceiling(item.Amount / 2.0) : item.Amount), from);
                            }

                            if (Give(from, item, true))
                            {
                                SendSuccessTo(from, item, null);
                            }
                            else
                            {
                                SendPackFullTo(from, item, def, null);
                                item.Delete();
                            }
                        }
                    }
                }

                if (type == null)
                {
                    def.SendMessageTo(from, def.FailMessage);

                    double skill = from.Skills[SkillName.Fishing].Value / 50;

                    if (0.5 / skill > Utility.RandomDouble())
                    {
                        OnToolUsed(from, tool, false);
                    }
                }
                else
                {
                    OnToolUsed(from, tool, true);
                }

                OnHarvestFinished(from, tool, def, vein, bank, null, null);
            }
            else
            {
                base.FinishHarvesting(from, tool, def, toHarvest, locked);
            }
        }