RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Crash when fishing over 120

aarony14

Traveler
Hi Everyone,

I was wondering if anyone could provide some insight to an issue I seem to be having. I was trying to create a fishing rod that increased fishing skill, which was no problems. The issue was when I used it, as soon I finished using the rod the server would crash. After some more testing I found that anytime the fishing skill was over 120 and I used a fishing rod to fish, the server would crash with an error:

Code:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Engines.Harvest.HarvestSystem.FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, Object toHarvest, Object locked)
   at Server.Engines.Harvest.HarvestSoundTimer.OnTick()
   at Server.Timer.Slice()
   at Server.Core.Main(String[] args)

I have looked at the HarvestSystem.cs file and honestly can't figure out where this issue is caused. I am using OWLTR by daat99. Here is an excerpt of the FinishHarvesting class:

Code:
        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 ) )
            {
                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;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;
            //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 )) )
            {
                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 = Construct( type, from );

                    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;
                        }

                        bank.Consume( item.Amount, from );
                        //daat99 OWLTR start - custom harvesting
                        string s_Type = CraftResources.GetInfo(CraftResources.GetFromType(type)).Name;
                        int i_Tokens = CraftResources.GetIndex(CraftResources.GetFromType(type))+1;
                        if (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 (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 ( Give( from, item, def.PlaceAtFeetIfFull ) )
                            {
                                SendSuccessTo( from, item, resource );
                            }
                            else
                            {
                                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 )
                        {
                            Item bonusItem = Construct( bonus.Type, from );

                            if ( 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 );
                            }
                        }
                    }
                }
            }

            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
            //daat99 OWLTR end - custom harvesting
            OnHarvestFinished( from, tool, def, vein, bank, resource, toHarvest );
        }

Does anyone think they can shed some light on why I can't fish with skill over 120 in fishing? Thanks for any help you can provide.
 

aarony14

Traveler
Thanks for the reply hammerhand. I guess I should have mentioned that the crash still happens if I completely remove the custom fishing pole script from my server and I manually set my character's fishing skill to say 130 and then I use a regular fishing pole.
 

_Epila_

Sorceror
Run the server with -debug option then paste Server.Engines.Harvest.HarvestSystem script and Fishing.cs
It will allow us to see in what line the problem occur
 

aarony14

Traveler
Thanks for replying Epile. Took some searching on how to do this but here is the new error:

Code:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
  at Server.Engines.Harvest.HarvestSystem.FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, Object toHarvest, Object locked) in d:\RunUO-2.4\Scripts\Engines\Harvest\Core\HarvestSystem.cs:line 202
  at Server.Engines.Harvest.HarvestSoundTimer.OnTick() in d:\RunUO-2.4\Scripts\Engines\Harvest\Core\HarvestSoundTimer.cs:line 30
  at Server.Timer.Slice()
  at Server.Core.Main(String[] args)

And here are the files you asked to see:

HarvestSystem.cs
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Targeting;
using daat99;
 
namespace Server.Engines.Harvest
{
    public abstract class HarvestSystem
    {
        private List<HarvestDefinition> m_Definitions;
 
        public List<HarvestDefinition> Definitions { get { return m_Definitions; } }
 
        public HarvestSystem()
        {
            m_Definitions = new List<HarvestDefinition>();
        }
 
        public virtual bool CheckTool( Mobile from, Item tool )
        {
            bool wornOut = ( tool == null || tool.Deleted || (tool is IUsesRemaining && ((IUsesRemaining)tool).UsesRemaining <= 0) );
 
            if ( wornOut )
                from.SendLocalizedMessage( 1044038 ); // You have worn out your tool!
 
            return !wornOut;
        }
 
        public virtual bool CheckHarvest( Mobile from, Item tool )
        {
            return CheckTool( from, tool );
        }
 
        public virtual bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
            return CheckTool( from, tool );
        }
 
