Overwrite

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,197 @@
using System;
using Server;
using Server.Regions;
using Server.Targeting;
using Server.Engines.CannedEvil;
using Server.Network;
using Server.Gumps;
using Server.Items;
using System.Linq;
namespace Server.Multis
{
public abstract class BaseBoatDeed : Item
{
[CommandProperty(AccessLevel.GameMaster)]
public int MultiID { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Offset { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Direction BoatDirection { get; set; }
public BaseBoatDeed(int id, Point3D offset)
: base(0x14F2)
{
Weight = 1.0;
if (!Core.AOS)
LootType = LootType.Newbied;
MultiID = id;
Offset = offset;
BoatDirection = Direction.North;
}
public BaseBoatDeed(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
writer.Write(MultiID);
writer.Write(Offset);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
MultiID = reader.ReadInt();
Offset = reader.ReadPoint3D();
break;
}
}
}
public override void OnDoubleClick(Mobile from)
{
BaseBoat boat = BaseBoat.FindBoatAt(from, from.Map);
if (from.AccessLevel < AccessLevel.GameMaster && (from.Map == Map.Ilshenar || from.Map == Map.Malas))
{
from.SendLocalizedMessage(1010567, null, 0x25); // You may not place a boat from this location.
}
else if (Core.HS && BaseBoat.HasBoat(from) && !Boat.IsRowBoat)
{
from.SendLocalizedMessage(1116758); // You already have a ship deployed!
}
else if (from.Region.IsPartOf(typeof(HouseRegion)) || boat != null && (boat.GetType() == Boat.GetType() || !boat.IsRowBoat && !(this is RowBoatDeed)))
{
from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house.
}
else if (!from.HasGump(typeof(BoatPlacementGump)))
{
if (Core.SE)
from.SendLocalizedMessage(502482); // Where do you wish to place the ship?
else
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502482); // Where do you wish to place the ship?
from.SendGump(new BoatPlacementGump(this, from));
}
}
public abstract BaseBoat Boat { get; }
public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
{
if (Deleted)
{
return;
}
else
{
Map map = from.Map;
if (map == null)
return;
if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
{
from.SendLocalizedMessage(1043284); // A ship can not be created here.
return;
}
BaseBoat b = BaseBoat.FindBoatAt(from, from.Map);
if (from.Region.IsPartOf(typeof(HouseRegion)) || b != null && (b.GetType() == Boat.GetType() || !b.IsRowBoat && !(this is RowBoatDeed)))
{
from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house.
return;
}
BoatDirection = d;
BaseBoat boat = Boat;
if (boat == null)
return;
p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, itemID))
{
if (boat.IsRowBoat)
{
BaseBoat lastrowboat = World.Items.Values.OfType<BaseBoat>().Where(x => x.Owner == from && x.IsRowBoat && x.Map != Map.Internal && !x.GetMobilesOnBoard().Any()).OrderByDescending(y => y.Serial).FirstOrDefault();
if (lastrowboat != null)
lastrowboat.Delete();
}
else
{
Delete();
}
boat.Owner = from;
boat.ItemID = itemID;
if (boat is BaseGalleon)
{
((BaseGalleon)boat).SecurityEntry = new SecurityEntry((BaseGalleon)boat);
((BaseGalleon)boat).BaseBoatHue = RandomBasePaintHue();
}
if (boat.IsClassicBoat)
{
uint keyValue = boat.CreateKeys(from);
if (boat.PPlank != null)
boat.PPlank.KeyValue = keyValue;
if (boat.SPlank != null)
boat.SPlank.KeyValue = keyValue;
}
boat.MoveToWorld(p, map);
boat.OnAfterPlacement(true);
var addon = LighthouseAddon.GetLighthouse(from);
if (addon != null)
{
if (boat.CanLinkToLighthouse)
from.SendLocalizedMessage(1154592); // You have linked your boat lighthouse.
else
from.SendLocalizedMessage(1154597); // Failed to link to lighthouse.
}
}
else
{
boat.Delete();
from.SendLocalizedMessage(1043284); // A ship can not be created here.
}
}
}
private int RandomBasePaintHue()
{
if (0.6 > Utility.RandomDouble())
{
return Utility.RandomMinMax(1701, 1754);
}
return Utility.RandomMinMax(1801, 1908);
}
}
}

View File

