#W# Initial Commit: Avatars Conquest

This commit is contained in:
WarrentyExpired 2026-07-04 10:35:30 -04:00
commit 5df497787a
7510 changed files with 416048 additions and 0 deletions

View file

@ -0,0 +1,100 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestBank
{
private int m_Current;
private int m_Maximum;
private DateTime m_NextRespawn;
private HarvestVein m_Vein, m_DefaultVein;
HarvestDefinition m_Definition;
public HarvestDefinition Definition
{
get { return m_Definition; }
}
public int Current
{
get
{
CheckRespawn();
return m_Current;
}
}
public HarvestVein Vein
{
get
{
CheckRespawn();
return m_Vein;
}
set
{
m_Vein = value;
}
}
public HarvestVein DefaultVein
{
get
{
CheckRespawn();
return m_DefaultVein;
}
}
public void CheckRespawn()
{
if ( m_Current == m_Maximum || m_NextRespawn > DateTime.Now )
return;
m_Current = m_Maximum;
if ( m_Definition.RandomizeVeins )
{
m_DefaultVein = m_Definition.GetVeinFrom( Utility.RandomDouble() );
}
m_Vein = m_DefaultVein;
}
public void Consume( int amount, Mobile from )
{
CheckRespawn();
if ( m_Current == m_Maximum )
{
double min = m_Definition.MinRespawn.TotalMinutes;
double max = m_Definition.MaxRespawn.TotalMinutes;
double rnd = Utility.RandomDouble();
m_Current = m_Maximum - amount;
double minutes = min + (rnd * (max - min));
m_NextRespawn = DateTime.Now + TimeSpan.FromMinutes( minutes );
}
else
{
m_Current -= amount;
}
if ( m_Current < 0 )
m_Current = 0;
}
public HarvestBank( HarvestDefinition def, HarvestVein defaultVein )
{
m_Maximum = Utility.RandomMinMax( def.MinTotal, def.MaxTotal );
m_Current = m_Maximum;
m_DefaultVein = defaultVein;
m_Vein = m_DefaultVein;
m_Definition = def;
}
}
}

View file

