protected override void OnTarget(Mobile from, object targeted) { if (m_Map.Deleted) { return; } Map map = m_Map.m_ChestMap; if (m_Map.m_Completed) { from.SendMessage("This treasure map has not yet been decoded."); } else if (!m_Map.Decoded) { from.SendMessage("You have not yet decoded this treasure map."); } else if (!m_Map.HasRequiredSkill(from)) { from.SendMessage("You are not skilled enough in cartography to attempt to locate this treasure."); } else if (!from.CanBeginAction(typeof(TreasureMap))) { from.SendMessage("You are already digging for treasure."); } else if (from.Map != m_Map.m_ChestMap) { from.SendMessage("You seem to be in the right location but 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 = from.Skills[SkillName.Mining].Value; 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_ActualLocation; 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. } } } }
protected override void OnTarget(Mobile from, object targeted) { if (m_Map.Deleted) { return; } Map map = m_Map.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 = from.Skills[SkillName.Mining].Value; 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 (targ3D.InRange(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 (targ3D.InRange(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 (targ3D.InRange(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); } } } }
protected override async void OnTarget(Mobile from, object targeted) { if (m_Map.Deleted) { return; } Map map = m_Map.m_Map; 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); } from.PlaySound(899); await Timer.Pause(600); from.PlaySound(901); await Timer.Pause(600); int maxRange; double skillValue = from.Skills[SkillName.Mining].Value; // TODO: Add Ranger classe bonus if (skillValue >= 140.0) { maxRange = 8; } else if (skillValue >= 120.0) { maxRange = 7; } else if (skillValue >= 100.0) { maxRange = 6; } else if (skillValue >= 80.0) { maxRange = 5; } else if (skillValue >= 60.0) { maxRange = 4; } else if (skillValue >= 40.0) { maxRange = 3; } else if (skillValue >= 20.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)) { 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, $"You dig for awhile and have a feeling to travel to the {sDir}."); } else { int z = map.GetAverageZ(x, y); new DigTimer(from, m_Map, new Point3D(x, y, z), map).Start(); } } }