@@ -0,0 +1,210 @@
using System;
using Server;
using Server.Gumps;
using Server.Items;
namespace Server.Multis
{
public abstract class BaseDockedBoat : Item
{
[CommandProperty(AccessLevel.GameMaster)]
public int MultiID { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Offset { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string ShipName
{
get
{
if (BoatItem == null || BoatItem.ShipName == null || BoatItem.ShipName.Trim().Length == 0)
return "Unnamed Ship";
return BoatItem.ShipName;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public Direction BoatDirection { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public BaseBoat BoatItem { get; set; }
public BaseDockedBoat(int id, Point3D offset, BaseBoat boat)
: base(0x14F4)
{
Weight = 1.0;
LootType = LootType.Blessed;
MultiID = id;
Offset = offset;
BoatDirection = Direction.North;
BoatItem = boat;
Hue = boat.Hue;
}
public override void OnAfterDelete()
{
base.OnAfterDelete();
if (BoatItem != null && !BoatItem.Deleted)
BoatItem.Delete();
}
public BaseDockedBoat(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)6); // version
writer.Write(MultiID);
writer.Write(Offset);
writer.Write(BoatItem);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 6:
{
MultiID = reader.ReadInt();
Offset = reader.ReadPoint3D();
BoatItem = reader.ReadItem() as BaseBoat;
break;
}
case 5:
{
MultiID = reader.ReadInt();
Offset = reader.ReadPoint3D();
reader.ReadString();
BoatItem = reader.ReadItem() as BaseBoat;
break;
}
}
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (Core.HS && BaseBoat.HasBoat(from))
{
from.SendLocalizedMessage(1116758); //You already have a ship deployed!
}
else if (!from.HasGump(typeof(BoatPlacementGump)))
{
from.SendLocalizedMessage(502482); // Where do you wish to place the ship?
from.SendGump(new BoatPlacementGump(this, from));
}
}
public abstract BaseBoat Boat { get; }
public override void AddNameProperty(ObjectPropertyList list)
{
list.Add(1041644, ShipName); //The ~1_VAL~ (Dry Docked)
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(LabelNumber);
}
public override void OnSingleClick(Mobile from)
{
if (ShipName != null)
LabelTo(from, ShipName);
else
base.OnSingleClick(from);
}
public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
{
if (Deleted)
{
return;
}
else if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else
{
Map map = from.Map;
if (map == null)
return;
BoatDirection = d;
BaseBoat boat = BoatItem;
if (boat == null || boat.Deleted)
boat = Boat;
if (boat == null)
return;
Mobile oldOwner = boat.Owner;
boat.BoatItem = this;
boat.Owner = from;
if (oldOwner != from && boat is BaseGalleon)
((BaseGalleon)boat).SecurityEntry = new SecurityEntry((BaseGalleon)boat);
p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, itemID) && map != Map.Ilshenar && map != Map.Malas)
{
boat.SetFacing(d);
boat.MoveToWorld(p, map);
boat.OnPlacement(from);
boat.Refresh();
boat.OnAfterPlacement(false);
var addon = LighthouseAddon.GetLighthouse(from);
if (addon != null)
{
if (boat.CanLinkToLighthouse)
from.SendLocalizedMessage(1154592); // You have linked your boat lighthouse.
else
from.SendLocalizedMessage(1154597); // Failed to link to lighthouse.
}
if (boat.IsClassicBoat)
{
uint keyValue = boat.CreateKeys(from);
if (boat.PPlank != null)
boat.PPlank.KeyValue = keyValue;
if (boat.SPlank != null)
boat.SPlank.KeyValue = keyValue;
}
Internalize();
}
else
{
from.SendLocalizedMessage(1043284); // A ship can not be created here.
}
}
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
namespace Server.Multis
{
public class ConfirmDryDockGump : Gump
{
private Mobile m_From;
private Mobile m_Dockmaster;
private BaseBoat m_Boat;
public ConfirmDryDockGump( Mobile from, BaseBoat boat, Mobile dockmaster ) : base( 150, 200 )
{
m_From = from;
m_Dockmaster = dockmaster;
m_Boat = boat;
m_From.CloseGump( typeof( ConfirmDryDockGump ) );
AddPage( 0 );
AddBackground( 0, 0, 220, 170, 5054 );
AddBackground( 10, 10, 200, 150, 3000 );
bool needsWarning = boat is BaseGalleon && ((BaseGalleon)boat).HasPaint;
//if (needsWarning)
// AddHtml(20, 20, 180, 80, "Do you wish to dry dock this boat?<br>WARNING: You will lose any non-permanent boat paint applied to your galleon.", true, true);
//else
AddHtmlLocalized(20, 20, 180, 80, 1018319, true, needsWarning); // Do you wish to dry dock this boat?
AddHtmlLocalized( 55, 100, 140, 25, 1011011, false, false ); // CONTINUE
AddButton( 20, 100, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 125, 140, 25, 1011012, false, false ); // CANCEL
AddButton( 20, 125, 4005, 4007, 1, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID == 2 )
m_Boat.EndDryDock( m_From, m_Dockmaster );
}
}
}

View File

@@ -0,0 +1,123 @@
using System;
using Server;
using Server.Multis;
using Server.Network;
namespace Server.Items
{
public class Hold : Container
{
public override int LabelNumber { get { return 1149699; } } // cargo hold
[CommandProperty(AccessLevel.GameMaster)]
public BaseBoat Boat { get; private set; }
public override int DefaultMaxWeight { get { return 400; } }
public Hold(BaseBoat boat) : base(0x3EAE)
{
Boat = boat;
Movable = false;
}
public Hold(Serial serial) : base(serial)
{
}
public virtual void SetFacing(Direction dir)
{
switch (dir)
{
case Direction.East: ItemID = 0x3E65; break;
case Direction.West: ItemID = 0x3E93; break;
case Direction.North: ItemID = 0x3EAE; break;
case Direction.South: ItemID = 0x3EB9; break;
}
}
public override bool OnDragDrop(Mobile from, Item item)
{
if (Boat == null || !Boat.Contains(from) || Boat.IsMoving)
return false;
return base.OnDragDrop(from, item);
}
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if (Boat == null || !Boat.Contains(from) || Boat.IsMoving)
return false;
return base.OnDragDropInto(from, item, p);
}
public override bool CheckItemUse(Mobile from, Item item)
{
if (item != this && (Boat == null || !Boat.Contains(from) || Boat.IsMoving))
return false;
return base.CheckItemUse(from, item);
}
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
{
if (Boat == null || !Boat.Contains(from) || Boat.IsMoving)
return false;
return base.CheckLift(from, item, ref reject);
}
public override void OnAfterDelete()
{
if (Boat != null)
Boat.Delete();
}
public override void OnDoubleClick(Mobile from)
{
if (Boat == null || !Boat.Contains(from))
{
if (Boat.TillerMan != null)
Boat.TillerManSay(502490); // You must be on the ship to open the hold.
}
else if (Boat.IsMoving && Boat.IsClassicBoat)
{
if (Boat.TillerMan != null)
Boat.TillerManSay(502491); // I can not open the hold while the ship is moving.
}
else
base.OnDoubleClick(from);
}
public override bool IsDecoContainer { get { return false; } }
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(Boat);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Boat = reader.ReadItem() as BaseBoat;
if (Boat == null || Parent != null)
Delete();
Movable = false;
break;
}
}
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using Server;
using Server.Items;
namespace Server.Multis
{
public class LargeBoat : BaseBoat
{
public override int NorthID{ get{ return 0x10; } }
public override int EastID{ get{ return 0x11; } }
public override int SouthID{ get{ return 0x12; } }
public override int WestID{ get{ return 0x13; } }
public override int HoldDistance{ get{ return 5; } }
public override int TillerManDistance{ get{ return -5; } }
public override Point2D StarboardOffset{ get{ return new Point2D( 2, -1 ); } }
public override Point2D PortOffset{ get{ return new Point2D( -2, -1 ); } }
public override Point3D MarkOffset{ get{ return new Point3D( 0, 0, 3 ); } }
public override BaseDockedBoat DockedBoat{ get{ return new LargeDockedBoat( this ); } }
[Constructable]
public LargeBoat(Direction d) : base(d, true)
{
}
public LargeBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class LargeBoatDeed : BaseBoatDeed
{
public override int LabelNumber{ get{ return 1041209; } } // large ship deed
public override BaseBoat Boat { get { return new LargeBoat(this.BoatDirection); } }
[Constructable]
public LargeBoatDeed() : base( 0x10, new Point3D( 0, -1, 0 ) )
{
}
public LargeBoatDeed( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class LargeDockedBoat : BaseDockedBoat
{
public override int LabelNumber { get { return 1116745; } } //Large Ship
public override BaseBoat Boat { get { return new LargeBoat(this.BoatDirection); } }
public LargeDockedBoat( BaseBoat boat ) : base( 0x10, new Point3D( 0, -1, 0 ), boat )
{
}
public LargeDockedBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using Server;
using Server.Items;
namespace Server.Multis
{
public class LargeDragonBoat : BaseBoat
{
public override int NorthID{ get{ return 0x14; } }
public override int EastID{ get{ return 0x15; } }
public override int SouthID{ get{ return 0x16; } }
public override int WestID{ get{ return 0x17; } }
public override int HoldDistance{ get{ return 5; } }
public override int TillerManDistance{ get{ return -5; } }
public override Point2D StarboardOffset{ get{ return new Point2D( 2, -1 ); } }
public override Point2D PortOffset{ get{ return new Point2D( -2, -1 ); } }
public override Point3D MarkOffset{ get{ return new Point3D( 0, 0, 3 ); } }
public override BaseDockedBoat DockedBoat{ get{ return new LargeDockedDragonBoat( this ); } }
[Constructable]
public LargeDragonBoat(Direction d) : base(d, true)
{
}
public LargeDragonBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class LargeDragonBoatDeed : BaseBoatDeed
{
public override int LabelNumber{ get{ return 1041210; } }// large dragon ship deed
public override BaseBoat Boat { get { return new LargeDragonBoat(this.BoatDirection); } }
[Constructable]
public LargeDragonBoatDeed() : base( 0x14, new Point3D( 0, -1, 0 ) )
{
}
public LargeDragonBoatDeed( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class LargeDockedDragonBoat : BaseDockedBoat
{
public override int LabelNumber { get { return 1116746; } } //Large Dragon Ship
public override BaseBoat Boat{ get{ return new LargeDragonBoat(this.BoatDirection); } }
public LargeDockedDragonBoat( BaseBoat boat ) : base( 0x14, new Point3D( 0, -1, 0 ), boat )
{
}
public LargeDockedDragonBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using Server;
using Server.Items;
namespace Server.Multis
{
public class MediumBoat : BaseBoat
{
public override int NorthID{ get{ return 0x8; } }
public override int EastID{ get{ return 0x9; } }
public override int SouthID{ get{ return 0xA; } }
public override int WestID{ get{ return 0xB; } }
public override int HoldDistance{ get{ return 4; } }
public override int TillerManDistance{ get{ return -5; } }
public override Point2D StarboardOffset{ get{ return new Point2D( 2, 0 ); } }
public override Point2D PortOffset{ get{ return new Point2D( -2, 0 ); } }
public override Point3D MarkOffset{ get{ return new Point3D( 0, 1, 3 ); } }
public override BaseDockedBoat DockedBoat{ get{ return new MediumDockedBoat( this ); } }
[Constructable]
public MediumBoat(Direction d) : base(d, true)
{
}
public MediumBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class MediumBoatDeed : BaseBoatDeed
{
public override int LabelNumber{ get{ return 1041207; } } // medium ship deed
public override BaseBoat Boat { get { return new MediumBoat(this.BoatDirection); } }
[Constructable]
public MediumBoatDeed() : base( 0x8, Point3D.Zero )
{
}
public MediumBoatDeed( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class MediumDockedBoat : BaseDockedBoat
{
public override int LabelNumber { get { return 1116743; } } //Medium Ship
public override BaseBoat Boat { get { return new MediumBoat(this.BoatDirection); } }
public MediumDockedBoat( BaseBoat boat ) : base( 0x8, Point3D.Zero, boat )
{
}
public MediumDockedBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using Server;
using Server.Items;
namespace Server.Multis
{
public class MediumDragonBoat : BaseBoat
{
public override int NorthID{ get{ return 0xC; } }
public override int EastID{ get{ return 0xD; } }
public override int SouthID{ get{ return 0xE; } }
public override int WestID{ get{ return 0xF; } }
public override int HoldDistance{ get{ return 4; } }
public override int TillerManDistance{ get{ return -5; } }
public override Point2D StarboardOffset{ get{ return new Point2D( 2, 0 ); } }
public override Point2D PortOffset{ get{ return new Point2D( -2, 0 ); } }
public override Point3D MarkOffset{ get{ return new Point3D( 0, 1, 3 ); } }
public override BaseDockedBoat DockedBoat{ get{ return new MediumDockedDragonBoat( this ); } }
[Constructable]
public MediumDragonBoat(Direction d) : base(d, true)
{
}
public MediumDragonBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class MediumDragonBoatDeed : BaseBoatDeed
{
public override int LabelNumber{ get{ return 1041208; } } // medium dragon ship deed
public override BaseBoat Boat { get { return new MediumDragonBoat(this.BoatDirection); } }
[Constructable]
public MediumDragonBoatDeed() : base( 0xC, Point3D.Zero )
{
}
public MediumDragonBoatDeed( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class MediumDockedDragonBoat : BaseDockedBoat
{
public override int LabelNumber { get { return 1116744; } } //Medium Dragon Ship
public override BaseBoat Boat { get { return new MediumDragonBoat(this.BoatDirection); } }
public MediumDockedDragonBoat( BaseBoat boat ) : base( 0xC, Point3D.Zero, boat )
{
}
public MediumDockedDragonBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
}

View File

@@ -0,0 +1,353 @@
using System;
using System.Collections.Generic;
using Server;
using Server.Multis;
using Server.ContextMenus;
using Server.Mobiles;
namespace Server.Items
{
public enum PlankSide { Port, Starboard }
public class Plank : Item, ILockable
{
private Timer m_CloseTimer;
public Plank(BaseBoat boat, PlankSide side, uint keyValue)
: base(0x3EB1 + (int)side)
{
Boat = boat;
Side = side;
KeyValue = keyValue;
Locked = true;
Movable = false;
}
public Plank(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);//version
writer.Write(Boat);
writer.Write((int)Side);
writer.Write(Locked);
writer.Write(KeyValue);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Boat = reader.ReadItem() as BaseBoat;
Side = (PlankSide)reader.ReadInt();
Locked = reader.ReadBool();
KeyValue = reader.ReadUInt();
if (Boat == null)
Delete();
break;
}
}
if (IsOpen)
{
m_CloseTimer = new CloseTimer(this);
m_CloseTimer.Start();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public BaseBoat Boat { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public PlankSide Side { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool Locked { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public uint KeyValue { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsOpen { get { return ItemID == 0x3ED5 || ItemID == 0x3ED4 || ItemID == 0x3E84 || ItemID == 0x3E89; } }
[CommandProperty(AccessLevel.GameMaster)]
public bool Starboard { get { return Side == PlankSide.Starboard; } }
public void SetFacing(Direction dir)
{
if (IsOpen)
{
switch (dir)
{
case Direction.North: ItemID = Starboard ? 0x3ED4 : 0x3ED5; break;
case Direction.East: ItemID = Starboard ? 0x3E84 : 0x3E89; break;
case Direction.South: ItemID = Starboard ? 0x3ED5 : 0x3ED4; break;
case Direction.West: ItemID = Starboard ? 0x3E89 : 0x3E84; break;
}
}
else
{
switch (dir)
{
case Direction.North: ItemID = Starboard ? 0x3EB2 : 0x3EB1; break;
case Direction.East: ItemID = Starboard ? 0x3E85 : 0x3E8A; break;
case Direction.South: ItemID = Starboard ? 0x3EB1 : 0x3EB2; break;
case Direction.West: ItemID = Starboard ? 0x3E8A : 0x3E85; break;
}
}
}
public void Open()
{
if (IsOpen || Deleted)
return;
if (m_CloseTimer != null)
m_CloseTimer.Stop();
if (Locked)
{
m_CloseTimer = new CloseTimer(this);
m_CloseTimer.Start();
}
switch (ItemID)
{
case 0x3EB1: ItemID = 0x3ED5; break;
case 0x3E8A: ItemID = 0x3E89; break;
case 0x3EB2: ItemID = 0x3ED4; break;
case 0x3E85: ItemID = 0x3E84; break;
}
}
public override bool OnMoveOver(Mobile from)
{
if (IsOpen)
{
if (from.Player && Boat != null && !Boat.Contains(from) && Locked) // If the plank is locked, no one can enter the ship from the outside.
return false;
if ((from.Player && (from.Direction & Direction.Running) != 0) || (Boat != null && !Boat.Contains(from)))
return true;
Map map = Map;
if (map == null)
return false;
int rx = 0, ry = 0;
if (ItemID == 0x3ED4)
rx = 1;
else if (ItemID == 0x3ED5)
rx = -1;
else if (ItemID == 0x3E84)
ry = 1;
else if (ItemID == 0x3E89)
ry = -1;
for (int i = 1; i <= 6; ++i)
{
int x = X + (i * rx);
int y = Y + (i * ry);
int z;
for (int j = -8; j <= 8; ++j)
{
z = from.Z + j;
if (map.CanFit(x, y, z, 16, false, false) && !Spells.SpellHelper.CheckMulti(new Point3D(x, y, z), map) && !Region.Find(new Point3D(x, y, z), map).IsPartOf(typeof(Factions.StrongholdRegion)))
{
if (i == 1 && j >= -2 && j <= 2)
return true;
from.Location = new Point3D(x, y, z);
return false;
}
}
z = map.GetAverageZ(x, y);
if (map.CanFit(x, y, z, 16, false, false) && !Spells.SpellHelper.CheckMulti(new Point3D(x, y, z), map) && !Region.Find(new Point3D(x, y, z), map).IsPartOf(typeof(Factions.StrongholdRegion)))
{
if (i == 1)
return true;
from.Location = new Point3D(x, y, z);
return false;
}
}
return true;
}
else
{
return false;
}
}
public bool CanClose()
{
Map map = Map;
if (map == null || Deleted)
return false;
IPooledEnumerable eable = GetObjectsInRange(0);
foreach (object o in eable)
{
if (o != this)
{
eable.Free();
return false;
}
}
eable.Free();
return true;
}
public void Close()
{
if (!IsOpen || !CanClose() || Deleted)
return;
if (m_CloseTimer != null)
m_CloseTimer.Stop();
m_CloseTimer = null;
switch (ItemID)
{
case 0x3ED5: ItemID = 0x3EB1; break;
case 0x3E89: ItemID = 0x3E8A; break;
case 0x3ED4: ItemID = 0x3EB2; break;
case 0x3E84: ItemID = 0x3E85; break;
}
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (!from.Alive && Boat.Contains(from))
{
list.Add(new PlanksContext(from, this));
}
}
public class PlanksContext : ContextMenuEntry
{
private Plank m_Plank;
private Mobile m_From;
public PlanksContext(Mobile from, Plank plank) : base(6132, 10)
{
m_Plank = plank;
m_From = from;
}
public override void OnClick()
{
m_Plank.OnDoubleClick(m_From);
}
}
public override void OnDoubleClickDead(Mobile from)
{
OnDoubleClick(from);
}
public override void OnDoubleClick(Mobile from)
{
if (Boat == null)
return;
Boat.Refresh();
if (BaseBoat.IsDriving(from))
{
from.SendLocalizedMessage(1116610); // You can't do that while piloting a ship!
return;
}
if (from.InRange(GetWorldLocation(), 8))
{
if (Boat.Contains(from))
{
if (IsOpen)
Close();
else
Open();
}
else
{
if (!IsOpen)
{
if (!Locked)
{
Open();
}
else if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.LocalOverheadMessage(Network.MessageType.Regular, 0x00, 502502); // That is locked but your godly powers allow access
Open();
}
else
{
from.LocalOverheadMessage(Network.MessageType.Regular, 0x00, 502503); // That is locked.
}
}
else if (!Locked)
{
Point3D p = new Point3D(X, Y, Z + 3);
BaseCreature.TeleportPets(from, p, Map);
from.Location = p;
}
else if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.LocalOverheadMessage(Network.MessageType.Regular, 0x00, 502502); // That is locked but your godly powers allow access
Point3D p = new Point3D(X, Y, Z + 3);
BaseCreature.TeleportPets(from, p, Map);
from.Location = p;
}
else
{
from.LocalOverheadMessage(Network.MessageType.Regular, 0x00, 502503); // That is locked.
}
}
}
}
private class CloseTimer : Timer
{
private Plank m_Plank;
public CloseTimer(Plank plank)
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0))
{
m_Plank = plank;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
m_Plank.Close();
}
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using Server;
using Server.Prompts;
namespace Server.Multis
{
public class RenameBoatPrompt : Prompt
{
public override int MessageCliloc { get { return 502580; } }
private BaseBoat m_Boat;
public RenameBoatPrompt( BaseBoat boat )
{
m_Boat = boat;
}
public override void OnResponse( Mobile from, string text )
{
m_Boat.EndRename( from, text );
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using Server;
using Server.Items;
namespace Server.Multis
{
public class SmallBoat : BaseBoat
{
public override int NorthID{ get{ return 0x0; } }
public override int EastID{ get{ return 0x1; } }
public override int SouthID{ get{ return 0x2; } }
public override int WestID{ get{ return 0x3; } }
public override int HoldDistance{ get{ return 4; } }
public override int TillerManDistance{ get{ return -4; } }
public override Point2D StarboardOffset{ get{ return new Point2D( 2, 0 ); } }
public override Point2D PortOffset{ get{ return new Point2D( -2, 0 ); } }
public override Point3D MarkOffset{ get{ return new Point3D( 0, 1, 3 ); } }
public override BaseDockedBoat DockedBoat{ get{ return new SmallDockedBoat( this ); } }
[Constructable]
public SmallBoat(Direction d) : base(d, true)
{
}
public SmallBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class SmallBoatDeed : BaseBoatDeed
{
public override int LabelNumber{ get{ return 1041205; } } // small ship deed
public override BaseBoat Boat { get { return new SmallBoat(this.BoatDirection); } }
[Constructable]
public SmallBoatDeed() : base( 0x0, Point3D.Zero )
{
}
public SmallBoatDeed( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class SmallDockedBoat : BaseDockedBoat
{
public override int LabelNumber { get { return 1116741; } } //Small Ship
public override BaseBoat Boat { get { return new SmallBoat(this.BoatDirection); } }
public SmallDockedBoat( BaseBoat boat ) : base( 0x0, Point3D.Zero, boat )
{
}
public SmallDockedBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using Server;
using Server.Items;
namespace Server.Multis
{
public class SmallDragonBoat : BaseBoat
{
public override int NorthID{ get{ return 0x4; } }
public override int EastID{ get{ return 0x5; } }
public override int SouthID{ get{ return 0x6; } }
public override int WestID{ get{ return 0x7; } }
public override int HoldDistance{ get{ return 4; } }
public override int TillerManDistance{ get{ return -4; } }
public override Point2D StarboardOffset{ get{ return new Point2D( 2, 0 ); } }
public override Point2D PortOffset{ get{ return new Point2D( -2, 0 ); } }
public override Point3D MarkOffset{ get{ return new Point3D( 0, 1, 3 ); } }
public override BaseDockedBoat DockedBoat{ get{ return new SmallDockedDragonBoat( this ); } }
[Constructable]
public SmallDragonBoat(Direction d) : base(d, true)
{
}
public SmallDragonBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class SmallDragonBoatDeed : BaseBoatDeed
{
public override int LabelNumber{ get{ return 1041206; } } // small dragon ship deed
public override BaseBoat Boat { get { return new SmallDragonBoat(this.BoatDirection); } }
[Constructable]
public SmallDragonBoatDeed() : base( 0x4, Point3D.Zero )
{
}
public SmallDragonBoatDeed( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
public class SmallDockedDragonBoat : BaseDockedBoat
{
public override int LabelNumber { get { return 1116742; } } //Small Dragon Ship
public override BaseBoat Boat { get { return new SmallDragonBoat(this.BoatDirection); } }
public SmallDockedDragonBoat( BaseBoat boat ) : base( 0x4, Point3D.Zero, boat )
{
}
public SmallDockedDragonBoat( Serial serial ) : base( serial )
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );
}
}
}

View File

@@ -0,0 +1,193 @@
using System;
using System.IO;
using Server;
using Server.Multis;
namespace Server.Misc
{
public class Strandedness
{
private static Point2D[] m_Felucca = new Point2D[]
{
new Point2D( 2528, 3568 ), new Point2D( 2376, 3400 ), new Point2D( 2528, 3896 ),
new Point2D( 2168, 3904 ), new Point2D( 1136, 3416 ), new Point2D( 1432, 3648 ),
new Point2D( 1416, 4000 ), new Point2D( 4512, 3936 ), new Point2D( 4440, 3120 ),
new Point2D( 4192, 3672 ), new Point2D( 4720, 3472 ), new Point2D( 3744, 2768 ),
new Point2D( 3480, 2432 ), new Point2D( 3560, 2136 ), new Point2D( 3792, 2112 ),
new Point2D( 2800, 2296 ), new Point2D( 2736, 2016 ), new Point2D( 4576, 1456 ),
new Point2D( 4680, 1152 ), new Point2D( 4304, 1104 ), new Point2D( 4496, 984 ),
new Point2D( 4248, 696 ), new Point2D( 4040, 616 ), new Point2D( 3896, 248 ),
new Point2D( 4176, 384 ), new Point2D( 3672, 1104 ), new Point2D( 3520, 1152 ),
new Point2D( 3720, 1360 ), new Point2D( 2184, 2152 ), new Point2D( 1952, 2088 ),
new Point2D( 2056, 1936 ), new Point2D( 1720, 1992 ), new Point2D( 472, 2064 ),
new Point2D( 656, 2096 ), new Point2D( 3008, 3592 ), new Point2D( 2784, 3472 ),
new Point2D( 5456, 2400 ), new Point2D( 5976, 2424 ), new Point2D( 5328, 3112 ),
new Point2D( 5792, 3152 ), new Point2D( 2120, 3616 ), new Point2D( 2136, 3128 ),
new Point2D( 1632, 3528 ), new Point2D( 1328, 3160 ), new Point2D( 1072, 3136 ),
new Point2D( 1128, 2976 ), new Point2D( 960, 2576 ), new Point2D( 752, 1832 ),
new Point2D( 184, 1488 ), new Point2D( 592, 1440 ), new Point2D( 368, 1216 ),
new Point2D( 232, 752 ), new Point2D( 696, 744 ), new Point2D( 304, 1000 ),
new Point2D( 840, 376 ), new Point2D( 1192, 624 ), new Point2D( 1200, 192 ),
new Point2D( 1512, 240 ), new Point2D( 1336, 456 ), new Point2D( 1536, 648 ),
new Point2D( 1104, 952 ), new Point2D( 1864, 264 ), new Point2D( 2136, 200 ),
new Point2D( 2160, 528 ), new Point2D( 1904, 512 ), new Point2D( 2240, 784 ),
new Point2D( 2536, 776 ), new Point2D( 2488, 216 ), new Point2D( 2336, 72 ),
new Point2D( 2648, 288 ), new Point2D( 2680, 576 ), new Point2D( 2896, 88 ),
new Point2D( 2840, 344 ), new Point2D( 3136, 72 ), new Point2D( 2968, 520 ),
new Point2D( 3192, 328 ), new Point2D( 3448, 208 ), new Point2D( 3432, 608 ),
new Point2D( 3184, 752 ), new Point2D( 2800, 704 ), new Point2D( 2768, 1016 ),
new Point2D( 2448, 1232 ), new Point2D( 2272, 920 ), new Point2D( 2072, 1080 ),
new Point2D( 2048, 1264 ), new Point2D( 1808, 1528 ), new Point2D( 1496, 1880 ),
new Point2D( 1656, 2168 ), new Point2D( 2096, 2320 ), new Point2D( 1816, 2528 ),
new Point2D( 1840, 2640 ), new Point2D( 1928, 2952 ), new Point2D( 2120, 2712 ),
new Point2D( 4551, 2345 )
};
private static Point2D[] m_Trammel = m_Felucca;
private static Point2D[] m_Ilshenar = new Point2D[]
{
new Point2D( 1252, 1180 ), new Point2D( 1562, 1090 ), new Point2D( 1444, 1016 ),
new Point2D( 1324, 968 ), new Point2D( 1418, 806 ), new Point2D( 1722, 874 ),
new Point2D( 1456, 684 ), new Point2D( 1036, 866 ), new Point2D( 612, 476 ),
new Point2D( 1476, 372 ), new Point2D( 762, 472 ), new Point2D( 812, 1162 ),
new Point2D( 1422, 1144 ), new Point2D( 1254, 1066 ), new Point2D( 1598, 870 ),
new Point2D( 1358, 866 ), new Point2D( 510, 302 ), new Point2D( 510, 392 )
};
private static Point2D[] m_Tokuno = new Point2D[]
{
//Makoto-Jima
new Point2D( 837, 1351 ), new Point2D( 941, 1241 ), new Point2D( 959, 1185 ),
new Point2D( 923, 1091 ), new Point2D( 904, 983 ), new Point2D( 845, 944 ),
new Point2D( 829, 896 ), new Point2D( 794, 852 ), new Point2D( 766, 821 ),
new Point2D( 695, 814 ), new Point2D( 576, 835 ), new Point2D( 518, 840 ),
new Point2D( 519, 902 ), new Point2D( 502, 950 ), new Point2D( 503, 1045 ),
new Point2D( 547, 1131 ), new Point2D( 518, 1204 ), new Point2D( 506, 1243 ),
new Point2D( 526, 1271 ), new Point2D( 562, 1295 ), new Point2D( 616, 1335 ),
new Point2D( 789, 1347 ), new Point2D( 712, 1359 ),
//Homare-Jima
new Point2D( 202, 498 ), new Point2D( 116, 600 ), new Point2D( 107, 699 ),
new Point2D( 162, 799 ), new Point2D( 158, 889 ), new Point2D( 169, 989 ),
new Point2D( 194, 1101 ), new Point2D( 250, 1163 ), new Point2D( 295, 1176 ),
new Point2D( 280, 1194 ), new Point2D( 286, 1102 ), new Point2D( 250, 1000 ),
new Point2D( 260, 906 ), new Point2D( 360, 838 ), new Point2D( 389, 763 ),
new Point2D( 415, 662 ), new Point2D( 500, 597 ), new Point2D( 570, 572 ),
new Point2D( 631, 577 ), new Point2D( 692, 500 ), new Point2D( 723, 445 ),
new Point2D( 672, 379 ), new Point2D( 626, 332 ), new Point2D( 494, 291 ),
new Point2D( 371, 336 ), new Point2D( 324, 334 ), new Point2D( 270, 362 ),
//Isamu-Jima
new Point2D( 1240, 1076 ), new Point2D( 1189, 1115 ), new Point2D( 1046, 1039 ),
new Point2D( 1025, 885 ), new Point2D( 907, 809 ), new Point2D( 840, 506 ),
new Point2D( 799, 396 ), new Point2D( 720, 258 ), new Point2D( 744, 158 ),
new Point2D( 904, 37 ), new Point2D( 974, 91 ), new Point2D( 1020, 187 ),
new Point2D( 1035, 288 ), new Point2D( 1104, 395 ), new Point2D( 1215, 462 ),
new Point2D( 1275, 488 ), new Point2D( 1348, 611 ), new Point2D( 1363, 739 ),
new Point2D( 1364, 765 ), new Point2D( 1364, 876 ), new Point2D( 1300, 936 ),
new Point2D( 1240, 1003 )
};
public static void Initialize()
{
EventSink.Login += new LoginEventHandler( EventSink_Login );
}
private static bool IsStranded( Mobile from )
{
Map map = from.Map;
if ( map == null || from.AccessLevel > AccessLevel.Player )
return false;
BaseBoat boat = BaseBoat.FindBoatAt(from, map);
if(boat != null && !boat.Deleted)
return false;
object surface = map.GetTopSurface( from.Location );
if ( surface is LandTile )
{
int id = ((LandTile)surface).ID;
return (id >= 168 && id <= 171)
|| (id >= 310 && id <= 311);
}
else if ( surface is StaticTile )
{
int id = ((StaticTile)surface).ID;
return (id >= 0x1796 && id <= 0x17B2);
}
return false;
}
public static void EventSink_Login( LoginEventArgs e )
{
Mobile from = e.Mobile;
if ( !IsStranded( from ) )
return;
Map map = from.Map;
Point2D[] list;
if( map == Map.Felucca )
list = m_Felucca;
else if( map == Map.Trammel )
list = m_Trammel;
else if( map == Map.Ilshenar )
list = m_Ilshenar;
else if( map == Map.Tokuno )
list = m_Tokuno;
else
return;
Point2D p = Point2D.Zero;
double pdist = double.MaxValue;
for ( int i = 0; i < list.Length; ++i )
{
double dist = from.GetDistanceToSqrt( list[i] );
if ( dist < pdist )
{
p = list[i];
pdist = dist;
}
}
int x = p.X, y = p.Y;
int z;
bool canFit = false;
z = map.GetAverageZ( x, y );
canFit = map.CanSpawnMobile( x, y, z );
for ( int i = 1; !canFit && i <= 40; i += 2 )
{
for ( int xo = -1; !canFit && xo <= 1; ++xo )
{
for ( int yo = -1; !canFit && yo <= 1; ++yo )
{
if ( xo == 0 && yo == 0 )
continue;
x = p.X + (xo * i);
y = p.Y + (yo * i);
z = map.GetAverageZ( x, y );
canFit = map.CanSpawnMobile( x, y, z );
}
}
}
if ( canFit )
from.Location = new Point3D( x, y, z );
}
}
}

View File

@@ -0,0 +1,297 @@
using System;
using Server;
using Server.Multis;
using Server.Network;
using Server.ContextMenus;
using System.Collections.Generic;
namespace Server.Items
{
public class TillerMan : Item
{
public virtual bool Babbles { get { return true; } }
public BaseBoat Boat { get; private set; }
private DateTime _NextBabble;
public TillerMan(BaseBoat boat)
: base(0x3E4E)
{
Boat = boat;
Movable = false;
}
public TillerMan(Serial serial)
: base(serial)
{
}
public virtual void SetFacing(Direction dir)
{
switch (dir)
{
case Direction.South: ItemID = 0x3E4B; break;
case Direction.North: ItemID = 0x3E4E; break;
case Direction.West: ItemID = 0x3E50; break;
case Direction.East: ItemID = 0x3E55; break; //Issue 99. Was Using Incorrect Graphic.
}
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (Boat.IsRowBoat)
return;
list.Add(Boat.Status);
list.Add(1116580 + (int)Boat.DamageTaken); //State: Prisine
}
public virtual void Say(int number)
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, number);
}
public virtual void Say(int number, string args)
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, number, args);
}
public override void AddNameProperty(ObjectPropertyList list)
{
if (Boat != null && Boat.ShipName != null)
list.Add(1042884, Boat.ShipName); // the tiller man of the ~1_SHIP_NAME~
else
base.AddNameProperty(list);
}
public override void OnSingleClick(Mobile from)
{
if (Boat != null && Boat.ShipName != null)
LabelTo(from, 1042884, Boat.ShipName); // the tiller man of the ~1_SHIP_NAME~
else
base.OnSingleClick(from);
}
public Mobile Pilot { get { return Boat != null ? Boat.Pilot : null; } }
public override void OnDoubleClickDead(Mobile m)
{
OnDoubleClick(m);
}
public override void OnDoubleClick(Mobile from)
{
from.RevealingAction();
BaseBoat boat = BaseBoat.FindBoatAt(from, from.Map);
Item mount = from.FindItemOnLayer(Layer.Mount);
if (boat == null || Boat == null || Boat != boat)
{
from.SendLocalizedMessage(1116724); // You cannot pilot a ship unless you are aboard it!
}
else if (Pilot != null && Pilot != from && Pilot == Boat.Owner)
{
from.SendLocalizedMessage(502221); // Someone else is already using this item.
}
else if (from.Flying)
{
from.SendLocalizedMessage(1116615); // You cannot pilot a ship while flying!
}
else if (from.Mounted && !(mount is BoatMountItem))
{
from.SendLocalizedMessage(1010097); // You cannot use this while mounted or flying.
}
else if (Pilot == null && Boat.Scuttled)
{
from.SendLocalizedMessage(1116725); // This ship is too damaged to sail!
}
else if (Pilot != null)
{
if (from != Pilot) // High authorized player takes control of the ship
{
boat.RemovePilot(from);
boat.LockPilot(from);
}
else
{
boat.RemovePilot(from);
}
}
else
{
boat.LockPilot(from);
}
}
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (dropped is MapItem && Boat != null && Boat.CanCommand(from) && Boat.Contains(from))
{
Boat.AssociateMap((MapItem)dropped);
}
return false;
}
public override void OnAfterDelete()
{
if (Boat != null)
Boat.Delete();
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (Boat.IsRowBoat)
return;
if (Boat != null)
{
if (Boat.Contains(from))
{
if (Boat.IsOwner(from))
list.Add(new RenameShipEntry(this, from));
list.Add(new EmergencyRepairEntry(this, from));
list.Add(new ShipRepairEntry(this, from));
}
else if (Boat.IsOwner(from))
{
list.Add(new DryDockEntry(Boat, from));
}
}
}
public void Babble()
{
if (Babbles)
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, 1114137, RandomBabbleArgs());
// Ar! Did I ever tell thee about the time I was in ~1_CITY~ and I met ~2_GENDER~ ~3_STORY~ Anyway, 'tis a dull story.
_NextBabble = DateTime.UtcNow + TimeSpan.FromMinutes(Utility.RandomMinMax(3, 10));
}
}
private string RandomBabbleArgs()
{
return string.Format("#{0}\t#{1}\t#{2}", Utility.Random(1114138, 13).ToString(),
Utility.Random(1114151, 2).ToString(),
Utility.RandomMinMax(1114153, 1114221).ToString());
}
public override void OnLocationChange(Point3D oldLocation)
{
if (_NextBabble < DateTime.UtcNow && 0.1 > Utility.RandomDouble())
{
Babble();
}
}
private class EmergencyRepairEntry : ContextMenuEntry
{
private TillerMan m_TillerMan;
private Mobile m_From;
public EmergencyRepairEntry(TillerMan tillerman, Mobile from)
: base(1116589, 5)
{
m_TillerMan = tillerman;
m_From = from;
}
public override void OnClick()
{
if (m_TillerMan != null && m_TillerMan.Boat != null)
{
BaseBoat g = m_TillerMan.Boat;
if (!g.Scuttled)
m_From.SendLocalizedMessage(1116595); //Your ship is not in need of emergency repairs in order to sail.
else if (g.IsUnderEmergencyRepairs())
{
TimeSpan left = g.GetEndEmergencyRepairs();
m_From.SendLocalizedMessage(1116592, left != TimeSpan.Zero ? left.TotalMinutes.ToString() : "0"); //Your ship is underway with emergency repairs holding for an estimated ~1_TIME~ more minutes.
}
else if (!g.TryEmergencyRepair(m_From))
m_From.SendLocalizedMessage(1116591, String.Format("{0}\t{1}", BaseGalleon.EmergencyRepairClothCost.ToString(), BaseGalleon.EmergencyRepairWoodCost)); //You need a minimum of ~1_CLOTH~ yards of cloth and ~2_WOOD~ pieces of lumber to effect emergency repairs.
}
}
}
private class ShipRepairEntry : ContextMenuEntry
{
private TillerMan m_TillerMan;
private Mobile m_From;
public ShipRepairEntry(TillerMan tillerman, Mobile from)
: base(1116590, 5)
{
m_TillerMan = tillerman;
m_From = from;
}
public override void OnClick()
{
if (m_TillerMan != null && m_TillerMan.Boat != null)
{
if (!BaseGalleon.IsNearLandOrDocks(m_TillerMan.Boat))
m_From.SendLocalizedMessage(1116594); //Your ship must be near shore or a sea market in order to effect permanent repairs.
else if (m_TillerMan.Boat.DamageTaken == DamageLevel.Pristine)
m_From.SendLocalizedMessage(1116596); //Your ship is in pristine condition and does not need repairs.
else
m_TillerMan.Boat.TryRepairs(m_From);
}
}
}
private class RenameShipEntry : ContextMenuEntry
{
private TillerMan m_TillerMan;
private readonly Mobile m_From;
public RenameShipEntry(TillerMan tillerman, Mobile from)
: base(1111680, 3)
{
m_TillerMan = tillerman;
m_From = from;
}
public override void OnClick()
{
if (m_TillerMan != null && m_TillerMan.Boat != null)
m_TillerMan.Boat.BeginRename(m_From);
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);//version
writer.Write(Boat);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Boat = reader.ReadItem() as BaseBoat;
if (Boat == null)
Delete();
break;
}
}
}
}
}