@ -0,0 +1,159 @@
using System;
using Server.Misc;
using System.Collections.Generic;
namespace Server.Engines.Harvest
{
public class HarvestDefinition
{
private int m_BankWidth, m_BankHeight;
private int m_MinTotal, m_MaxTotal;
private int[] m_Tiles;
private bool m_RangedTiles;
private TimeSpan m_MinRespawn, m_MaxRespawn;
private int m_MaxRange;
private int m_ConsumedPerHarvest;
private bool m_PlaceAtFeetIfFull;
private Trades m_Trade;
private int[] m_EffectActions;
private int[] m_EffectCounts;
private int[] m_EffectSounds;
private TimeSpan m_EffectSoundDelay;
private TimeSpan m_EffectDelay;
private object m_NoResourcesMessage, m_OutOfRangeMessage, m_TimedOutOfRangeMessage, m_DoubleHarvestMessage, m_FailMessage, m_PackFullMessage, m_ToolBrokeMessage;
private HarvestResource[] m_Resources;
private HarvestVein[] m_Veins;
private bool m_RaceBonus;
private bool m_RandomizeVeins;
public int BankWidth{ get{ return m_BankWidth; } set{ m_BankWidth = value; } }
public int BankHeight{ get{ return m_BankHeight; } set{ m_BankHeight = value; } }
public int MinTotal{ get{ return m_MinTotal; } set{ m_MinTotal = value; } }
public int MaxTotal{ get{ return m_MaxTotal; } set{ m_MaxTotal = value; } }
public int[] Tiles{ get{ return m_Tiles; } set{ m_Tiles = value; } }
public bool RangedTiles{ get{ return m_RangedTiles; } set{ m_RangedTiles = value; } }
public TimeSpan MinRespawn{ get{ return m_MinRespawn; } set{ m_MinRespawn = value; } }
public TimeSpan MaxRespawn{ get{ return m_MaxRespawn; } set{ m_MaxRespawn = value; } }
public int MaxRange{ get{ return m_MaxRange; } set{ m_MaxRange = value; } }
public int ConsumedPerHarvest{ get{ return m_ConsumedPerHarvest; } set{ m_ConsumedPerHarvest = value; } }
public bool PlaceAtFeetIfFull{ get{ return m_PlaceAtFeetIfFull; } set{ m_PlaceAtFeetIfFull = value; } }
public Trades Trade{ get{ return m_Trade; } set{ m_Trade = value; } }
public int[] EffectActions{ get{ return m_EffectActions; } set{ m_EffectActions = value; } }
public int[] EffectCounts{ get{ return m_EffectCounts; } set{ m_EffectCounts = value; } }
public int[] EffectSounds{ get{ return m_EffectSounds; } set{ m_EffectSounds = value; } }
public TimeSpan EffectSoundDelay{ get{ return m_EffectSoundDelay; } set{ m_EffectSoundDelay = value; } }
public TimeSpan EffectDelay{ get{ return m_EffectDelay; } set{ m_EffectDelay = value; } }
public object NoResourcesMessage{ get{ return m_NoResourcesMessage; } set{ m_NoResourcesMessage = value; } }
public object OutOfRangeMessage{ get{ return m_OutOfRangeMessage; } set{ m_OutOfRangeMessage = value; } }
public object TimedOutOfRangeMessage{ get{ return m_TimedOutOfRangeMessage; } set{ m_TimedOutOfRangeMessage = value; } }
public object DoubleHarvestMessage{ get{ return m_DoubleHarvestMessage; } set{ m_DoubleHarvestMessage = value; } }
public object FailMessage{ get{ return m_FailMessage; } set{ m_FailMessage = value; } }
public object PackFullMessage{ get{ return m_PackFullMessage; } set{ m_PackFullMessage = value; } }
public object ToolBrokeMessage{ get{ return m_ToolBrokeMessage; } set{ m_ToolBrokeMessage = value; } }
public HarvestResource[] Resources{ get{ return m_Resources; } set{ m_Resources = value; } }
public HarvestVein[] Veins{ get{ return m_Veins; } set{ m_Veins = value; } }
public bool RaceBonus { get { return m_RaceBonus; } set { m_RaceBonus = value; } }
public bool RandomizeVeins { get { return m_RandomizeVeins; } set { m_RandomizeVeins = value; } }
private Dictionary<Map, Dictionary<Point2D, HarvestBank>> m_BanksByMap;
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks{ get{ return m_BanksByMap; } set{ m_BanksByMap = value; } }
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 /= m_BankWidth;
y /= m_BankHeight;
Dictionary<Point2D, HarvestBank> banks = null;
m_BanksByMap.TryGetValue( map, out banks );
if ( banks == null )
m_BanksByMap[map] = banks = new Dictionary<Point2D, HarvestBank>();
Point2D key = new Point2D( x, y );
HarvestBank bank = null;
banks.TryGetValue( key, out 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 ( m_Veins.Length == 1 )
return m_Veins[0];
double randomValue;
if ( m_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 ( m_Veins.Length == 1 )
return m_Veins[0];
randomValue *= 100;
for ( int i = 0; i < m_Veins.Length; ++i )
{
if ( randomValue <= m_Veins[i].VeinChance )
return m_Veins[i];
randomValue -= m_Veins[i].VeinChance;
}
return null;
}
public HarvestDefinition()
{
m_BanksByMap = new Dictionary<Map, Dictionary<Point2D, HarvestBank>>();
}
public bool Validate( int tileID )
{
if ( m_RangedTiles )
{
bool contains = false;
for ( int i = 0; !contains && i < m_Tiles.Length; i += 2 )
contains = ( tileID >= m_Tiles[i] && tileID <= m_Tiles[i + 1] );
return contains;
}
else
{
int dist = -1;
for ( int i = 0; dist < 0 && i < m_Tiles.Length; ++i )
dist = ( m_Tiles[i] - tileID );
return ( dist == 0 );
}
}
}
}

View file

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

View file

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

View file

@ -0,0 +1,498 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Misc;
using Server.Targeting;
using Server.Regions;
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 )
{
if ( from.Region is DungeonRegion )
{
from.SendLocalizedMessage( 1005213 ); // You can't do that.
return false;
}
return CheckTool( from, tool );
}
public virtual bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
if ( from.Region is DungeonRegion )
{
from.SendLocalizedMessage( 1005213 ); // You can't do that.
return false;
}
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 = SkillCheck.TradeSkill( from, def.Trade, false );
double skillValue = skillBase;
Type type = null;
if ( skillBase >= resource.ReqSkill && SkillCheck.TestTrade( from, def.Trade, resource.MinSkill, resource.MaxSkill ) )
{
type = GetResourceType( from, tool, def, map, loc, resource );
if ( type != null )
type = MutateType( type, from, tool, def, map, loc, resource );
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 )
{
item.Amount = def.ConsumedPerHarvest;
}
if ( item is WoodBoard )
{
item.ItemID = 0x1BE0;
item.Weight = 2.0;
}
bank.Consume( item.Amount, from );
if ( Give( from, item, def.PlaceAtFeetIfFull ) )
{
SendSuccessTo( from, item, resource );
}
else
{
SendPackFullTo( from, item, def, resource );
item.Delete();
}
if ( tool is BaseAxe && !(tool is Pickaxe) )
{
((BaseWeapon)tool).HitPoints--;
}
else 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 );
OnHarvestFinished( from, tool, def, vein, bank, resource, toHarvest );
}
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.Orc );
if( vein.ChanceToFallback > (Utility.RandomDouble() + (racialBonus ? .20 : 0)) )
return fallback;
double skillValue = SkillCheck.TradeSkill( from, def.Trade, false );
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()
{
}
}
}

View file

@ -0,0 +1,80 @@
using System;
using Server;
using Server.Items;
using Server.Targeting;
using Server.Multis;
using Server.Mobiles;
namespace Server.Engines.Harvest
{
public class HarvestTarget : Target
{
private Item m_Tool;
private 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 )
{
IPoint3D p3D = targeted as IPoint3D;
if ( m_System is Fishing && ( from.Map != Map.Britannia || p3D.Z != -5 ) )
from.SendMessage( "You cannot fish here!" );
else 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 );
else
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,31 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestTimer : Timer
{
private Mobile m_From;
private Item m_Tool;
private HarvestSystem m_System;
private HarvestDefinition m_Definition;
private object m_ToHarvest, m_Locked;
private int m_Index, m_Count;
public HarvestTimer( Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest, object locked ) : base( TimeSpan.Zero, def.EffectDelay )
{
m_From = from;
m_Tool = tool;
m_System = system;
m_Definition = def;
m_ToHarvest = toHarvest;
m_Locked = locked;
m_Count = Utility.RandomList( def.EffectCounts );
}
protected override void OnTick()
{
if ( !m_System.OnHarvesting( m_From, m_Tool, m_Definition, m_ToHarvest, m_Locked, ++m_Index == m_Count ) )
Stop();
}
}
}

View file

@ -0,0 +1,25 @@
using System;
namespace Server.Engines.Harvest
{
public class HarvestVein
{
private double m_VeinChance;
private double m_ChanceToFallback;
private HarvestResource m_PrimaryResource;
private HarvestResource m_FallbackResource;
public double VeinChance{ get{ return m_VeinChance; } set{ m_VeinChance = value; } }
public double ChanceToFallback{ get{ return m_ChanceToFallback; } set{ m_ChanceToFallback = value; } }
public HarvestResource PrimaryResource{ get{ return m_PrimaryResource; } set{ m_PrimaryResource = value; } }
public HarvestResource FallbackResource{ get{ return m_FallbackResource; } set{ m_FallbackResource = value; } }
public HarvestVein( double veinChance, double chanceToFallback, HarvestResource primaryResource, HarvestResource fallbackResource )
{
m_VeinChance = veinChance;
m_ChanceToFallback = chanceToFallback;
m_PrimaryResource = primaryResource;
m_FallbackResource = fallbackResource;
}
}
}

View file

