Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
69
Projects/Scripts/Items/Skill Items/Fishing/FishingPole.cs
Normal file
69
Projects/Scripts/Items/Skill Items/Fishing/FishingPole.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
using System.Collections.Generic;
|
||||
using Server.ContextMenus;
|
||||
using Server.Engines.Harvest;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class FishingPole : Item
|
||||
{
|
||||
[Constructible]
|
||||
public FishingPole() : base(0x0DC0)
|
||||
{
|
||||
Layer = Layer.TwoHanded;
|
||||
Weight = 8.0;
|
||||
}
|
||||
|
||||
public FishingPole(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
Point3D loc = GetWorldLocation();
|
||||
|
||||
if (!from.InLOS(loc) || !from.InRange(loc, 2))
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1019045); // I can't reach that
|
||||
else
|
||||
Fishing.System.BeginHarvesting(from, this);
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
BaseHarvestTool.AddContextMenuEntries(from, this, list, Fishing.System);
|
||||
}
|
||||
|
||||
public override bool CheckConflictingLayer(Mobile m, Item item, Layer layer)
|
||||
{
|
||||
if (base.CheckConflictingLayer(m, item, layer))
|
||||
return true;
|
||||
|
||||
if (layer == Layer.OneHanded)
|
||||
{
|
||||
m.SendLocalizedMessage(500214); // You already have something in both hands.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (version < 1 && Layer == Layer.OneHanded)
|
||||
Layer = Layer.TwoHanded;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class MessageInABottle : Item
|
||||
{
|
||||
private int m_Level;
|
||||
|
||||
public MessageInABottle(Map map = null) : this(map, GetRandomLevel())
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MessageInABottle(Map map, int level) : base(0x099F)
|
||||
{
|
||||
Weight = 1.0;
|
||||
TargetMap = map ?? Map.Trammel;
|
||||
m_Level = level;
|
||||
}
|
||||
|
||||
public MessageInABottle(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1041080; // a message in a bottle
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Map TargetMap{ get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Level
|
||||
{
|
||||
get => m_Level;
|
||||
set => m_Level = Math.Max(1, Math.Min(value, 4));
|
||||
}
|
||||
|
||||
public static int GetRandomLevel()
|
||||
{
|
||||
if (Core.AOS && 1 > Utility.Random(25))
|
||||
return 4; // ancient
|
||||
|
||||
return Utility.RandomMinMax(1, 3);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(3); // version
|
||||
|
||||
writer.Write(m_Level);
|
||||
|
||||
writer.Write(TargetMap);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 3:
|
||||
case 2:
|
||||
{
|
||||
m_Level = reader.ReadInt();
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
TargetMap = reader.ReadMap();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
TargetMap = Map.Trammel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 2)
|
||||
m_Level = GetRandomLevel();
|
||||
|
||||
if (version < 3 && TargetMap == Map.Tokuno)
|
||||
TargetMap = Map.Trammel;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
ReplaceWith(new SOS(TargetMap, m_Level));
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501891); // You extract the message from the bottle.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
326
Projects/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs
Normal file
326
Projects/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs
Normal file
|
|
@ -0,0 +1,326 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
[Flippable(0x14ED, 0x14EE)]
|
||||
public class SOS : Item
|
||||
{
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsAncient)
|
||||
return 1063450; // an ancient SOS
|
||||
|
||||
return 1041081; // a waterstained SOS
|
||||
}
|
||||
}
|
||||
|
||||
private int m_Level;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool IsAncient => m_Level >= 4;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Level
|
||||
{
|
||||
get => m_Level;
|
||||
set
|
||||
{
|
||||
m_Level = Math.Max(1, Math.Min(value, 4));
|
||||
UpdateHue();
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Map TargetMap{ get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Point3D TargetLocation{ get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int MessageIndex{ get; set; }
|
||||
|
||||
public void UpdateHue()
|
||||
{
|
||||
if (IsAncient)
|
||||
Hue = 0x481;
|
||||
else
|
||||
Hue = 0;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SOS(Map map = null) : this(map, MessageInABottle.GetRandomLevel())
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SOS(Map map, int level) : base(0x14EE)
|
||||
{
|
||||
Weight = 1.0;
|
||||
|
||||
m_Level = level;
|
||||
MessageIndex = Utility.Random(MessageEntry.Entries.Length);
|
||||
TargetMap = map ?? Map.Trammel;
|
||||
TargetLocation = FindLocation(TargetMap);
|
||||
|
||||
UpdateHue();
|
||||
}
|
||||
|
||||
public SOS(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(4); // version
|
||||
|
||||
writer.Write(m_Level);
|
||||
|
||||
writer.Write(TargetMap);
|
||||
writer.Write(TargetLocation);
|
||||
writer.Write(MessageIndex);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 4:
|
||||
case 3:
|
||||
case 2:
|
||||
{
|
||||
m_Level = reader.ReadInt();
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
TargetMap = reader.ReadMap();
|
||||
TargetLocation = reader.ReadPoint3D();
|
||||
MessageIndex = reader.ReadInt();
|
||||
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
TargetMap = Map;
|
||||
|
||||
if (TargetMap == null || TargetMap == Map.Internal)
|
||||
TargetMap = Map.Trammel;
|
||||
|
||||
TargetLocation = FindLocation(TargetMap);
|
||||
MessageIndex = Utility.Random(MessageEntry.Entries.Length);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 2)
|
||||
m_Level = MessageInABottle.GetRandomLevel();
|
||||
|
||||
if (version < 3)
|
||||
UpdateHue();
|
||||
|
||||
if (version < 4 && TargetMap == Map.Tokuno)
|
||||
TargetMap = Map.Trammel;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
MessageEntry entry;
|
||||
|
||||
if (MessageIndex >= 0 && MessageIndex < MessageEntry.Entries.Length)
|
||||
entry = MessageEntry.Entries[MessageIndex];
|
||||
else
|
||||
entry = MessageEntry.Entries[MessageIndex = Utility.Random(MessageEntry.Entries.Length)];
|
||||
|
||||
//from.CloseGump( typeof( MessageGump ) );
|
||||
from.SendGump(new MessageGump(entry, TargetMap, TargetLocation));
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] m_WaterTiles =
|
||||
{
|
||||
0x00A8, 0x00AB,
|
||||
0x0136, 0x0137
|
||||
};
|
||||
|
||||
private static Rectangle2D[] m_BritRegions = { new Rectangle2D(0, 0, 5120, 4096) };
|
||||
|
||||
private static Rectangle2D[] m_IlshRegions =
|
||||
{ new Rectangle2D(1472, 272, 304, 240), new Rectangle2D(1240, 1000, 312, 160) };
|
||||
|
||||
private static Rectangle2D[] m_MalasRegions = { new Rectangle2D(1376, 1520, 464, 280) };
|
||||
|
||||
public static Point3D FindLocation(Map map)
|
||||
{
|
||||
if (map == null || map == Map.Internal)
|
||||
return Point3D.Zero;
|
||||
|
||||
Rectangle2D[] regions;
|
||||
|
||||
if (map == Map.Felucca || map == Map.Trammel)
|
||||
regions = m_BritRegions;
|
||||
else if (map == Map.Ilshenar)
|
||||
regions = m_IlshRegions;
|
||||
else if (map == Map.Malas)
|
||||
regions = m_MalasRegions;
|
||||
else
|
||||
regions = new[] { new Rectangle2D(0, 0, map.Width, map.Height) };
|
||||
|
||||
if (regions.Length == 0)
|
||||
return Point3D.Zero;
|
||||
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
Rectangle2D reg = regions[Utility.Random(regions.Length)];
|
||||
int x = Utility.Random(reg.X, reg.Width);
|
||||
int y = Utility.Random(reg.Y, reg.Height);
|
||||
|
||||
if (!ValidateDeepWater(map, x, y))
|
||||
continue;
|
||||
|
||||
bool valid = true;
|
||||
|
||||
for (int j = 1, offset = 5; valid && j <= 5; ++j, offset += 5)
|
||||
if (!ValidateDeepWater(map, x + offset, y + offset))
|
||||
valid = false;
|
||||
else if (!ValidateDeepWater(map, x + offset, y - offset))
|
||||
valid = false;
|
||||
else if (!ValidateDeepWater(map, x - offset, y + offset))
|
||||
valid = false;
|
||||
else if (!ValidateDeepWater(map, x - offset, y - offset))
|
||||
valid = false;
|
||||
|
||||
if (valid)
|
||||
return new Point3D(x, y, 0);
|
||||
}
|
||||
|
||||
return Point3D.Zero;
|
||||
}
|
||||
|
||||
private static bool ValidateDeepWater(Map map, int x, int y)
|
||||
{
|
||||
int tileID = map.Tiles.GetLandTile(x, y).ID;
|
||||
bool water = false;
|
||||
|
||||
for (int i = 0; !water && i < m_WaterTiles.Length; i += 2)
|
||||
water = tileID >= m_WaterTiles[i] && tileID <= m_WaterTiles[i + 1];
|
||||
|
||||
return water;
|
||||
}
|
||||
|
||||
#if false
|
||||
private class MessageGump : Gump
|
||||
{
|
||||
public MessageGump( MessageEntry entry, Map map, Point3D loc ) : base( (640 - entry.Width) / 2, (480 - entry.Height) / 2 )
|
||||
{
|
||||
int xLong = 0, yLat = 0;
|
||||
int xMins = 0, yMins = 0;
|
||||
bool xEast = false, ySouth = false;
|
||||
string fmt;
|
||||
|
||||
if ( Sextant.Format( loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
|
||||
fmt =
|
||||
String.Format( "{0}°{1}'{2},{3}°{4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
|
||||
else
|
||||
fmt = "?????";
|
||||
|
||||
AddPage( 0 );
|
||||
AddBackground( 0, 0, entry.Width, entry.Height, 2520 );
|
||||
AddHtml( 38, 38, entry.Width - 83, entry.Height - 86, String.Format( entry.Message, fmt ), false, false );
|
||||
}
|
||||
}
|
||||
#else
|
||||
private class MessageGump : Gump
|
||||
{
|
||||
public MessageGump(MessageEntry entry, Map map, Point3D loc) : base(150, 50)
|
||||
{
|
||||
int xLong = 0, yLat = 0;
|
||||
int xMins = 0, yMins = 0;
|
||||
bool xEast = false, ySouth = false;
|
||||
string fmt;
|
||||
|
||||
if (Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
|
||||
fmt = $"{yLat}°{yMins}'{(ySouth ? "S" : "N")},{xLong}°{xMins}'{(xEast ? "E" : "W")}";
|
||||
else
|
||||
fmt = "?????";
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 40, 350, 300, 2520);
|
||||
|
||||
AddHtmlLocalized(30, 80, 285, 160, 1018326, true,
|
||||
true); /* This is a message hastily scribbled by a passenger aboard a sinking ship.
|
||||
* While it is probably too late to save the passengers and crew,
|
||||
* perhaps some treasure went down with the ship!
|
||||
* The message gives the ship's last known sextant co-ordinates.
|
||||
*/
|
||||
|
||||
AddHtml(35, 240, 230, 20, fmt);
|
||||
|
||||
AddButton(35, 265, 4005, 4007, 0);
|
||||
AddHtmlLocalized(70, 265, 100, 20, 1011036); // OKAY
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private class MessageEntry
|
||||
{
|
||||
public MessageEntry(int width, int height, string message)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public int Width{ get; }
|
||||
|
||||
public int Height{ get; }
|
||||
|
||||
public string Message{ get; }
|
||||
|
||||
public static MessageEntry[] Entries{ get; } =
|
||||
{
|
||||
new MessageEntry(280, 180,
|
||||
"...Ar! {0} and a fair wind! No chance... storms, though--ar! Is that a sea serp...<br><br>uh oh."),
|
||||
new MessageEntry(280, 215,
|
||||
"...been inside this whale for three days now. I've run out of food I can pick out of his teeth. I took a sextant reading through the blowhole: {0}. I'll never see my treasure again..."),
|
||||
new MessageEntry(280, 285,
|
||||
"...grand adventure! Captain Quacklebush had me swab down the decks daily...<br> ...pirates came, I was in the rigging practicing with my sextant. {0} if I am not mistaken...<br> ....scuttled the ship, and our precious cargo went with her and the screaming pirates, down to the bottom of the sea..."),
|
||||
new MessageEntry(280, 180,
|
||||
"Help! Ship going dow...n heavy storms...precious cargo...st reach dest...current coordinates {0}...ve any survivors... ease!"),
|
||||
new MessageEntry(280, 215,
|
||||
"...know that the wreck is near {0} but have not found it. Could the message passed down in my family for generations be wrong? No... I swear on the soul of my grandfather, I will find..."),
|
||||
new MessageEntry(280, 195,
|
||||
"...never expected an iceberg...silly woman on bow crushed instantly...send help to {0}...ey'll never forget the tragedy of the sinking of the Miniscule..."),
|
||||
new MessageEntry(280, 265,
|
||||
"...nobody knew I was a girl. They just assumed I was another sailor...then we met the undine. {0}. It was demanded sacrifice...I was youngset, they figured...<br> ...grabbed the captain's treasure, screamed, 'It'll go down with me!'<br> ...they took me up on it."),
|
||||
new MessageEntry(280, 230,
|
||||
"...so I threw the treasure overboard, before the curse could get me too. But I was too late. Now I am doomed to wander these seas, a ghost forever. Join me: seek ye at {0} if thou wishest my company..."),
|
||||
new MessageEntry(280, 285,
|
||||
"...then the ship exploded. A dragon swooped by. The slime swallowed Bertie whole--he screamed, it was amazing. The sky glowed orange. A sextant reading put us at {0}. Norma was chattering about sailing over the edge of the world. I looked at my hands and saw through them..."),
|
||||
new MessageEntry(280, 285,
|
||||
"...trapped on a deserted island, with a magic fountain supplying wood, fresh water springs, gorgeous scenery, and my lovely young wife. I know the ship with all our life's earnings sank at {0} but I don't know what our coordinates are... someone has GOT to rescue me before Sunday's finals game or I'll go mad..."),
|
||||
new MessageEntry(280, 160,
|
||||
"WANTED: divers exp...d in shipwre...overy. Must have own vess...pply at {0}<br>...good benefits, flexible hours..."),
|
||||
new MessageEntry(280, 250,
|
||||
"...was a cad and a boor, no matter what momma s...rew him overboard! Oh, Anna, 'twas so exciting!<br> Unfort...y he grabbe...est, and all his riches went with him!<br> ...sked the captain, and he says we're at {0}<br>...so maybe...")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
159
Projects/Scripts/Items/Skill Items/Fishing/Misc/Sextant.cs
Normal file
159
Projects/Scripts/Items/Skill Items/Fishing/Misc/Sextant.cs
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class Sextant : Item
|
||||
{
|
||||
[Constructible]
|
||||
public Sextant() : base(0x1058)
|
||||
{
|
||||
Weight = 2.0;
|
||||
}
|
||||
|
||||
public Sextant(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
int xLong = 0, yLat = 0;
|
||||
int xMins = 0, yMins = 0;
|
||||
bool xEast = false, ySouth = false;
|
||||
|
||||
if (Format(from.Location, from.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
|
||||
{
|
||||
string location = $"{yLat}<7D> {yMins}'{(ySouth ? "S" : "N")}, {xLong}<7D> {xMins}'{(xEast ? "E" : "W")}";
|
||||
from.LocalOverheadMessage(MessageType.Regular, from.SpeechHue, false, location);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ComputeMapDetails(Map map, int x, int y, out int xCenter, out int yCenter, out int xWidth,
|
||||
out int yHeight)
|
||||
{
|
||||
xWidth = 5120;
|
||||
yHeight = 4096;
|
||||
|
||||
if (map == Map.Trammel || map == Map.Felucca)
|
||||
{
|
||||
if (x >= 0 && y >= 0 && x < 5120 && y < 4096)
|
||||
{
|
||||
xCenter = 1323;
|
||||
yCenter = 1624;
|
||||
}
|
||||
else if (x >= 5120 && y >= 2304 && x < 6144 && y < 4096)
|
||||
{
|
||||
xCenter = 5936;
|
||||
yCenter = 3112;
|
||||
}
|
||||
else
|
||||
{
|
||||
xCenter = 0;
|
||||
yCenter = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (x >= 0 && y >= 0 && x < map.Width && y < map.Height)
|
||||
{
|
||||
xCenter = 1323;
|
||||
yCenter = 1624;
|
||||
}
|
||||
else
|
||||
{
|
||||
xCenter = 0;
|
||||
yCenter = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Point3D ReverseLookup(Map map, int xLong, int yLat, int xMins, int yMins, bool xEast, bool ySouth)
|
||||
{
|
||||
if (map == null || map == Map.Internal)
|
||||
return Point3D.Zero;
|
||||
|
||||
if (!ComputeMapDetails(map, 0, 0, out int xCenter, out int yCenter, out int xWidth, out int yHeight))
|
||||
return Point3D.Zero;
|
||||
|
||||
double absLong = xLong + (double)xMins / 60;
|
||||
double absLat = yLat + (double)yMins / 60;
|
||||
|
||||
if (!xEast)
|
||||
absLong = 360.0 - absLong;
|
||||
|
||||
if (!ySouth)
|
||||
absLat = 360.0 - absLat;
|
||||
|
||||
int x = xCenter + (int)(absLong * xWidth / 360);
|
||||
int y = yCenter + (int)(absLat * yHeight / 360);
|
||||
|
||||
if (x < 0)
|
||||
x += xWidth;
|
||||
else if (x >= xWidth)
|
||||
x -= xWidth;
|
||||
|
||||
if (y < 0)
|
||||
y += yHeight;
|
||||
else if (y >= yHeight)
|
||||
y -= yHeight;
|
||||
|
||||
int z = map.GetAverageZ(x, y);
|
||||
|
||||
return new Point3D(x, y, z);
|
||||
}
|
||||
|
||||
public static bool Format(Point3D p, Map map, ref int xLong, ref int yLat, ref int xMins, ref int yMins,
|
||||
ref bool xEast, ref bool ySouth)
|
||||
{
|
||||
if (map == null || map == Map.Internal)
|
||||
return false;
|
||||
|
||||
int x = p.X, y = p.Y;
|
||||
|
||||
if (!ComputeMapDetails(map, x, y, out int xCenter, out int yCenter, out int xWidth, out int yHeight))
|
||||
return false;
|
||||
|
||||
double absLong = (double)((x - xCenter) * 360) / xWidth;
|
||||
double absLat = (double)((y - yCenter) * 360) / yHeight;
|
||||
|
||||
if (absLong > 180.0)
|
||||
absLong = -180.0 + absLong % 180.0;
|
||||
|
||||
if (absLat > 180.0)
|
||||
absLat = -180.0 + absLat % 180.0;
|
||||
|
||||
bool east = absLong >= 0, south = absLat >= 0;
|
||||
|
||||
if (absLong < 0.0)
|
||||
absLong = -absLong;
|
||||
|
||||
if (absLat < 0.0)
|
||||
absLat = -absLat;
|
||||
|
||||
xLong = (int)absLong;
|
||||
yLat = (int)absLat;
|
||||
|
||||
xMins = (int)(absLong % 1.0 * 60);
|
||||
yMins = (int)(absLat % 1.0 * 60);
|
||||
|
||||
xEast = east;
|
||||
ySouth = south;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public interface IShipwreckedItem
|
||||
{
|
||||
bool IsShipwreckedItem{ get; set; }
|
||||
}
|
||||
|
||||
public class ShipwreckedItem : Item, IDyable, IShipwreckedItem
|
||||
{
|
||||
public ShipwreckedItem(int itemID) : base(itemID)
|
||||
{
|
||||
int weight = ItemData.Weight;
|
||||
|
||||
if (weight >= 255)
|
||||
weight = 1;
|
||||
|
||||
Weight = weight;
|
||||
}
|
||||
|
||||
public ShipwreckedItem(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Dye(Mobile from, DyeTub sender)
|
||||
{
|
||||
if (Deleted)
|
||||
return false;
|
||||
|
||||
if (ItemID >= 0x13A4 && ItemID <= 0x13AE)
|
||||
{
|
||||
Hue = sender.DyedHue;
|
||||
return true;
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage(sender.FailMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
#region IShipwreckedItem Members
|
||||
|
||||
bool IShipwreckedItem.IsShipwreckedItem
|
||||
{
|
||||
get => true;
|
||||
set { }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
LabelTo(from, 1050039, $"#{LabelNumber}\t#1041645");
|
||||
}
|
||||
|
||||
public override void AddNameProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.AddNameProperties(list);
|
||||
list.Add(1041645); // recovered from a shipwreck
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,424 @@
|
|||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
using Server.Spells;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class SpecialFishingNet : Item
|
||||
{
|
||||
private static int[] m_Hues =
|
||||
{
|
||||
0x09B,
|
||||
0x0CD,
|
||||
0x0D3,
|
||||
0x14D,
|
||||
0x1DD,
|
||||
0x1E9,
|
||||
0x1F4,
|
||||
0x373,
|
||||
0x451,
|
||||
0x47F,
|
||||
0x489,
|
||||
0x492,
|
||||
0x4B5,
|
||||
0x8AA
|
||||
};
|
||||
|
||||
private static int[] m_WaterTiles =
|
||||
{
|
||||
0x00A8, 0x00AB,
|
||||
0x0136, 0x0137
|
||||
};
|
||||
|
||||
private static int[] m_UndeepWaterTiles =
|
||||
{
|
||||
0x1797, 0x179C
|
||||
};
|
||||
|
||||
[Constructible]
|
||||
public SpecialFishingNet() : base(0x0DCA)
|
||||
{
|
||||
Weight = 1.0;
|
||||
|
||||
if (0.01 > Utility.RandomDouble())
|
||||
Hue = Utility.RandomList(m_Hues);
|
||||
else
|
||||
Hue = 0x8A0;
|
||||
}
|
||||
|
||||
public SpecialFishingNet(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1041079; // a special fishing net
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool InUse{ get; set; }
|
||||
|
||||
public virtual bool RequireDeepWater => true;
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
AddNetProperties(list);
|
||||
}
|
||||
|
||||
protected virtual void AddNetProperties(ObjectPropertyList list)
|
||||
{
|
||||
// as if the name wasn't enough..
|
||||
list.Add(1017410); // Special Fishing Net
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write(InUse);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
InUse = reader.ReadBool();
|
||||
|
||||
if (InUse)
|
||||
Delete();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Stackable = false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (InUse)
|
||||
{
|
||||
from.SendLocalizedMessage(1010483); // Someone is already using that net!
|
||||
}
|
||||
else if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1010484); // Where do you wish to use the net?
|
||||
from.BeginTarget(-1, true, TargetFlags.None, OnTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTarget(Mobile from, object obj)
|
||||
{
|
||||
if (Deleted || InUse)
|
||||
return;
|
||||
|
||||
if (!(obj is IPoint3D p3D))
|
||||
return;
|
||||
|
||||
Map map = from.Map;
|
||||
|
||||
if (map == null || map == Map.Internal)
|
||||
return;
|
||||
|
||||
int x = p3D.X, y = p3D.Y, z = map.GetAverageZ(x, y); // OSI just takes the targeted Z
|
||||
|
||||
if (!from.InRange(p3D, 6))
|
||||
{
|
||||
from.SendLocalizedMessage(500976); // You need to be closer to the water to fish!
|
||||
}
|
||||
else if (!from.InLOS(obj))
|
||||
{
|
||||
from.SendLocalizedMessage(500979); // You cannot see that location.
|
||||
}
|
||||
else if (RequireDeepWater
|
||||
? FullValidation(map, x, y)
|
||||
: ValidateDeepWater(map, x, y) || ValidateUndeepWater(map, obj, ref z))
|
||||
{
|
||||
Point3D p = new Point3D(x, y, z);
|
||||
|
||||
if (GetType() == typeof(SpecialFishingNet))
|
||||
for (int i = 1; i < Amount; ++i) // these were stackable before, doh
|
||||
from.AddToBackpack(new SpecialFishingNet());
|
||||
|
||||
InUse = true;
|
||||
Movable = false;
|
||||
MoveToWorld(p, map);
|
||||
|
||||
SpellHelper.Turn(from, p);
|
||||
from.Animate(12, 5, 1, true, false, 0);
|
||||
|
||||
Effects.SendLocationEffect(p, map, 0x352D, 16, 4);
|
||||
Effects.PlaySound(p, map, 0x364);
|
||||
|
||||
int index = 0;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 14,
|
||||
() => DoEffect(from, p, index++));
|
||||
|
||||
from.SendLocalizedMessage(RequireDeepWater
|
||||
? 1010487
|
||||
: 1074492); // You plunge the net into the sea... / You plunge the net into the water...
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(RequireDeepWater
|
||||
? 1010485
|
||||
: 1074491); // You can only use this net in deep water! / You can only use this net in water!
|
||||
}
|
||||
}
|
||||
|
||||
private void DoEffect(Mobile from, Point3D p, int index)
|
||||
{
|
||||
if (Deleted)
|
||||
return;
|
||||
|
||||
if (index == 1)
|
||||
{
|
||||
Effects.SendLocationEffect(p, Map, 0x352D, 16, 4);
|
||||
Effects.PlaySound(p, Map, 0x364);
|
||||
}
|
||||
else if (index <= 7 || index == 14)
|
||||
{
|
||||
if (RequireDeepWater)
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
switch (Utility.Random(8))
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
x = -1;
|
||||
y = -1;
|
||||
break;
|
||||
case 1:
|
||||
x = -1;
|
||||
y = 0;
|
||||
break;
|
||||
case 2:
|
||||
x = -1;
|
||||
y = +1;
|
||||
break;
|
||||
case 3:
|
||||
x = 0;
|
||||
y = -1;
|
||||
break;
|
||||
case 4:
|
||||
x = 0;
|
||||
y = +1;
|
||||
break;
|
||||
case 5:
|
||||
x = +1;
|
||||
y = -1;
|
||||
break;
|
||||
case 6:
|
||||
x = +1;
|
||||
y = 0;
|
||||
break;
|
||||
case 7:
|
||||
x = +1;
|
||||
y = +1;
|
||||
break;
|
||||
}
|
||||
|
||||
Effects.SendLocationEffect(new Point3D(p.X + x, p.Y + y, p.Z), Map, 0x352D, 16, 4);
|
||||
}
|
||||
else
|
||||
Effects.SendLocationEffect(p, Map, 0x352D, 16, 4);
|
||||
|
||||
if (Utility.RandomBool())
|
||||
Effects.PlaySound(p, Map, 0x364);
|
||||
|
||||
if (index == 14)
|
||||
FinishEffect(p, Map, from);
|
||||
else
|
||||
Z -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual int GetSpawnCount()
|
||||
{
|
||||
int count = Utility.RandomMinMax(1, 3);
|
||||
|
||||
if (Hue != 0x8A0)
|
||||
count += Utility.RandomMinMax(1, 2);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
protected void Spawn(Point3D p, Map map, BaseCreature spawn)
|
||||
{
|
||||
if (map == null)
|
||||
{
|
||||
spawn.Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
int x = p.X, y = p.Y;
|
||||
|
||||
for (int j = 0; j < 20; ++j)
|
||||
{
|
||||
int tx = p.X - 2 + Utility.Random(5);
|
||||
int ty = p.Y - 2 + Utility.Random(5);
|
||||
|
||||
LandTile t = map.Tiles.GetLandTile(tx, ty);
|
||||
|
||||
if (t.Z == p.Z && (t.ID >= 0xA8 && t.ID <= 0xAB || t.ID >= 0x136 && t.ID <= 0x137) &&
|
||||
!SpellHelper.CheckMulti(new Point3D(tx, ty, p.Z), map))
|
||||
{
|
||||
x = tx;
|
||||
y = ty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spawn.MoveToWorld(new Point3D(x, y, p.Z), map);
|
||||
|
||||
if (spawn is Kraken && 0.2 > Utility.RandomDouble())
|
||||
spawn.PackItem(new MessageInABottle(map == Map.Felucca ? Map.Felucca : Map.Trammel));
|
||||
}
|
||||
|
||||
protected virtual void FinishEffect(Point3D p, Map map, Mobile from)
|
||||
{
|
||||
from.RevealingAction();
|
||||
|
||||
int count = GetSpawnCount();
|
||||
|
||||
for (int i = 0; map != null && i < count; ++i)
|
||||
{
|
||||
BaseCreature spawn;
|
||||
|
||||
switch (Utility.Random(4))
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
spawn = new SeaSerpent();
|
||||
break;
|
||||
case 1:
|
||||
spawn = new DeepSeaSerpent();
|
||||
break;
|
||||
case 2:
|
||||
spawn = new WaterElemental();
|
||||
break;
|
||||
case 3:
|
||||
spawn = new Kraken();
|
||||
break;
|
||||
}
|
||||
|
||||
Spawn(p, map, spawn);
|
||||
|
||||
spawn.Combatant = from;
|
||||
}
|
||||
|
||||
Delete();
|
||||
}
|
||||
|
||||
public static bool FullValidation(Map map, int x, int y)
|
||||
{
|
||||
bool valid = ValidateDeepWater(map, x, y);
|
||||
|
||||
for (int j = 1, offset = 5; valid && j <= 5; ++j, offset += 5)
|
||||
if (!ValidateDeepWater(map, x + offset, y + offset))
|
||||
valid = false;
|
||||
else if (!ValidateDeepWater(map, x + offset, y - offset))
|
||||
valid = false;
|
||||
else if (!ValidateDeepWater(map, x - offset, y + offset))
|
||||
valid = false;
|
||||
else if (!ValidateDeepWater(map, x - offset, y - offset))
|
||||
valid = false;
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
private static bool ValidateDeepWater(Map map, int x, int y)
|
||||
{
|
||||
int tileID = map.Tiles.GetLandTile(x, y).ID;
|
||||
bool water = false;
|
||||
|
||||
for (int i = 0; !water && i < m_WaterTiles.Length; i += 2)
|
||||
water = tileID >= m_WaterTiles[i] && tileID <= m_WaterTiles[i + 1];
|
||||
|
||||
return water;
|
||||
}
|
||||
|
||||
private static bool ValidateUndeepWater(Map map, object obj, ref int z)
|
||||
{
|
||||
if (!(obj is StaticTarget))
|
||||
return false;
|
||||
|
||||
StaticTarget target = (StaticTarget)obj;
|
||||
|
||||
if (BaseHouse.FindHouseAt(target.Location, map, 0) != null)
|
||||
return false;
|
||||
|
||||
int itemID = target.ItemID;
|
||||
|
||||
for (int i = 0; i < m_UndeepWaterTiles.Length; i += 2)
|
||||
if (itemID >= m_UndeepWaterTiles[i] && itemID <= m_UndeepWaterTiles[i + 1])
|
||||
{
|
||||
z = target.Z;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class FabledFishingNet : SpecialFishingNet
|
||||
{
|
||||
[Constructible]
|
||||
public FabledFishingNet()
|
||||
{
|
||||
Hue = 0x481;
|
||||
}
|
||||
|
||||
public FabledFishingNet(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1063451; // a fabled fishing net
|
||||
|
||||
protected override void AddNetProperties(ObjectPropertyList list)
|
||||
{
|
||||
}
|
||||
|
||||
protected override int GetSpawnCount()
|
||||
{
|
||||
return base.GetSpawnCount() + 4;
|
||||
}
|
||||
|
||||
protected override void FinishEffect(Point3D p, Map map, Mobile from)
|
||||
{
|
||||
Spawn(p, map, new Leviathan(from));
|
||||
|
||||
base.FinishEffect(p, map, from);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue