Exemplo n.º 1
0
        private static void ProcessTypes()
        {
            m_Factions = new FactionCollection();
            m_Towns    = new TownCollection();

            foreach (Library l in ScriptCompiler.Libraries)
            {
                Type[] types = l.TypeCache.Types;

                for (int j = 0; j < types.Length; ++j)
                {
                    Type type = types[j];

                    if (type.IsSubclassOf(typeof(Faction)))
                    {
                        Faction faction = Construct(type) as Faction;

                        if (faction != null)
                        {
                            Faction.Factions.Add(faction);
                        }
                    }
                    else if (type.IsSubclassOf(typeof(Town)))
                    {
                        Town town = Construct(type) as Town;

                        if (town != null)
                        {
                            Town.Towns.Add(town);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void FactionTownReset_OnCommand(CommandEventArgs e)
        {
            MonolithCollection monoliths = BaseMonolith.Monoliths;

            for (int i = 0; i < monoliths.Count; ++i)
            {
                monoliths[i].Sigil = null;
            }

            TownCollection towns = Town.Towns;

            for (int i = 0; i < towns.Count; ++i)
            {
                towns[i].Silver  = 0;
                towns[i].Sheriff = null;
                towns[i].Finance = null;
                towns[i].Tax     = 0;
                towns[i].Owner   = null;
            }

            SigilCollection sigils = Sigil.Sigils;

            for (int i = 0; i < sigils.Count; ++i)
            {
                sigils[i].Corrupted         = null;
                sigils[i].Corrupting        = null;
                sigils[i].LastStolen        = DateTime.MinValue;
                sigils[i].GraceStart        = DateTime.MinValue;
                sigils[i].CorruptionStart   = DateTime.MinValue;
                sigils[i].PurificationStart = DateTime.MinValue;
                sigils[i].LastMonolith      = null;
                sigils[i].ReturnHome();
            }

            FactionCollection factions = Faction.Factions;

            for (int i = 0; i < factions.Count; ++i)
            {
                Faction f = factions[i];

                ArrayList list = new ArrayList(f.State.FactionItems);

                for (int j = 0; j < list.Count; ++j)
                {
                    FactionItem fi = (FactionItem)list[j];

                    if (fi.Expiration == DateTime.MinValue)
                    {
                        fi.Item.Delete();
                    }
                    else
                    {
                        fi.Detach();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static Faction Parse(string name)
        {
            FactionCollection factions = Factions;

            for (int i = 0; i < factions.Count; ++i)
            {
                Faction faction = factions[i];

                if (Insensitive.Equals(faction.Definition.FriendlyName, name))
                {
                    return(faction);
                }
            }

            return(null);
        }
Exemplo n.º 4
0
        public static bool StabilityActive()
        {
            FactionCollection factions = Factions;

            for (int i = 0; i < factions.Count; ++i)
            {
                Faction faction = factions[i];

                if (faction.Members.Count > StabilityActivation)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 5
0
        public const int StabilityActivation = 200;     // Stablity code goes into effect when largest faction has > 200 people

        public static Faction FindSmallestFaction()
        {
            FactionCollection factions = Factions;
            Faction           smallest = null;

            for (int i = 0; i < factions.Count; ++i)
            {
                Faction faction = factions[i];

                if (smallest == null || faction.Members.Count < smallest.Members.Count)
                {
                    smallest = faction;
                }
            }

            return(smallest);
        }
Exemplo n.º 6
0
        public static void GenerateFactions_OnCommand(CommandEventArgs e)
        {
            new FactionPersistance();

            FactionCollection factions = Faction.Factions;

            foreach (Faction faction in factions)
            {
                Generate(faction);
            }

            TownCollection towns = Town.Towns;

            foreach (Town town in towns)
            {
                Generate(town);
            }
        }
Exemplo n.º 7
0
        private static void ProcessTypes()
        {
            m_Factions = new FactionCollection();

            m_Factions.Add(new CouncilOfMages());
            m_Factions.Add(new Minax());
            m_Factions.Add(new Shadowlords());
            m_Factions.Add(new TrueBritannians());

            m_Towns = new TownCollection();

            m_Towns.Add(new Britain());
            m_Towns.Add(new Magincia());
            m_Towns.Add(new Minoc());
            m_Towns.Add(new Moonglow());
            m_Towns.Add(new SkaraBrae());
            m_Towns.Add(new Trinsic());
            m_Towns.Add(new Vesper());
            m_Towns.Add(new Yew());
        }
        private static void ProcessTypes()
        {
            m_Factions = new FactionCollection();
            m_Towns    = new TownCollection();

            Assembly[] asms = ScriptCompiler.Assemblies;

            for (int i = 0; i < asms.Length; ++i)
            {
                Assembly  asm   = asms[i];
                TypeCache tc    = ScriptCompiler.GetTypeCache(asm);
                Type[]    types = tc.Types;

                for (int j = 0; j < types.Length; ++j)
                {
                    Type type = types[j];

                    if (type.IsSubclassOf(typeof(Faction)))
                    {
                        Faction faction = Construct(type) as Faction;

                        if (faction != null)
                        {
                            Faction.Factions.Add(faction);
                        }
                    }
                    else if (type.IsSubclassOf(typeof(Town)))
                    {
                        Town town = Construct(type) as Town;

                        if (town != null)
                        {
                            Town.Towns.Add(town);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0);                // version

            FactionCollection factions = Faction.Factions;

            for (int i = 0; i < factions.Count; ++i)
            {
                writer.WriteEncodedInt((int)PersistedType.Faction);
                factions[i].State.Serialize(writer);
            }

            TownCollection towns = Town.Towns;

            for (int i = 0; i < towns.Count; ++i)
            {
                writer.WriteEncodedInt((int)PersistedType.Town);
                towns[i].State.Serialize(writer);
            }

            writer.WriteEncodedInt((int)PersistedType.Terminator);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Default constructor for enumerator.
 /// </summary>
 /// <param name="collection">Instance of the collection to enumerate.</param>
 internal FactionCollectionEnumerator(FactionCollection collection)
 {
     _index = -1;
     _collection = collection;
 }
Exemplo n.º 11
0
        private static void ProcessTypes()
        {
            m_Factions = new FactionCollection();
            m_Towns = new TownCollection();

            Assembly[] asms = ScriptCompiler.Assemblies;

            for ( int i = 0; i < asms.Length; ++i )
            {
                Assembly asm = asms[i];
                TypeCache tc = ScriptCompiler.GetTypeCache( asm );
                Type[] types = tc.Types;

                for ( int j = 0; j < types.Length; ++j )
                {
                    Type type = types[j];

                    if ( type.IsSubclassOf( typeof( Faction ) ) )
                    {
                        Faction faction = Construct( type ) as Faction;

                        if ( faction != null )
                            Faction.Factions.Add( faction );
                    }
                    else if ( type.IsSubclassOf( typeof( Town ) ) )
                    {
                        Town town = Construct( type ) as Town;

                        if ( town != null )
                            Town.Towns.Add( town );
                    }
                }
            }
        }
Exemplo n.º 12
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            base.OnSpeech(e);

            Mobile from = e.Mobile;

            if (!e.Handled && InRange(from, ListenRange) && from.Alive)
            {
                if (e.HasKeyword(0xE6) && (Insensitive.Equals(e.Speech, "orders") || WasNamed(e.Speech)))                         // *orders*
                {
                    if (m_Town == null || !m_Town.IsSheriff(from))
                    {
                        this.Say(1042189);                           // I don't work for you!
                    }
                    else if (Town.FromRegion(this.Region) == m_Town)
                    {
                        this.Say(1042180);                           // Your orders, sire?
                        m_OrdersEnd = Core.Now + TimeSpan.FromSeconds(10.0);
                    }
                }
                else if (Core.Now < m_OrdersEnd)
                {
                    if (m_Town != null && m_Town.IsSheriff(from) && Town.FromRegion(this.Region) == m_Town)
                    {
                        m_OrdersEnd = Core.Now + TimeSpan.FromSeconds(10.0);

                        bool         understood = true;
                        ReactionType newType    = 0;

                        if (Insensitive.Contains(e.Speech, "attack"))
                        {
                            newType = ReactionType.Attack;
                        }
                        else if (Insensitive.Contains(e.Speech, "warn"))
                        {
                            newType = ReactionType.Warn;
                        }
                        else if (Insensitive.Contains(e.Speech, "ignore"))
                        {
                            newType = ReactionType.Ignore;
                        }
                        else
                        {
                            understood = false;
                        }

                        if (understood)
                        {
                            understood = false;

                            if (Insensitive.Contains(e.Speech, "civil"))
                            {
                                ChangeReaction(null, newType);
                                understood = true;
                            }

                            FactionCollection factions = Faction.Factions;

                            for (int i = 0; i < factions.Count; ++i)
                            {
                                Faction faction = factions[i];

                                if (faction != m_Faction && Insensitive.Contains(e.Speech, faction.Definition.Keyword))
                                {
                                    ChangeReaction(faction, newType);
                                    understood = true;
                                }
                            }
                        }
                        else if (Insensitive.Contains(e.Speech, "patrol"))
                        {
                            Home              = Location;
                            RangeHome         = 6;
                            Combatant         = null;
                            m_Orders.Movement = MovementType.Patrol;
                            Say(1005146);                               // This spot looks like it needs protection!  I shall guard it with my life.
                            understood = true;
                        }
                        else if (Insensitive.Contains(e.Speech, "follow"))
                        {
                            Home              = Location;
                            RangeHome         = 6;
                            Combatant         = null;
                            m_Orders.Follow   = from;
                            m_Orders.Movement = MovementType.Follow;
                            Say(1005144);                               // Yes, Sire.
                            understood = true;
                        }

                        if (!understood)
                        {
                            Say(1042183);                               // I'm sorry, I don't understand your orders...
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        private static void ProcessTypes()
        {
            m_Factions = new FactionCollection();

            m_Factions.Add( new CouncilOfMages() );
            m_Factions.Add( new Minax() );
            m_Factions.Add( new Shadowlords() );
            m_Factions.Add( new TrueBritannians() );

            m_Towns = new TownCollection();

            m_Towns.Add( new Britain() );
            m_Towns.Add( new Magincia() );
            m_Towns.Add( new Minoc() );
            m_Towns.Add( new Moonglow() );
            m_Towns.Add( new SkaraBrae() );
            m_Towns.Add( new Trinsic() );
            m_Towns.Add( new Vesper() );
            m_Towns.Add( new Yew() );
        }
 /// <summary>
 /// Default constructor for enumerator.
 /// </summary>
 /// <param name="collection">Instance of the collection to enumerate.</param>
 internal FactionCollectionEnumerator(FactionCollection collection)
 {
     _index      = -1;
     _collection = collection;
 }
Exemplo n.º 15
0
        private static void ProcessTypes()
        {
            m_Factions = new FactionCollection();
            m_Towns = new TownCollection();

            foreach (Library l in ScriptCompiler.Libraries) {
                Type[] types = l.TypeCache.Types;

                for ( int j = 0; j < types.Length; ++j )
                {
                    Type type = types[j];

                    if ( type.IsSubclassOf( typeof( Faction ) ) )
                    {
                        Faction faction = Construct( type ) as Faction;

                        if ( faction != null )
                            Faction.Factions.Add( faction );
                    }
                    else if ( type.IsSubclassOf( typeof( Town ) ) )
                    {
                        Town town = Construct( type ) as Town;

                        if ( town != null )
                            Town.Towns.Add( town );
                    }
                }
            }
        }