Exemplo n.º 1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                bool     isGround = false;
                IPoint3D p        = targeted as IPoint3D;

                if (p == null)
                {
                    return;
                }
                Point3D loc = new Point3D(p);

                if (m_Item.Count != 0)
                {
                    if (Utility.InRange(loc, m_Item.First, 2))
                    {
                        m_From.SendMessage("You are to close to your last digging location.");
                        return;
                    }
                    else if (Utility.InRange(loc, m_Item.Second, 2))
                    {
                        m_From.SendMessage("You are to close to your last digging location.");
                        return;
                    }
                    else if (Utility.InRange(loc, m_Item.Third, 2))
                    {
                        m_From.SendMessage("You are to close to your last digging location.");
                        return;
                    }
                    else if (Utility.InRange(loc, m_Item.Fourth, 2))
                    {
                        m_From.SendMessage("You are to close to your last digging location.");
                        return;
                    }
                    else if (Utility.InRange(loc, m_Item.Fifth, 2))
                    {
                        m_From.SendMessage("You are to close to your last digging location.");
                        return;
                    }
                    if ((Utility.InRange(loc, m_Item.First, 2) || Utility.InRange(loc, m_Item.Second, 2) || Utility.InRange(loc, m_Item.Third, 2) || Utility.InRange(loc, m_Item.Fourth, 2) || Utility.InRange(loc, m_Item.Fifth, 2)))
                    {
                        m_From.SendMessage("You are to close to one of your last five digging locations.");
                        return;
                    }
                }
                switch (m_Item.Count)
                {
                case 0:
                    m_Item.First = loc; m_Item.Third = new Point3D(0, 0, 0); m_Item.Count += 1; break;

                case 1:
                    m_Item.Second = loc; m_Item.Fourth = new Point3D(0, 0, 0); m_Item.Count += 1; break;

                case 2:
                    m_Item.Third = loc; m_Item.Fifth = new Point3D(0, 0, 0); m_Item.Count += 1; break;

                case 3:
                    m_Item.Fourth = loc; m_Item.First = new Point3D(0, 0, 0);; m_Item.Count += 1; break;

                case 4:
                    m_Item.Fifth = loc; m_Item.Second = new Point3D(0, 0, 0); m_Item.Count += 1; break;

                case 5: m_Item.Count = 0; break;

                default: m_Item.Count = 0; break;     // Added as a Just in case, shouldn't get past 5!!!
                }

                if (targeted is LandTarget)
                {
                    if (Utility.InsensitiveCompare(((LandTarget)targeted).Name, "grass") == 0 || Utility.InsensitiveCompare(((LandTarget)targeted).Name, "snow") == 0 || Utility.InsensitiveCompare(((LandTarget)targeted).Name, "forest") == 0 || Utility.InsensitiveCompare(((LandTarget)targeted).Name, "grasses") == 0 || Utility.InsensitiveCompare(((LandTarget)targeted).Name, "dirt") == 0 || Utility.InsensitiveCompare(((LandTarget)targeted).Name, "sand") == 0 || Utility.InsensitiveCompare(((LandTarget)targeted).Name, "rock") == 0)
                    {
                        isGround = true;
                    }

                    if (isGround)
                    {
                        m_Item.Uses -= 1;
                        if (m_Item.Uses <= 0)
                        {
                            m_Item.Delete();
                            if (m_From != null)
                            {
                                m_From.SendMessage("Your shovel has broken.");
                            }
                        }

                        if (m_From != null)
                        {
                            m_From.SendMessage("You start to dig.");
                        }

                        DigTimer dt = new DigTimer(m_From, m_Item, TimeSpan.FromSeconds(10.0));
                        dt.Start();
                        m_From.PlaySound(Utility.RandomList(0x125, 0x126));
                        m_From.Animate(11, 1, 3, true, true, 0);
                        m_Item.IsDigging = true;
                    }
                }
                else if (targeted is Item)
                {
                    Item i = (Item)targeted;

                    foreach (int check in m_Ground)
                    {
                        if (check == i.ItemID)
                        {
                            isGround = true;
                        }
                    }

                    if (isGround == true)
                    {
                        m_Item.Uses -= 1;
                        if (m_Item.Uses == 0)
                        {
                            m_Item.Delete();
                            if (m_From != null)
                            {
                                m_From.SendMessage("Your shovel has broken.");
                            }
                        }

                        if (m_From != null)
                        {
                            m_From.SendMessage("You start to dig.");
                        }

                        DigTimer dt = new DigTimer(m_From, m_Item, TimeSpan.FromSeconds(10.0));
                        dt.Start();
                        m_From.PlaySound(Utility.RandomList(0x125, 0x126));
                        m_From.Animate(11, 1, 3, true, true, 0);
                        m_Item.IsDigging = true;
                    }
                    else
                    {
                        if (m_From != null)
                        {
                            m_From.SendMessage("You can not dig there.");
                        }
                    }
                }
                else if (targeted is StaticTarget)
                {
                    StaticTarget i = (StaticTarget)targeted;

                    foreach (int check in m_Ground)
                    {
                        if (check == i.ItemID)
                        {
                            isGround = true;
                        }
                    }

                    if (isGround)
                    {
                        m_Item.Uses -= 1;
                        if (m_Item.Uses <= 0)
                        {
                            m_Item.Delete();
                            if (m_From != null)
                            {
                                m_From.SendMessage("Your shovel has broken.");
                            }
                        }

                        if (m_From != null)
                        {
                            m_From.SendMessage("You start to dig.");
                        }

                        DigTimer dt = new DigTimer(m_From, m_Item, TimeSpan.FromSeconds(10.0));
                        dt.Start();
                        m_From.PlaySound(Utility.RandomList(0x125, 0x126));
                        m_From.Animate(11, 1, 3, true, true, 0);
                        m_Item.IsDigging = true;
                    }
                }
                else
                {
                    m_From.SendMessage("You can not dig there.");
                }
            }