Esempio n. 1
0
        public void Capture(Faction f)
        {
            f.Silver += SilverCaptureBonus;

            if (m_State.Owner == f)
            {
                return;
            }

            if (m_State.Owner == null)               // going from unowned to owned
            {
                LastIncome = DateTime.Now;
            }
            else if (f == null)               // going from owned to unowned
            {
                LastIncome = DateTime.MinValue;
            }
            // otherwise changing hands, income timer doesn't change

            m_State.Owner = f;

            Sheriff = null;
            Finance = null;

            TownMonolith monolith = this.Monolith;

            if (monolith != null)
            {
                monolith.Faction = f;
            }

            VendorListCollection vendorLists = VendorLists;

            for (int i = 0; i < vendorLists.Count; ++i)
            {
                VendorList vendorList           = vendorLists[i];
                FactionVendorCollection vendors = vendorList.Vendors;

                for (int j = vendors.Count - 1; j >= 0; --j)
                {
                    vendors[j].Delete();
                }
            }

            GuardListCollection guardLists = GuardLists;

            for (int i = 0; i < guardLists.Count; ++i)
            {
                GuardList guardList           = guardLists[i];
                FactionGuardCollection guards = guardList.Guards;

                for (int j = guards.Count - 1; j >= 0; --j)
                {
                    guards[j].Delete();
                }
            }

            ConstructGuardLists();
        }
Esempio n. 2
0
		public static void Generate( Town town )
		{
			Map facet = Faction.Facet;

			TownDefinition def = town.Definition;

			if ( !CheckExistance( def.Monolith, facet, typeof( TownMonolith ) ) )
			{
				TownMonolith mono = new TownMonolith( town );
				mono.MoveToWorld( def.Monolith, facet );
				mono.Sigil = new Sigil( town );
			}

			if ( !CheckExistance( def.TownStone, facet, typeof( TownStone ) ) )
				new TownStone( town ).MoveToWorld( def.TownStone, facet );
		}
Esempio n. 3
0
        public static void Generate(Town town)
        {
            var facet = Faction.Facet;

            var def = town.Definition;

            if (!CheckExistence(def.Monolith, facet, typeof(TownMonolith)))
            {
                var mono = new TownMonolith(town);
                mono.MoveToWorld(def.Monolith, facet);
                mono.Sigil = new Sigil(town);
            }

            if (!CheckExistence(def.TownStone, facet, typeof(TownStone)))
            {
                new TownStone(town).MoveToWorld(def.TownStone, facet);
            }
        }
Esempio n. 4
0
        // jakob, added this command
        public static void ResetFactionTowns_OnCommand(CommandEventArgs e)
        {
            List <Sigil> sigils = Sigil.Sigils;

            foreach (Sigil sigil in sigils)
            {
                Town         town = sigil.Town;
                TownMonolith m    = town.Monolith;
                m.Sigil               = sigil;
                sigil.LastMonolith    = null;
                sigil.Corrupting      = null;
                sigil.CorruptionStart = DateTime.MinValue;
                town.Capture(null);
                sigil.Corrupted         = null;
                sigil.PurificationStart = DateTime.MinValue;
            }

            e.Mobile.SendMessage("Faction towns are now reset. ;-)");
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                if (reader.ReadBool())
                {
                    m_Monolith = (TownMonolith)reader.ReadItem();
                }

                break;
            }
            }

            UpdateHue();
        }
Esempio n. 6
0
        public static void Generate(Town town)
        {
            Map facet = Faction.Facet;

            TownDefinition def = town.Definition;

            if (!CheckExistance(def.Monolith, facet, typeof(TownMonolith)))
            {
                TownMonolith mono = new TownMonolith(town);
                mono.MoveToWorld(def.Monolith, facet);
                mono.Sigil = new Sigil(town);
                WeakEntityCollection.Add("factions", mono);
                WeakEntityCollection.Add("factions", mono.Sigil);
            }

            if (!CheckExistance(def.TownStone, facet, typeof(TownStone)))
            {
                TownStone stone = new TownStone(town);
                WeakEntityCollection.Add("factions", stone);
                stone.MoveToWorld(def.TownStone, facet);
            }
        }
