Ejemplo n.º 1
0
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            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;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

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

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

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

            double skillBase = from.Skills[def.Skill].Base;

            Type type = null;

            if (CheckHarvestSkill(map, loc, from, resource, def))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

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

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        int amount        = def.ConsumedPerHarvest;
                        int feluccaAmount = def.ConsumedPerFeluccaHarvest;
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = map == Map.Felucca && !Siege.SiegeShard;

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = feluccaRacialAmount;
                            }
                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = racialAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }

                            // Void Pool Rewards
                            item.Amount += WoodsmansTalisman.CheckHarvest(from, type, this);
                        }

                        bank.Consume(amount, from);
                        EventSink.InvokeResourceHarvestSuccess(new ResourceHarvestSuccessEventArgs(from, tool, item, this));

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

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            if (bonus.RequiredMap == null || bonus.RequiredMap == from.Map)
                            {
                                Item bonusItem = Construct(bonus.Type, from, tool);

                                if (Give(from, bonusItem, true))                                        //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                                {
                                    bonus.SendSuccessTo(from);
                                }
                                else
                                {
                                    bonusItem.Delete();
                                }
                            }
                        }
                    }

                    #region High Seas
                    OnToolUsed(from, tool, item != null);
                    #endregion
                }

                // Siege rules will take into account axes and polearms used for lumberjacking
                if (tool is IUsesRemaining && (tool is BaseHarvestTool || tool is Pickaxe || tool is SturdyPickaxe || tool is GargoylesPickaxe || Siege.SiegeShard))
                {
                    IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                    toolWithUses.ShowUsesRemaining = true;

                    if (toolWithUses.UsesRemaining > 0)
                    {
                        --toolWithUses.UsesRemaining;
                    }

                    if (toolWithUses.UsesRemaining < 1)
                    {
                        tool.Delete();
                        def.SendMessageTo(from, def.ToolBrokeMessage);
                    }
                }
            }

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

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Ejemplo n.º 2
0
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

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

            int     tileID;
            Map     map;
            Point3D loc;

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

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

            if (this.SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

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

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = this.MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

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

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            // if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
            // {
            // type = this.GetResourceType(from, tool, def, map, loc, resource);

            // if (type != null)
            // type = this.MutateType(type, from, tool, def, map, loc, resource);

            //daat99 OWLTR start - daat99 harvesting
            type = GetResourceType(from, tool, def, map, loc, resource);
            bool daatHarvesting = false;

            if (daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_MINING) && (type.IsSubclassOf(typeof(BaseOre)) || type.IsSubclassOf(typeof(BaseGranite))))
            {
                daatHarvesting = true;
            }
            else if (daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING) && type.IsSubclassOf(typeof(BaseLog)))
            {
                daatHarvesting = true;
            }
            if (daatHarvesting || (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill)))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }
                if (daatHarvesting)
                {
                    type = ResourceHelper.GetDaat99HarvestedType(type, bank.Vein.IsProspected, skillValue);
                    from.CheckSkill(def.Skill, 0.0, from.Skills[def.Skill].Cap + (vein.IsProspected?10.0:0.0));
                }
                //daat99 OWLTR end - daat99 harvesting
                if (type != null)
                {
                    Item item = this.Construct(type, from, tool);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerFeluccaHarvest;

                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = (map == Map.Felucca);

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = feluccaRacialAmount;
                            }
                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = racialAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }

                            // Void Pool Rewards
                            item.Amount += WoodsmansTalisman.CheckHarvest(from, type, this);
                        }

                        bank.Consume(item.Amount, from);
                        EventSink.InvokeResourceHarvestSuccess(new ResourceHarvestSuccessEventArgs(from, tool, item, this));

                        //daat99 OWLTR start - custom harvesting
                        CraftResource craftResourceFromType = CraftResources.GetFromType(type);
                        string        s_Type   = "UNKNOWN";
                        int           i_Tokens = 1;
                        if (craftResourceFromType != CraftResource.None)
                        {
                            s_Type   = CraftResources.GetInfo(craftResourceFromType).Name;
                            i_Tokens = CraftResources.GetIndex(craftResourceFromType) + 1;
                        }
                        if (craftResourceFromType != CraftResource.None && daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_MINING) && def.Skill == SkillName.Mining && (type.IsSubclassOf(typeof(Server.Items.BaseOre)) || type.IsSubclassOf(typeof(Server.Items.BaseGranite))))
                        {
                            if (type.IsSubclassOf(typeof(Server.Items.BaseOre)))
                            {
                                if (Give(from, item, def.PlaceAtFeetIfFull))
                                {
                                    from.SendMessage("You dig some {0} ore and placed it in your backpack.", s_Type);
                                }
                                else
                                {
                                    from.SendMessage("Your backpack is full, so the ore you mined is lost.");
                                    item.Delete();
                                }
                            }
                            else
                            {
                                if (Give(from, item, def.PlaceAtFeetIfFull))
                                {
                                    from.SendMessage("You carefully extract some workable stone from the ore vein.");
                                }
                                else
                                {
                                    from.SendMessage("Your backpack is full, so the ore you mined is lost.");
                                    item.Delete();
                                }
                            }
                        }
                        else if (craftResourceFromType != CraftResource.None && OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING) && def.Skill == SkillName.Lumberjacking)
                        {
                            if (Give(from, item, def.PlaceAtFeetIfFull))
                            {
                                from.SendMessage("You placed some {0} logs in your backpack.", s_Type);
                            }
                            else
                            {
                                from.SendMessage("You can't place any wood into your backpack!");
                                item.Delete();
                            }
                        }
                        else
                        {
                            //daat99 OWLTR end - custom harvesting

                            if (this.Give(from, item, def.PlaceAtFeetIfFull))
                            {
                                this.SendSuccessTo(from, item, resource);
                            }
                            else
                            {
                                this.SendPackFullTo(from, item, def, resource);
                                item.Delete();
                            }

                            //daat99 OWLTR start - custom harvesting
                        }
                        if (from.Map == Map.Felucca)
                        {
                            i_Tokens = (int)(i_Tokens * 1.5);
                        }
                        if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.HARVEST_GIVE_TOKENS))
                        {
                            TokenSystem.GiveTokensToPlayer(from as Server.Mobiles.PlayerMobile, i_Tokens);
                        }
                        //daat99 OWLTR end - custom harvesting

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            if (bonus.RequiredMap == null || bonus.RequiredMap == from.Map)
                            {
                                Item bonusItem = this.Construct(bonus.Type, from, tool);

                                if (this.Give(from, bonusItem, true))                                   //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                                {
                                    bonus.SendSuccessTo(from);
                                }
                                else
                                {
                                    item.Delete();
                                }
                            }
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }

                    #region High Seas
                    OnToolUsed(from, tool, item != null);
                    #endregion
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }
            //daat99 OWLTR start - custom harvesting
            if (this is Lumberjacking || this is Mining)
            {
                OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest, type);
            }
            else
            {
                this.OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
            }            //daat99 OWLTR end - custom harvesting
        }