Пример #1
0
        public override void OnDoubleClick(Mobile from)
        {
            Faction faction = Faction.Find(from);

            if (faction == null)
            {
                from.SendLocalizedMessage(1010353, "", 0x23);                   // Only faction members may place faction traps
            }
            else if (faction != m_Faction)
            {
                from.SendLocalizedMessage(1010354, "", 0x23);                   // You may only place faction traps created by your faction
            }
            else if (faction.Traps.Count >= faction.MaximumTraps)
            {
                from.SendLocalizedMessage(1010358, "", 0x23);                   // Your faction already has the maximum number of traps placed
            }
            else
            {
                BaseFactionTrap trap = Construct(from);

                if (trap == null)
                {
                    return;
                }

                int message = trap.IsValidLocation(from.Location, from.Map);

                if (message > 0)
                {
                    from.SendLocalizedMessage(message, "", 0x23);
                    trap.Delete();
                }
                else
                {
                    //addon begin
                    bool nearbytraps          = false;
                    IPooledEnumerable inRange = from.Map.GetItemsInRange(from.Location, 1);
                    foreach (Item trg in inRange)
                    {
                        if (trg is BaseFactionTrap)
                        {
                            from.SendMessage("You cannot place a trap this close to another trap.");
                            trap.Delete();
                            nearbytraps = true;
                            break;
                        }
                    }
                    inRange.Free();
                    //addon end
                    if (!nearbytraps)
                    {
                        from.SendLocalizedMessage(1010360);                           // You arm the trap and carefully hide it from view
                        trap.MoveToWorld(from.Location, from.Map);
                        faction.Traps.Add(trap);
                        Delete();
                    }
                }
            }
        }
Пример #2
0
        public override void OnDoubleClick(Mobile from)
        {
            Faction faction = Faction.Find(from);

            if (faction == null)
            {
                from.SendLocalizedMessage(1010353, "", 0x23); // Only faction members may place faction traps
            }
            else if (faction != this.m_Faction)
            {
                from.SendLocalizedMessage(1010354, "", 0x23); // You may only place faction traps created by your faction
            }
            else if (faction.Traps.Count >= faction.MaximumTraps)
            {
                from.SendLocalizedMessage(1010358, "", 0x23); // Your faction already has the maximum number of traps placed
            }
            else
            {
                BaseFactionTrap trap = this.Construct(from);

                if (trap == null)
                {
                    return;
                }

                int message = trap.IsValidLocation(from.Location, from.Map);

                if (message > 0)
                {
                    from.SendLocalizedMessage(message, "", 0x23);
                    trap.Delete();
                }
                else
                {
                    from.SendLocalizedMessage(1010360); // You arm the trap and carefully hide it from view
                    trap.MoveToWorld(from.Location, from.Map);
                    faction.Traps.Add(trap);
                    this.Delete();
                }
            }
        }
        public override void OnDoubleClick(Mobile from)
        {
            Faction faction = Faction.Find(from);

            if (faction == null)
            {
                from.SendAsciiMessage(0x23, "Only faction members may place faction traps.");
            }
            else if (faction != m_Faction)
            {
                from.SendAsciiMessage(0x23, "You may only place faction traps created by your faction.");
            }
            else if (faction.Traps.Count >= faction.MaximumTraps)
            {
                from.SendAsciiMessage(0x23, "Your faction already has the maximum number of traps placed.");
            }
            else
            {
                BaseFactionTrap trap = Construct(from);

                if (trap == null)
                {
                    return;
                }

                string message = trap.IsValidLocation(from.Location, from.Map);

                if (message != "")
                {
                    from.SendAsciiMessage(0x23, message);
                    trap.Delete();
                }
                else
                {
                    from.SendAsciiMessage("You arm the trap and carefully hide it from view.");
                    trap.MoveToWorld(from.Location, from.Map);
                    faction.Traps.Add(trap);
                    Delete();
                }
            }
        }
        public override void OnDoubleClick(Mobile from)
        {
            BaseFactionTrap trap = Construct(from);

            if (trap == null)
            {
                return;
            }

            int message = trap.IsValidLocation(from.Location, from.Map);

            if (message > 0)
            {
                from.SendLocalizedMessage(message, "", 0x23);
                trap.Delete();
            }
            else
            {
                from.SendLocalizedMessage(1010360);                   // You arm the trap and carefully hide it from view
                trap.MoveToWorld(from.Location, from.Map);
                Delete();
            }
        }
