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:
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:
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.
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.