        public virtual bool CheckRange( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
        {
            bool inRange = ( from.Map == map && from.InRange( loc, def.MaxRange ) );
 
            if ( !inRange )
                def.SendMessageTo( from, timed ? def.TimedOutOfRangeMessage : def.OutOfRangeMessage );
 
            return inRange;
        }
 
        public virtual bool CheckResources( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
        {
            HarvestBank bank = def.GetBank( map, loc.X, loc.Y );
            bool available = ( bank != null && bank.Current >= def.ConsumedPerHarvest );
 
            if ( !available )
                def.SendMessageTo( from, timed ? def.DoubleHarvestMessage : def.NoResourcesMessage );
 
            return available;
        }
 
        public virtual void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
        {
        }
 
        public virtual object GetLock( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
            /* Here we prevent multiple harvesting.
            *
            * Some options:
            *  - 'return tool;' : This will allow the player to harvest more than once concurrently, but only if they use multiple tools. This seems to be as OSI.
            *  - 'return GetType();' : This will disallow multiple harvesting of the same type. That is, we couldn't mine more than once concurrently, but we could be both mining and lumberjacking.
            *  - 'return typeof( HarvestSystem );' : This will completely restrict concurrent harvesting.
            */
 
            return tool;
        }
 
        public virtual void OnConcurrentHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
        }
 
        public virtual void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
        }
 
