Esempio n. 1
0
        public bool CanChange(Mobile from)
        {
            bool bReturn = false;

            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(true);
            }

            CustomRegion cr = CustomRegion.FindDRDTRegion(from.Map, this.Location);

            if (cr is TownshipRegion)
            {
                TownshipRegion tsr = cr as TownshipRegion;
                if (tsr != null && tsr.TStone != null && tsr.TStone.Guild != null &&
                    tsr.TStone.Guild == from.Guild)
                {
                    bReturn = true;
                }
                else
                {
                    from.SendMessage("You must be a member of this township to modify this wall.");
                    bReturn = false;
                }
            }
            else
            {
                from.SendMessage("You must be within the township to modify this wall.");
                bReturn = false;
            }

            return(bReturn);
        }
Esempio n. 2
0
        public bool CheckLooting(Mobile from)
        {
            try
            {
                if (from.AccessLevel == AccessLevel.Player)
                {
                    RegionControl regstone = null;
                    CustomRegion  reg      = null;
                    if (this.Deleted == false)
                    {
                        reg = CustomRegion.FindDRDTRegion(this);
                    }
                    if (reg != null)
                    {
                        regstone = reg.GetRegionControler();
                    }

                    // if this region does not allow looting, fail
                    if (regstone != null && regstone.BlockLooting == true)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Server.Commands.LogHelper.LogException(ex);
            }

            return(true);
        }
Esempio n. 3
0
        public static bool IsInIOBRegion(Mobile m)
        {
            try
            {
                RegionControl regstone = null;
                //check if there is a DRDT region and also if were in a house and if so use the DRDT rules
                CustomRegion inHouse = null;
                inHouse = CustomRegion.FindDRDTRegion(m);
                if (inHouse != null)
                {
                    regstone = inHouse.GetRegionControler();
                }

                if ((regstone != null && regstone.IOBAlign != IOBAlignment.None) || (regstone != null && regstone.IOBZone))
                {
                    return(true);
                }
            }
            catch (NullReferenceException e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("{0}", e);
            }
            catch
            {
                Console.WriteLine("Caught Exception in IOBRegions::IsInIOBRegion()");
            }

            return(IsInIOBRegion(m.Location.X, m.Location.Y));
        }
Esempio n. 4
0
        public bool CheckHSequence(Mobile target)
        {
            try
            {
                RegionControl regstone = null;
                CustomRegion  reg      = null;
                if (target != null)
                {
                    reg = CustomRegion.FindDRDTRegion(target);
                }
                if (reg != null)
                {
                    regstone = reg.GetRegionControler();
                }

                //if your in a region area spells will fail if disallowed, prevents the run outside of area precast
                //run back into region then release spell ability
                if (m_Caster != null && target != null && m_Caster.Spell != null && m_Caster.Region != target.Region && regstone != null && (regstone.IsRestrictedSpell(m_Caster.Spell, m_Caster) || regstone.IsMagicIsolated) && m_Caster.AccessLevel == AccessLevel.Player && ((m_Caster is BaseCreature && !regstone.RestrictCreatureMagic) || m_Caster is PlayerMobile))
                {
                    m_State = SpellState.None;
                    if (m_Caster.Spell == this)
                    {
                        m_Caster.Spell = null;
                    }
                    Targeting.Target.Cancel(m_Caster);
                    m_Caster.SendMessage("You cannot cast your spell into that area.");
                    return(false);
                }
            }
            catch (NullReferenceException e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("{0} Caught exception.", e);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }

            if (!target.Alive)
            {
                m_Caster.SendLocalizedMessage(501857);                 // This spell won't work on that!
                return(false);
            }
            else if (Caster.CanBeHarmful(target) && CheckSequence())
            {
                Caster.DoHarmful(target);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the kin city.
        /// </summary>
        /// <param name="i">The i.</param>
        /// <returns></returns>
        public static KinCityRegion GetKinCityAt(Item i)
        {
            CustomRegion c = CustomRegion.FindDRDTRegion(i, i.Location);

            if (c is KinCityRegion)
            {
                return((KinCityRegion)c);
            }

            return(null);
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the kin city
        /// </summary>
        /// <param name="m">The m.</param>
        /// <returns></returns>
        public static KinCityRegion GetKinCityAt(Map map, Point3D point)
        {
            CustomRegion c = CustomRegion.FindDRDTRegion(map, point);

            if (c is KinCityRegion)
            {
                return((KinCityRegion)c);
            }

            return(null);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the kin city
        /// </summary>
        /// <param name="m">The m.</param>
        /// <returns></returns>
        public static KinCityRegion GetKinCityAt(Mobile m)
        {
            CustomRegion c = CustomRegion.FindDRDTRegion(m);

            if (c is KinCityRegion)
            {
                return((KinCityRegion)c);
            }

            return(null);
        }
Esempio n. 8
0
        public void NotifyOfDamager(Mobile damager)
        {
            if (damager == null)
            {
                return;                              //safety
            }
            Point3D      targetPoint = this.Location;
            CustomRegion cr          = CustomRegion.FindDRDTRegion(damager.Map, targetPoint);

            if (cr is TownshipRegion)
            {
                TownshipRegion tsr = cr as TownshipRegion;
                if (tsr != null &&
                    tsr.TStone != null &&
                    tsr.TStone.Guild != null &&
                    tsr.TStone.Guild != damager.Guild)
                {
                    // every 10 minutes we will get a message unless the damager changes.
                    //	also, township members can type .status from within the township to dump the spam queue
                    string text = string.Format("{0} at {1} is damaging your township's wall.", damager.Name, damager.Location.ToString());
                    if (tsr.IsSpam(damager, text) == false)
                    {
                        tsr.QueueSpam(damager, text);
                        tsr.TStone.Guild.GuildMessage(text);
                        try
                        {
                            string allytext = "[" + TownshipStone.GetTownshipSizeDesc(tsr.TStone.ActivityLevel) + " of the " + tsr.TStone.GuildName + "]: " + text;
                            foreach (Server.Guilds.Guild g in tsr.TStone.Guild.Allies)
                            {
                                g.GuildMessage(allytext);
                            }
                        }
                        catch (Exception exc)
                        {
                            Server.Commands.LogHelper.LogException(exc);
                        }
                    }
                    else
                    {
                        tsr.QueueSpam(damager, text);
                    }
                }
            }
        }
Esempio n. 9
0
        public static IOBAlignment GetIOBStronghold(Mobile m)
        {
            RegionControl regstone = null;
            //check if there is a DRDT region and also if were in a house and if so use the DRDT rules
            CustomRegion inHouse = null;

            inHouse = CustomRegion.FindDRDTRegion(m);

            if (inHouse != null)
            {
                regstone = inHouse.GetRegionControler();
            }

            if (regstone != null && regstone.IOBAlign != IOBAlignment.None)
            {
                return(regstone.IOBAlign);
            }

            return(GetIOBStronghold(m.Location.X, m.Location.Y));
        }
Esempio n. 10
0
        /// <summary>
        /// Determines if an area is within a capture area. (this will probably be deperecated)
        /// </summary>
        /// <param name="m">The mobile</param>
        /// <returns></returns>
        public static bool InCaptureArea(Mobile m)
        {
            if (m == null || m.Deleted)
            {
                return(false);
            }

            CustomRegion cr = CustomRegion.FindDRDTRegion(m);

            if (cr != null)
            {
                RegionControl rc = cr.GetRegionControler();
                if (rc != null)
                {
                    if (rc.CaptureArea)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 11
0
        public void NotifyOfDamager(Mobile damager)
        {
            if (damager == null)
            {
                return;                              //safety
            }
            Point3D      targetPoint = this.Location;
            CustomRegion cr          = CustomRegion.FindDRDTRegion(damager.Map, targetPoint);

            if (cr is TownshipRegion)
            {
                TownshipRegion tsr = cr as TownshipRegion;
                if (tsr != null &&
                    tsr.TStone != null &&
                    tsr.TStone.Guild != null &&
                    tsr.TStone.Guild != damager.Guild)
                {
                    tsr.TStone.Guild.GuildMessage(
                        string.Format("{0} at {1} is damaging your township's wall.",
                                      damager.Name, damager.Location.ToString()));
                }
            }
        }
Esempio n. 12
0
            public bool CheckStealing(Corpse corpse)
            {
                if (!corpse.IsCriminalAction(m_Thief))
                {
                    return(true);
                }

                try
                {
                    if (m_Thief.AccessLevel == AccessLevel.Player)
                    {
                        RegionControl regstone = null;
                        CustomRegion  reg      = null;
                        if (corpse.Deleted == false)
                        {
                            reg = CustomRegion.FindDRDTRegion(corpse);
                        }
                        if (reg != null)
                        {
                            regstone = reg.GetRegionControler();
                        }

                        // if this region does not allow looting, fail
                        if (regstone != null && regstone.BlockLooting == true)
                        {
                            return(false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Server.Commands.LogHelper.LogException(ex);
                }

                return(true);
            }
Esempio n. 13
0
        public virtual bool CheckSequence()
        {
            try
            {
                RegionControl regstone = null;
                CustomRegion  reg      = null;
                if (m_Caster != null)
                {
                    reg = CustomRegion.FindDRDTRegion(m_Caster);
                }
                if (reg != null)
                {
                    regstone = reg.GetRegionControler();
                }

                //if your in a region area spells will fail if disallowed, prevents the run outside of area precast
                //run back into region then release spell ability
                if (m_Caster != null && m_Caster.Spell != null && regstone != null && regstone.IsRestrictedSpell(m_Caster.Spell, m_Caster) && m_Caster.AccessLevel == AccessLevel.Player && ((m_Caster is BaseCreature && !regstone.RestrictCreatureMagic) || m_Caster is PlayerMobile))
                {
                    m_State = SpellState.None;
                    if (m_Caster.Spell == this)
                    {
                        m_Caster.Spell = null;
                    }
                    Targeting.Target.Cancel(m_Caster);
                    if (regstone.MagicMsgFailure == null)
                    {
                        m_Caster.SendMessage("You cannot cast that spell here.");
                    }
                    else
                    {
                        m_Caster.SendMessage(regstone.MagicMsgFailure);
                    }
                }
            }
            catch (NullReferenceException e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("{0} Caught exception.", e);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }


            int mana = ScaleMana(GetMana());

            if (m_Caster.Deleted || !m_Caster.Alive || m_Caster.Spell != this || m_State != SpellState.Sequencing)
            {
                DoFizzle();
            }
            else if (m_Scroll != null && !(m_Scroll is Runebook) && (m_Scroll.Amount <= 0 || m_Scroll.Deleted || m_Scroll.RootParent != m_Caster || (m_Scroll is BaseWand && (((BaseWand)m_Scroll).Charges <= 0 || m_Scroll.Parent != m_Caster))))
            {
                DoFizzle();
            }
            else if (!ConsumeReagents())
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502630);                 // More reagents are needed for this spell.
            }
            else if (m_Caster.Mana < mana)
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana for this spell.
            }
            else if (Core.AOS && (m_Caster.Frozen || m_Caster.Paralyzed))
            {
                m_Caster.SendLocalizedMessage(502646);                 // You cannot cast a spell while frozen.
                DoFizzle();
            }
            else if (!CheckFizzle())
            {
                m_Caster.Mana -= mana;

                if (m_Scroll is SpellScroll)
                {
                    m_Scroll.Consume();
                }
                else if (m_Scroll is BaseWand)
                {
                    ((BaseWand)m_Scroll).ConsumeCharge(m_Caster);
                }

                if (m_Scroll is BaseWand)
                {
                    bool m = m_Scroll.Movable;

                    m_Scroll.Movable = false;

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    m_Scroll.Movable = m;
                }
                else
                {
                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }
                }

                int karma = ComputeKarmaAward();

                if (karma != 0)
                {
                    Misc.Titles.AwardKarma(Caster, karma, true);
                }

                /*
                 * if ( TransformationSpell.UnderTransformation( m_Caster, typeof( VampiricEmbraceSpell ) ) )
                 * {
                 *      bool garlic = false;
                 *
                 *      for ( int i = 0; !garlic && i < m_Info.Reagents.Length; ++i )
                 *              garlic = ( m_Info.Reagents[i] == Reagent.Garlic );
                 *
                 *      if ( garlic )
                 *      {
                 *              m_Caster.SendLocalizedMessage( 1061651 ); // The garlic burns you!
                 *              AOS.Damage( m_Caster, Utility.RandomMinMax( 17, 23 ), 100, 0, 0, 0, 0 );
                 *      }
                 * }
                 */

                return(true);
            }
            else
            {
                DoFizzle();
            }

            return(false);
        }
Esempio n. 14
0
        public static bool TryPlace(Mobile from, int boardsRequired, int ingotsRequired, Item tool)
        {
            bool bReturn = false;

            if (tool.IsChildOf(from.Backpack) || tool.Parent == from)
            {
                PlayerMobile pm = from as PlayerMobile;

                if (pm != null)
                {
                    Point3D      targetPoint = from.Location;
                    CustomRegion cr          = CustomRegion.FindDRDTRegion(from.Map, targetPoint);
                    if (cr is TownshipRegion)
                    {
                        TownshipRegion tsr = cr as TownshipRegion;
                        if (tsr != null && tsr.TStone != null && tsr.TStone.Guild != null &&
                            tsr.TStone.Guild == from.Guild)
                        {
                            //for Adam, check for 100% ownership
                            if (1.0 == TownshipDeed.GetPercentageOfGuildedHousesInArea(tsr.TStone.TownshipCenter, tsr.TStone.Map, tsr.TStone.Extended ? TownshipStone.EXTENDED_RADIUS : TownshipStone.INITIAL_RADIUS, tsr.TStone.Guild, false))
                            {
                                //make sure we're not in a house, or right beside it
                                BaseHouse house             = null;
                                bool      bHouseRestriction = false;

                                //find all the houses within 5 tiles of this location
                                int radius = 5;
                                Dictionary <BaseHouse, int> houseDict = new Dictionary <BaseHouse, int>();

                                for (int i = radius * -1; i <= radius && house == null; i++)
                                {
                                    for (int j = radius * -1; j <= radius && house == null; j++)
                                    {
                                        Point3D currentCheck = new Point3D(targetPoint.X + i, targetPoint.Y + j, targetPoint.Z);

                                        //skip point-in-township test if we're checking a point right next to where we want to place
                                        if (!((i <= 1 && i >= -1) && (j <= 1 && j >= -1)))
                                        {
                                            //ensure that the point we're checking is actually in the township
                                            if (!tsr.IsPointInTownship(currentCheck))
                                            {
                                                continue;
                                            }
                                        }

                                        house = BaseHouse.FindHouseAt(currentCheck, from.Map, 16);
                                        if (house != null)
                                        {
                                            int distance = (int)Math.Sqrt(sqr(currentCheck.X - targetPoint.X) + sqr(currentCheck.Y - targetPoint.Y));
                                            if (houseDict.ContainsKey(house))
                                            {
                                                int saveddistance = houseDict[house];
                                                if (saveddistance > distance)
                                                {
                                                    houseDict[house] = distance;
                                                }
                                            }
                                            else
                                            {
                                                houseDict.Add(house, distance);
                                            }
                                        }
                                    }
                                }

                                //now we have a list of all houses within the radius from the point where the wall is to be built and their distance from the point
                                foreach (BaseHouse h in houseDict.Keys)
                                {
                                    if (h.Owner != null)
                                    {
                                        if (tsr.TStone.Guild.IsMember(h.Owner) == false && houseDict[h] <= 5.0)
                                        {
                                            bHouseRestriction = true;
                                            break;
                                        }
                                        //										else if (houseDict[h] <= 1.0)
                                        //										{
                                        //											bHouseRestriction = true;
                                        //											break;
                                        //										}
                                    }
                                }

                                if (bHouseRestriction == false)
                                {
                                    //next check for teleporters
                                    bool bTeleporterRestriction   = false;
                                    int  iTeleporterDistanceRange = TownshipSettings.WallTeleporterDistance;

                                    IPooledEnumerable itemlist = from.Map.GetItemsInRange(targetPoint, iTeleporterDistanceRange);
                                    foreach (Item item in itemlist)
                                    {
                                        if (item is Teleporter)
                                        {
                                            bTeleporterRestriction = true;
                                            break;
                                        }
                                    }
                                    itemlist.Free();


                                    if (bTeleporterRestriction == false)
                                    {
                                        bool   hasResources = false;
                                        Item[] boards       = from.Backpack.FindItemsByType(typeof(Board), true);
                                        Item[] ingots       = from.Backpack.FindItemsByType(typeof(IronIngot), true);

                                        int boardCount = 0;
                                        int ingotCount = 0;
                                        for (int i = 0; i < boards.Length; i++)
                                        {
                                            boardCount += boards[i].Amount;
                                        }
                                        for (int i = 0; i < ingots.Length; i++)
                                        {
                                            ingotCount += ingots[i].Amount;
                                        }

                                        hasResources = (boardCount >= boardsRequired) && (ingotCount >= ingotsRequired);

                                        if (hasResources)
                                        {
                                            from.Backpack.ConsumeTotal(typeof(Board), boardsRequired);
                                            from.Backpack.ConsumeTotal(typeof(IronIngot), ingotsRequired);
                                            //from.SendMessage("You place the wall.");

                                            bReturn = true;
                                        }
                                        else
                                        {
                                            from.SendMessage("You don't have the resources to build this wall.");
                                            from.SendMessage("You need {0} boards and {1} iron ingots.", boardsRequired, ingotsRequired);
                                        }
                                    }
                                    else
                                    {
                                        from.SendMessage("You can't place this here.");
                                        from.SendMessage("Certain areas are restricted from placement because they would block normal transportation and entrances/exits.");
                                    }
                                }
                                else
                                {
                                    from.SendMessage("You can't place this in or by a house.");
                                    from.SendMessage("You can place outside of one tile from a house that the township owns,");
                                    from.SendMessage("but not within 6 tiles of a house that the township doesn't own.");
                                }
                            }
                            else
                            {
                                from.SendMessage("Your guild must own all houses in this township to build fortifications..");
                            }
                        }
                        else
                        {
                            from.SendMessage("You must place this within the township that your guild owns.");
                        }
                    }
                    else
                    {
                        from.SendMessage("You must place this within the township that your guild owns.");
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(1042001);                 // That must be in your pack for you to use it.
            }

            return(bReturn);
        }