コード例 #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int index = info.ButtonID - 1;

            if (index >= 0 && index < m_Values.Length)
            {
                try
                {
                    object toSet = m_Values[index];
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, (toSet == null ? "(-null-)" : toSet.ToString()));
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
        }
コード例 #2
0
            public override void OnResponse(int hue)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, hue.ToString());
                    m_Property.SetValue(m_Object, hue, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }

                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
コード例 #3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                IPoint3D p = targeted as IPoint3D;

                if (p != null)
                {
                    try
                    {
                        Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point2D(p).ToString());
                        m_Property.SetValue(m_Object, new Point2D(p), null);
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                        if (Miscellanious.ValidateLabeling(m_Object))
                        {
                            if (m_Object is Item)
                            {
                                ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                            }

                            if (m_Object is Mobile)
                            {
                                ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                            }
                        }
                    }
                    catch
                    {
                        m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                    }
                }
            }
コード例 #4
0
        public override void OnResponse(NetState sender, RelayInfo relayInfo)
        {
            int index = relayInfo.ButtonID - 1;

            if (index >= 0 && index < m_Names.Length)
            {
                try
                {
                    MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new Type[] { typeof(string) });

                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, m_Names[index]);

                    if (info != null)
                    {
                        m_Property.SetValue(m_Object, info.Invoke(null, new object[] { m_Names[index] }), null);
                    }
                    else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
                    {
                        m_Property.SetValue(m_Object, Enum.Parse(m_Property.PropertyType, m_Names[index], false), null);
                    }

                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
        }
コード例 #5
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            try
            {
                if (m_Type == typeof(Type))
                {
                    targeted = targeted.GetType();
                }
                else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) && targeted is AddonComponent)
                {
                    targeted = ((AddonComponent)targeted).Addon;
                }

                if (m_Type.IsAssignableFrom(targeted.GetType()))
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString());
                    m_Property.SetValue(m_Object, targeted, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                else
                {
                    m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name);
                }
            }
            catch
            {
                m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
            }
        }
コード例 #6
0
        public static string InternalSetValue(Mobile from, object logobj, object o, PropertyInfo p, string pname, string value, bool shouldLog)
        {
            object toSet  = null;
            string result = ConstructFromString(p.PropertyType, o, value, ref toSet);

            if (result != null)
            {
                return(result);
            }

            try
            {
                if (shouldLog)
                {
                    CommandLogging.LogChangeProperty(from, logobj, pname, value);
                }

                p.SetValue(o, toSet, null);

                if (Miscellanious.ValidateLabeling(o) && from.AccessLevel < AccessLevel.Administrator)
                {
                    if (o is Mobile)
                    {
                        (o as Mobile).Cheater_Name = String.Format("This mobile modified by GM {0}", from.Name);
                    }
                    if (o is Item)
                    {
                        (o as Item).Cheater_Name = String.Format("This item modified by GM {0}", from.Name);
                    }
                }
                return("Property has been set.");
            }
            catch
            {
                return("An exception was caught, the property may not be set.");
            }
        }
コード例 #7
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            object toSet;
            bool   shouldSet, shouldSend = true;

            switch (info.ButtonID)
            {
            case 1:
            {
                TextRelay text = info.GetTextEntry(0);

                if (text != null)
                {
                    try
                    {
                        toSet     = PropertiesGump.GetObjectFromString(m_Property.PropertyType, text.Text);
                        shouldSet = true;
                    }
                    catch
                    {
                        toSet     = null;
                        shouldSet = false;
                        m_Mobile.SendMessage("Bad format");
                    }
                }
                else
                {
                    toSet     = null;
                    shouldSet = false;
                }

                break;
            }

            case 2:                     // Null
            {
                toSet     = null;
                shouldSet = true;

                break;
            }

            case 3:                     // Hue Picker
            {
                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                m_Mobile.SendHuePicker(new InternalPicker(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));

                break;
            }

            case 4:                     // Body Picker
            {
                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));

                break;
            }

            default:
            {
                toSet     = null;
                shouldSet = false;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
コード例 #8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            TimeSpan toSet;
            bool     shouldSet, shouldSend;

            TextRelay h = info.GetTextEntry(0);
            TextRelay m = info.GetTextEntry(1);
            TextRelay s = info.GetTextEntry(2);

            switch (info.ButtonID)
            {
            case 1:                     // Zero
            {
                toSet      = TimeSpan.Zero;
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            case 2:                     // From H:M:S
            {
                if (h != null && m != null && s != null)
                {
                    try
                    {
                        toSet      = TimeSpan.Parse(h.Text + ":" + m.Text + ":" + s.Text);
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 3:                     // From H
            {
                if (h != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromHours(Utility.ToDouble(h.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 4:                     // From M
            {
                if (m != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromMinutes(Utility.ToDouble(m.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 5:                     // From S
            {
                if (s != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromSeconds(Utility.ToDouble(s.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            default:
            {
                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = true;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
コード例 #9
0
        public static void Fill(LockableContainer cont, int level)
        {
            cont.Movable = false;
            cont.Locked  = true;

            if (level == 0)
            {
                cont.LockLevel = 0;                 // Can't be unlocked

                cont.DropItem(new Gold(Utility.RandomMinMax(50, 100)));

                if (Utility.RandomDouble() < 0.75)
                {
                    cont.DropItem(new TreasureMap(0, Map.Trammel));
                }
            }
            else
            {
                cont.Enabled   = true;
                cont.TrapType  = TrapType.ExplosionTrap;
                cont.TrapPower = level * 25;

                switch (level)
                {
                case 1:
                    cont.RequiredSkill = 36;
                    break;

                case 2:
                    cont.RequiredSkill = 76;
                    break;

                case 3:
                    cont.RequiredSkill = 84;
                    break;

                case 4:
                    cont.RequiredSkill = 92;
                    break;

                case 5:
                    cont.RequiredSkill = 100;
                    break;

                case 6:
                    cont.RequiredSkill = 100;
                    break;
                }

                cont.LockLevel    = cont.RequiredSkill - 10;
                cont.MaxLockLevel = cont.RequiredSkill + 40;

                cont.DropItem(new Gold(level * 1000));

                for (int i = 0; i < level * 5; ++i)
                {
                    cont.DropItem(Loot.RandomScroll(0, 63, SpellbookType.Regular));
                }

                for (int i = 0; i < level * 6; ++i)
                {
                    Item item;

                    if (Core.AOS)
                    {
                        item = Loot.RandomArmorOrShieldOrWeaponOrJewelry();
                    }
                    else
                    {
                        item = Loot.RandomArmorOrShieldOrWeapon();
                    }

                    if (item is BaseWeapon)
                    {
                        BaseWeapon weapon = (BaseWeapon)item;

                        if (Core.AOS)
                        {
                            int attributeCount;
                            int min, max;

                            GetRandomAOSStats(out attributeCount, out min, out max);

                            BaseRunicTool.ApplyAttributesTo(weapon, attributeCount, min, max);
                        }
                        else
                        {
                            weapon.DamageLevel     = (WeaponDamageLevel)Utility.Random(6);
                            weapon.AccuracyLevel   = (WeaponAccuracyLevel)Utility.Random(6);
                            weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(6);
                        }

                        cont.DropItem(item);
                    }
                    else if (item is BaseArmor)
                    {
                        BaseArmor armor = (BaseArmor)item;

                        if (Core.AOS)
                        {
                            int attributeCount;
                            int min, max;

                            GetRandomAOSStats(out attributeCount, out min, out max);

                            BaseRunicTool.ApplyAttributesTo(armor, attributeCount, min, max);
                        }
                        else
                        {
                            armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(6);
                            armor.Durability      = (ArmorDurabilityLevel)Utility.Random(6);
                        }

                        cont.DropItem(item);
                    }
                    else if (item is BaseJewel)
                    {
                        int attributeCount;
                        int min, max;

                        GetRandomAOSStats(out attributeCount, out min, out max);

                        BaseRunicTool.ApplyAttributesTo((BaseJewel)item, attributeCount, min, max);

                        cont.DropItem(item);
                    }
                }
            }

            int reagents;

            if (level == 0)
            {
                reagents = 12;
            }
            else
            {
                reagents = level * 3;
            }

            for (int i = 0; i < reagents; i++)
            {
                Item item = Loot.RandomPossibleReagent();
                item.Amount = Utility.RandomMinMax(40, 60);
                cont.DropItem(item);
            }

            int gems;

            if (level == 0)
            {
                gems = 2;
            }
            else
            {
                gems = level * 3;
            }

            for (int i = 0; i < gems; i++)
            {
                Item item = Loot.RandomGem();
                cont.DropItem(item);
            }

            if (level == 6 && Core.AOS)
            {
                Item item = (Item)Activator.CreateInstance(m_Artifacts[Utility.Random(m_Artifacts.Length)]);
                if (cont is TreasureMapChest && (cont as TreasureMapChest).Owner.AccessLevel > AccessLevel.Player && Miscellanious.ValidateLabeling(item))
                {
                    item.Cheater_Name = String.Format("This item received by GM {0}", (cont as TreasureMapChest).Owner.Name);
                }
                cont.DropItem(item);
            }
        }
コード例 #10
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            object toSet;
            bool   shouldSet, shouldSend = true;
            object viewProps = null;

            switch (info.ButtonID)
            {
            case 0:                     // closed
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));

                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 1:                     // Change by Target
            {
                m_Mobile.Target = new SetObjectTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List);
                toSet           = null;
                shouldSet       = false;
                shouldSend      = false;
                break;
            }

            case 2:                     // Change by Serial
            {
                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                m_Mobile.SendMessage("Enter the serial you wish to find:");
                m_Mobile.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List);

                break;
            }

            case 3:                     // Nullify
            {
                toSet     = null;
                shouldSet = true;

                break;
            }

            case 4:                     // View Properties
            {
                toSet     = null;
                shouldSet = false;

                object obj = m_Property.GetValue(m_Object, null);

                if (obj == null)
                {
                    m_Mobile.SendMessage("The property is null and so you cannot view its properties.");
                }
                else if (!Scripts.Commands.BaseCommand.IsAccessible(m_Mobile, obj))
                {
                    m_Mobile.SendMessage("You may not view their properties.");
                }
                else
                {
                    viewProps = obj;
                }

                break;
            }

            default:
            {
                toSet     = null;
                shouldSet = false;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
            }

            if (viewProps != null)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, viewProps));
            }
        }
コード例 #11
0
            public override void OnResponse(Mobile from, string text)
            {
                object toSet;
                bool   shouldSet;

                try
                {
                    int serial = Utility.ToInt32(text);

                    toSet = World.FindEntity(serial);

                    if (toSet == null)
                    {
                        shouldSet = false;
                        m_Mobile.SendMessage("No object with that serial was found.");
                    }
                    else if (!m_Type.IsAssignableFrom(toSet.GetType()))
                    {
                        toSet     = null;
                        shouldSet = false;
                        m_Mobile.SendMessage("The object with that serial could not be assigned to a property of type : {0}", m_Type.Name);
                    }
                    else
                    {
                        shouldSet = true;
                    }
                }
                catch
                {
                    toSet     = null;
                    shouldSet = false;
                    m_Mobile.SendMessage("Bad format");
                }

                if (shouldSet)
                {
                    try
                    {
                        Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString());
                        m_Property.SetValue(m_Object, toSet, null);
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                        if (Miscellanious.ValidateLabeling(m_Object))
                        {
                            if (m_Object is Item)
                            {
                                ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                            }

                            if (m_Object is Mobile)
                            {
                                ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                            }
                        }
                    }
                    catch
                    {
                        m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                    }
                }

                m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
            }
コード例 #12
0
        public static string IncreaseValue(Mobile from, object o, string[] args)
        {
            Type type = o.GetType();

            object[]       realObjs   = new object[args.Length / 2];
            PropertyInfo[] realProps  = new PropertyInfo[args.Length / 2];
            int[]          realValues = new int[args.Length / 2];

            bool positive = false, negative = false;

            for (int i = 0; i < realProps.Length; ++i)
            {
                string name = args[i * 2];

                try
                {
                    string valueString = args[1 + (i * 2)];

                    if (valueString.StartsWith("0x"))
                    {
                        realValues[i] = Convert.ToInt32(valueString.Substring(2), 16);
                    }
                    else
                    {
                        realValues[i] = Convert.ToInt32(valueString);
                    }
                }
                catch
                {
                    return("Offset value could not be parsed.");
                }

                if (realValues[i] > 0)
                {
                    positive = true;
                }
                else if (realValues[i] < 0)
                {
                    negative = true;
                }
                else
                {
                    return("Zero is not a valid value to offset.");
                }

                string failReason = null;
                realObjs[i]  = o;
                realProps[i] = GetPropertyInfo(from, ref realObjs[i], name, PropertyAccess.ReadWrite, ref failReason);

                if (failReason != null)
                {
                    return(failReason);
                }

                if (realProps[i] == null)
                {
                    return("Property not found.");
                }
            }

            for (int i = 0; i < realProps.Length; ++i)
            {
                object obj = realProps[i].GetValue(realObjs[i], null);
                long   v   = (long)Convert.ChangeType(obj, TypeCode.Int64);
                v += realValues[i];

                realProps[i].SetValue(realObjs[i], Convert.ChangeType(v, realProps[i].PropertyType), null);
            }

            if (Miscellanious.ValidateLabeling(o) && from.AccessLevel < AccessLevel.Administrator)
            {
                if (o is Mobile)
                {
                    (o as Mobile).Cheater_Name = String.Format("This mobile modified by GM {0}", from.Name);
                }
                if (o is Item)
                {
                    (o as Item).Cheater_Name = String.Format("This item modified by GM {0}", from.Name);
                }
            }

            if (realProps.Length == 1)
            {
                if (positive)
                {
                    return("The property has been increased.");
                }

                return("The property has been decreased.");
            }

            if (positive && negative)
            {
                return("The properties have been changed.");
            }

            if (positive)
            {
                return("The properties have been increased.");
            }

            return("The properties have been decreased.");
        }
コード例 #13
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int index = info.ButtonID - 1;

            if (index == -1)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
            else if (index >= 0 && index < 4)
            {
                if (m_Monster == null)
                {
                    LoadLists();
                }

                ModelBodyType type;
                ArrayList     list;

                switch (index)
                {
                default:
                case 0:
                    type = ModelBodyType.Monsters;
                    list = m_Monster;
                    break;

                case 1:
                    type = ModelBodyType.Animals;
                    list = m_Animal;
                    break;

                case 2:
                    type = ModelBodyType.Sea;
                    list = m_Sea;
                    break;

                case 3:
                    type = ModelBodyType.Human;
                    list = m_Human;
                    break;
                }

                m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, 0, list, type));
            }
            else if (m_OurList != null)
            {
                index -= 4;

                if (index == 0 && m_OurPage > 0)
                {
                    m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage - 1, m_OurList, m_OurType));
                }
                else if (index == 1 && ((m_OurPage + 1) * 12) < m_OurList.Count)
                {
                    m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage + 1, m_OurList, m_OurType));
                }
                else
                {
                    index -= 2;

                    if (index >= 0 && index < m_OurList.Count)
                    {
                        try
                        {
                            InternalEntry entry = (InternalEntry)m_OurList[index];

                            Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, entry.Body.ToString());
                            m_Property.SetValue(m_Object, entry.Body, null);
                            PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                            if (Miscellanious.ValidateLabeling(m_Object))
                            {
                                if (m_Object is Item)
                                {
                                    ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                                }

                                if (m_Object is Mobile)
                                {
                                    ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                                }
                            }
                        }
                        catch
                        {
                            m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                        }

                        m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage, m_OurList, m_OurType));
                    }
                }
            }
        }
コード例 #14
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Point2D toSet;
            bool    shouldSet, shouldSend;

            switch (info.ButtonID)
            {
            case 1:                     // Current location
            {
                toSet      = new Point2D(m_Mobile.Location);
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            case 2:                     // Pick location
            {
                m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List);

                toSet      = Point2D.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 3:                     // Use values
            {
                TextRelay x = info.GetTextEntry(0);
                TextRelay y = info.GetTextEntry(1);

                toSet      = new Point2D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text));
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            default:
            {
                toSet      = Point2D.Zero;
                shouldSet  = false;
                shouldSend = true;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
コード例 #15
0
            protected override void OnTarget(Mobile from, object targ)
            {
                bool done = false;

                if (!(targ is Item))
                {
                    from.SendMessage("You can only dupe items.");
                    return;
                }

                CommandLogging.WriteLine(from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), m_InBag, m_Amount);

                Item      copy = (Item)targ;
                Container pack;

                if (m_InBag)
                {
                    if (copy.Parent is Container)
                    {
                        pack = (Container)copy.Parent;
                    }
                    else if (copy.Parent is Mobile)
                    {
                        pack = ((Mobile)copy.Parent).Backpack;
                    }
                    else
                    {
                        pack = null;
                    }
                }
                else
                {
                    pack = from.Backpack;
                }

                Type t = copy.GetType();

                ConstructorInfo[] info = t.GetConstructors();

                foreach (ConstructorInfo c in info)
                {
                    //if ( !c.IsDefined( typeof( ConstructableAttribute ), false ) ) continue;

                    ParameterInfo[] paramInfo = c.GetParameters();

                    if (paramInfo.Length == 0)
                    {
                        object[] objParams = new object[0];

                        try
                        {
                            from.SendMessage("Duping {0}...", m_Amount);
                            for (int i = 0; i < m_Amount; i++)
                            {
                                object o = c.Invoke(objParams);

                                if (o != null && o is Item)
                                {
                                    Item newItem = (Item)o;
                                    CopyProperties(newItem, copy);                                       //copy.Dupe( item, copy.Amount );
                                    newItem.Parent = null;

                                    if (Miscellanious.ValidateLabeling(newItem))
                                    {
                                        newItem.Cheater_Name = String.Format("This item duped by GM {0}", from.Name);
                                    }

                                    if (pack != null)
                                    {
                                        pack.DropItem(newItem);
                                    }
                                    else
                                    {
                                        newItem.MoveToWorld(from.Location, from.Map);
                                    }
                                }
                            }
                            from.SendMessage("Done");
                            done = true;
                        }
                        catch
                        {
                            from.SendMessage("Error!");
                            return;
                        }
                    }
                }

                if (!done)
                {
                    from.SendMessage("Unable to dupe.  Item must have a 0 parameter constructor.");
                }
            }
コード例 #16
0
        public static int Build(Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, ArrayList packs)
        {
            try
            {
                Map map = from.Map;

                int objectCount = (packs == null ? (((end.X - start.X) + 1) * ((end.Y - start.Y) + 1)) : packs.Count);

                if (objectCount >= 20)
                {
                    from.SendMessage("Constructing {0} objects, please wait.", objectCount);
                }

                bool sendError = true;

                StringBuilder sb = new StringBuilder();
                sb.Append("Serials: ");

                if (packs != null)
                {
                    for (int i = 0; i < packs.Count; ++i)
                    {
                        object built = Build(from, ctor, values, props, realProps, ref sendError);

                        if (built is IEntity)
                        {
                            sb.AppendFormat("0x{0:X}; ", ((IEntity)built).Serial.Value);
                        }
                        else
                        {
                            continue;
                        }

                        if (built is Item)
                        {
                            Container pack = (Container)packs[i];

                            if (Miscellanious.ValidateLabeling(built))
                            {
                                ((Item)built).Cheater_Name = String.Format("This item created by GM {0}", from.Name);
                            }

                            pack.DropItem((Item)built);
                        }
                        else if (built is Mobile)
                        {
                            Mobile m = (Mobile)built;

                            if (Miscellanious.ValidateLabeling(built))
                            {
                                m.Cheater_Name = String.Format("This mobile created by GM {0}", from.Name);
                            }

                            m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map);
                        }
                    }
                }
                else
                {
                    for (int x = start.X; x <= end.X; ++x)
                    {
                        for (int y = start.Y; y <= end.Y; ++y)
                        {
                            object built = Build(from, ctor, values, props, realProps, ref sendError);

                            if (built is IEntity)
                            {
                                sb.AppendFormat("0x{0:X}; ", ((IEntity)built).Serial.Value);
                            }
                            else
                            {
                                continue;
                            }

                            if (built is Item)
                            {
                                Item item = (Item)built;

                                if (Miscellanious.ValidateLabeling(item))
                                {
                                    item.Cheater_Name = String.Format("This item created by GM {0}", from.Name);
                                }

                                item.MoveToWorld(new Point3D(x, y, start.Z), map);
                            }
                            else if (built is Mobile)
                            {
                                Mobile m = (Mobile)built;

                                if (Miscellanious.ValidateLabeling(m))
                                {
                                    m.Cheater_Name = String.Format("This mobile created by GM {0}", from.Name);
                                }

                                m.MoveToWorld(new Point3D(x, y, start.Z), map);
                            }
                        }
                    }
                }

                CommandLogging.WriteLine(from, sb.ToString());

                return(objectCount);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(0);
            }
        }