public async void StartFishing(Creature creature, int delay)
{
var rnd = RandomProvider.Get();
var prop = creature.Temp.FishingProp;
await Task.Delay(delay);
// Check that the prop is still the same (player could have canceled
// and restarted, spawning a new one) and the prop wasn't removed
// from region (e.g. >reloadscripts).
if (creature.Temp.FishingProp != prop || creature.Temp.FishingProp.Region == Region.Limbo)
return;
// Update prop state
creature.Temp.FishingProp.SetState("normal");
await Task.Delay(rnd.Next(5000, 120000));
if (creature.Temp.FishingProp != prop || creature.Temp.FishingProp.Region == Region.Limbo)
return;
// Update prop state
creature.Temp.FishingProp.SetState("hooked");
// Get fishing drop
creature.Temp.FishingDrop = this.GetFishingDrop(creature, rnd);
if (creature.Temp.FishingDrop == null)
{
Log.Debug("Fishing.StartFishing: No drop found.");
return;
}
// Random time
var time = 10000;
switch (rnd.Next(4))
{
case 0: time = 4000; break;
case 1: time = 8000; break;
case 2: time = 6000; break;
case 3: time = 10000; break;
}
var catchSize = CatchSize.Something;
var fishSpeed = 1f;
var fishData = AuraData.FishDb.Find(creature.Temp.FishingDrop.ItemId);
if (fishData != null && fishData.SizeMin + fishData.SizeMax != 0)
catchSize = (rnd.NextDouble() < 0.5 ? CatchSize.SmallCatch : CatchSize.BigOne);
// Request action
creature.Temp.FishingActionRequested = true;
creature.Temp.CatchSize = catchSize;
Send.FishingActionRequired(creature, catchSize, time, fishSpeed);
}