Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,70 @@
using System;
namespace Server.Engines.Harvest
{
public class BonusHarvestResource
{
private readonly TextDefinition m_SuccessMessage;
private Type m_Type;
private double m_ReqSkill, m_Chance;
public BonusHarvestResource(double reqSkill, double chance, TextDefinition message, Type type)
: this(reqSkill, chance, message, type, null)
{ }
public BonusHarvestResource(double reqSkill, double chance, TextDefinition message, Type type, Map requiredMap)
{
this.m_ReqSkill = reqSkill;
this.m_Chance = chance;
this.m_Type = type;
this.m_SuccessMessage = message;
RequiredMap = requiredMap;
}
public Map RequiredMap { get; private set; }
public Type Type
{
get
{
return this.m_Type;
}
set
{
this.m_Type = value;
}
}
public double ReqSkill
{
get
{
return this.m_ReqSkill;
}
set
{
this.m_ReqSkill = value;
}
}
public double Chance
{
get
{
return this.m_Chance;
}
set
{
this.m_Chance = value;
}
}
public TextDefinition SuccessMessage
{
get
{
return this.m_SuccessMessage;
}
}
public void SendSuccessTo(Mobile m)
{
TextDefinition.SendMessageTo(m, this.m_SuccessMessage);
}
}
}

View File

@@ -0,0 +1,99 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestBank
{
private readonly int m_Maximum;
readonly HarvestDefinition m_Definition;
private int m_Current;
private DateTime m_NextRespawn;
private HarvestVein m_Vein, m_DefaultVein;
public HarvestBank(HarvestDefinition def, HarvestVein defaultVein)
{
this.m_Maximum = Utility.RandomMinMax(def.MinTotal, def.MaxTotal);
this.m_Current = this.m_Maximum;
this.m_DefaultVein = defaultVein;
this.m_Vein = this.m_DefaultVein;
this.m_Definition = def;
}
public HarvestDefinition Definition
{
get
{
return this.m_Definition;
}
}
public int Current
{
get
{
this.CheckRespawn();
return this.m_Current;
}
}
public HarvestVein Vein
{
get
{
this.CheckRespawn();
return this.m_Vein;
}
set
{
this.m_Vein = value;
}
}
public HarvestVein DefaultVein
{
get
{
this.CheckRespawn();
return this.m_DefaultVein;
}
}
public void CheckRespawn()
{
if (this.m_Current == this.m_Maximum || this.m_NextRespawn > DateTime.UtcNow)
return;
this.m_Current = this.m_Maximum;
if (this.m_Definition.RandomizeVeins)
{
this.m_DefaultVein = this.m_Definition.GetVeinFrom(Utility.RandomDouble());
}
this.m_Vein = this.m_DefaultVein;
}
public void Consume(int amount, Mobile from)
{
this.CheckRespawn();
if (this.m_Current == this.m_Maximum)
{
double min = this.m_Definition.MinRespawn.TotalMinutes;
double max = this.m_Definition.MaxRespawn.TotalMinutes;
double rnd = Utility.RandomDouble();
this.m_Current = this.m_Maximum - amount;
double minutes = min + (rnd * (max - min));
if (this.m_Definition.RaceBonus && from.Race == Race.Elf) //def.RaceBonus = Core.ML
minutes *= .75; //25% off the time.
this.m_NextRespawn = DateTime.UtcNow + TimeSpan.FromMinutes(minutes);
}
else
{
this.m_Current -= amount;
}
if (this.m_Current < 0)
this.m_Current = 0;
}
}
}

View File