Esempio n. 7
0
        public static void Generate(Town town)
        {
            Map facet = Faction.Facet;

            TownDefinition def = town.Definition;

            if (!CheckExistance(def.Monolith, facet, typeof(TownMonolith)))
            {
                TownMonolith mono = new TownMonolith(town);
                mono.MoveToWorld(def.Monolith, facet);
                mono.Sigil = new Sigil(town);
				WeakEntityCollection.Add("factions", mono);
				WeakEntityCollection.Add("factions", mono.Sigil);
			}

			if (!CheckExistance(def.TownStone, facet, typeof(TownStone)))
			{
				TownStone stone = new TownStone(town);
				WeakEntityCollection.Add("factions", stone);
				stone.MoveToWorld(def.TownStone, facet);
			}
        }
Esempio n. 8
0
        private void Sigil_OnTarget(Mobile from, object obj)
        {
            if (Deleted || !IsChildOf(from.Backpack))
            {
                return;
            }

            #region Give To Mobile
            if (obj is Mobile)
            {
                if (obj is PlayerMobile)
                {
                    PlayerMobile targ = (PlayerMobile)obj;

                    Faction toFaction   = Faction.Find(targ);
                    Faction fromFaction = Faction.Find(from);

                    if (toFaction == null)
                    {
                        from.SendLocalizedMessage(1005223); // You cannot give the sigil to someone not in a faction
                    }
                    else if (fromFaction != toFaction)
                    {
                        from.SendLocalizedMessage(1005222); // You cannot give the sigil to someone not in your faction
                    }
                    else if (Sigil.ExistsOn(targ))
                    {
                        from.SendLocalizedMessage(1005220); // You cannot give this sigil to someone who already has a sigil
                    }
                    else if (!targ.Alive)
                    {
                        from.SendLocalizedMessage(1042248); // You cannot give a sigil to a dead person.
                    }
                    else if (from.NetState != null && targ.NetState != null)
                    {
                        Container pack = targ.Backpack;

                        if (pack != null)
                        {
                            pack.DropItem(this);
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1005221); //You cannot give the sigil to them
                }
            }
            #endregion
            else if (obj is BaseMonolith)
            {
                #region Put in Stronghold
                if (obj is StrongholdMonolith)
                {
                    StrongholdMonolith m = (StrongholdMonolith)obj;

                    if (m.Faction == null || m.Faction != Faction.Find(from))
                    {
                        from.SendLocalizedMessage(1042246); // You can't place that on an enemy monolith
                    }
                    else if (m.Town == null || m.Town != m_Town)
                    {
                        from.SendLocalizedMessage(1042247); // That is not the correct faction monolith
                    }
                    else
                    {
                        m.Sigil = this;

                        Faction newController = m.Faction;
                        Faction oldController = m_Corrupting;

                        if (oldController == null)
                        {
                            if (m_Corrupted != newController)
                            {
                                BeginCorrupting(newController);
                            }
                        }
                        else if (m_GraceStart > DateTime.MinValue && (m_GraceStart + CorruptionGrace) < DateTime.UtcNow)
                        {
                            if (m_Corrupted != newController)
                            {
                                BeginCorrupting(newController); // grace time over, reset period
                            }
                            else
                            {
                                ClearCorrupting();
                            }

                            m_GraceStart = DateTime.MinValue;
                        }
                        else if (newController == oldController)
                        {
                            m_GraceStart = DateTime.MinValue; // returned within grace period
                        }
                        else if (m_GraceStart == DateTime.MinValue)
                        {
                            m_GraceStart = DateTime.UtcNow;
                        }

                        m_PurificationStart = DateTime.MinValue;
                    }
                }
                #endregion
                #region Put in Town
                else if (obj is TownMonolith)
                {
                    TownMonolith m = (TownMonolith)obj;

                    if (m.Town == null || m.Town != m_Town)
                    {
                        from.SendLocalizedMessage(1042245); // This is not the correct town sigil monolith
                    }
                    else if (m_Corrupted == null || m_Corrupted != Faction.Find(from))
                    {
                        from.SendLocalizedMessage(1042244); // Your faction did not corrupt this sigil.  Take it to your stronghold.
                    }
                    else
                    {
                        m.Sigil = this;

                        m_Corrupting        = null;
                        m_PurificationStart = DateTime.UtcNow;
                        m_CorruptionStart   = DateTime.MinValue;

                        m_Town.Capture(m_Corrupted);
                        m_Corrupted = null;
                    }
                }
                #endregion
            }
            else
            {
                from.SendLocalizedMessage(1005224);     //	You can't use the sigil on that
            }

            Update();
        }
Esempio n. 9
0
        public void Capture(Faction f)
        {
            if (m_State.Owner == f)
            {
                return;
            }

            if (m_State.Owner == null)               // going from unowned to owned
            {
                LastIncome = DateTime.Now;
                f.Silver  += SilverCaptureBonus;
            }
            else if (f == null)               // going from owned to unowned
            {
                LastIncome = DateTime.MinValue;
            }
            else             // otherwise changing hands, income timer doesn't change
            {
                f.Silver += SilverCaptureBonus;
            }

            if (m_State.Owner != null && m_State.Owner != f)
            {
                if (m_State.Owner.OwnedTowns - 1 <= 2)
                {
                    m_State.Owner.DeputyCommander = null;
                }
            }

            m_State.Owner = f;

            Sheriff = null;
            Finance = null;

            TownMonolith monolith = this.Monolith;

            if (monolith != null)
            {
                monolith.Faction = f;
            }

            List <VendorList> vendorLists = VendorLists;

            for (int i = 0; i < vendorLists.Count; ++i)
            {
                VendorList vendorList            = vendorLists[i];
                List <BaseFactionVendor> vendors = vendorList.Vendors;

                for (int j = vendors.Count - 1; j >= 0; --j)
                {
                    vendors[j].Delete();
                }
            }

            List <GuardList> guardLists = GuardLists;

            for (int i = 0; i < guardLists.Count; ++i)
            {
                GuardList guardList            = guardLists[i];
                List <BaseFactionGuard> guards = guardList.Guards;

                for (int j = guards.Count - 1; j >= 0; --j)
                {
                    guards[j].Delete();
                }
            }

            ConstructGuardLists();
        }
Esempio n. 10
0
        private void Sigil_OnTarget(Mobile from, object obj)
        {
            if (Deleted || !IsChildOf(from.Backpack))
            {
                return;
            }

            #region Give To Mobile
            if (obj is Mobile)
            {
                if (obj is PlayerMobile)
                {
                    PlayerMobile targ = (PlayerMobile)obj;

                    Faction toFaction   = Faction.Find(targ);
                    Faction fromFaction = Faction.Find(from);

                    if (toFaction == null)
                    {
                        from.SendLocalizedMessage(1005223);                           // You cannot give the sigil to someone not in a faction
                    }
                    else if (fromFaction != toFaction)
                    {
                        from.SendLocalizedMessage(1005222);                           // You cannot give the sigil to someone not in your faction
                    }
                    else if (Sigil.ExistsOn(targ))
                    {
                        from.SendLocalizedMessage(1005220);                           // You cannot give this sigil to someone who already has a sigil
                    }
                    else if (!targ.Alive)
                    {
                        from.SendLocalizedMessage(1042248);                           // You cannot give a sigil to a dead person.
                    }
                    else if (from.NetState != null && targ.NetState != null)
                    {
                        Container pack = targ.Backpack;

                        if (pack != null)
                        {
                            pack.DropItem(this);
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1005221);                       //You cannot give the sigil to them
                }
            }
            #endregion
            else if (obj is BaseMonolith)
            {
                #region Put in Stronghold
                if (obj is StrongholdMonolith)
                {
                    StrongholdMonolith m = (StrongholdMonolith)obj;

                    if (m.Faction == null || m.Faction != Faction.Find(from))
                    {
                        from.SendLocalizedMessage(1042246);                           // You can't place that on an enemy monolith
                    }
                    else if (m.Town == null || m.Town != m_Town)
                    {
                        from.SendLocalizedMessage(1042247);                           // That is not the correct faction monolith
                    }
                    else
                    {
                        m.Sigil = this;

                        Faction newController = m.Faction;
                        Faction oldController = m_Corrupting;

                        if (m_OriginalThief != null && newController != PlayerState.Find(m_OriginalThief).Faction)
                        {
                            UpdateThief(null);
                        }

                        if (oldController == null)
                        {
                            if (m_Corrupted != newController)
                            {
                                BeginCorrupting(newController);
                            }
                        }
                        else if (m_GraceStart > DateTime.MinValue && (m_GraceStart + CorruptionGrace) < DateTime.UtcNow)
                        {
                            if (m_Corrupted != newController)
                            {
                                BeginCorrupting(newController);                                   // grace time over, reset period
                            }
                            else
                            {
                                ClearCorrupting();
                            }

                            m_GraceStart = DateTime.MinValue;
                        }
                        else if (newController == oldController)
                        {
                            m_GraceStart = DateTime.MinValue;                             // returned within grace period
                        }
                        else if (m_GraceStart == DateTime.MinValue)
                        {
                            m_GraceStart = DateTime.UtcNow;
                        }

                        m_PurificationStart = DateTime.MinValue;
                    }
                }
                #endregion
                #region Put in Town
                else if (obj is TownMonolith)
                {
                    TownMonolith m = (TownMonolith)obj;

                    if (m.Town == null || m.Town != m_Town)
                    {
                        from.SendLocalizedMessage(1042245);                           // This is not the correct town sigil monolith
                    }
                    else if (m_Corrupted == null || m_Corrupted != Faction.Find(from))
                    {
                        from.SendLocalizedMessage(1042244);                           // Your faction did not corrupt this sigil.  Take it to your stronghold.
                    }
                    else
                    {
                        m.Sigil = this;

                        m_Corrupting        = null;
                        m_PurificationStart = DateTime.UtcNow;
                        m_CorruptionStart   = DateTime.MinValue;

                        bool isTownAlreadyOwned = (m_Town.Owner == m_Corrupted);

                        m_Town.Capture(m_Corrupted);

                        m_Corrupted = null;

                        if (!isTownAlreadyOwned && m_OriginalThief != null && m_OriginalThief.NetState != null)
                        {
                            int punkte = 10;
                            int silver = 750;

                            PlayerState ps = PlayerState.Find(m_OriginalThief);
                            Faction     deliverersfaction     = Faction.Find(from);
                            Faction     originalthiefsfaction = Faction.Find(m_OriginalThief);

                            if (ps != null && deliverersfaction == originalthiefsfaction)
                            {
                                ps.KillPoints += punkte;
                                ps.Faction.AwardSilver(m_OriginalThief, silver);

                                string args = String.Format("{0}\t{1}", punkte, silver);
                                m_OriginalThief.SendLocalizedMessage(1094922, args);                                   // Thine heroic efforts in capturing the sigil has yielded ~1_POINTS~ kill points and ~2_SILVER~ silver.
                            }
                        }

                        m_OriginalThief = null;
                        m_PreviousThief = null;
                    }
                }
                #endregion
            }
            else
            {
                from.SendLocalizedMessage(1005224);                   //	You can't use the sigil on that
            }

            Update();
        }
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 0:
				{
					if ( reader.ReadBool() )
						m_Monolith = (TownMonolith)reader.ReadItem();

					break;
				}
			}

			UpdateHue();
		}