        public virtual bool BeginHarvesting( Mobile from, Item tool )
        {
            if ( !CheckHarvest( from, tool ) )
                return false;
 
            from.Target = new HarvestTarget( tool, this );
            return true;
        }
 
        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 ) )
            {
                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;
            double skillValue = from.Skills[def.Skill].Value;
 
            Type type = null;
            //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 )) )
            {
                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 = Construct( type, from );
 
                    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;
                        }
 
                        bank.Consume( item.Amount, from );
                        //daat99 OWLTR start - custom harvesting
                        string s_Type = CraftResources.GetInfo(CraftResources.GetFromType(type)).Name;
                        int i_Tokens = CraftResources.GetIndex(CraftResources.GetFromType(type))+1;
                        if (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 (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 ( Give( from, item, def.PlaceAtFeetIfFull ) )
                            {
                                SendSuccessTo( from, item, resource );
                            }
                            else
                            {
                                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 )
                        {
                            Item bonusItem = Construct( bonus.Type, from );
 
                            if ( 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 );
                            }
                        }
                    }
                }
            }
 
            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
            //daat99 OWLTR end - custom harvesting
            OnHarvestFinished( from, tool, def, vein, bank, resource, toHarvest );
        }
 
        //daat99 OWLTR start - custom resources
        public virtual void OnHarvestFinished( Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested, Type type )
        {
        }
        //daat99 OWLTR end - custom resources
 
        public virtual void OnHarvestFinished( Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested )
        {
        }
 
        public virtual bool SpecialHarvest( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc )
        {
            return false;
        }
 
        public virtual Item Construct( Type type, Mobile from )
        {
            try{ return Activator.CreateInstance( type ) as Item; }
            catch{ return null; }
        }
 
        public virtual HarvestVein MutateVein( Mobile from, Item tool, HarvestDefinition def, HarvestBank bank, object toHarvest, HarvestVein vein )
        {
            return vein;
        }
 
        public virtual void SendSuccessTo( Mobile from, Item item, HarvestResource resource )
        {
            resource.SendSuccessTo( from );
        }
 
        public virtual void SendPackFullTo( Mobile from, Item item, HarvestDefinition def, HarvestResource resource )
        {
            def.SendMessageTo( from, def.PackFullMessage );
        }
 
        public virtual bool Give( Mobile m, Item item, bool placeAtFeet )
        {
            if ( m.PlaceInBackpack( item ) )
                return true;
 
            if ( !placeAtFeet )
                return false;
 
            Map map = m.Map;
 
            if ( map == null )
                return false;
 
            List<Item> atFeet = new List<Item>();
 
            foreach ( Item obj in m.GetItemsInRange( 0 ) )
                atFeet.Add( obj );
 
            for ( int i = 0; i < atFeet.Count; ++i )
            {
                Item check = atFeet[i];
 
                if ( check.StackWith( m, item, false ) )
                    return true;
            }
 
            item.MoveToWorld( m.Location, map );
            return true;
        }
 
        public virtual Type MutateType( Type type, Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
        {
            return from.Region.GetResource( type );
        }
 
        public virtual Type GetResourceType( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
        {
            if ( resource.Types.Length > 0 )
                return resource.Types[Utility.Random( resource.Types.Length )];
 
            return null;
        }
 
        public virtual HarvestResource MutateResource( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestVein vein, HarvestResource primary, HarvestResource fallback )
        {
            bool racialBonus = (def.RaceBonus && from.Race == Race.Elf );
 
            if( vein.ChanceToFallback > (Utility.RandomDouble() + (racialBonus ? .20 : 0)) )
                return fallback;
 
            double skillValue = from.Skills[def.Skill].Value;
 
            if ( fallback != null && (skillValue < primary.ReqSkill || skillValue < primary.MinSkill) )
                return fallback;
 
            return primary;
        }
 
        public virtual bool OnHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked, bool last )
        {
            if ( !CheckHarvest( from, tool ) )
            {
                from.EndAction( locked );
                return false;
            }
 
            int tileID;
            Map map;
            Point3D loc;
 
            if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
            {
                from.EndAction( locked );
                OnBadHarvestTarget( from, tool, toHarvest );
                return false;
            }
            else if ( !def.Validate( tileID ) )
            {
                from.EndAction( locked );
                OnBadHarvestTarget( from, tool, toHarvest );
                return false;
            }
            else if ( !CheckRange( from, tool, def, map, loc, true ) )
            {
                from.EndAction( locked );
                return false;
            }
            else if ( !CheckResources( from, tool, def, map, loc, true ) )
            {
                from.EndAction( locked );
                return false;
            }
            else if ( !CheckHarvest( from, tool, def, toHarvest ) )
            {
                from.EndAction( locked );
                return false;
            }
 
            DoHarvestingEffect( from, tool, def, map, loc );
 
            new HarvestSoundTimer( from, tool, this, def, toHarvest, locked, last ).Start();
 
            return !last;
        }
 
        public virtual void DoHarvestingSound( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
            if ( def.EffectSounds.Length > 0 )
                from.PlaySound( Utility.RandomList( def.EffectSounds ) );
        }
 
        public virtual void DoHarvestingEffect( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc )
        {
            from.Direction = from.GetDirectionTo( loc );
 
            if ( !from.Mounted )
                from.Animate( Utility.RandomList( def.EffectActions ), 5, 1, true, false, 0 );
        }
 
        public virtual HarvestDefinition GetDefinition( int tileID )
        {
            HarvestDefinition def = null;
 
            for ( int i = 0; def == null && i < m_Definitions.Count; ++i )
            {
                HarvestDefinition check = m_Definitions[i];
 
                if ( check.Validate( tileID ) )
                    def = check;
            }
 
            return def;
        }
 
        public virtual void StartHarvesting( Mobile from, Item tool, object toHarvest )
        {
            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;
            }
 
            HarvestDefinition def = GetDefinition( tileID );
 
            if ( def == null )
            {
                OnBadHarvestTarget( from, tool, toHarvest );
                return;
            }
 
            if ( !CheckRange( from, tool, def, map, loc, false ) )
                return;
            else if ( !CheckResources( from, tool, def, map, loc, false ) )
                return;
            else if ( !CheckHarvest( from, tool, def, toHarvest ) )
                return;
 
            object toLock = GetLock( from, tool, def, toHarvest );
 
            if ( !from.BeginAction( toLock ) )
            {
                OnConcurrentHarvest( from, tool, def, toHarvest );
                return;
            }
 
            new HarvestTimer( from, tool, this, def, toHarvest, toLock ).Start();
            OnHarvestStarted( from, tool, def, toHarvest );
        }
 
        public virtual bool GetHarvestDetails( Mobile from, Item tool, object toHarvest, out int tileID, out Map map, out Point3D loc )
        {
            if ( toHarvest is Static && !((Static)toHarvest).Movable )
            {
                Static obj = (Static)toHarvest;
 
                tileID = (obj.ItemID & 0x3FFF) | 0x4000;
                map = obj.Map;
                loc = obj.GetWorldLocation();
            }
            else if ( toHarvest is StaticTarget )
            {
                StaticTarget obj = (StaticTarget)toHarvest;
 
                tileID = (obj.ItemID & 0x3FFF) | 0x4000;
                map = from.Map;
                loc = obj.Location;
            }
            else if ( toHarvest is LandTarget )
            {
                LandTarget obj = (LandTarget)toHarvest;
 
                tileID = obj.TileID;
                map = from.Map;
                loc = obj.Location;
            }
            else
            {
                tileID = 0;
                map = null;
                loc = Point3D.Zero;
                return false;
            }
 
            return ( map != null && map != Map.Internal );
        }
    }
}
 
namespace Server
{
    public interface IChopable
    {
        void OnChop( Mobile from );
    }
 
    [AttributeUsage( AttributeTargets.Class )]
    public class FurnitureAttribute : Attribute
    {
        public static bool Check( Item item )
        {
            return ( item != null && item.GetType().IsDefined( typeof( FurnitureAttribute ), false ) );
        }
 
        public FurnitureAttribute()
        {
        }
    }
}

Edit: I don't see the line numbers on here so here is line 202 as stated in the error:
Code:
string s_Type = CraftResources.GetInfo(CraftResources.GetFromType(type)).Name;


Fishing.cs
Code:
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Engines.Quests;
using Server.Engines.Quests.Collector;
using System.Collections.Generic;
 
namespace Server.Engines.Harvest
{
    public class Fishing : HarvestSystem
    {
        private static Fishing m_System;
 
        public static Fishing System
        {
            get
            {
                if ( m_System == null )
                    m_System = new Fishing();
 
                return m_System;
            }
        }
 
        private HarvestDefinition m_Definition;
 
        public HarvestDefinition Definition
        {
            get{ return m_Definition; }
        }
 
        private Fishing()
        {
            HarvestResource[] res;
            HarvestVein[] veins;
 
            #region Fishing
            HarvestDefinition fish = new HarvestDefinition();
 
            // Resource banks are every 8x8 tiles
            fish.BankWidth = 8;
            fish.BankHeight = 8;
 
            // Every bank holds from 5 to 15 fish
            fish.MinTotal = 5;
            fish.MaxTotal = 15;
 
            // A resource bank will respawn its content every 10 to 20 minutes
            fish.MinRespawn = TimeSpan.FromMinutes( 10.0 );
            fish.MaxRespawn = TimeSpan.FromMinutes( 20.0 );
 
            // Skill checking is done on the Fishing skill
            fish.Skill = SkillName.Fishing;
 
            // Set the list of harvestable tiles
            fish.Tiles = m_WaterTiles;
            fish.RangedTiles = true;
 
            // Players must be within 4 tiles to harvest
            fish.MaxRange = 4;
 
            // One fish per harvest action
            fish.ConsumedPerHarvest = 1;
            fish.ConsumedPerFeluccaHarvest = 1;
 
            // The fishing
            fish.EffectActions = new int[]{ 12 };
            fish.EffectSounds = new int[0];
            fish.EffectCounts = new int[]{ 1 };
            fish.EffectDelay = TimeSpan.Zero;
            fish.EffectSoundDelay = TimeSpan.FromSeconds( 8.0 );
 
            fish.NoResourcesMessage = 503172; // The fish don't seem to be biting here.
            fish.FailMessage = 503171; // You fish a while, but fail to catch anything.
            fish.TimedOutOfRangeMessage = 500976; // You need to be closer to the water to fish!
            fish.OutOfRangeMessage = 500976; // You need to be closer to the water to fish!
            fish.PackFullMessage = 503176; // You do not have room in your backpack for a fish.
            fish.ToolBrokeMessage = 503174; // You broke your fishing pole.
 
            res = new HarvestResource[]
                {
                    new HarvestResource( 00.0, 00.0, 100.0, 1043297, typeof( Fish ) )
                };
 
            veins = new HarvestVein[]
                {
                    new HarvestVein( 100.0, 0.0, res[0], null )
                };
 
            fish.Resources = res;
            fish.Veins = veins;
 
            if ( Core.ML )
            {
                fish.BonusResources = new BonusHarvestResource[]
                {
                    new BonusHarvestResource( 0, 99.4, null, null ), //set to same chance as mining ml gems
                    new BonusHarvestResource( 80.0, .6, 1072597, typeof( WhitePearl ) )
                };
            }
 
            m_Definition = fish;
            Definitions.Add( fish );
            #endregion
        }
 
