Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 • committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -13,13 +13,13 @@ namespace Server.Engines.Harvest
SuccessMessage = message;
}
public Type Type{ get; set; }
public Type Type { get; set; }
public double ReqSkill{ get; set; }
public double ReqSkill { get; set; }
public double Chance{ get; set; }
public double Chance { get; set; }
public TextDefinition SuccessMessage{ get; }
public TextDefinition SuccessMessage { get; }
public void SendSuccessTo(Mobile m)
{

View file

@ -0,0 +1,10 @@
using System;
namespace Server
{
[AttributeUsage(AttributeTargets.Class)]
public class FurnitureAttribute : Attribute
{
public static bool Check(Item item) => item?.GetType().IsDefined(typeof(FurnitureAttribute), false) == true;
}
}

View file

@ -5,7 +5,7 @@ namespace Server.Engines.Harvest
public class HarvestBank
{
private int m_Current;
private int m_Maximum;
private readonly int m_Maximum;
private DateTime m_NextRespawn;
private HarvestVein m_Vein, m_DefaultVein;
@ -19,7 +19,7 @@ namespace Server.Engines.Harvest
Definition = def;
}
public HarvestDefinition Definition{ get; }
public HarvestDefinition Definition { get; }
public int Current
{
@ -56,7 +56,7 @@ namespace Server.Engines.Harvest
m_Current = m_Maximum;
if (Definition.RandomizeVeins) m_DefaultVein = Definition.GetVeinFrom(Utility.RandomDouble());
if (Definition.RandomizeVeins) m_DefaultVein = Definition.GetVeinFrom(Utility.Random(Definition.VeinWeights));
m_Vein = m_DefaultVein;
}
@ -74,8 +74,8 @@ namespace Server.Engines.Harvest
m_Current = m_Maximum - amount;
double minutes = min + rnd * (max - min);
if (Definition.RaceBonus && from.Race == Race.Elf) //def.RaceBonus = Core.ML
minutes *= .75; //25% off the time.
if (Definition.RaceBonus && from.Race == Race.Elf) // def.RaceBonus = Core.ML
minutes *= .75; // 25% off the time.
m_NextRespawn = DateTime.UtcNow + TimeSpan.FromMinutes(minutes);
}
@ -88,4 +88,4 @@ namespace Server.Engines.Harvest
m_Current = 0;
}
}
}
}

View file

@ -1,71 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server.Engines.Harvest
{
public class HarvestDefinition
{
public int BankWidth{ get; set; }
public int BankWidth { get; set; }
public int BankHeight{ get; set; }
public int BankHeight { get; set; }
public int MinTotal{ get; set; }
public int MinTotal { get; set; }
public int MaxTotal{ get; set; }
public int MaxTotal { get; set; }
public int[] Tiles{ get; set; }
public int[] Tiles { get; set; }
public bool RangedTiles{ get; set; }
public bool RangedTiles { get; set; }
public TimeSpan MinRespawn{ get; set; }
public TimeSpan MinRespawn { get; set; }
public TimeSpan MaxRespawn{ get; set; }
public TimeSpan MaxRespawn { get; set; }
public int MaxRange{ get; set; }
public int MaxRange { get; set; }
public int ConsumedPerHarvest{ get; set; }
public int ConsumedPerHarvest { get; set; }
public int ConsumedPerFeluccaHarvest{ get; set; }
public int ConsumedPerFeluccaHarvest { get; set; }
public bool PlaceAtFeetIfFull{ get; set; }
public bool PlaceAtFeetIfFull { get; set; }
public SkillName Skill{ get; set; }
public SkillName Skill { get; set; }
public int[] EffectActions{ get; set; }
public int[] EffectActions { get; set; }
public int[] EffectCounts{ get; set; }
public int[] EffectCounts { get; set; }
public int[] EffectSounds{ get; set; }
public int[] EffectSounds { get; set; }
public TimeSpan EffectSoundDelay{ get; set; }
public TimeSpan EffectSoundDelay { get; set; }
public TimeSpan EffectDelay{ get; set; }
public TimeSpan EffectDelay { get; set; }
public object NoResourcesMessage{ get; set; }
public TextDefinition NoResourcesMessage { get; set; }
public object OutOfRangeMessage{ get; set; }
public TextDefinition OutOfRangeMessage { get; set; }
public object TimedOutOfRangeMessage{ get; set; }
public TextDefinition TimedOutOfRangeMessage { get; set; }
public object DoubleHarvestMessage{ get; set; }
public TextDefinition DoubleHarvestMessage { get; set; }
public object FailMessage{ get; set; }
public TextDefinition FailMessage { get; set; }
public object PackFullMessage{ get; set; }
public TextDefinition PackFullMessage { get; set; }
public object ToolBrokeMessage{ get; set; }
public TextDefinition ToolBrokeMessage { get; set; }
public HarvestResource[] Resources{ get; set; }
public HarvestResource[] Resources { get; set; }
public HarvestVein[] Veins{ get; set; }
private HarvestVein[] m_Veins;
public BonusHarvestResource[] BonusResources{ get; set; }
public HarvestVein[] Veins
{
get => m_Veins;
set
{
m_Veins = value;
VeinWeights = m_Veins.Aggregate<HarvestVein, uint>(0, (current, t) => current + t.VeinChance);
}
}
public bool RaceBonus{ get; set; }
public BonusHarvestResource[] BonusResources { get; set; }
public bool RandomizeVeins{ get; set; }
public bool RaceBonus { get; set; }
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks{ get; }
public bool RandomizeVeins { get; set; }
public uint VeinWeights { get; private set; }
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks { get; }
= new Dictionary<Map, Dictionary<Point2D, HarvestBank>>();
public void SendMessageTo(Mobile from, object message)
@ -100,28 +113,18 @@ namespace Server.Engines.Harvest
if (Veins.Length == 1)
return Veins[0];
double randomValue;
if (RandomizeVeins) return GetVeinFrom(Utility.Random(1000u));
if (RandomizeVeins)
{
randomValue = Utility.RandomDouble();
}
else
{
Random random = new Random(x * 17 + y * 11 + map.MapID * 3);
randomValue = random.NextDouble();
}
return GetVeinFrom(randomValue);
// TODO: Introduce pulling primes from a config and writing them if they don't exist to the config
using Xoshiro256PlusPlus random = new Xoshiro256PlusPlus((ulong)(x * 17 + y * 11 + map.MapID * 3));
return GetVeinFrom(random.Next(VeinWeights));
}
public HarvestVein GetVeinFrom(double randomValue)
public HarvestVein GetVeinFrom(uint randomValue)
{
if (Veins.Length == 1)
return Veins[0];
randomValue *= 100;
for (int i = 0; i < Veins.Length; ++i)
{
if (randomValue <= Veins[i].VeinChance)

View file

@ -13,15 +13,15 @@ namespace Server.Engines.Harvest
SuccessMessage = message;
}
public Type[] Types{ get; set; }
public Type[] Types { get; set; }
public double ReqSkill{ get; set; }
public double ReqSkill { get; set; }
public double MinSkill{ get; set; }
public double MinSkill { get; set; }
public double MaxSkill{ get; set; }
public double MaxSkill { get; set; }
public object SuccessMessage{ get; }
public object SuccessMessage { get; }
public void SendSuccessTo(Mobile m)
{

View file

@ -2,12 +2,13 @@ namespace Server.Engines.Harvest
{
public class HarvestSoundTimer : Timer
{
private HarvestDefinition m_Definition;
private Mobile m_From;
private bool m_Last;
private HarvestSystem m_System;
private object m_ToHarvest, m_Locked;
private Item m_Tool;
private readonly HarvestDefinition m_Definition;
private readonly Mobile m_From;
private readonly bool m_Last;
private readonly HarvestSystem m_System;
private readonly object m_ToHarvest;
private readonly object m_Locked;
private readonly Item m_Tool;
public HarvestSoundTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest,
object locked, bool last) : base(def.EffectSoundDelay)

View file

@ -11,11 +11,11 @@ namespace Server.Engines.Harvest
{
public HarvestSystem() => Definitions = new List<HarvestDefinition>();
public List<HarvestDefinition> Definitions{ get; }
public List<HarvestDefinition> Definitions { get; }
public virtual bool CheckTool(Mobile from, Item tool)
{
bool wornOut = tool?.Deleted != false || tool is IUsesRemaining remaining && remaining.UsesRemaining <= 0;
bool wornOut = tool?.Deleted != false || (tool as IUsesRemaining)?.UsesRemaining <= 0;
if (wornOut)
from.SendLocalizedMessage(1044038); // You have worn out your tool!
@ -139,7 +139,7 @@ namespace Server.Engines.Harvest
}
else
{
//The whole harvest system is kludgy and I'm sure this is just adding to it.
// The whole harvest system is kludgy and I'm sure this is just adding to it.
if (item.Stackable)
{
int amount = def.ConsumedPerHarvest;
@ -152,11 +152,11 @@ namespace Server.Engines.Harvest
bool inFelucca = map == Map.Felucca;
if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount &&
0.1 > Utility.RandomDouble())
Utility.RandomDouble() < 0.1)
item.Amount = feluccaRacialAmount;
else if (inFelucca && bank.Current >= feluccaAmount)
item.Amount = feluccaAmount;
else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble())
else if (eligableForRacialBonus && bank.Current >= racialAmount && Utility.RandomDouble() < 0.1)
item.Amount = racialAmount;
else
item.Amount = amount;
@ -180,8 +180,7 @@ namespace Server.Engines.Harvest
{
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
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();
@ -349,10 +348,10 @@ namespace Server.Engines.Harvest
from.Animate(Utility.RandomList(def.EffectActions), 5, 1, true, false, 0);
}
public virtual HarvestDefinition GetDefinition(int tileID)
{
return Definitions.FirstOrDefault(check => check.Validate(tileID));
}
public virtual HarvestDefinition GetDefinition() => Definitions.First();
public virtual HarvestDefinition GetDefinition(int tileID) =>
Definitions.FirstOrDefault(check => check.Validate(tileID));
public virtual void StartHarvesting(Mobile from, Item tool, object toHarvest)
{
@ -425,17 +424,3 @@ namespace Server.Engines.Harvest
}
}
}
namespace Server
{
public interface IChopable
{
void OnChop(Mobile from);
}
[AttributeUsage(AttributeTargets.Class)]
public class FurnitureAttribute : Attribute
{
public static bool Check(Item item) => item?.GetType().IsDefined(typeof(FurnitureAttribute), false) == true;
}
}

View file

@ -8,8 +8,8 @@ namespace Server.Engines.Harvest
{
public class HarvestTarget : Target
{
private HarvestSystem m_System;
private Item m_Tool;
private readonly HarvestSystem m_System;
private readonly Item m_Tool;
public HarvestTarget(Item tool, HarvestSystem system) : base(-1, true, TargetFlags.None)
{
@ -47,7 +47,7 @@ namespace Server.Engines.Harvest
}
}
if (m_System is Lumberjacking && targeted is IChopable chopable)
if (m_System is Lumberjacking && targeted is IChoppable chopable)
{
chopable.OnChop(from);
}

View file

@ -4,12 +4,14 @@ namespace Server.Engines.Harvest
{
public class HarvestTimer : Timer
{
private HarvestDefinition m_Definition;
private Mobile m_From;
private int m_Index, m_Count;
private HarvestSystem m_System;
private object m_ToHarvest, m_Locked;
private Item m_Tool;
private readonly HarvestDefinition m_Definition;
private readonly Mobile m_From;
private int m_Index;
private readonly int m_Count;
private readonly HarvestSystem m_System;
private readonly object m_ToHarvest;
private readonly object m_Locked;
private readonly Item m_Tool;
public HarvestTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest,
object locked) : base(TimeSpan.Zero, def.EffectDelay)

View file

@ -2,7 +2,7 @@ namespace Server.Engines.Harvest
{
public class HarvestVein
{
public HarvestVein(double veinChance, double chanceToFallback, HarvestResource primaryResource,
public HarvestVein(uint veinChance, double chanceToFallback, HarvestResource primaryResource,
HarvestResource fallbackResource)
{
VeinChance = veinChance;
@ -11,12 +11,12 @@ namespace Server.Engines.Harvest
FallbackResource = fallbackResource;
}
public double VeinChance{ get; set; }
public uint VeinChance { get; set; }
public double ChanceToFallback{ get; set; }
public double ChanceToFallback { get; set; }
public HarvestResource PrimaryResource{ get; set; }
public HarvestResource PrimaryResource { get; set; }
public HarvestResource FallbackResource{ get; set; }
public HarvestResource FallbackResource { get; set; }
}
}
}

View file

@ -0,0 +1,7 @@
namespace Server
{
public interface IChoppable
{
void OnChop(Mobile from);
}
}

View file

@ -14,7 +14,7 @@ namespace Server.Engines.Harvest
{
private static Fishing m_System;
private static MutateEntry[] m_MutateTable =
private static readonly MutateEntry[] m_MutateTable =
{
new MutateEntry(80.0, 80.0, 4080.0, true, typeof(SpecialFishingNet)),
new MutateEntry(80.0, 80.0, 4080.0, true, typeof(BigFish)),
@ -26,7 +26,7 @@ namespace Server.Engines.Harvest
new MutateEntry(0.0, 200.0, -200.0, false, new Type[] { null })
};
private static int[] m_WaterTiles =
private static readonly int[] m_WaterTiles =
{
0x00A8, 0x00AB,
0x0136, 0x0137,
@ -53,7 +53,7 @@ namespace Server.Engines.Harvest
ConsumedPerHarvest = 1,
ConsumedPerFeluccaHarvest = 1,
EffectActions = new[] { 12 },
EffectSounds = new int[0],
EffectSounds = Array.Empty<int>(),
EffectCounts = new[] { 1 },
EffectDelay = TimeSpan.Zero,
EffectSoundDelay = TimeSpan.FromSeconds(8.0),
@ -70,7 +70,7 @@ namespace Server.Engines.Harvest
};
HarvestVein[] veins = {
new HarvestVein(100.0, 0.0, res[0], null)
new HarvestVein(1000, 0.0, res[0], null)
};
fish.Resources = res;
@ -79,18 +79,15 @@ namespace Server.Engines.Harvest
if (Core.ML)
fish.BonusResources = new[]
{
new BonusHarvestResource(0, 99.4, null, null), //set to same chance as mining ml gems
new BonusHarvestResource(0, 99.4, null, null), // set to same chance as mining ml gems
new BonusHarvestResource(80.0, .6, 1072597, typeof(WhitePearl))
};
Definition = fish;
Definitions.Add(fish);
}
public static Fishing System => m_System ?? (m_System = new Fishing());
public HarvestDefinition Definition{ get; }
public override void OnConcurrentHarvest(Mobile from, Item tool, HarvestDefinition def, object toHarvest)
{
from.SendLocalizedMessage(500972); // You are already fishing.
@ -199,72 +196,72 @@ namespace Server.Engines.Harvest
switch (Utility.Random(8))
{
case 0: // Body parts
{
int[] list =
{
0x1CDD, 0x1CE5, // arm
0x1CE0, 0x1CE8, // torso
0x1CE1, 0x1CE9, // head
0x1CE2, 0x1CEC // leg
};
int[] list =
{
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 =
{
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 =
{
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 1: // Bone parts
{
int[] list =
{
0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls
0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
0x1B15, 0x1B16 // pelvis bones
};
break;
}
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 =
{
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;
}
}
if (preLoot != null)
@ -309,7 +306,7 @@ namespace Server.Engines.Harvest
{
BaseCreature serp;
if (0.25 > Utility.RandomDouble())
if (Utility.RandomDouble() < 0.25)
serp = new DeepSeaSerpent();
else
serp = new SeaSerpent();
@ -325,7 +322,7 @@ namespace Server.Engines.Harvest
LandTile t = map.Tiles.GetLandTile(tx, ty);
if (t.Z == -5 && (t.ID >= 0xA8 && t.ID <= 0xAB || t.ID >= 0x136 && t.ID <= 0x137) &&
if (t.Z == -5 && ((t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137)) &&
!SpellHelper.CheckMulti(new Point3D(tx, ty, -5), map))
{
x = tx;
@ -425,7 +422,7 @@ namespace Server.Engines.Harvest
if (GetHarvestDetails(from, tool, toHarvest, out _, out Map map, out Point3D loc))
Timer.DelayCall(TimeSpan.FromSeconds(1.5),
delegate
() =>
{
if (Core.ML)
from.RevealingAction();
@ -485,9 +482,11 @@ namespace Server.Engines.Harvest
private class MutateEntry
{
public bool m_DeepWater;
public double m_ReqSkill, m_MinSkill, m_MaxSkill;
public Type[] m_Types;
public readonly bool m_DeepWater;
public readonly double m_ReqSkill;
public readonly double m_MinSkill;
public readonly double m_MaxSkill;
public readonly Type[] m_Types;
public MutateEntry(double reqSkill, double minSkill, double maxSkill, bool deepWater, params Type[] types)
{

View file

@ -9,9 +9,7 @@ namespace Server.Engines.Harvest
{
private static Lumberjacking m_System;
#region Tile lists
private static int[] m_TreeTiles =
private static readonly int[] m_TreeTiles =
{
0x4CCA, 0x4CCB, 0x4CCC, 0x4CCD, 0x4CD0, 0x4CD3, 0x4CD6, 0x4CD8,
0x4CDA, 0x4CDD, 0x4CE0, 0x4CE3, 0x4CE6, 0x4CF8, 0x4CFB, 0x4CFE,
@ -36,8 +34,6 @@ namespace Server.Engines.Harvest
0x52C6, 0x52C7
};
#endregion
private Lumberjacking()
{
HarvestResource[] res;
@ -81,21 +77,20 @@ namespace Server.Engines.Harvest
new HarvestResource(100.0, 60.0, 140.0, 1072546, typeof(FrostwoodLog))
};
veins = new[]
{
new HarvestVein(49.0, 0.0, res[0], null), // Ordinary Logs
new HarvestVein(30.0, 0.5, res[1], res[0]), // Oak
new HarvestVein(10.0, 0.5, res[2], res[0]), // Ash
new HarvestVein(05.0, 0.5, res[3], res[0]), // Yew
new HarvestVein(03.0, 0.5, res[4], res[0]), // Heartwood
new HarvestVein(02.0, 0.5, res[5], res[0]), // Bloodwood
new HarvestVein(01.0, 0.5, res[6], res[0]) // Frostwood
new HarvestVein(490, 0.0, res[0], null), // Ordinary Logs
new HarvestVein(300, 0.5, res[1], res[0]), // Oak
new HarvestVein(100, 0.5, res[2], res[0]), // Ash
new HarvestVein(050, 0.5, res[3], res[0]), // Yew
new HarvestVein(030, 0.5, res[4], res[0]), // Heartwood
new HarvestVein(020, 0.5, res[5], res[0]), // Bloodwood
new HarvestVein(010, 0.5, res[6], res[0]) // Frostwood
};
lumber.BonusResources = new[]
{
new BonusHarvestResource(0, 83.9, null, null), //Nothing
new BonusHarvestResource(0, 83.9, null, null), // Nothing
new BonusHarvestResource(100, 10.0, 1072548, typeof(BarkFragment)),
new BonusHarvestResource(100, 03.0, 1072550, typeof(LuminescentFungi)),
new BonusHarvestResource(100, 02.0, 1072547, typeof(SwitchItem)),
@ -112,7 +107,7 @@ namespace Server.Engines.Harvest
veins = new[]
{
new HarvestVein(100.0, 0.0, res[0], null)
new HarvestVein(1000, 0.0, res[0], null)
};
}
@ -122,14 +117,11 @@ namespace Server.Engines.Harvest
lumber.RaceBonus = Core.ML;
lumber.RandomizeVeins = Core.ML;
Definition = lumber;
Definitions.Add(lumber);
}
public static Lumberjacking System => m_System ?? (m_System = new Lumberjacking());
public HarvestDefinition Definition{ get; }
public override bool CheckHarvest(Mobile from, Item tool)
{
if (!base.CheckHarvest(from, tool))

View file

@ -10,7 +10,7 @@ namespace Server.Engines.Harvest
{
private static Mining m_System;
private static int[] m_Offsets =
private static readonly int[] m_Offsets =
{
-1, -1,
-1, 0,
@ -24,8 +24,6 @@ namespace Server.Engines.Harvest
private Mining()
{
#region Mining for ore and stone
OreAndStone = new HarvestDefinition
{
BankWidth = 8,
@ -74,15 +72,15 @@ namespace Server.Engines.Harvest
};
HarvestVein[] veins = {
new HarvestVein(49.6, 0.0, res[0], null), // Iron
new HarvestVein(11.2, 0.5, res[1], res[0]), // Dull Copper
new HarvestVein(09.8, 0.5, res[2], res[0]), // Shadow Iron
new HarvestVein(08.4, 0.5, res[3], res[0]), // Copper
new HarvestVein(07.0, 0.5, res[4], res[0]), // Bronze
new HarvestVein(05.6, 0.5, res[5], res[0]), // Gold
new HarvestVein(04.2, 0.5, res[6], res[0]), // Agapite
new HarvestVein(02.8, 0.5, res[7], res[0]), // Verite
new HarvestVein(01.4, 0.5, res[8], res[0]) // Valorite
new HarvestVein(496, 0.0, res[0], null), // Iron
new HarvestVein(112, 0.5, res[1], res[0]), // Dull Copper
new HarvestVein(098, 0.5, res[2], res[0]), // Shadow Iron
new HarvestVein(084, 0.5, res[3], res[0]), // Copper
new HarvestVein(070, 0.5, res[4], res[0]), // Bronze
new HarvestVein(056, 0.5, res[5], res[0]), // Gold
new HarvestVein(042, 0.5, res[6], res[0]), // Agapite
new HarvestVein(028, 0.5, res[7], res[0]), // Verite
new HarvestVein(014, 0.5, res[8], res[0]) // Valorite
};
OreAndStone.Resources = res;
@ -91,7 +89,7 @@ namespace Server.Engines.Harvest
if (Core.ML)
OreAndStone.BonusResources = new[]
{
new BonusHarvestResource(0, 99.4, null, null), //Nothing
new BonusHarvestResource(0, 99.4, null, null), // Nothing
new BonusHarvestResource(100, .1, 1072562, typeof(BlueDiamond)),
new BonusHarvestResource(100, .1, 1072567, typeof(DarkSapphire)),
new BonusHarvestResource(100, .1, 1072570, typeof(EcruCitrine)),
@ -105,10 +103,6 @@ namespace Server.Engines.Harvest
Definitions.Add(OreAndStone);
#endregion
#region Mining for sand
Sand = new HarvestDefinition
{
BankWidth = 8,
@ -143,22 +137,20 @@ namespace Server.Engines.Harvest
veins = new[]
{
new HarvestVein(100.0, 0.0, res[0], null)
new HarvestVein(1000, 0.0, res[0], null)
};
Sand.Resources = res;
Sand.Veins = veins;
Definitions.Add(Sand);
#endregion
}
public static Mining System => m_System ?? (m_System = new Mining());
public HarvestDefinition OreAndStone{ get; }
public HarvestDefinition OreAndStone { get; }
public HarvestDefinition Sand{ get; }
public HarvestDefinition Sand { get; }
public override Type GetResourceType(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc,
HarvestResource resource)
@ -166,13 +158,11 @@ namespace Server.Engines.Harvest
if (def != OreAndStone)
return base.GetResourceType(from, tool, def, map, loc, resource);
if (from.Skills.Mining.Base >= 100.0 && from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone
&& 0.1 > Utility.RandomDouble())
&& Utility.RandomDouble() < 0.1)
return resource.Types[1];
return resource.Types[0];
}
public override bool CheckHarvest(Mobile from, Item tool)
@ -247,7 +237,7 @@ namespace Server.Engines.Harvest
public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein,
HarvestBank bank, HarvestResource resource, object harvested)
{
if (tool is GargoylesPickaxe && def == OreAndStone && 0.1 > Utility.RandomDouble())
if (tool is GargoylesPickaxe && def == OreAndStone && Utility.RandomDouble() < 0.1)
{
HarvestResource res = vein.PrimaryResource;
@ -324,9 +314,7 @@ namespace Server.Engines.Harvest
from.SendLocalizedMessage(501863); // You can't mine that.
}
#region Tile lists
private static int[] m_MountainAndCaveTiles =
private static readonly int[] m_MountainAndCaveTiles =
{
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 236, 237, 238, 239, 240, 241, 242, 243,
@ -365,7 +353,7 @@ namespace Server.Engines.Harvest
0x4549, 0x454A, 0x454B, 0x454C, 0x454D, 0x454E, 0x454F
};
private static int[] m_SandTiles =
private static readonly int[] m_SandTiles =
{
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
@ -389,7 +377,5 @@ namespace Server.Engines.Harvest
1617, 1618, 1623, 1624, 1625, 1626, 1635, 1636, 1637,
1638, 1639, 1640, 1641, 1642, 1647, 1648, 1649, 1650
};
#endregion
}
}