Пример #5
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 5:
            {
                m_LastAtrophy = reader.ReadDateTime();
                goto case 4;
            }

            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                m_Election = new Election(reader);

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                m_Commander = reader.ReadMobile();

                if (version < 5)
                {
                    m_LastAtrophy = DateTime.UtcNow;
                }

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new List <PlayerState>();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        m_Members.Add(pl);
                    }
                }

                m_Faction.State = this;

                m_Faction.ZeroRankOffset = m_Members.Count;
                m_Members.Sort();

                for (int i = m_Members.Count - 1; i >= 0; i--)
                {
                    PlayerState player = m_Members[i];

                    if (player.KillPoints <= 0)
                    {
                        m_Faction.ZeroRankOffset = i;
                    }
                    else
                    {
                        player.RankIndex = i;
                    }
                }

                m_FactionItems = new List <FactionItem>();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach));         // sandbox attachment
                    }
                }

                m_FactionTraps = new List <BaseFactionTrap>();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            m_FactionTraps.Add(trap);
                        }
                    }
                }

                break;
            }
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }
Пример #6
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                m_Election = new Election(reader);

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                m_Commander = reader.ReadMobile();

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new PlayerStateCollection();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        m_Members.Add(pl);
                    }
                }

                m_Faction.State = this;
                m_Faction.UpdateRanks();

                m_FactionItems = new FactionItemCollection();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        if (!factionItem.HasExpired)
                        {
                            factionItem.Attach();
                        }
                        else
                        {
                            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.Detach));                                         // sandbox detachment
                        }
                    }
                }

                m_FactionTraps = new FactionTrapCollection();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            m_FactionTraps.Add(trap);
                        }
                    }
                }

                break;
            }
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }
Пример #7
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 6:
            case 5:
            {
                m_LastAtrophy = reader.ReadDateTime();
                goto case 4;
            }

            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                Election ele = new Election(reader);

                if (Settings.Enabled)
                {
                    m_Election = ele;
                }
                else
                {
                    m_Election = new Election(m_Faction);
                }

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                if (m_Election.Faction == null)
                {
                    m_Election.Faction = m_Faction;
                }

                m_Commander = reader.ReadMobile();

                if (version < 5)
                {
                    m_LastAtrophy = DateTime.UtcNow;
                }

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new List <PlayerState>();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        if (Settings.Enabled)
                        {
                            m_Members.Add(pl);
                        }
                        else
                        {
                            Settings.AddDisabledNotice(pl.Mobile);
                        }
                    }
                }

                m_Faction.State = this;

                m_Faction.ZeroRankOffset = m_Members.Count;
                m_Members.Sort();

                for (int i = m_Members.Count - 1; i >= 0; i--)
                {
                    PlayerState player = m_Members[i];

                    if (player.KillPoints <= 0)
                    {
                        m_Faction.ZeroRankOffset = i;
                    }
                    else
                    {
                        player.RankIndex = i;
                    }
                }

                m_FactionItems = new List <FactionItem>();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        if (Settings.Enabled)
                        {
                            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach));         // sandbox attachment
                        }
                    }
                }

                m_FactionTraps = new List <BaseFactionTrap>();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            if (Settings.Enabled)
                            {
                                m_FactionTraps.Add(trap);
                            }
                            else
                            {
                                trap.Delete();
                            }
                        }
                    }
                }

                break;
            }
            }

            if (version < 6 && Settings.Enabled && Core.ML)
            {
                FactionCollectionBox box = new FactionCollectionBox(m_Faction);
                WeakEntityCollection.Add("factions", box);
                box.MoveToWorld(m_Faction.Definition.Stronghold.CollectionBox, Faction.Facet);
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }