#W# Initial Commit: Avatars Conquest
This commit is contained in:
commit
8eae46895e
7512 changed files with 416187 additions and 0 deletions
36
Scripts/Items/Maps/BlankMap.cs
Normal file
36
Scripts/Items/Maps/BlankMap.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class BlankMap : MapItem
|
||||
{
|
||||
[Constructable]
|
||||
public BlankMap()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
SendLocalizedMessageTo( from, 500208 ); // It appears to be blank.
|
||||
}
|
||||
|
||||
public BlankMap( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
53
Scripts/Items/Maps/CityMap.cs
Normal file
53
Scripts/Items/Maps/CityMap.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class CityMap : MapItem
|
||||
{
|
||||
[Constructable]
|
||||
public CityMap()
|
||||
{
|
||||
SetDisplay( 0, 0, 5119, 4095, 400, 400 );
|
||||
}
|
||||
|
||||
public override void CraftInit( Mobile from )
|
||||
{
|
||||
double skillValue = Server.Misc.SkillCheck.TradeSkill( from, Trades.Cartography, false );
|
||||
int dist = 64 + (int)(skillValue * 4);
|
||||
|
||||
if ( dist < 200 )
|
||||
dist = 200;
|
||||
|
||||
int size = 32 + (int)(skillValue * 2);
|
||||
|
||||
if ( size < 200 )
|
||||
size = 200;
|
||||
else if ( size > 400 )
|
||||
size = 400;
|
||||
|
||||
SetDisplay( from.X - dist, from.Y - dist, from.X + dist, from.Y + dist, size, size );
|
||||
}
|
||||
|
||||
public override int LabelNumber{ get{ return 1015231; } } // city map
|
||||
|
||||
public CityMap( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Scripts/Items/Maps/IndecipherableMap.cs
Normal file
42
Scripts/Items/Maps/IndecipherableMap.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class IndecipherableMap : MapItem
|
||||
{
|
||||
public override int LabelNumber{ get{ return 1070799; } } // indecipherable map
|
||||
|
||||
[Constructable]
|
||||
public IndecipherableMap()
|
||||
{
|
||||
if ( Utility.RandomDouble() < 0.2 )
|
||||
Hue = 0x965;
|
||||
else
|
||||
Hue = 0x961;
|
||||
}
|
||||
|
||||
public IndecipherableMap( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
from.SendLocalizedMessage( 1070801 ); // You cannot decipher this ruined map.
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Scripts/Items/Maps/LocalMap.cs
Normal file
43
Scripts/Items/Maps/LocalMap.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class LocalMap : MapItem
|
||||
{
|
||||
[Constructable]
|
||||
public LocalMap()
|
||||
{
|
||||
SetDisplay( 0, 0, 5119, 4095, 400, 400 );
|
||||
}
|
||||
|
||||
public override void CraftInit( Mobile from )
|
||||
{
|
||||
double skillValue = Server.Misc.SkillCheck.TradeSkill( from, Trades.Cartography, false );
|
||||
int dist = 64 + (int)(skillValue * 2);
|
||||
|
||||
SetDisplay( from.X - dist, from.Y - dist, from.X + dist, from.Y + dist, 200, 200 );
|
||||
}
|
||||
|
||||
public override int LabelNumber{ get{ return 1015230; } } // local map
|
||||
|
||||
public LocalMap( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
385
Scripts/Items/Maps/MapItem.cs
Normal file
385
Scripts/Items/Maps/MapItem.cs
Normal file
|
|
@ -0,0 +1,385 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Network;
|
||||
using Server.Engines.Craft;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
[Flipable( 0x14EB, 0x14EC )]
|
||||
public class MapItem : Item, ICraftable
|
||||
{
|
||||
private Rectangle2D m_Bounds;
|
||||
|
||||
private int m_Width, m_Height;
|
||||
|
||||
private bool m_Protected;
|
||||
private bool m_Editable;
|
||||
|
||||
private List<Point2D> m_Pins = new List<Point2D>();
|
||||
|
||||
private const int MaxUserPins = 50;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Protected
|
||||
{
|
||||
get { return m_Protected; }
|
||||
set { m_Protected = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Rectangle2D Bounds
|
||||
{
|
||||
get { return m_Bounds; }
|
||||
set { m_Bounds = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { m_Width = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { m_Height = value; }
|
||||
}
|
||||
|
||||
public List<Point2D> Pins
|
||||
{
|
||||
get { return m_Pins; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public MapItem() : base( 0x14EC )
|
||||
{
|
||||
Weight = 1.0;
|
||||
|
||||
m_Width = 200;
|
||||
m_Height = 200;
|
||||
}
|
||||
|
||||
public virtual void CraftInit( Mobile from )
|
||||
{
|
||||
}
|
||||
|
||||
public void SetDisplay( int x1, int y1, int x2, int y2, int w, int h )
|
||||
{
|
||||
Width = w;
|
||||
Height = h;
|
||||
|
||||
if ( x1 < 0 )
|
||||
x1 = 0;
|
||||
|
||||
if ( y1 < 0 )
|
||||
y1 = 0;
|
||||
|
||||
if ( x2 >= 5120 )
|
||||
x2 = 5119;
|
||||
|
||||
if ( y2 >= 4096 )
|
||||
y2 = 4095;
|
||||
|
||||
Bounds = new Rectangle2D( x1, y1, x2-x1, y2-y1 );
|
||||
}
|
||||
|
||||
public MapItem( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from.InRange( GetWorldLocation(), 2 ) )
|
||||
DisplayTo( from );
|
||||
else
|
||||
from.SendLocalizedMessage( 500446 ); // That is too far away.
|
||||
}
|
||||
|
||||
public virtual void DisplayTo( Mobile from )
|
||||
{
|
||||
from.Send( new MapDetails( this ) );
|
||||
from.Send( new MapDisplay( this ) );
|
||||
|
||||
for ( int i = 0; i < m_Pins.Count; ++i )
|
||||
from.Send( new MapAddPin( this, m_Pins[i] ) );
|
||||
|
||||
from.Send( new MapSetEditable( this, ValidateEdit( from ) ) );
|
||||
}
|
||||
|
||||
public virtual void OnAddPin( Mobile from, int x, int y )
|
||||
{
|
||||
if ( !ValidateEdit( from ) )
|
||||
return;
|
||||
else if ( m_Pins.Count >= MaxUserPins )
|
||||
return;
|
||||
|
||||
Validate( ref x, ref y );
|
||||
AddPin( x, y );
|
||||
}
|
||||
|
||||
public virtual void OnRemovePin( Mobile from, int number )
|
||||
{
|
||||
if ( !ValidateEdit( from ) )
|
||||
return;
|
||||
|
||||
RemovePin( number );
|
||||
}
|
||||
|
||||
public virtual void OnChangePin( Mobile from, int number, int x, int y )
|
||||
{
|
||||
if ( !ValidateEdit( from ) )
|
||||
return;
|
||||
|
||||
Validate( ref x, ref y );
|
||||
ChangePin( number, x, y );
|
||||
}
|
||||
|
||||
public virtual void OnInsertPin( Mobile from, int number, int x, int y )
|
||||
{
|
||||
if ( !ValidateEdit( from ) )
|
||||
return;
|
||||
else if ( m_Pins.Count >= MaxUserPins )
|
||||
return;
|
||||
|
||||
Validate( ref x, ref y );
|
||||
InsertPin( number, x, y );
|
||||
}
|
||||
|
||||
public virtual void OnClearPins( Mobile from )
|
||||
{
|
||||
if ( !ValidateEdit( from ) )
|
||||
return;
|
||||
|
||||
ClearPins();
|
||||
}
|
||||
|
||||
public virtual void OnToggleEditable( Mobile from )
|
||||
{
|
||||
if ( Validate( from ) )
|
||||
m_Editable = !m_Editable;
|
||||
|
||||
from.Send( new MapSetEditable( this, Validate( from ) && m_Editable ) );
|
||||
}
|
||||
|
||||
public virtual void Validate( ref int x, ref int y )
|
||||
{
|
||||
if ( x < 0 )
|
||||
x = 0;
|
||||
else if ( x >= m_Width )
|
||||
x = m_Width - 1;
|
||||
|
||||
if ( y < 0 )
|
||||
y = 0;
|
||||
else if ( y >= m_Height )
|
||||
y = m_Height - 1;
|
||||
}
|
||||
|
||||
public virtual bool ValidateEdit( Mobile from )
|
||||
{
|
||||
return m_Editable && Validate( from );
|
||||
}
|
||||
|
||||
public virtual bool Validate( Mobile from )
|
||||
{
|
||||
if ( !from.CanSee( this ) || from.Map != this.Map || !from.Alive || InSecureTrade )
|
||||
return false;
|
||||
else if ( from.AccessLevel >= AccessLevel.GameMaster )
|
||||
return true;
|
||||
else if ( !Movable || m_Protected || !from.InRange( GetWorldLocation(), 2 ) )
|
||||
return false;
|
||||
|
||||
object root = RootParent;
|
||||
|
||||
if ( root is Mobile && root != from )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ConvertToWorld( int x, int y, out int worldX, out int worldY )
|
||||
{
|
||||
worldX = ( ( m_Bounds.Width * x ) / Width ) + m_Bounds.X;
|
||||
worldY = ( ( m_Bounds.Height * y ) / Height ) + m_Bounds.Y;
|
||||
}
|
||||
|
||||
public void ConvertToMap( int x, int y, out int mapX, out int mapY )
|
||||
{
|
||||
mapX = ( ( x - m_Bounds.X ) * Width ) / m_Bounds.Width;
|
||||
mapY = ( ( y - m_Bounds.Y ) * Width ) / m_Bounds.Height;
|
||||
}
|
||||
|
||||
public virtual void AddWorldPin( int x, int y )
|
||||
{
|
||||
int mapX, mapY;
|
||||
ConvertToMap( x, y, out mapX, out mapY );
|
||||
|
||||
AddPin( mapX, mapY );
|
||||
}
|
||||
|
||||
public virtual void AddPin( int x, int y )
|
||||
{
|
||||
m_Pins.Add( new Point2D( x, y ) );
|
||||
}
|
||||
|
||||
public virtual void RemovePin( int index )
|
||||
{
|
||||
if ( index > 0 && index < m_Pins.Count )
|
||||
m_Pins.RemoveAt( index );
|
||||
}
|
||||
|
||||
public virtual void InsertPin( int index, int x, int y )
|
||||
{
|
||||
if ( index < 0 || index >= m_Pins.Count )
|
||||
m_Pins.Add( new Point2D( x, y ) );
|
||||
else
|
||||
m_Pins.Insert( index, new Point2D( x, y ) );
|
||||
}
|
||||
|
||||
public virtual void ChangePin( int index, int x, int y )
|
||||
{
|
||||
if ( index >= 0 && index < m_Pins.Count )
|
||||
m_Pins[index] = new Point2D( x, y );
|
||||
}
|
||||
|
||||
public virtual void ClearPins()
|
||||
{
|
||||
m_Pins.Clear();
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
|
||||
writer.Write( m_Bounds );
|
||||
|
||||
writer.Write( m_Width );
|
||||
writer.Write( m_Height );
|
||||
|
||||
writer.Write( m_Protected );
|
||||
|
||||
writer.Write( m_Pins.Count );
|
||||
for ( int i = 0; i < m_Pins.Count; ++i )
|
||||
writer.Write( m_Pins[i] );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Bounds = reader.ReadRect2D();
|
||||
|
||||
m_Width = reader.ReadInt();
|
||||
m_Height = reader.ReadInt();
|
||||
|
||||
m_Protected = reader.ReadBool();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
for ( int i = 0; i < count; i++ )
|
||||
m_Pins.Add( reader.ReadPoint2D() );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register( 0x56, 11, true, new OnPacketReceive( OnMapCommand ) );
|
||||
}
|
||||
|
||||
private static void OnMapCommand( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
MapItem map = World.FindItem( pvSrc.ReadInt32() ) as MapItem;
|
||||
|
||||
if ( map == null )
|
||||
return;
|
||||
|
||||
int command = pvSrc.ReadByte();
|
||||
int number = pvSrc.ReadByte();
|
||||
|
||||
int x = pvSrc.ReadInt16();
|
||||
int y = pvSrc.ReadInt16();
|
||||
|
||||
switch ( command )
|
||||
{
|
||||
case 1: map.OnAddPin( from, x, y ); break;
|
||||
case 2: map.OnInsertPin( from, number, x, y ); break;
|
||||
case 3: map.OnChangePin( from, number, x, y ); break;
|
||||
case 4: map.OnRemovePin( from, number ); break;
|
||||
case 5: map.OnClearPins( from ); break;
|
||||
case 6: map.OnToggleEditable( from ); break;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class MapDetails : Packet
|
||||
{
|
||||
public MapDetails( MapItem map ) : base ( 0x90, 19 )
|
||||
{
|
||||
m_Stream.Write( (int) map.Serial );
|
||||
m_Stream.Write( (short) 0x139D );
|
||||
m_Stream.Write( (short) map.Bounds.Start.X );
|
||||
m_Stream.Write( (short) map.Bounds.Start.Y );
|
||||
m_Stream.Write( (short) map.Bounds.End.X );
|
||||
m_Stream.Write( (short) map.Bounds.End.Y );
|
||||
m_Stream.Write( (short) map.Width );
|
||||
m_Stream.Write( (short) map.Height );
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class MapCommand : Packet
|
||||
{
|
||||
public MapCommand( MapItem map, int command, int number, int x, int y ) : base ( 0x56, 11 )
|
||||
{
|
||||
m_Stream.Write( (int) map.Serial );
|
||||
m_Stream.Write( (byte) command );
|
||||
m_Stream.Write( (byte) number );
|
||||
m_Stream.Write( (short) x );
|
||||
m_Stream.Write( (short) y );
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class MapDisplay : MapCommand
|
||||
{
|
||||
public MapDisplay( MapItem map ) : base( map, 5, 0, 0, 0 )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class MapAddPin : MapCommand
|
||||
{
|
||||
public MapAddPin( MapItem map, Point2D point ) : base( map, 1, 0, point.X, point.Y )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class MapSetEditable : MapCommand
|
||||
{
|
||||
public MapSetEditable( MapItem map, bool editable ) : base( map, 7, editable ? 1 : 0, 0, 0 )
|
||||
{
|
||||
}
|
||||
}
|
||||
#region ICraftable Members
|
||||
|
||||
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
|
||||
{
|
||||
CraftInit( from );
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
151
Scripts/Items/Maps/PresetMap.cs
Normal file
151
Scripts/Items/Maps/PresetMap.cs
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class PresetMap : MapItem
|
||||
{
|
||||
private int m_LabelNumber;
|
||||
|
||||
[Constructable]
|
||||
public PresetMap( PresetMapType type )
|
||||
{
|
||||
int v = (int)type;
|
||||
|
||||
if ( v >= 0 && v < PresetMapEntry.Table.Length )
|
||||
InitEntry( PresetMapEntry.Table[v] );
|
||||
}
|
||||
|
||||
public PresetMap( PresetMapEntry entry )
|
||||
{
|
||||
InitEntry( entry );
|
||||
}
|
||||
|
||||
public void InitEntry( PresetMapEntry entry )
|
||||
{
|
||||
m_LabelNumber = entry.Name;
|
||||
|
||||
Width = entry.Width;
|
||||
Height = entry.Height;
|
||||
|
||||
Bounds = entry.Bounds;
|
||||
}
|
||||
|
||||
public override int LabelNumber{ get{ return (m_LabelNumber == 0 ? base.LabelNumber : m_LabelNumber); } }
|
||||
|
||||
public PresetMap( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
|
||||
writer.Write( (int) m_LabelNumber );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_LabelNumber = reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PresetMapEntry
|
||||
{
|
||||
private int m_Name;
|
||||
private int m_Width, m_Height;
|
||||
private Rectangle2D m_Bounds;
|
||||
|
||||
public int Name{ get{ return m_Name; } }
|
||||
public int Width{ get{ return m_Width; } }
|
||||
public int Height{ get{ return m_Height; } }
|
||||
public Rectangle2D Bounds{ get{ return m_Bounds; } }
|
||||
|
||||
public PresetMapEntry( int name, int width, int height, int xLeft, int yTop, int xRight, int yBottom )
|
||||
{
|
||||
m_Name = name;
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
m_Bounds = new Rectangle2D( xLeft, yTop, xRight - xLeft, yBottom - yTop );
|
||||
}
|
||||
|
||||
private static PresetMapEntry[] m_Table = new PresetMapEntry[]
|
||||
{
|
||||
new PresetMapEntry( 1041189, 200, 200, 1092, 1396, 1736, 1924 ), // map of Britain
|
||||
new PresetMapEntry( 1041203, 200, 200, 0256, 1792, 1736, 2560 ), // map of Britain to Skara Brae
|
||||
new PresetMapEntry( 1041192, 200, 200, 1024, 1280, 2304, 3072 ), // map of Britain to Trinsic
|
||||
new PresetMapEntry( 1041183, 200, 200, 2500, 1900, 3000, 2400 ), // map of Buccaneer's Den
|
||||
new PresetMapEntry( 1041198, 200, 200, 2560, 1792, 3840, 2560 ), // map of Buccaneer's Den to Magincia
|
||||
new PresetMapEntry( 1041194, 200, 200, 2560, 1792, 3840, 3072 ), // map of Buccaneer's Den to Ocllo
|
||||
new PresetMapEntry( 1041181, 200, 200, 1088, 3572, 1528, 4056 ), // map of Jhelom
|
||||
new PresetMapEntry( 1041186, 200, 200, 3530, 2022, 3818, 2298 ), // map of Magincia
|
||||
new PresetMapEntry( 1041199, 200, 200, 3328, 1792, 3840, 2304 ), // map of Magincia to Ocllo
|
||||
new PresetMapEntry( 1041182, 200, 200, 2360, 0356, 2706, 0702 ), // map of Minoc
|
||||
new PresetMapEntry( 1041190, 200, 200, 0000, 0256, 2304, 3072 ), // map of Minoc to Yew
|
||||
new PresetMapEntry( 1041191, 200, 200, 2467, 0572, 2878, 0746 ), // map of Minoc to Vesper
|
||||
new PresetMapEntry( 1041188, 200, 200, 4156, 0808, 4732, 1528 ), // map of Moonglow
|
||||
new PresetMapEntry( 1041201, 200, 200, 3328, 0768, 4864, 1536 ), // map of Moonglow to Nujelm
|
||||
new PresetMapEntry( 1041185, 200, 200, 3446, 1030, 3832, 1424 ), // map of Nujelm
|
||||
new PresetMapEntry( 1041197, 200, 200, 3328, 1024, 3840, 2304 ), // map of Nujelm to Magincia
|
||||
new PresetMapEntry( 1041187, 200, 200, 3582, 2456, 3770, 2742 ), // map of Ocllo
|
||||
new PresetMapEntry( 1041184, 200, 200, 2714, 3329, 3100, 3639 ), // map of Serpent's Hold
|
||||
new PresetMapEntry( 1041200, 200, 200, 2560, 2560, 3840, 3840 ), // map of Serpent's Hold to Ocllo
|
||||
new PresetMapEntry( 1041180, 200, 200, 0524, 2064, 0960, 2452 ), // map of Skara Brae
|
||||
new PresetMapEntry( 1041204, 200, 200, 0000, 0000, 5199, 4095 ), // map of The World
|
||||
new PresetMapEntry( 1041177, 200, 200, 1792, 2630, 2118, 2952 ), // map of Trinsic
|
||||
new PresetMapEntry( 1041193, 200, 200, 1792, 1792, 3072, 3072 ), // map of Trinsic to Buccaneer's Den
|
||||
new PresetMapEntry( 1041195, 200, 200, 0256, 1792, 2304, 4095 ), // map of Trinsic to Jhelom
|
||||
new PresetMapEntry( 1041178, 200, 200, 2636, 0592, 3064, 1012 ), // map of Vesper
|
||||
new PresetMapEntry( 1041196, 200, 200, 2636, 0592, 3840, 1536 ), // map of Vesper to Nujelm
|
||||
new PresetMapEntry( 1041179, 200, 200, 0236, 0741, 0766, 1269 ), // map of Yew
|
||||
new PresetMapEntry( 1041202, 200, 200, 0000, 0512, 1792, 2048 ) // map of Yew to Britain
|
||||
};
|
||||
|
||||
public static PresetMapEntry[] Table{ get{ return m_Table; } }
|
||||
}
|
||||
|
||||
public enum PresetMapType
|
||||
{
|
||||
Britain,
|
||||
BritainToSkaraBrae,
|
||||
BritainToTrinsic,
|
||||
BucsDen,
|
||||
BucsDenToMagincia,
|
||||
BucsDenToOcllo,
|
||||
Jhelom,
|
||||
Magincia,
|
||||
MaginciaToOcllo,
|
||||
Minoc,
|
||||
MinocToYew,
|
||||
MinocToVesper,
|
||||
Moonglow,
|
||||
MoonglowToNujelm,
|
||||
Nujelm,
|
||||
NujelmToMagincia,
|
||||
Ocllo,
|
||||
SerpentsHold,
|
||||
SerpentsHoldToOcllo,
|
||||
SkaraBrae,
|
||||
TheWorld,
|
||||
Trinsic,
|
||||
TrinsicToBucsDen,
|
||||
TrinsicToJhelom,
|
||||
Vesper,
|
||||
VesperToNujelm,
|
||||
Yew,
|
||||
YewToBritain
|
||||
}
|
||||
}
|
||||
53
Scripts/Items/Maps/SeaChart.cs
Normal file
53
Scripts/Items/Maps/SeaChart.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class SeaChart : MapItem
|
||||
{
|
||||
[Constructable]
|
||||
public SeaChart()
|
||||
{
|
||||
SetDisplay( 0, 0, 5119, 4095, 400, 400 );
|
||||
}
|
||||
|
||||
public override void CraftInit( Mobile from )
|
||||
{
|
||||
double skillValue = Server.Misc.SkillCheck.TradeSkill( from, Trades.Cartography, false );
|
||||
int dist = 64 + (int)(skillValue * 10);
|
||||
|
||||
if ( dist < 200 )
|
||||
dist = 200;
|
||||
|
||||
int size = 24 + (int)(skillValue * 3.3);
|
||||
|
||||
if ( size < 200 )
|
||||
size = 200;
|
||||
else if ( size > 400 )
|
||||
size = 400;
|
||||
|
||||
SetDisplay( from.X - dist, from.Y - dist, from.X + dist, from.Y + dist, size, size );
|
||||
}
|
||||
|
||||
public override int LabelNumber{ get{ return 1015232; } } // sea chart
|
||||
|
||||
public SeaChart( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
862
Scripts/Items/Maps/TreasureMap.cs
Normal file
862
Scripts/Items/Maps/TreasureMap.cs
Normal file
|
|
@ -0,0 +1,862 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
using Server.ContextMenus;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class TreasureMap : MapItem
|
||||
{
|
||||
private int m_Level;
|
||||
private bool m_Completed;
|
||||
private Mobile m_CompletedBy;
|
||||
private Mobile m_Decoder;
|
||||
private Map m_Map;
|
||||
private Point2D m_Location;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Level{ get{ return m_Level; } set{ m_Level = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Completed{ get{ return m_Completed; } set{ m_Completed = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Mobile CompletedBy{ get{ return m_CompletedBy; } set{ m_CompletedBy = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Mobile Decoder{ get{ return m_Decoder; } set{ m_Decoder = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Map ChestMap{ get{ return m_Map; } set{ m_Map = value; InvalidateProperties(); } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Point2D ChestLocation{ get{ return m_Location; } set{ m_Location = value; } }
|
||||
|
||||
private static Point2D[] m_Locations;
|
||||
|
||||
private static Type[][] m_SpawnTypes = new Type[][]
|
||||
{
|
||||
new Type[]{ typeof( HeadlessOne ), typeof( Skeleton ) },
|
||||
new Type[]{ typeof( Mongbat ), typeof( Ratman ), typeof( HeadlessOne ), typeof( Skeleton ), typeof( Zombie ) },
|
||||
new Type[]{ typeof( OrcishMage ), typeof( Gargoyle ), typeof( Gazer ), typeof( HellHound ), typeof( EarthElemental ) },
|
||||
new Type[]{ typeof( Lich ), typeof( OgreLord ), typeof( DreadSpider ), typeof( AirElemental ), typeof( FireElemental ) },
|
||||
new Type[]{ typeof( DreadSpider ), typeof( LichLord ), typeof( Daemon ), typeof( ElderGazer ), typeof( OgreLord ) },
|
||||
new Type[]{ typeof( LichLord ), typeof( Daemon ), typeof( ElderGazer ), typeof( PoisonElemental ), typeof( BloodElemental ) },
|
||||
new Type[]{ typeof( AncientWyrm ), typeof( Balron ), typeof( BloodElemental ), typeof( PoisonElemental ), typeof( Titan ) }
|
||||
};
|
||||
|
||||
public const double LootChance = 0.01; // 1% chance to appear as loot
|
||||
|
||||
public static Point2D GetRandomLocation()
|
||||
{
|
||||
if ( m_Locations == null )
|
||||
LoadLocations();
|
||||
|
||||
if ( m_Locations.Length > 0 )
|
||||
return m_Locations[Utility.Random( m_Locations.Length )];
|
||||
|
||||
return Point2D.Zero;
|
||||
}
|
||||
|
||||
private static void LoadLocations()
|
||||
{
|
||||
string filePath = Path.Combine( Core.BaseDirectory, "Data/Config/treasure.cfg" );
|
||||
|
||||
List<Point2D> list = new List<Point2D>();
|
||||
|
||||
if ( File.Exists( filePath ) )
|
||||
{
|
||||
using ( StreamReader ip = new StreamReader( filePath ) )
|
||||
{
|
||||
string line;
|
||||
|
||||
while ( (line = ip.ReadLine()) != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] split = line.Split( ' ' );
|
||||
|
||||
int x = Convert.ToInt32( split[0] ), y = Convert.ToInt32( split[1] );
|
||||
|
||||
Point2D loc = new Point2D( x, y );
|
||||
list.Add( loc );
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_Locations = list.ToArray();
|
||||
}
|
||||
|
||||
public static BaseCreature Spawn( int level, Point3D p, bool guardian )
|
||||
{
|
||||
if ( level >= 0 && level < m_SpawnTypes.Length )
|
||||
{
|
||||
BaseCreature bc;
|
||||
|
||||
try
|
||||
{
|
||||
bc = (BaseCreature)Activator.CreateInstance( m_SpawnTypes[level][Utility.Random( m_SpawnTypes[level].Length )] );
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
bc.Home = p;
|
||||
bc.RangeHome = 5;
|
||||
|
||||
if ( guardian && level == 0 )
|
||||
{
|
||||
bc.Name = "a chest guardian";
|
||||
bc.Hue = 0x835;
|
||||
}
|
||||
|
||||
return bc;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BaseCreature Spawn( int level, Point3D p, Map map, Mobile target, bool guardian )
|
||||
{
|
||||
if ( map == null )
|
||||
return null;
|
||||
|
||||
BaseCreature c = Spawn( level, p, guardian );
|
||||
|
||||
if ( c != null )
|
||||
{
|
||||
bool spawned = false;
|
||||
|
||||
for ( int i = 0; !spawned && i < 10; ++i )
|
||||
{
|
||||
int x = p.X - 3 + Utility.Random( 7 );
|
||||
int y = p.Y - 3 + Utility.Random( 7 );
|
||||
|
||||
if ( map.CanSpawnMobile( x, y, p.Z ) )
|
||||
{
|
||||
c.MoveToWorld( new Point3D( x, y, p.Z ), map );
|
||||
spawned = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int z = map.GetAverageZ( x, y );
|
||||
|
||||
if ( map.CanSpawnMobile( x, y, z ) )
|
||||
{
|
||||
c.MoveToWorld( new Point3D( x, y, z ), map );
|
||||
spawned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !spawned )
|
||||
{
|
||||
c.Delete();
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
c.Combatant = target;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public TreasureMap( int level, Map map )
|
||||
{
|
||||
m_Level = level;
|
||||
m_Map = map;
|
||||
m_Location = GetRandomLocation();
|
||||
|
||||
Width = 300;
|
||||
Height = 300;
|
||||
|
||||
int width = 600;
|
||||
int height = 600;
|
||||
|
||||
int x1 = m_Location.X - Utility.RandomMinMax( width / 4, (width / 4) * 3 );
|
||||
int y1 = m_Location.Y - Utility.RandomMinMax( height / 4, (height / 4) * 3 );
|
||||
|
||||
if ( x1 < 0 )
|
||||
x1 = 0;
|
||||
|
||||
if ( y1 < 0 )
|
||||
y1 = 0;
|
||||
|
||||
int x2 = x1 + width;
|
||||
int y2 = y1 + height;
|
||||
|
||||
if ( x2 >= 5120 )
|
||||
x2 = 5119;
|
||||
|
||||
if ( y2 >= 4096 )
|
||||
y2 = 4095;
|
||||
|
||||
x1 = x2 - width;
|
||||
y1 = y2 - height;
|
||||
|
||||
Bounds = new Rectangle2D( x1, y1, width, height );
|
||||
Protected = true;
|
||||
|
||||
AddWorldPin( m_Location.X, m_Location.Y );
|
||||
}
|
||||
|
||||
public TreasureMap( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public static bool HasDiggingTool( Mobile m )
|
||||
{
|
||||
if ( m.Backpack == null )
|
||||
return false;
|
||||
|
||||
List<BaseHarvestTool> items = m.Backpack.FindItemsByType<BaseHarvestTool>();
|
||||
|
||||
foreach ( BaseHarvestTool tool in items )
|
||||
{
|
||||
if ( tool.HarvestSystem == Engines.Harvest.Mining.System )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnBeginDig( Mobile from )
|
||||
{
|
||||
if ( m_Completed )
|
||||
{
|
||||
from.SendLocalizedMessage( 503028 ); // The treasure for this map has already been found.
|
||||
}
|
||||
else if ( m_Decoder != from && !HasRequiredSkill( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 503031 ); // You did not decode this map and have no clue where to look for the treasure.
|
||||
}
|
||||
else if ( !from.CanBeginAction( typeof( TreasureMap ) ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 503020 ); // You are already digging treasure.
|
||||
}
|
||||
else if ( from.Map != this.m_Map )
|
||||
{
|
||||
from.SendLocalizedMessage( 1010479 ); // You seem to be in the right place, but may be on the wrong facet!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 503033 ); // Where do you wish to dig?
|
||||
from.Target = new DigTarget( this );
|
||||
}
|
||||
}
|
||||
|
||||
private class DigTarget : Target
|
||||
{
|
||||
private TreasureMap m_Map;
|
||||
|
||||
public DigTarget( TreasureMap map ) : base( 6, true, TargetFlags.None )
|
||||
{
|
||||
m_Map = map;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
if ( m_Map.Deleted )
|
||||
return;
|
||||
|
||||
Map map = m_Map.m_Map;
|
||||
|
||||
if ( m_Map.m_Completed )
|
||||
{
|
||||
from.SendLocalizedMessage( 503028 ); // The treasure for this map has already been found.
|
||||
}
|
||||
/*
|
||||
else if ( from != m_Map.m_Decoder )
|
||||
{
|
||||
from.SendLocalizedMessage( 503016 ); // Only the person who decoded this map may actually dig up the treasure.
|
||||
}
|
||||
*/
|
||||
else if ( m_Map.m_Decoder != from && !m_Map.HasRequiredSkill( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 503031 ); // You did not decode this map and have no clue where to look for the treasure.
|
||||
return;
|
||||
}
|
||||
else if ( !from.CanBeginAction( typeof( TreasureMap ) ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 503020 ); // You are already digging treasure.
|
||||
}
|
||||
else if ( !HasDiggingTool( from ) )
|
||||
{
|
||||
from.SendMessage( "You must have a digging tool to dig for treasure." );
|
||||
}
|
||||
else if ( from.Map != map )
|
||||
{
|
||||
from.SendLocalizedMessage( 1010479 ); // You seem to be in the right place, but may be on the wrong facet!
|
||||
}
|
||||
else
|
||||
{
|
||||
IPoint3D p = targeted as IPoint3D;
|
||||
|
||||
Point3D targ3D;
|
||||
if ( p is Item )
|
||||
targ3D = ((Item)p).GetWorldLocation();
|
||||
else
|
||||
targ3D = new Point3D( p );
|
||||
|
||||
int maxRange;
|
||||
double skillValue = Server.Misc.SkillCheck.TradeSkill( from, Trades.Mining, false );
|
||||
|
||||
if ( skillValue >= 100.0 )
|
||||
maxRange = 4;
|
||||
else if ( skillValue >= 81.0 )
|
||||
maxRange = 3;
|
||||
else if ( skillValue >= 51.0 )
|
||||
maxRange = 2;
|
||||
else
|
||||
maxRange = 1;
|
||||
|
||||
Point2D loc = m_Map.m_Location;
|
||||
int x = loc.X, y = loc.Y;
|
||||
|
||||
Point3D chest3D0 = new Point3D( loc, 0 );
|
||||
|
||||
if ( Utility.InRange( targ3D, chest3D0, maxRange ) )
|
||||
{
|
||||
if ( from.Location.X == x && from.Location.Y == y )
|
||||
{
|
||||
from.SendLocalizedMessage( 503030 ); // The chest can't be dug up because you are standing on top of it.
|
||||
}
|
||||
else if ( map != null )
|
||||
{
|
||||
int z = map.GetAverageZ( x, y );
|
||||
|
||||
if ( !map.CanFit( x, y, z, 16, true, true ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 503021 ); // You have found the treasure chest but something is keeping it from being dug up.
|
||||
}
|
||||
else if ( from.BeginAction( typeof( TreasureMap ) ) )
|
||||
{
|
||||
new DigTimer( from, m_Map, new Point3D( x, y, z ), map ).Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 503020 ); // You are already digging treasure.
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_Map.Level > 0 )
|
||||
{
|
||||
if ( Utility.InRange( targ3D, chest3D0, 8 ) ) // We're close, but not quite
|
||||
{
|
||||
from.SendLocalizedMessage( 503032 ); // You dig and dig but no treasure seems to be here.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 503035 ); // You dig and dig but fail to find any treasure.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Utility.InRange( targ3D, chest3D0, 8 ) ) // We're close, but not quite
|
||||
{
|
||||
from.SendAsciiMessage( 0x44, "The treasure chest is very close!" );
|
||||
}
|
||||
else
|
||||
{
|
||||
Direction dir = Utility.GetDirection( targ3D, chest3D0 );
|
||||
|
||||
string sDir;
|
||||
switch ( dir )
|
||||
{
|
||||
case Direction.North: sDir = "north"; break;
|
||||
case Direction.Right: sDir = "northeast"; break;
|
||||
case Direction.East: sDir = "east"; break;
|
||||
case Direction.Down: sDir = "southeast"; break;
|
||||
case Direction.South: sDir = "south"; break;
|
||||
case Direction.Left: sDir = "southwest"; break;
|
||||
case Direction.West: sDir = "west"; break;
|
||||
default: sDir = "northwest"; break;
|
||||
}
|
||||
|
||||
from.SendAsciiMessage( 0x44, "Try looking for the treasure chest more to the {0}.", sDir );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DigTimer : Timer
|
||||
{
|
||||
private Mobile m_From;
|
||||
private TreasureMap m_TreasureMap;
|
||||
|
||||
private Point3D m_Location;
|
||||
private Map m_Map;
|
||||
|
||||
private TreasureChestDirt m_Dirt1;
|
||||
private TreasureChestDirt m_Dirt2;
|
||||
private TreasureMapChest m_Chest;
|
||||
|
||||
private int m_Count;
|
||||
|
||||
private DateTime m_NextSkillTime;
|
||||
private DateTime m_NextSpellTime;
|
||||
private DateTime m_NextActionTime;
|
||||
private DateTime m_LastMoveTime;
|
||||
|
||||
public DigTimer( Mobile from, TreasureMap treasureMap, Point3D location, Map map ) : base( TimeSpan.Zero, TimeSpan.FromSeconds( 1.0 ) )
|
||||
{
|
||||
m_From = from;
|
||||
m_TreasureMap = treasureMap;
|
||||
|
||||
m_Location = location;
|
||||
m_Map = map;
|
||||
|
||||
m_NextSkillTime = from.NextSkillTime;
|
||||
m_NextSpellTime = from.NextSpellTime;
|
||||
m_NextActionTime = from.NextActionTime;
|
||||
m_LastMoveTime = from.LastMoveTime;
|
||||
|
||||
Priority = TimerPriority.TenMS;
|
||||
}
|
||||
|
||||
private void Terminate()
|
||||
{
|
||||
Stop();
|
||||
m_From.EndAction( typeof( TreasureMap ) );
|
||||
|
||||
if ( m_Chest != null )
|
||||
m_Chest.Delete();
|
||||
|
||||
if ( m_Dirt1 != null )
|
||||
{
|
||||
m_Dirt1.Delete();
|
||||
m_Dirt2.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if ( m_NextSkillTime != m_From.NextSkillTime || m_NextSpellTime != m_From.NextSpellTime || m_NextActionTime != m_From.NextActionTime )
|
||||
{
|
||||
Terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_LastMoveTime != m_From.LastMoveTime )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 503023 ); // You cannot move around while digging up treasure. You will need to start digging anew.
|
||||
Terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
int z = ( m_Chest != null ) ? m_Chest.Z + m_Chest.ItemData.Height : int.MinValue;
|
||||
int height = 16;
|
||||
|
||||
if ( z > m_Location.Z )
|
||||
height -= ( z - m_Location.Z );
|
||||
else
|
||||
z = m_Location.Z;
|
||||
|
||||
if ( !m_Map.CanFit( m_Location.X, m_Location.Y, z, height, true, true, false ) )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 503024 ); // You stop digging because something is directly on top of the treasure chest.
|
||||
Terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
m_Count++;
|
||||
|
||||
m_From.RevealingAction();
|
||||
m_From.Direction = m_From.GetDirectionTo( m_Location );
|
||||
|
||||
if ( m_Count > 1 && m_Dirt1 == null )
|
||||
{
|
||||
m_Dirt1 = new TreasureChestDirt();
|
||||
m_Dirt1.MoveToWorld( m_Location, m_Map );
|
||||
|
||||
m_Dirt2 = new TreasureChestDirt();
|
||||
m_Dirt2.MoveToWorld( new Point3D( m_Location.X, m_Location.Y - 1, m_Location.Z ), m_Map );
|
||||
}
|
||||
|
||||
if ( m_Count == 5 )
|
||||
{
|
||||
m_Dirt1.Turn1();
|
||||
}
|
||||
else if ( m_Count == 10 )
|
||||
{
|
||||
m_Dirt1.Turn2();
|
||||
m_Dirt2.Turn2();
|
||||
}
|
||||
else if ( m_Count > 10 )
|
||||
{
|
||||
if ( m_Chest == null )
|
||||
{
|
||||
m_Chest = new TreasureMapChest( m_From, m_TreasureMap.Level, true );
|
||||
m_Chest.MoveToWorld( new Point3D( m_Location.X, m_Location.Y, m_Location.Z - 15 ), m_Map );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Chest.Z++;
|
||||
}
|
||||
|
||||
Effects.PlaySound( m_Chest, m_Map, 0x33B );
|
||||
}
|
||||
|
||||
if ( m_Chest != null && m_Chest.Location.Z >= m_Location.Z )
|
||||
{
|
||||
Stop();
|
||||
m_From.EndAction( typeof( TreasureMap ) );
|
||||
|
||||
m_Chest.Temporary = false;
|
||||
m_TreasureMap.Completed = true;
|
||||
m_TreasureMap.CompletedBy = m_From;
|
||||
|
||||
int spawns;
|
||||
switch ( m_TreasureMap.Level )
|
||||
{
|
||||
case 0: spawns = 3; break;
|
||||
case 1: spawns = 0; break;
|
||||
default: spawns = 4; break;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < spawns; ++i )
|
||||
{
|
||||
BaseCreature bc = Spawn( m_TreasureMap.Level, m_Chest.Location, m_Chest.Map, null, true );
|
||||
|
||||
if ( bc != null )
|
||||
m_Chest.Guardians.Add( bc );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_From.Body.IsHuman && !m_From.Mounted )
|
||||
m_From.Animate( 11, 5, 1, true, false, 0 );
|
||||
|
||||
new SoundTimer( m_From, 0x125 + (m_Count % 2) ).Start();
|
||||
}
|
||||
}
|
||||
|
||||
private class SoundTimer : Timer
|
||||
{
|
||||
private Mobile m_From;
|
||||
private int m_SoundID;
|
||||
|
||||
public SoundTimer( Mobile from, int soundID ) : base( TimeSpan.FromSeconds( 0.9 ) )
|
||||
{
|
||||
m_From = from;
|
||||
m_SoundID = soundID;
|
||||
|
||||
Priority = TimerPriority.TenMS;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_From.PlaySound( m_SoundID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( !from.InRange( GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !m_Completed && m_Decoder == null )
|
||||
Decode( from );
|
||||
else
|
||||
DisplayTo( from );
|
||||
}
|
||||
|
||||
private double GetMinSkillLevel()
|
||||
{
|
||||
switch ( m_Level )
|
||||
{
|
||||
case 1: return -3.0;
|
||||
case 2: return 41.0;
|
||||
case 3: return 51.0;
|
||||
case 4: return 61.0;
|
||||
case 5: return 70.0;
|
||||
case 6: return 70.0;
|
||||
|
||||
default: return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasRequiredSkill( Mobile from )
|
||||
{
|
||||
return ( Server.Misc.SkillCheck.TradeSkill( from, Trades.Cartography, false ) >= GetMinSkillLevel() );
|
||||
}
|
||||
|
||||
public void Decode( Mobile from )
|
||||
{
|
||||
if ( m_Completed || m_Decoder != null )
|
||||
return;
|
||||
|
||||
double minSkill = GetMinSkillLevel();
|
||||
|
||||
if ( Server.Misc.SkillCheck.TradeSkill( from, Trades.Cartography, false ) < minSkill )
|
||||
from.SendLocalizedMessage( 503013 ); // The map is too difficult to attempt to decode.
|
||||
|
||||
double maxSkill = minSkill + 60.0;
|
||||
|
||||
if ( !Server.Misc.SkillCheck.TestTrade( from, Trades.Cartography, minSkill, maxSkill ) )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 503018 ); // You fail to make anything of the map.
|
||||
return;
|
||||
}
|
||||
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 503019 ); // You successfully decode a treasure map!
|
||||
Decoder = from;
|
||||
DisplayTo( from );
|
||||
}
|
||||
|
||||
public override void DisplayTo( Mobile from )
|
||||
{
|
||||
if ( m_Completed )
|
||||
{
|
||||
SendLocalizedMessageTo( from, 503014 ); // This treasure hunt has already been completed.
|
||||
}
|
||||
else if ( m_Decoder != from && !HasRequiredSkill( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 503031 ); // You did not decode this map and have no clue where to look for the treasure.
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendLocalizedMessageTo( from, 503017 ); // The treasure is marked by the red pin. Grab a shovel and go dig it up!
|
||||
}
|
||||
|
||||
from.PlaySound( 0x249 );
|
||||
base.DisplayTo( from );
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
base.GetContextMenuEntries( from, list );
|
||||
|
||||
if ( !m_Completed )
|
||||
{
|
||||
if ( m_Decoder == null )
|
||||
{
|
||||
list.Add( new DecodeMapEntry( this ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bool digTool = HasDiggingTool( from );
|
||||
|
||||
list.Add( new OpenMapEntry( this ) );
|
||||
list.Add( new DigEntry( this, digTool ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DecodeMapEntry : ContextMenuEntry
|
||||
{
|
||||
private TreasureMap m_Map;
|
||||
|
||||
public DecodeMapEntry( TreasureMap map ) : base( 6147, 2 )
|
||||
{
|
||||
m_Map = map;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( !m_Map.Deleted )
|
||||
m_Map.Decode( Owner.From );
|
||||
}
|
||||
}
|
||||
|
||||
private class OpenMapEntry : ContextMenuEntry
|
||||
{
|
||||
private TreasureMap m_Map;
|
||||
|
||||
public OpenMapEntry( TreasureMap map ) : base( 6150, 2 )
|
||||
{
|
||||
m_Map = map;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( !m_Map.Deleted )
|
||||
m_Map.DisplayTo( Owner.From );
|
||||
}
|
||||
}
|
||||
|
||||
private class DigEntry : ContextMenuEntry
|
||||
{
|
||||
private TreasureMap m_Map;
|
||||
|
||||
public DigEntry( TreasureMap map, bool enabled ) : base( 6148, 2 )
|
||||
{
|
||||
m_Map = map;
|
||||
|
||||
if ( !enabled )
|
||||
this.Flags |= CMEFlags.Disabled;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( m_Map.Deleted )
|
||||
return;
|
||||
|
||||
Mobile from = Owner.From;
|
||||
|
||||
if ( HasDiggingTool( from ) )
|
||||
m_Map.OnBeginDig( from );
|
||||
else
|
||||
from.SendMessage( "You must have a digging tool to dig for treasure." );
|
||||
}
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Decoder != null )
|
||||
{
|
||||
if ( m_Level == 6 )
|
||||
return 1063453;
|
||||
else
|
||||
return 1041516 + m_Level;
|
||||
}
|
||||
else if ( m_Level == 6 )
|
||||
return 1063452;
|
||||
else
|
||||
return 1041510 + m_Level;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
list.Add( 1041502 ); // for somewhere in Britannia
|
||||
|
||||
if ( m_Completed )
|
||||
{
|
||||
list.Add( 1041507, m_CompletedBy == null ? "someone" : m_CompletedBy.Name ); // completed by ~1_val~
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
if ( m_Completed )
|
||||
{
|
||||
from.Send( new MessageLocalizedAffix( Serial, ItemID, MessageType.Label, 0x3B2, 3, 1048030, "", AffixType.Append, String.Format( " completed by {0}", m_CompletedBy == null ? "someone" : m_CompletedBy.Name ), "" ) );
|
||||
}
|
||||
else if ( m_Decoder != null )
|
||||
{
|
||||
if ( m_Level == 6 )
|
||||
LabelTo( from, 1063453 );
|
||||
else
|
||||
LabelTo( from, 1041516 + m_Level );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Level == 6 )
|
||||
LabelTo( from, 1041522, String.Format( "#{0}\t \t#{1}", 1063452, m_Map == Map.Britannia ? 1041502 : 1041503 ) );
|
||||
else
|
||||
LabelTo( from, 1041522, String.Format( "#{0}\t \t#{1}", 1041510 + m_Level, m_Map == Map.Britannia ? 1041502 : 1041503 ) );
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 1 );
|
||||
|
||||
writer.Write( (Mobile) m_CompletedBy );
|
||||
|
||||
writer.Write( m_Level );
|
||||
writer.Write( m_Completed );
|
||||
writer.Write( m_Decoder );
|
||||
writer.Write( m_Map );
|
||||
writer.Write( m_Location );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_CompletedBy = reader.ReadMobile();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Level = (int)reader.ReadInt();
|
||||
m_Completed = reader.ReadBool();
|
||||
m_Decoder = reader.ReadMobile();
|
||||
m_Map = reader.ReadMap();
|
||||
m_Location = reader.ReadPoint2D();
|
||||
|
||||
if ( version == 0 && m_Completed )
|
||||
m_CompletedBy = m_Decoder;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TreasureChestDirt : Item
|
||||
{
|
||||
public TreasureChestDirt() : base( 0x912 )
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromMinutes( 2.0 ), new TimerCallback( Delete ) );
|
||||
}
|
||||
|
||||
public TreasureChestDirt( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public void Turn1()
|
||||
{
|
||||
this.ItemID = 0x913;
|
||||
}
|
||||
|
||||
public void Turn2()
|
||||
{
|
||||
this.ItemID = 0x914;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Scripts/Items/Maps/WorldMap.cs
Normal file
51
Scripts/Items/Maps/WorldMap.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class WorldMap : MapItem
|
||||
{
|
||||
[Constructable]
|
||||
public WorldMap()
|
||||
{
|
||||
SetDisplay( 0, 0, 5119, 4095, 400, 400 );
|
||||
}
|
||||
|
||||
public override void CraftInit( Mobile from )
|
||||
{
|
||||
// Unlike the others, world map is not based on crafted location
|
||||
|
||||
double skillValue = Server.Misc.SkillCheck.TradeSkill( from, Trades.Cartography, false );
|
||||
int x20 = (int)(skillValue * 20);
|
||||
int size = 25 + (int)(skillValue * 6.6);
|
||||
|
||||
if ( size < 200 )
|
||||
size = 200;
|
||||
else if ( size > 400 )
|
||||
size = 400;
|
||||
|
||||
SetDisplay( 1344 - x20, 1600 - x20, 1472 + x20, 1728 + x20, size, size );
|
||||
}
|
||||
|
||||
public override int LabelNumber{ get{ return 1015233; } } // world map
|
||||
|
||||
public WorldMap( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue