Esempio n. 1
0
        public virtual int IsValidLocation(Point3D p, Map m)
        {
            if (m == null)
            {
                return(502956);                // You cannot place a trap on that.
            }
            if (Core.ML)
            {
                foreach (Item item in m.GetItemsInRange(p, 0))
                {
                    if (item is BaseFactionTrap && ((BaseFactionTrap)item).Faction == this.Faction)
                    {
                        return(1075263);                        // There is already a trap belonging to your faction at this location.;
                    }
                }
            }

            switch (AllowedPlacing)
            {
            case AllowedPlacing.FactionStronghold:
            {
                StrongholdRegion region = (StrongholdRegion)Region.Find(p, m).GetRegion(typeof(StrongholdRegion));

                if (region != null && region.Faction == m_Faction)
                {
                    return(0);
                }

                return(1010355);                        // This trap can only be placed in your stronghold
            }

            case AllowedPlacing.AnyFactionTown:
            {
                Town town = Town.FromRegion(Region.Find(p, m));

                if (town != null)
                {
                    return(0);
                }

                return(1010356);                        // This trap can only be placed in a faction town
            }

            case AllowedPlacing.ControlledFactionTown:
            {
                Town town = Town.FromRegion(Region.Find(p, m));

                if (town != null && town.Owner == m_Faction)
                {
                    return(0);
                }

                return(1010357);                        // This trap can only be placed in a town your faction controls
            }
            }

            return(0);
        }
Esempio n. 2
0
        public virtual int IsValidLocation(Point3D p, Map m)
        {
            //Region r = Region.Find( p, m );

            // Check if another trap exists in this point
            if (m.GetItemsAtWorldPoint(p).OfType <BaseFactionTrap>().Any())
            {
                return(1075263);                // There is already a trap belonging to your faction at this location
            }

            switch (AllowedPlacing)
            {
            case AllowedPlacing.FactionStronghold:
            {
                StrongholdRegion region = Region.Find(p, m) as StrongholdRegion;

                if (region != null && region.Faction == m_Faction)
                {
                    return(0);
                }

                return(1010355);                                // This trap can only be placed in your stronghold
            }

            case AllowedPlacing.AnyFactionTown:
            {
                Town town = Town.FromRegion(Region.Find(p, m));

                if (town != null)
                {
                    return(0);
                }

                return(1010356);                                // This trap can only be placed in a faction town
            }

            case AllowedPlacing.ControlledFactionTown:
            {
                Town town = Town.FromRegion(Region.Find(p, m));

                if (town != null && town.Owner == m_Faction)
                {
                    return(0);
                }

                return(1010357);                                // This trap can only be placed in a town your faction controls
            }
            }

            return(0);
        }
        public virtual int IsValidLocation(Point3D p, Map m)
        {
            Region r = Region.Find(p, m);

            switch (AllowedPlacing)
            {
            case AllowedPlacing.FactionStronghold:
            {
                StrongholdRegion region = Region.Find(p, m) as StrongholdRegion;

                if (region != null && region.Faction == m_Faction)
                {
                    return(0);
                }

                return(1010355);                        // This trap can only be placed in your stronghold
            }

            case AllowedPlacing.AnyFactionTown:
            {
                Town town = Town.FromRegion(Region.Find(p, m));

                if (town != null)
                {
                    return(0);
                }

                return(1010356);                        // This trap can only be placed in a faction town
            }

            case AllowedPlacing.ControlledFactionTown:
            {
                Town town = Town.FromRegion(Region.Find(p, m));

                if (town != null && town.Owner == m_Faction)
                {
                    return(0);
                }

                return(1010357);                        // This trap can only be placed in a town your faction controls
            }
            }

            return(0);
        }