Exemplo n.º 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            default:
            {
                int count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    ItemStore store = new ItemStore(reader);
                    Stores.Add(store);

                    store.Owner = this;

                    //TODO: handle exceptions
                    Type keytype = ScriptCompiler.FindTypeByName(reader.ReadString());
                    KeyTypes.Add(keytype);



                    //handle synchronization between store and entry listing within the KeyType
                    try
                    {
                        BaseStoreKey synchkey = (BaseStoreKey)Activator.CreateInstance(keytype);

                        store.SynchronizeStore(synchkey.EntryStructure);
                        store.DisplayColumns = synchkey.DisplayColumns;

                        synchkey.Delete();
                    }
                    catch
                    {
                    }
                }

                break;
            }
            }
        }
Exemplo n.º 2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!(targeted is BaseStoreKey))
                {
                    from.SendMessage("You cannot add that.");
                    return;
                }

                BaseStoreKey key = (BaseStoreKey)targeted;

                if (!key.IsChildOf(from.Backpack))
                {
                    from.SendMessage("That must be in your backpack to add");
                    return;
                }

                //cannot add keys that cannot be use from backpack
                if (!key.CanUseFromPack)
                {
                    from.SendMessage("That type cannot be added to master keys.  Try locking it down in your house instead.");
                    return;
                }

                if (_MasterItemStoreKey.KeyTypes.Count >= _MasterItemStoreKey.MaxEntries)
                {
                    from.SendMessage("You cannot add any more to that");
                    return;
                }

                _MasterItemStoreKey.AddKey(key);

                from.CloseGump(typeof(ItemStoreGump));
                from.CloseGump(typeof(ListEntryGump));


                from.SendGump(new MasterItemStoreKeyGump(from, _MasterItemStoreKey));
            }
Exemplo n.º 3
0
        //this removes a key type from the master key and generates a new item
        public BaseStoreKey RemoveKey(int index)
        {
            if (index < 0 || index >= KeyTypes.Count)
            {
                return(null);
            }

            //create new key object
            BaseStoreKey key = (BaseStoreKey)Activator.CreateInstance(KeyTypes[index]);

            key.SetStore(ItemStore.Clone(Stores[index]));

            //set up the key store to the right owner
            key.Store.Owner = key;

            key.LootType = Stores[index].LootType;
            key.Insured  = Stores[index].Insured;

            //remove the entry from the KeyTypes and Stores lists
            Stores.RemoveAt(index);
            KeyTypes.RemoveAt(index);

            return(key);
        }
Exemplo n.º 4
0
        //add a specified key into the master key, if it can take it
        public bool AddKey(BaseStoreKey key)
        {
            //if this key type already exists within the master key
            if (KeyTypes.IndexOf(key.GetType()) > -1)
            {
                return(false);
            }

            ItemStore newstore = ItemStore.Clone(key.Store);

            newstore.Owner = this;

            //save the loot type for this key into the store
            newstore.LootType = key.LootType;
            newstore.Insured  = key.Insured;

            Stores.Add(newstore);
            KeyTypes.Add(key.GetType());

            //remove the keys from the world
            key.Delete();

            return(true);
        }
Exemplo n.º 5
0
		//add a specified key into the master key, if it can take it
		public bool AddKey( BaseStoreKey key )
		{
			//if this key type already exists within the master key
			if( KeyTypes.IndexOf( key.GetType() ) > -1 )
			{
				return false;
			}
			
			ItemStore newstore = ItemStore.Clone( key.Store );
			newstore.Owner = this;
			
			//save the loot type for this key into the store
			newstore.LootType = key.LootType;
			newstore.Insured = key.Insured;
			
			Stores.Add( newstore );
			KeyTypes.Add( key.GetType() );
			
			//remove the keys from the world
			key.Delete();
			
			return true;
			
			
		}
Exemplo n.º 6
0
        public virtual bool OnFired(Mobile attacker, IDamageable damageable)
        {
            WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

            //Type type = (Color)Enum.Parse(typeof(Enumeration.ArrowType), m_ArrowType);

            // Respect special moves that use no ammo
            if (ability != null && ability.ConsumeAmmo == false)
            {
                return(true);
            }

            if (attacker.Player)
            {
                BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
                Container  pack   = attacker.Backpack;

                int lowerAmmo = AosAttributes.GetValue(attacker, AosAttribute.LowerAmmoCost);

                if (quiver == null || Utility.Random(100) >= lowerAmmo)
                {
                    if (quiver != null && quiver.ConsumeTotal(SpecialAmmoType, 1))
                    {
                        //attacker.SendMessage("1");
                        quiver.InvalidateWeight();
                    }
                    //else if (pack == null || !pack.ConsumeTotal(m_ArrowType, 1))
                    /* UNIVERSAL STORAGE KEY BEGIN */

                    else if (pack == null || !pack.ConsumeTotal(SpecialAmmoType, 1) && !BaseStoreKey.Consume(pack, SpecialAmmoType, 1))
                    {
                        //attacker.SendMessage("2");
                        return(false);
                    }
                }
                // if( ArrowSelection > 0 & (pack == null || pack.FindItemByType(SpecialAmmoType) == null) )
                // {
                // return false;
                // }
                else if (quiver.FindItemByType(SpecialAmmoType) == null && (pack == null || pack.FindItemByType(SpecialAmmoType) == null))
                {
                    // lower ammo cost should not work when we have no ammo at all
                    //attacker.SendMessage("4");
                    return(false);
                }
                // else if( SpecialAmmoType != null && quiver.FindItemByType(SpecialAmmoType) == null && (pack == null || pack.FindItemByType(SpecialAmmoType) == null) )
                // {
                // return false;
                // }
            }

            attacker.MovingEffect(damageable, EffectID, 18, 1, false, false);


            return(true);
        }