        public override void OnConcurrentHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
            from.SendLocalizedMessage( 500972 ); // You are already fishing.
        }
 
        private class MutateEntry
        {
            public double m_ReqSkill, m_MinSkill, m_MaxSkill;
            public bool m_DeepWater;
            public Type[] m_Types;
 
            public MutateEntry( double reqSkill, double minSkill, double maxSkill, bool deepWater, params Type[] types )
            {
                m_ReqSkill = reqSkill;
                m_MinSkill = minSkill;
                m_MaxSkill = maxSkill;
                m_DeepWater = deepWater;
                m_Types = types;
            }
        }
 
        private static MutateEntry[] m_MutateTable = new MutateEntry[]
            {
                new MutateEntry(  80.0,  80.0,  4080.0,  true, typeof( SpecialFishingNet ) ),
                new MutateEntry(  80.0,  80.0,  4080.0,  true, typeof( BigFish ) ),
                new MutateEntry(  90.0,  80.0,  4080.0,  true, typeof( TreasureMap ) ),
                new MutateEntry( 100.0,  80.0,  4080.0,  true, typeof( MessageInABottle ) ),
                new MutateEntry(  0.0, 125.0, -2375.0, false, typeof( PrizedFish ), typeof( WondrousFish ), typeof( TrulyRareFish ), typeof( PeculiarFish ) ),
                new MutateEntry(  0.0, 105.0,  -420.0, false, typeof( Boots ), typeof( Shoes ), typeof( Sandals ), typeof( ThighBoots ) ),
                new MutateEntry(  0.0, 200.0,  -200.0, false, new Type[1]{ null } )
            };
 
        public override bool SpecialHarvest( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc )
        {
            PlayerMobile player = from as PlayerMobile;
 
            if ( player != null )
            {
                QuestSystem qs = player.Quest;
 
                if ( qs is CollectorQuest )
                {
                    QuestObjective obj = qs.FindObjective( typeof( FishPearlsObjective ) );
 
                    if ( obj != null && !obj.Completed )
                    {
                        if ( Utility.RandomDouble() < 0.5 )
                        {
                            player.SendLocalizedMessage( 1055086, "", 0x59 ); // You pull a shellfish out of the water, and find a rainbow pearl inside of it.
 
                            obj.CurProgress++;
                        }
                        else
                        {
                            player.SendLocalizedMessage( 1055087, "", 0x2C ); // You pull a shellfish out of the water, but it doesn't have a rainbow pearl.
                        }
 
                        return true;
                    }
                }
            }
 
            return false;
        }
 
        public override Type MutateType( Type type, Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
        {
            bool deepWater = SpecialFishingNet.FullValidation( map, loc.X, loc.Y );
 
            double skillBase = from.Skills[SkillName.Fishing].Base;
            double skillValue = from.Skills[SkillName.Fishing].Value;
 
            for ( int i = 0; i < m_MutateTable.Length; ++i )
            {
                MutateEntry entry = m_MutateTable[i];
 
                if ( !deepWater && entry.m_DeepWater )
                    continue;
 
                if ( skillBase >= entry.m_ReqSkill )
                {
                    double chance = (skillValue - entry.m_MinSkill) / (entry.m_MaxSkill - entry.m_MinSkill);
 
                    if ( chance > Utility.RandomDouble() )
                        return entry.m_Types[Utility.Random( entry.m_Types.Length )];
                }
            }
 
            return type;
        }
 
        private static Map SafeMap( Map map )
        {
            if ( map == null || map == Map.Internal )
                return Map.Trammel;
 
            return map;
        }
 
        public override bool CheckResources( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
        {
            Container pack = from.Backpack;
 
            if ( pack != null )
            {
                List<SOS> messages = pack.FindItemsByType<SOS>();
 
                for ( int i = 0; i < messages.Count; ++i )
                {
                    SOS sos = messages[i];
 
                    if ( ( from.Map == Map.Felucca || from.Map == Map.Trammel ) && from.InRange( sos.TargetLocation, 60 ) )
                        return true;
                }
            }
 
            return base.CheckResources( from, tool, def, map, loc, timed );
        }
 
        public override Item Construct( Type type, Mobile from )
        {
            if ( type == typeof( TreasureMap ) )
            {
                int level;
                if ( from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) )
                    level = 0;
                else
                    level = 1;
 
                return new TreasureMap( level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel );
            }
            else if ( type == typeof( MessageInABottle ) )
            {
                return new MessageInABottle( from.Map == Map.Felucca ? Map.Felucca : Map.Trammel );
            }
 
            Container pack = from.Backpack;
 
            if ( pack != null )
            {
                List<SOS> messages = pack.FindItemsByType<SOS>();
 
                for ( int i = 0; i < messages.Count; ++i )
                {
                    SOS sos = messages[i];
 
                    if ( ( from.Map == Map.Felucca || from.Map == Map.Trammel ) && from.InRange( sos.TargetLocation, 60 ) )
                    {
                        Item preLoot = null;
 
                        switch ( Utility.Random( 8 ) )
                        {
                            case 0: // Body parts
                            {
                                int[] list = new int[]
                                    {
                                        0x1CDD, 0x1CE5, // arm
                                        0x1CE0, 0x1CE8, // torso
                                        0x1CE1, 0x1CE9, // head
                                        0x1CE2, 0x1CEC // leg
                                    };
 
                                preLoot = new ShipwreckedItem( Utility.RandomList( list ) );
                                break;
                            }
                            case 1: // Bone parts
                            {
                                int[] list = new int[]
                                    {
                                        0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls
                                        0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
                                        0x1B15, 0x1B16 // pelvis bones
                                    };
 
                                preLoot = new ShipwreckedItem( Utility.RandomList( list ) );
                                break;
                            }
                            case 2: // Paintings and portraits
                            {
                                preLoot = new ShipwreckedItem( Utility.Random( 0xE9F, 10 ) );
                                break;
                            }
                            case 3: // Pillows
                            {
                                preLoot = new ShipwreckedItem( Utility.Random( 0x13A4, 11 ) );
                                break;
                            }
                            case 4: // Shells
                            {
                                preLoot = new ShipwreckedItem( Utility.Random( 0xFC4, 9 ) );
                                break;
                            }
                            case 5:    //Hats
                            {
                                if ( Utility.RandomBool() )
                                    preLoot = new SkullCap();
                                else
                                    preLoot = new TricorneHat();
 
                                break;
                            }
                            case 6: // Misc
                            {
                                int[] list = new int[]
                                    {
                                        0x1EB5, // unfinished barrel
                                        0xA2A, // stool
                                        0xC1F, // broken clock
                                        0x1047, 0x1048, // globe
                                        0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves
                                    };
 
                                if ( Utility.Random( list.Length + 1 ) == 0 )
                                    preLoot = new Candelabra();
                                else
                                    preLoot = new ShipwreckedItem( Utility.RandomList( list ) );
 
                                break;
                            }
                         
                            case 7:    //Aether Fragment.  Added entire case 7 for this
                            {
                                preLoot = new AetherFragment();
                                break;
                            }
                        }
 
                        if ( preLoot != null )
                        {
                            if ( preLoot is IShipwreckedItem )
                                ( (IShipwreckedItem)preLoot ).IsShipwreckedItem = true;
 
                            return preLoot;
                        }
 
                        LockableContainer chest;
                 
                        if ( Utility.RandomBool() )
                            chest = new MetalGoldenChest();
                        else
                            chest = new WoodenChest();
 
                        if ( sos.IsAncient )
                            chest.Hue = 0x481;
 
                        TreasureMapChest.Fill( chest, Math.Max( 1, Math.Min( 4, sos.Level ) ) );
 
                        if ( sos.IsAncient )
                            chest.DropItem( new FabledFishingNet() );
                        else
                            chest.DropItem( new SpecialFishingNet() );
 
                        chest.Movable = true;
                        chest.Locked = false;
                        chest.TrapType = TrapType.None;
                        chest.TrapPower = 0;
                        chest.TrapLevel = 0;
 
                        sos.Delete();
 
                        return chest;
                    }
                }
            }
 
            return base.Construct( type, from );
        }
 
        public override bool Give( Mobile m, Item item, bool placeAtFeet )
        {
            if ( item is TreasureMap || item is MessageInABottle || item is SpecialFishingNet )
            {
                BaseCreature serp;
 
                if ( 0.25 > Utility.RandomDouble() )
                    serp = new DeepSeaSerpent();
                else
                    serp = new SeaSerpent();
 
                int x = m.X, y = m.Y;
 
                Map map = m.Map;
 
                for ( int i = 0; map != null && i < 20; ++i )
                {
                    int tx = m.X - 10 + Utility.Random( 21 );
                    int ty = m.Y - 10 + Utility.Random( 21 );
 
                    LandTile t = map.Tiles.GetLandTile( tx, ty );
 
                    if ( t.Z == -5 && ( (t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137) ) && !Spells.SpellHelper.CheckMulti( new Point3D( tx, ty, -5 ), map ) )
                    {
                        x = tx;
                        y = ty;
                        break;
                    }
                }
 
                serp.MoveToWorld( new Point3D( x, y, -5 ), map );
 
                serp.Home = serp.Location;
                serp.RangeHome = 10;
 
                serp.PackItem( item );
 
                m.SendLocalizedMessage( 503170 ); // Uh oh! That doesn't look like a fish!
 
                return true; // we don't want to give the item to the player, it's on the serpent
            }
 
            if ( item is BigFish || item is WoodenChest || item is MetalGoldenChest )
                placeAtFeet = true;
 
            return base.Give( m, item, placeAtFeet );
        }
 
        public override void SendSuccessTo( Mobile from, Item item, HarvestResource resource )
        {
            if ( item is BigFish )
            {
                from.SendLocalizedMessage( 1042635 ); // Your fishing pole bends as you pull a big fish from the depths!
 
                ((BigFish)item).Fisher = from;
            }
            else if ( item is WoodenChest || item is MetalGoldenChest )
            {
                from.SendLocalizedMessage( 503175 ); // You pull up a heavy chest from the depths of the ocean!
            }
            else
            {
                int number;
                string name;
 
                if ( item is BaseMagicFish )
                {
                    number = 1008124;
                    name = "a mess of small fish";
                }
                else if ( item is Fish )
                {
                    number = 1008124;
                    name = item.ItemData.Name;
                }
                else if ( item is BaseShoes )
                {
                    number = 1008124;
                    name = item.ItemData.Name;
                }
                else if ( item is TreasureMap )
                {
                    number = 1008125;
                    name = "a sodden piece of parchment";
                }
                else if ( item is MessageInABottle )
                {
                    number = 1008125;
                    name = "a bottle, with a message in it";
                }
                else if ( item is SpecialFishingNet )
                {
                    number = 1008125;
                    name = "a special fishing net"; // TODO: this is just a guess--what should it really be named?
                }
                else
                {
                    number = 1043297;
 
                    if ( (item.ItemData.Flags & TileFlag.ArticleA) != 0 )
                        name = "a " + item.ItemData.Name;
                    else if ( (item.ItemData.Flags & TileFlag.ArticleAn) != 0 )
                        name = "an " + item.ItemData.Name;
                    else
                        name = item.ItemData.Name;
                }
 
                NetState ns = from.NetState;
 
                if ( ns == null )
                    return;
 
                if ( number == 1043297 || ns.HighSeas )
                    from.SendLocalizedMessage( number, name );
                else
                    from.SendLocalizedMessage( number, true, name );
            }
        }
 
        public override void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
            base.OnHarvestStarted( from, tool, def, toHarvest );
 
            int tileID;
            Map map;
            Point3D loc;
 
            if ( GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
                Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ),
                    delegate
                    {
                        if( Core.ML )
                            from.RevealingAction();
 
                        Effects.SendLocationEffect( loc, map, 0x352D, 16, 4 );
                        Effects.PlaySound( loc, map, 0x364 );
                    } );
        }
 
        public override void OnHarvestFinished( Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested )
        {
            base.OnHarvestFinished( from, tool, def, vein, bank, resource, harvested );
 
            if ( Core.ML )
                from.RevealingAction();
        }
 
        public override object GetLock( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
            return this;
        }
 
        public override bool BeginHarvesting( Mobile from, Item tool )
        {
            if ( !base.BeginHarvesting( from, tool ) )
                return false;
 
            from.SendLocalizedMessage( 500974 ); // What water do you want to fish in?
            return true;
        }
 
        public override bool CheckHarvest( Mobile from, Item tool )
        {
            if ( !base.CheckHarvest( from, tool ) )
                return false;
 
            if ( from.Mounted )
            {
                from.SendLocalizedMessage( 500971 ); // You can't fish while riding!
                return false;
            }
 
            return true;
        }
 
        public override bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
        {
            if ( !base.CheckHarvest( from, tool, def, toHarvest ) )
                return false;
 
            if ( from.Mounted )
            {
                from.SendLocalizedMessage( 500971 ); // You can't fish while riding!
                return false;
            }
 
            return true;
        }
 
        private static int[] m_WaterTiles = new int[]
            {
                0x00A8, 0x00AB,
                0x0136, 0x0137,
                0x5797, 0x579C,
                0x746E, 0x7485,
                0x7490, 0x74AB,
                0x74B5, 0x75D5
            };
    }
}
 

_Epila_

Sorceror
Seems to be a problem with daat99's OWLTR system. Unfortunately I never used this system, have no idea of what is going wrong.
Check the mods, maybe you forgot something, that's my best for something I never used

You can check if type is null, but I don't know how the system will behave
 

aarony14

Traveler
Well upon further investigation it seems the crash happens upon every successful fishing attempt. The only time it doesn't crash is when I get the message "You fish a while but fail to catch anything". I never noticed it before because I don't have players on my shard. I don't think I made changes to HarvestSystem.cs but just to be sure I replaced it with the one that came with Daat99's package untouched and I still get the crash.

Is anyone else using Daat99's OWLTR with master storage and is able to fish successfully?

Oh, and I do appreciate your time Epila.


*EDIT: It turns out that it was an issue with the version of OWLTR I was using. I was using version 3.0.0 and found that there was a version 3.01.00 which included a new version of HarvestSystem.cs. After updating the files it seems to be working fine now. Thanks for pointing me in the right direction Epila.
 
Top