Esempio n. 1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_DisplayMap.Deleted)
                {
                    return;
                }

                Map map = m_DisplayMap.m_DisplayMap;

                if (m_DisplayMap.m_Completed)
                {
                    from.SendLocalizedMessage(503028);                       // The treasure for this map has already been found.
                }
                else if (m_DisplayMap.m_Decoder != from && !m_DisplayMap.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(ArtifactMap)))
                {
                    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_DisplayMap.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(ArtifactMap)))
                            {
                                new DigTimer(from, m_DisplayMap, new Point3D(x, y, z), map).Start();
                            }
                            else
                            {
                                from.SendLocalizedMessage(503020);                                   // You are already digging treasure.
                            }
                        }
                    }
                    else if (m_DisplayMap.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);
                        }
                    }
                }
            }