@@ -0,0 +1,171 @@
using System;
using System.Collections.Generic;
namespace Server.Engines.Harvest
{
public class HarvestDefinition
{
public HarvestDefinition()
{
Banks = new Dictionary<Map, Dictionary<Point2D, HarvestBank>>();
}
public int BankWidth { get; set; }
public int BankHeight { get; set; }
public int MinTotal { get; set; }
public int MaxTotal { get; set; }
public int[] Tiles { get; set; }
public int[] SpecialTiles { get; set; }
public bool RangedTiles { get; set; }
public TimeSpan MinRespawn { get; set; }
public TimeSpan MaxRespawn { get; set; }
public int MaxRange { get; set; }
public int ConsumedPerHarvest { get; set; }
public int ConsumedPerFeluccaHarvest { get; set; }
public bool PlaceAtFeetIfFull { get; set; }
public SkillName Skill { get; set; }
public int[] EffectActions { get; set; }
public int[] EffectCounts { get; set; }
public int[] EffectSounds { get; set; }
public TimeSpan EffectSoundDelay { get; set; }
public TimeSpan EffectDelay { get; set; }
public object NoResourcesMessage { get; set; }
public object OutOfRangeMessage { get; set; }
public object TimedOutOfRangeMessage { get; set; }
public object DoubleHarvestMessage { get; set; }
public object FailMessage { get; set; }
public object PackFullMessage { get; set; }
public object ToolBrokeMessage { get; set; }
public HarvestResource[] Resources { get; set; }
public HarvestVein[] Veins { get; set; }
public BonusHarvestResource[] BonusResources { get; set; }
public bool RaceBonus { get; set; }
public bool RandomizeVeins { get; set; }
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks { get; set; }
public void SendMessageTo(Mobile from, object message)
{
if (message is int)
from.SendLocalizedMessage((int)message);
else if (message is string)
from.SendMessage((string)message);
}
public HarvestBank GetBank(Map map, int x, int y)
{
if (map == null || map == Map.Internal)
return null;
x /= BankWidth;
y /= BankHeight;
Banks.TryGetValue(map, out Dictionary<Point2D, HarvestBank> banks);
if (banks == null)
Banks[map] = banks = new Dictionary<Point2D, HarvestBank>();
Point2D key = new Point2D(x, y);
banks.TryGetValue(key, out HarvestBank bank);
if (bank == null)
banks[key] = bank = new HarvestBank(this, GetVeinAt(map, x, y));
return bank;
}
public HarvestVein GetVeinAt(Map map, int x, int y)
{
if (Veins.Length == 1)
return Veins[0];
double randomValue;
if (RandomizeVeins)
{
randomValue = Utility.RandomDouble();
}
else
{
Random random = new Random((x * 17) + (y * 11) + (map.MapID * 3));
randomValue = random.NextDouble();
}
return GetVeinFrom(randomValue);
}
public HarvestVein GetVeinFrom(double randomValue)
{
if (Veins.Length == 1)
return Veins[0];
randomValue *= 100;
for (int i = 0; i < Veins.Length; ++i)
{
if (randomValue <= Veins[i].VeinChance)
return Veins[i];
randomValue -= Veins[i].VeinChance;
}
return null;
}
public BonusHarvestResource GetBonusResource()
{
if (BonusResources == null)
return null;
double randomValue = Utility.RandomDouble() * 100;
for (int i = 0; i < BonusResources.Length; ++i)
{
if (randomValue <= BonusResources[i].Chance)
return BonusResources[i];
randomValue -= BonusResources[i].Chance;
}
return null;
}
public bool Validate(int tileID)
{
if (RangedTiles)
{
bool contains = false;
for (int i = 0; !contains && i < Tiles.Length; i += 2)
contains = tileID >= Tiles[i] && tileID <= Tiles[i + 1];
return contains;
}
else
{
int dist = -1;
for (int i = 0; dist < 0 && i < Tiles.Length; ++i)
dist = Tiles[i] - tileID;
return dist == 0;
}
}
#region High Seas
public bool ValidateSpecial(int tileID)
{
//No Special tiles were initiated so always true
if (SpecialTiles == null || SpecialTiles.Length == 0)
return true;
for (int i = 0; i < SpecialTiles.Length; i++)
{
if (tileID == SpecialTiles[i])
return true;
}
return false;
}
#endregion
}
}

View File

@@ -0,0 +1,30 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestResource
{
public HarvestResource(double reqSkill, double minSkill, double maxSkill, object message, params Type[] types)
{
ReqSkill = reqSkill;
MinSkill = minSkill;
MaxSkill = maxSkill;
Types = types;
SuccessMessage = message;
}
public Type[] Types { get; set; }
public double ReqSkill { get; set; }
public double MinSkill { get; set; }
public double MaxSkill { get; set; }
public object SuccessMessage { get; }
public void SendSuccessTo(Mobile m)
{
if (SuccessMessage is int)
m.SendLocalizedMessage((int)SuccessMessage);
else if (SuccessMessage is string)
m.SendMessage((string)SuccessMessage);
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestSoundTimer : Timer
{
private readonly Mobile m_From;
private readonly Item m_Tool;
private readonly HarvestSystem m_System;
private readonly HarvestDefinition m_Definition;
private readonly object m_ToHarvest;
private readonly object m_Locked;
private readonly bool m_Last;
public HarvestSoundTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest, object locked, bool last)
: base(def.EffectSoundDelay)
{
this.m_From = from;
this.m_Tool = tool;
this.m_System = system;
this.m_Definition = def;
this.m_ToHarvest = toHarvest;
this.m_Locked = locked;
this.m_Last = last;
}
protected override void OnTick()
{
this.m_System.DoHarvestingSound(this.m_From, this.m_Tool, this.m_Definition, this.m_ToHarvest);
if (this.m_Last)
this.m_System.FinishHarvesting(this.m_From, this.m_Tool, this.m_Definition, this.m_ToHarvest, this.m_Locked);
}
}
}

View File

@@ -0,0 +1,130 @@
using System;
using Server.Engines.Quests;
using Server.Engines.Quests.Hag;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Engines.Harvest
{
public class HarvestTarget : Target
{
private readonly Item m_Tool;
private readonly HarvestSystem m_System;
public HarvestTarget(Item tool, HarvestSystem system)
: base(-1, true, TargetFlags.None)
{
m_Tool = tool;
m_System = system;
DisallowMultis = true;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (m_System is Mining)
{
if (targeted is StaticTarget)
{
int itemID = ((StaticTarget)targeted).ItemID;
// grave
if (itemID == 0xED3 || itemID == 0xEDF || itemID == 0xEE0 || itemID == 0xEE1 || itemID == 0xEE2 || itemID == 0xEE8)
{
PlayerMobile player = from as PlayerMobile;
if (player != null)
{
QuestSystem qs = player.Quest;
if (qs is WitchApprenticeQuest)
{
FindIngredientObjective obj = qs.FindObjective(typeof(FindIngredientObjective)) as FindIngredientObjective;
if (obj != null && !obj.Completed && obj.Ingredient == Ingredient.Bones)
{
player.SendLocalizedMessage(1055037); // You finish your grim work, finding some of the specific bones listed in the Hag's recipe.
obj.Complete();
return;
}
}
}
}
}
else if (targeted is LandTarget && ((LandTarget)targeted).TileID >= 113 && ((LandTarget)targeted).TileID <= 120)
{
if (Server.Engines.Quests.TheGreatVolcanoQuest.OnHarvest(from, m_Tool))
return;
}
}
if (m_System is Lumberjacking && targeted is IChopable)
((IChopable)targeted).OnChop(from);
else if (m_System is Lumberjacking && targeted is IAxe && m_Tool is BaseAxe)
{
IAxe obj = (IAxe)targeted;
Item item = (Item)targeted;
if (!item.IsChildOf(from.Backpack))
from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
else if (obj.Axe(from, (BaseAxe)m_Tool))
from.PlaySound(0x13E);
}
else if (m_System is Lumberjacking && targeted is ICarvable)
((ICarvable)targeted).Carve(from, (Item)m_Tool);
else if (m_System is Lumberjacking && FurnitureAttribute.Check(targeted as Item))
DestroyFurniture(from, (Item)targeted);
else if (m_System is Mining && targeted is TreasureMap)
((TreasureMap)targeted).OnBeginDig(from);
#region High Seas
else if (m_System is Mining && targeted is NiterDeposit)
((NiterDeposit)targeted).OnMine(from, m_Tool);
else if (m_System is Lumberjacking && targeted is CrackedLavaRockEast)
((CrackedLavaRockEast)targeted).OnCrack(from);
else if (m_System is Lumberjacking && targeted is CrackedLavaRockSouth)
((CrackedLavaRockSouth)targeted).OnCrack(from);
#endregion
else
{
// If we got here and we're lumberjacking then we didn't target something that can be done from the pack
if (m_System is Lumberjacking && m_Tool.Parent != from)
{
from.SendLocalizedMessage(500487); // The axe must be equipped for any serious wood chopping.
return;
}
m_System.StartHarvesting(from, m_Tool, targeted);
}
}
private void DestroyFurniture(Mobile from, Item item)
{
if (!from.InRange(item.GetWorldLocation(), 3))
{
from.SendLocalizedMessage(500446); // That is too far away.
return;
}
else if (!item.IsChildOf(from.Backpack) && !item.Movable)
{
from.SendLocalizedMessage(500462); // You can't destroy that while it is here.
return;
}
from.SendLocalizedMessage(500461); // You destroy the item.
Effects.PlaySound(item.GetWorldLocation(), item.Map, 0x3B3);
if (item is Container)
{
if (item is TrapableContainer)
(item as TrapableContainer).ExecuteTrap(from);
((Container)item).Destroy();
}
else
{
item.Delete();
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestTimer : Timer
{
private readonly Mobile m_From;
private readonly Item m_Tool;
private readonly HarvestSystem m_System;
private readonly HarvestDefinition m_Definition;
private readonly object m_ToHarvest;
private readonly object m_Locked;
private readonly int m_Count;
private int m_Index;
public HarvestTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest, object locked)
: base(TimeSpan.Zero, def.EffectDelay)
{
this.m_From = from;
this.m_Tool = tool;
this.m_System = system;
this.m_Definition = def;
this.m_ToHarvest = toHarvest;
this.m_Locked = locked;
this.m_Count = Utility.RandomList(def.EffectCounts);
}
protected override void OnTick()
{
if (!this.m_System.OnHarvesting(this.m_From, this.m_Tool, this.m_Definition, this.m_ToHarvest, this.m_Locked, ++this.m_Index == this.m_Count))
this.Stop();
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestVein
{
public HarvestVein(double veinChance, double chanceToFallback, HarvestResource primaryResource, HarvestResource fallbackResource)
{
VeinChance = veinChance;
ChanceToFallback = chanceToFallback;
PrimaryResource = primaryResource;
FallbackResource = fallbackResource;
}
public double VeinChance { get; set; }
public double ChanceToFallback { get; set; }
public HarvestResource PrimaryResource { get; set; }
public HarvestResource FallbackResource { get; set; }
}
}