@ -0,0 +1,527 @@
using System;
using Server;
using Server.Misc;
using Server.Items;
using Server.Mobiles;
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 = new HarvestResource[]{ new HarvestResource( 00.0, 00.0, 100.0, 1043297, typeof( Fish ) ) };
HarvestVein[] veins = new HarvestVein[]{ new HarvestVein( 100.0, 0.0, res[0], null ) };
#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 );
fish.Trade = Trades.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;
// 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.
fish.Resources = res;
fish.Veins = veins;
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 Type MutateType( Type type, Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
{
if ( !IsOnBoat( from ) )
return type;
bool deepWater = SpecialFishingNet.FullValidation( map, loc.X, loc.Y );
if ( !IsOnBoat( from ) )
deepWater = false;
double skillBase = SkillCheck.TradeSkill( from, Trades.Fishing, false );
double skillValue = skillBase;
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.Britannia;
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.Britannia && from.InRange( sos.TargetLocation, 60 ) )
return true;
}
}
return base.CheckResources( from, tool, def, map, loc, timed );
}
public static bool IsOnBoat( Mobile m )
{
if ( m.Z != -2 )
return false;
bool KeepSearching = true;
bool IsOnShip = false;
foreach ( Item boatman in m.GetItemsInRange( 15 ) )
{
if ( KeepSearching )
{
if ( boatman is TillerMan )
{
IsOnShip = true;
if ( IsOnShip == true ){ KeepSearching = false; }
}
}
}
return IsOnShip;
}
public override Item Construct( Type type, Mobile from )
{
if ( type == typeof( TreasureMap ) )
{
int level = 1;
return new TreasureMap( level, Map.Britannia );
}
else if ( type == typeof( MessageInABottle ) )
{
return new MessageInABottle();
}
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.Britannia && 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.RandomPainting() );
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;
}
}
if ( preLoot != null )
{
if ( preLoot is IShipwreckedItem )
( (IShipwreckedItem)preLoot ).IsShipwreckedItem = true;
return preLoot;
}
LockableContainer chest;
if ( sos.IsAncient )
chest = new AncientChest();
else
chest = new SunkenChest();
TreasureMapChest.Fill( chest, Math.Max( 1, Math.Max( 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 = "a fish";
}
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;
}
if ( number == 1043297 )
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
{
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 );
}
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;
}
public static int[] m_WaterTiles = new int[]
{
0x00A8, 0x00A9, 0x00AA, 0x00AB,
0x0136, 0x0137,
0x5797, 0x5798, 0x5799, 0x579A, 0x579B, 0x579C,
0x746E, 0x746F, 0x7470, 0x7471, 0x7472, 0x7473, 0x7474, 0x7475, 0x7476, 0x7477, 0x7478, 0x7479, 0x747A, 0x747B, 0x747C, 0x747ED, 0x747E, 0x747F,
0x7480, 0x7481, 0x7482, 0x7483, 0x7484, 0x7485,
0x7494, 0x7495, 0x7496, 0x7497, 0x7498, 0x7499, 0x749A, 0x749B, 0x749C, 0x749D, 0x749E,
0x74A0, 0x74A1, 0x74A2, 0x74A3, 0x74A4, 0x74A5, 0x74A6, 0x74A7, 0x74A8, 0x74A9, 0x74AA, 0x74AB,
0x74B8, 0x74BA, 0x74BB, 0x74BD, 0x74BE, 0x74BF,
0x74C0, 0x74C2, 0x74C3, 0x74C4, 0x74C5, 0x74C7, 0x74C8, 0x74C9, 0x74CA
};
}
}

View file

@ -0,0 +1,161 @@
using System;
using Server;
using Server.Items;
using Server.Misc;
namespace Server.Engines.Harvest
{
public class Lumberjacking : HarvestSystem
{
private static Lumberjacking m_System;
public static Lumberjacking System
{
get
{
if ( m_System == null )
m_System = new Lumberjacking();
return m_System;
}
}
private HarvestDefinition m_Definition;
public HarvestDefinition Definition
{
get{ return m_Definition; }
}
private Lumberjacking()
{
HarvestResource[] res = new HarvestResource[]{ new HarvestResource( 00.0, 00.0, 100.0, 500498, typeof( WoodBoard ) ) };
HarvestVein[] veins = new HarvestVein[]{ new HarvestVein( 100.0, 0.0, res[0], null ) };
#region Lumberjacking
HarvestDefinition lumber = new HarvestDefinition();
// Resource banks are every 4x3 tiles
lumber.BankWidth = 4;
lumber.BankHeight = 3;
// Every bank holds from 20 to 45 logs
lumber.MinTotal = 20;
lumber.MaxTotal = 45;
// A resource bank will respawn its content every 20 to 30 minutes
lumber.MinRespawn = TimeSpan.FromMinutes( 20.0 );
lumber.MaxRespawn = TimeSpan.FromMinutes( 30.0 );
lumber.Trade = Trades.Lumberjacking;
// Set the list of harvestable tiles
lumber.Tiles = m_TreeTiles;
// Players must be within 2 tiles to harvest
lumber.MaxRange = 2;
// Ten logs per harvest action
lumber.ConsumedPerHarvest = 10;
// The chopping effect
lumber.EffectActions = new int[]{ 13 };
lumber.EffectSounds = new int[]{ 0x13E };
lumber.EffectCounts = new int[]{ 1, 2, 2, 2, 3 };
lumber.EffectDelay = TimeSpan.FromSeconds( 1.6 );
lumber.EffectSoundDelay = TimeSpan.FromSeconds( 0.9 );
lumber.NoResourcesMessage = 500493; // There's not enough wood here to harvest.
lumber.FailMessage = 500495; // You hack at the tree for a while, but fail to produce any useable wood.
lumber.OutOfRangeMessage = 500446; // That is too far away.
lumber.PackFullMessage = 500497; // You can't place any wood into your backpack!
lumber.ToolBrokeMessage = 500499; // You broke your axe.
lumber.Resources = res;
lumber.Veins = veins;
lumber.RandomizeVeins = false;
m_Definition = lumber;
Definitions.Add( lumber );
#endregion
}
public override bool CheckHarvest( Mobile from, Item tool )
{
if ( !base.CheckHarvest( from, tool ) )
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 ( tool.Parent != from )
{
from.SendLocalizedMessage( 500487 ); // The axe must be equipped for any serious wood chopping.
return false;
}
return true;
}
public override void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
{
if ( toHarvest is Mobile )
{
Mobile obj = (Mobile)toHarvest;
obj.PublicOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 500450 ); // You can only skin dead creatures.
}
else if ( toHarvest is Item )
{
Item obj = (Item)toHarvest;
obj.PublicOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 500464 ); // Use this on corpses to carve away meat and hide
}
else if ( toHarvest is Targeting.StaticTarget || toHarvest is Targeting.LandTarget )
from.SendLocalizedMessage( 500489 ); // You can't use an axe on that.
else
from.SendLocalizedMessage( 1005213 ); // You can't do that
}
public override void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
base.OnHarvestStarted( from, tool, def, toHarvest );
}
public static void Initialize()
{
Array.Sort( m_TreeTiles );
}
#region Tile lists
private static int[] m_TreeTiles = new int[]
{
0x4CCA, 0x4CCB, 0x4CCC, 0x4CCD, 0x4CD0, 0x4CD3, 0x4CD6, 0x4CD8,
0x4CDA, 0x4CDD, 0x4CE0, 0x4CE3, 0x4CE6, 0x4CF8, 0x4CFB, 0x4CFE,
0x4D01, 0x4D41, 0x4D42, 0x4D43, 0x4D44, 0x4D57, 0x4D58, 0x4D59,
0x4D5A, 0x4D5B, 0x4D6E, 0x4D6F, 0x4D70, 0x4D71, 0x4D72, 0x4D84,
0x4D85, 0x4D86, 0x4D94, 0x4D98, 0x4D9C, 0x4DA0, 0x4DA4, 0x4DA8,
0x4CCE, 0x4CCF, 0x4CD1, 0x4CD2, 0x4CD4, 0x4CD5, 0x4CD7, 0x4CD9,
0x4CDB, 0x4CDC, 0x4CDE, 0x4CDF, 0x4CE1, 0x4CE2, 0x4CE4, 0x4CE5,
0x4CE7, 0x4CE8, 0x4CF9, 0x4CFA, 0x4CFC, 0x4CFD, 0x4CFF, 0x4D00,
0x4D02, 0x4D03, 0x4D45, 0x4D46, 0x4D47, 0x4D48, 0x4D49, 0x4D4A,
0x4D4B, 0x4D4C, 0x4D4D, 0x4D4E, 0x4D4F, 0x4D50, 0x4D51, 0x4D52,
0x4D53, 0x4D5C, 0x4D5D, 0x4D5E, 0x4D5F, 0x4D60, 0x4D61, 0x4D62,
0x4D63, 0x4D64, 0x4D65, 0x4D66, 0x4D67, 0x4D68, 0x4D69, 0x4D73,
0x4D74, 0x4D75, 0x4D76, 0x4D77, 0x4D78, 0x4D79, 0x4D7A, 0x4D7B,
0x4D7C, 0x4D7D, 0x4D7E, 0x4D7F, 0x4D87, 0x4D88, 0x4D89, 0x4D8A,
0x4D8B, 0x4D8C, 0x4D8D, 0x4D8E, 0x4D8F, 0x4D90, 0x4D95, 0x4D96,
0x4D97, 0x4D99, 0x4D9A, 0x4D9B, 0x4D9D, 0x4D9E, 0x4D9F, 0x4DA1,
0x4DA2, 0x4DA3, 0x4DA5, 0x4DA6, 0x4DA7, 0x4DA9, 0x4DAA, 0x4DAB,
0x52B5, 0x52B6, 0x52B7, 0x52B8, 0x52B9, 0x52BA, 0x52BB, 0x52BC,
0x52BD, 0x52BE, 0x52BF, 0x52C0, 0x52C1, 0x52C2, 0x52C3, 0x52C4,
0x52C5, 0x52C6, 0x52C7, 0x624A, 0x624C, 0x624D, 0x58D4, 0x58D5,
0x58D6, 0x58D7, 0x58D8, 0x58D9, 0x58DA, 0x58DB, 0x58DC
};
#endregion
}
}

View file

@ -0,0 +1,211 @@
using System;
using Server;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Engines.Harvest
{
public class Mining : HarvestSystem
{
private static Mining m_System;
public static Mining System
{
get
{
if ( m_System == null )
m_System = new Mining();
return m_System;
}
}
private HarvestDefinition m_OreAndStone;
public HarvestDefinition OreAndStone
{
get{ return m_OreAndStone; }
}
private Mining()
{
HarvestResource[] res = new HarvestResource[]{ new HarvestResource( 00.0, 00.0, 100.0, 503044, typeof( IronOre ) ) };
HarvestVein[] veins = new HarvestVein[]{ new HarvestVein( 100.0, 0.0, res[0], null ) };
#region Mining for ore and stone
HarvestDefinition oreAndStone = m_OreAndStone = new HarvestDefinition();
// Resource banks are every 8x8 tiles
oreAndStone.BankWidth = 8;
oreAndStone.BankHeight = 8;
// Every bank holds from 10 to 34 ore
oreAndStone.MinTotal = 10;
oreAndStone.MaxTotal = 34;
// A resource bank will respawn its content every 10 to 20 minutes
oreAndStone.MinRespawn = TimeSpan.FromMinutes( 10.0 );
oreAndStone.MaxRespawn = TimeSpan.FromMinutes( 20.0 );
oreAndStone.Trade = Trades.Mining;
// Set the list of harvestable tiles
oreAndStone.Tiles = m_MountainAndCaveTiles;
// Players must be within 2 tiles to harvest
oreAndStone.MaxRange = 2;
// One ore per harvest action
oreAndStone.ConsumedPerHarvest = 1;
// The digging effect
oreAndStone.EffectActions = new int[]{ 11 };
oreAndStone.EffectSounds = new int[]{ 0x125, 0x126 };
oreAndStone.EffectCounts = new int[]{ 1 };
oreAndStone.EffectDelay = TimeSpan.FromSeconds( 1.6 );
oreAndStone.EffectSoundDelay = TimeSpan.FromSeconds( 0.9 );
oreAndStone.NoResourcesMessage = 503040; // There is no metal here to mine.
oreAndStone.DoubleHarvestMessage = 503042; // Someone has gotten to the metal before you.
oreAndStone.TimedOutOfRangeMessage = 503041; // You have moved too far away to continue mining.
oreAndStone.OutOfRangeMessage = 500446; // That is too far away.
oreAndStone.FailMessage = 503043; // You loosen some rocks but fail to find any useable ore.
oreAndStone.PackFullMessage = 1010481; // Your backpack is full, so the ore you mined is lost.
oreAndStone.ToolBrokeMessage = 1044038; // You have worn out your tool!
oreAndStone.Resources = res;
oreAndStone.Veins = veins;
oreAndStone.RandomizeVeins = false;
Definitions.Add( oreAndStone );
#endregion
}
public override Type GetResourceType( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
{
return base.GetResourceType( from, tool, def, map, loc, resource );
}
public override bool CheckHarvest( Mobile from, Item tool )
{
if ( !base.CheckHarvest( from, tool ) )
return false;
if ( from.Mounted )
{
from.SendLocalizedMessage( 501864 ); // You can't mine while riding.
return false;
}
else if ( from.IsBodyMod && !from.Body.IsHuman )
{
from.SendLocalizedMessage( 501865 ); // You can't mine while polymorphed.
return false;
}
return true;
}
public override void SendSuccessTo( Mobile from, Item item, HarvestResource resource )
{
base.SendSuccessTo( from, item, resource );
}
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( 501864 ); // You can't mine while riding.
return false;
}
else if ( from.IsBodyMod && !from.Body.IsHuman )
{
from.SendLocalizedMessage( 501865 ); // You can't mine while polymorphed.
return false;
}
return true;
}
private static int[] m_Offsets = new int[]
{
-1, -1,
-1, 0,
-1, 1,
0, -1,
0, 1,
1, -1,
1, 0,
1, 1
};
public override bool BeginHarvesting( Mobile from, Item tool )
{
if ( !base.BeginHarvesting( from, tool ) )
return false;
from.SendLocalizedMessage( 503033 ); // Where do you wish to dig?
return true;
}
public override void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
{
base.OnHarvestStarted( from, tool, def, toHarvest );
}
public override void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
{
if ( toHarvest is LandTarget )
from.SendLocalizedMessage( 501862 ); // You can't mine there.
else
from.SendLocalizedMessage( 501863 ); // You can't mine that.
}
#region Tile lists
private static int[] m_MountainAndCaveTiles = new int[]
{
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 236, 237, 238, 239, 240, 241, 242, 243,
244, 245, 246, 247, 252, 253, 254, 255, 256, 257,
258, 259, 260, 261, 262, 263, 268, 269, 270, 271,
272, 273, 274, 275, 276, 277, 278, 279, 286, 287,
288, 289, 290, 291, 292, 293, 294, 296, 296, 297,
321, 322, 323, 324, 467, 468, 469, 470, 471, 472,
473, 474, 476, 477, 478, 479, 480, 481, 482, 483,
484, 485, 486, 487, 492, 493, 494, 495, 543, 544,
545, 546, 547, 548, 549, 550, 551, 552, 553, 554,
555, 556, 557, 558, 559, 560, 561, 562, 563, 564,
565, 566, 567, 568, 569, 570, 571, 572, 573, 574,
575, 576, 577, 578, 579, 581, 582, 583, 584, 585,
586, 587, 588, 589, 590, 591, 592, 593, 594, 595,
596, 597, 598, 599, 600, 601, 610, 611, 612, 613,
1010, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749,
1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1771, 1772,
1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782,
1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1801, 1802,
1803, 1804, 1805, 1806, 1807, 1808, 1809, 1811, 1812, 1813,
1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823,
1824, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839,
1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849,
1850, 1851, 1852, 1853, 1854, 1861, 1862, 1863, 1864, 1865,
1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875,
1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1981,
1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2028, 2029, 2030, 2031, 2032, 2033, 2100,
2101, 2102, 2103, 2104, 2105,
0x453B, 0x453C, 0x453D, 0x453E, 0x453F, 0x4540, 0x4541,
0x4542, 0x4543, 0x4544, 0x4545, 0x4546, 0x4547, 0x4548,
0x4549, 0x454A, 0x454B, 0x454C, 0x454D, 0x454E, 0x454F
};
#endregion
}
}