コード例 #1
0
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public ItemWeapon()
 {
     this.flags			= ItemFlags.None;
     this.equipSlot		= 0;
     this.currentAmmo	= -1;
     this.ammo			= null;
 }
コード例 #2
0
ファイル: Item.cs プロジェクト: ephe-meral/gw-interface
 public Item(ItemType type, uint model, string name, ItemFlags flags, ItemColor color, IEnumerable<ItemStat> stats)
 {
     _type = type;
                 _model = model;
                 _color = color;
                 Name = name;
                 _flags = flags;
                 _stats = stats.ToArray();
 }
コード例 #3
0
ファイル: DatItems.cs プロジェクト: PimentelM/extibiabot
 public static bool GetFlag(int itemID, ItemFlags flag)
 {
     try
     {
         if (itemID > 99 && itemID < 15000)
         {
             int flags = Memory.ReadInt32(DatAddress(itemID) + Addresses.Client.DatFlagsOffset);
             if (flags == 0)
                 return false;
             if ((flags & (int)flag) != 0) return true;
             return false;
         }
     }
     catch (ArgumentException e)
     {             
         Debug.Report(e);
     }
     return false;
 }
コード例 #4
0
	public MenuItem(MenuMerge mergeType, int mergeOrder, Shortcut shortcut,
					String text, EventHandler onClick, EventHandler onPopup,
					EventHandler onSelect, MenuItem[] items)
			: base(items)
			{
				this.flags = ItemFlags.Default;
				this.mergeType = mergeType;
				this.mergeOrder = mergeOrder;
				this.shortcut = shortcut;
				this.text = text;
				if(onClick != null)
				{
					Click += onClick;
				}
				if(onPopup != null)
				{
					Popup += onPopup;
				}
				if(onSelect != null)
				{
					Select += onSelect;
				}
			}
コード例 #5
0
 public Task<GetItemsResponse> GetItemsByLikes(ItemFlags flags, ItemStatus status, string likes) => GetItems(flags, status, false, null, null, likes, false);
コード例 #6
0
 public Task<GetItemsResponse> GetItemsByTag(ItemFlags flags, ItemStatus status, string tags) => GetItems(flags, status, false, tags, null, null, false);
コード例 #7
0
ファイル: ImageList.cs プロジェクト: yonder/mono
 internal ImageListItem(Image value, int imageCount) : this(value)
 {
     this.Flags      = ItemFlags.ImageStrip;
     this.ImageCount = imageCount;
 }
コード例 #8
0
			public Item(string name, ItemProp[] details, ItemFlags flags = ItemFlags.AllOperationsAvailable) {
				this.name = name;
				this.details = details;
				this.flags = flags;
			}
コード例 #9
0
ファイル: Item.cs プロジェクト: tkiapril/aura
		/// <summary>
		/// Returns true if item has the given flags.
		/// </summary>
		/// <param name="flags"></param>
		/// <returns></returns>
		public bool Is(ItemFlags flags)
		{
			return (this.OptionInfo.Flags & flags) != 0;
		}
コード例 #10
0
        public static void AddToMenu(Menu menu, ItemFlags itemFlags)
        {
            try
            {
                _menu      = menu;
                _itemFlags = itemFlags;

                foreach (var item in
                         Items.Where(
                             i =>
                             i.CombatFlags.HasFlag(ObjectManager.Player.IsMelee ? CombatFlags.Melee : CombatFlags.Ranged) &&
                             ((i.Flags & _itemFlags) != 0)))
                {
                    if (item.Flags.HasFlag(ItemFlags.Offensive) || item.Flags.HasFlag(ItemFlags.Flee))
                    {
                        var itemMenu = _menu.AddSubMenu(new Menu(item.DisplayName, _menu.Name + "." + item.Name));

                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".min-enemies-range", "Min. Enemies in Range").SetValue(
                                new Slider(1, 0, 5)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".player-health-below", "Player Health % <=").SetValue(
                                new Slider(100)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".player-health-above", "Player Health % >=").SetValue(
                                new Slider(0)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".target-health-below", "Target Health % <=").SetValue(
                                new Slider(90)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".target-health-above", "Target Health % >=").SetValue(
                                new Slider(0)));

                        if (item.Flags.HasFlag(ItemFlags.Flee))
                        {
                            itemMenu.AddItem(new MenuItem(itemMenu.Name + ".flee", "Use Flee").SetValue(true));
                        }
                        if (item.Flags.HasFlag(ItemFlags.Offensive))
                        {
                            itemMenu.AddItem(new MenuItem(itemMenu.Name + ".combo", "Use Combo").SetValue(true));
                        }
                    }
                }

                var muramanaMenu = _menu.AddSubMenu(new Menu("Muramana", _menu.Name + ".muramana"));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".min-enemies-range", "Min. Enemies in Range").SetValue(
                        new Slider(1, 0, 5)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".player-mana-above", "Player Mana % >=").SetValue(new Slider(30)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".player-health-below", "Player Health % <=").SetValue(
                        new Slider(100)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".player-health-above", "Player Health % >=").SetValue(
                        new Slider(0)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".target-health-below", "Target Health % <=").SetValue(
                        new Slider(100)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".target-health-above", "Target Health % >=").SetValue(
                        new Slider(0)));

                muramanaMenu.AddItem(new MenuItem(muramanaMenu.Name + ".combo", "Use Combo").SetValue(true));

                menu.AddItem(new MenuItem(menu.Name + ".enabled", "Enabled").SetValue(false));
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
コード例 #11
0
ファイル: Item.cs プロジェクト: nopehight/CharacterEditor
        public void Read(BinaryReader reader)
        {
            Type = reader.ReadByte();
            Subtype = reader.ReadByte();
            reader.Skip(2);
            Modifier = reader.ReadInt16();
            reader.Skip(2);
            RecipeType = reader.ReadByte();
            reader.Skip(3);
            Rarity = reader.ReadByte();
            Material = reader.ReadByte();
            Flags = (ItemFlags)reader.ReadByte();
            reader.Skip(1);
            Level = reader.ReadInt16();
            reader.Skip(2);

            for (int i = 0; i < AttributeCount; ++i)
            {
                ItemAttribute attribute = new ItemAttribute();
                attribute.Read(reader);

                Attributes.Add(attribute);
            }

            // AttributesUsed is calculated on write
            reader.Skip(4);

            ActualModifier = Modifier;
        }
コード例 #12
0
 public Task<GetItemsResponse> GetItemsByUser(ItemFlags flags, ItemStatus status, INamedPr0grammUser user)
 {
     if (user == null)
         throw new ArgumentNullException(nameof(user));
     return GetItemsByUser(flags, status, user.Name);
 }
コード例 #13
0
 public Dictionary <int, ItemEntity> LoadItemsLocatedAt(ItemEntity location, ItemFlags ignoreFlag = ItemFlags.None)
 {
     return(this.ItemDB.LoadItemsLocatedAt(location.ID, ignoreFlag));
 }
コード例 #14
0
 public Task<GetItemsResponse> GetItemsAround(ItemFlags flags, ItemStatus status, bool following, string tags, string user, string likes, bool self, IPr0grammItem aroundItem)
 {
     if (aroundItem == null)
         throw new ArgumentNullException(nameof(aroundItem));
     return GetItemsAround(flags, status, following, tags, user, likes, self, aroundItem.Id);
 }
コード例 #15
0
 public Task<GetItemsResponse> GetItemsAround(ItemFlags flags, ItemStatus status, bool following, string tags, string user, string likes, bool self, int aroundId)
 {
     return Client.Items.GetItemsAround(flags,
         (int)status,
         following ? 1 : 0,
         string.IsNullOrEmpty(tags) ? null : tags,
         string.IsNullOrEmpty(user) ? null : user,
         string.IsNullOrEmpty(likes) ? null : likes,
         self ? 1 : 0,
         aroundId);
 }
コード例 #16
0
 public Task<GetItemsResponse> GetItemsOlder(ItemFlags flags, ItemStatus status, bool following, string tags, string user, string likes, bool self, IPr0grammItem olderThan)
 {
     if (olderThan == null)
         throw new ArgumentNullException(nameof(olderThan));
     return GetItemsOlder(flags, status, following, tags, user, likes, self, olderThan.Id);
 }
コード例 #17
0
 internal Task<GetItemsResponse> GetItems(ItemFlags flags, ItemStatus status, bool following, string tags, string user, string likes, bool self)
 {
     return Client.Items.GetItems(
         flags,
         (int)status,
         following ? 1 : 0,
         string.IsNullOrEmpty(tags) ? null : tags,
         string.IsNullOrEmpty(user) ? null : user,
         string.IsNullOrEmpty(likes) ? null : likes,
         self ? 1 : 0);
 }
コード例 #18
0
 public Task<GetItemsResponse> GetItemsBySelf(ItemFlags flags, ItemStatus status) => GetItems(flags, status, false, null, null, null, true);
コード例 #19
0
 // Superseded function.
 public bool AppendMenu(int ID, String Item, ItemFlags Flags)
 {
     return(apiAppendMenu(m_SysMenu, (int)Flags, ID, Item) == 0);
 }
コード例 #20
0
 public ItemEntity CreateSimpleItem(ItemType type, int owner, int location, ItemFlags flag, int quantity = 1,
                                    bool contraband = false, bool singleton = false)
 {
     return(this.CreateSimpleItem(type.Name, type.ID, owner, location, flag, quantity, contraband, singleton));
 }
コード例 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemMeta"/> class.
        /// </summary>
        /// <param name="handle">Unique handle of item.</param>
        /// <param name="type">Underlying type of item that this item will be implemented of.</param>
        /// <param name="displayName">Default display name this item should have.</param>
        /// <param name="defaultWeight">Default item weight of this item.</param>
        /// <param name="flags">Behaviour flags of this item.</param>
        /// <exception cref="ArgumentException"><paramref name="type"/> is invalid.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="handle"/> or <paramref name="type"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="defaultWeight"/> is 0 or lower.</exception>
        public ItemMeta(string handle, Type type, string displayName, int defaultWeight, ItemFlags flags = ItemFlags.None)
        {
            if (string.IsNullOrWhiteSpace(handle))
            {
                throw new ArgumentNullException(nameof(handle));
            }

            if (string.IsNullOrWhiteSpace(displayName))
            {
                throw new ArgumentNullException(nameof(displayName));
            }

            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (typeof(IItem).IsAssignableFrom(type) == false)
            {
                throw new ArgumentException($"The given item type does not implement {typeof(IItem)}.", nameof(type));
            }

            if (defaultWeight <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(defaultWeight), "The given defaultWeight has to be 1 or higher");
            }

            this.Handle        = handle;
            this.Type          = type;
            this.DisplayName   = displayName;
            this.DefaultWeight = defaultWeight;
            this.Flags         = flags;
        }
コード例 #22
0
        public ItemEntity CreateSimpleItem(string itemName, int typeID, int ownerID, int locationID, ItemFlags flag,
                                           int quantity      = 1, bool contraband = false, bool singleton = false, double x = 0.0, double y = 0.0, double z = 0.0,
                                           string customInfo = null)
        {
            int itemID = (int)this.ItemDB.CreateItem(itemName, typeID, ownerID, locationID, flag, contraband, singleton,
                                                     quantity, 0, 0, 0, null);

            ItemEntity entity = this.LoadItem(itemID);

            // check if the inventory that loads this item is loaded
            // and ensure the item is added in there
            if (this.IsItemLoaded(entity.LocationID) == true)
            {
                ItemInventory inventory = this.GetItem(entity.LocationID) as ItemInventory;

                inventory.AddItem(entity);

                // look for any metainventories too
                try
                {
                    ItemInventory metaInventory =
                        this.MetaInventoryManager.GetOwnerInventoriesAtLocation(entity.LocationID, entity.OwnerID);

                    metaInventory.AddItem(entity);
                }
                catch (ArgumentOutOfRangeException)
                {
                    // ignore the exception, this is expected when no meta inventories are registered
                }
            }

            return(entity);
        }
コード例 #23
0
ファイル: ItemWeapon.cs プロジェクト: dreamsxin/ZeldaOracle
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public ItemWeapon()
 {
     this.flags		= ItemFlags.None;
     this.equipSlot	= 0;
 }
コード例 #24
0
 public ItemEntity CreateSimpleItem(string itemName, ItemType type, ItemEntity owner, ItemEntity location, ItemFlags flag,
                                    bool contraband = false, bool singleton = false, int quantity = 1, double x = 0.0, double y = 0.0, double z = 0.0, string customInfo = null)
 {
     return(this.CreateSimpleItem(itemName, type.ID, owner.ID, location.ID, flag, quantity, contraband, singleton,
                                  x, y, z, customInfo));
 }
コード例 #25
0
 // Insert a menu at the given position. The value of the position
 // depends on the value of Flags. See the article for a detailed
 // description.
 public bool InsertMenu(int pos, ItemFlags flags, int id, string item)
 {
     flags |= ItemFlags.mfByPosition;
     return apiInsertMenu(hSystemMenu, pos, (int)flags, id, item) == 0;
 }
コード例 #26
0
 public ItemEntity CreateSimpleItem(ItemType type, ItemEntity owner, ItemEntity location, ItemFlags flags,
                                    int quantity = 1, bool contraband = false, bool singleton = false)
 {
     return(this.CreateSimpleItem(type.Name, type, owner, location, flags, contraband, singleton, quantity, 0, 0,
                                  0, null));
 }
コード例 #27
0
ファイル: SystemMenu.cs プロジェクト: kusarius/LinguaTest
 // Insert a menu at the given position. The value of the position
 // depends on the value of Flags. See the article for a detailed
 // description.
 public bool InsertMenu(int Pos, ItemFlags Flags, int ID, String Item)
 {
     return (apiInsertMenu(m_SysMenu, Pos, (Int32)Flags, ID, Item) == 0);
 }
コード例 #28
0
 public Task <GetFollowListResponse> GetFollowList(ItemFlags flags) => Client.User.GetFollowList(flags);
コード例 #29
0
ファイル: ImageList.cs プロジェクト: carrie901/mono
				internal ImageListItem(Image value, Color transparentColor) : this(value)
				{
					this.Flags = ItemFlags.UseTransparentColor;
					this.TransparentColor = transparentColor;
				}
コード例 #30
0
 public Task <GetItemsResponse> GetItemsByUser(ItemFlags flags, ItemStatus status, string user) => GetItems(flags, status, false, null, user, null, false);
コード例 #31
0
ファイル: ImageList.cs プロジェクト: yonder/mono
 internal ImageListItem(Image value, Color transparentColor) : this(value)
 {
     this.Flags            = ItemFlags.UseTransparentColor;
     this.TransparentColor = transparentColor;
 }
コード例 #32
0
 public Task <GetItemsResponse> GetItemsBySelf(ItemFlags flags, ItemStatus status) => GetItems(flags, status, false, null, null, null, true);
コード例 #33
0
 /// <inheritdoc />
 public ItemQueryResponseInfo(ItemClassType classType, int subClassType, int soundOverrideSubclass, string[] itemNames, int displayId, ItemQuality quality, ItemFlags itemFlags, ItemFlags2 itemFlags2, int buyPrice, int sellPrice, int inventoryType, uint allowableClass, int allowableRace, int itemLevel, int requiredLevel, int requiredSkill, int requiredSkillRank, int requiredSpell, int requiredHonorRank, int requiredCityRank, int requiredReptuationFaction, int requiredReptuationRank, int maxCount, int maxStackable, int containerSlots, StatInfo[] statInfos, int scalingStatDistribution, int scalingStatValue, ItemDamageDefinition[] itemDamageMods, int[] resistances, int delay, int ammoType, float rangedModRange, ItemSpellInfo[] spellInfos, ItemBondingType bondingType, string itemDescription, int pageText, int languageId, int pageMaterial, int startQuest, int lockId, int material, int sheath, int randomProperty, int randomSuffix, int block, int itemSet, int maxdurability, int area, int map, BAG_FAMILY_MASK bagFamily, ItemSocketInfo socketInformation, int requiredDisenchantSkill, int armorDamageModifier, int duration, int itemLimitCategory, int holidayId)
 {
     ClassType             = classType;
     SubClassType          = subClassType;
     SoundOverrideSubclass = soundOverrideSubclass;
     ItemNames             = itemNames;
     DisplayId             = displayId;
     Quality                   = quality;
     ItemFlags                 = itemFlags;
     ItemFlags2                = itemFlags2;
     BuyPrice                  = buyPrice;
     SellPrice                 = sellPrice;
     InventoryType             = inventoryType;
     AllowableClass            = allowableClass;
     AllowableRace             = allowableRace;
     ItemLevel                 = itemLevel;
     RequiredLevel             = requiredLevel;
     RequiredSkill             = requiredSkill;
     RequiredSkillRank         = requiredSkillRank;
     RequiredSpell             = requiredSpell;
     RequiredHonorRank         = requiredHonorRank;
     RequiredCityRank          = requiredCityRank;
     RequiredReptuationFaction = requiredReptuationFaction;
     RequiredReptuationRank    = requiredReptuationRank;
     MaxCount                  = maxCount;
     MaxStackable              = maxStackable;
     ContainerSlots            = containerSlots;
     StatInfos                 = statInfos;
     ScalingStatDistribution   = scalingStatDistribution;
     ScalingStatValue          = scalingStatValue;
     ItemDamageMods            = itemDamageMods;
     Resistances               = resistances;
     Delay                   = delay;
     AmmoType                = ammoType;
     RangedModRange          = rangedModRange;
     SpellInfos              = spellInfos;
     BondingType             = bondingType;
     ItemDescription         = itemDescription;
     PageText                = pageText;
     LanguageId              = languageId;
     PageMaterial            = pageMaterial;
     StartQuest              = startQuest;
     LockID                  = lockId;
     Material                = material;
     Sheath                  = sheath;
     RandomProperty          = randomProperty;
     RandomSuffix            = randomSuffix;
     Block                   = block;
     ItemSet                 = itemSet;
     Maxdurability           = maxdurability;
     Area                    = area;
     Map                     = map;
     BagFamily               = bagFamily;
     SocketInformation       = socketInformation;
     RequiredDisenchantSkill = requiredDisenchantSkill;
     ArmorDamageModifier     = armorDamageModifier;
     Duration                = duration;
     ItemLimitCategory       = itemLimitCategory;
     HolidayId               = holidayId;
 }
コード例 #34
0
 public Task<GetItemsResponse> GetItemsByUser(ItemFlags flags, ItemStatus status, string user) => GetItems(flags, status, false, null, user, null, false);
コード例 #35
0
 public Task <GetItemsResponse> GetItemsByTag(ItemFlags flags, ItemStatus status, string tags) => GetItems(flags, status, false, tags, null, null, false);
コード例 #36
0
ファイル: ItemReader.cs プロジェクト: Codinablack/Tibia
        /// <summary>
        ///     Loads the specified file name.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <returns>The collection of items.</returns>
        /// <exception cref="FileFormatException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        private IEnumerable <IItem> Load(string fileName)
        {
            OpenFile(fileName);

            // File version
            Reader.ReadUInt32();

            // Initialize
            InitializeRoot();

            //if (!ParseNode(Root))
            //    throw new FileFormatException("Could not parse root node.");
            // TODO: This should probably throw an exception if the return is 'false'(?)
            ParseNode(Root);

            Node node = GetRootNode();

            if (!ReadProperty(node, out ItemStreamReader itemStreamReader))
            {
                throw new FileFormatException("Could not parse root node properties.");
            }

            // First byte of OTB is 0
            // TODO: Use propertyReader.Skip(byte.size); - byte.size is unknown
            itemStreamReader.ReadByte();

            // Flags (4 bytes) unused
            itemStreamReader.ReadUInt32();

            RootAttribute rootAttribute = (RootAttribute)itemStreamReader.ReadByte();

            if (rootAttribute != RootAttribute.Version)
            {
                throw new FileFormatException("Could not find item version.");
            }

            ItemsMetadata metadata = itemStreamReader.ReadMetadata();

            if (metadata == null)
            {
                throw new FileFormatException("Could not read OTBI metadata.");
            }

            Node childNode = node.Child;

            while (childNode != null)
            {
                if (!ReadProperty(childNode, out ItemStreamReader propertyReader))
                {
                    throw new FileFormatException("Could not parse waypoint properties.");
                }

                IItem item = new Item();
                item.GroupType = (ItemGroupType)childNode.Type;

                ItemFlags itemFlags = (ItemFlags)propertyReader.ReadUInt32();

                if (itemFlags.HasFlag(ItemFlags.Stackable))
                {
                    item.Features.Add(new StackableFeature(100));
                }

                if (itemFlags.HasFlag(ItemFlags.Pickupable))
                {
                    item.Features.Add(new PickupableFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.SolidBlock))
                {
                    item.Features.Add(new SolidBlockFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.ProjectileBlocker))
                {
                    item.Features.Add(new ProjectileBlockerFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.PathBlocker))
                {
                    item.Features.Add(new PathBlockerFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.HasHeight))
                {
                    item.Features.Add(new HeightFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Useable))
                {
                    item.Features.Add(new UseableFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Moveable))
                {
                    item.Features.Add(new MoveableFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.AlwaysOnTop))
                {
                    item.Features.Add(new AlwaysOnTopFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Vertical))
                {
                    item.Features.Add(new VerticalFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Horizontal))
                {
                    item.Features.Add(new HorizontalFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Hangable))
                {
                    item.Features.Add(new HangableFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.DistanceReadable))
                {
                    item.Features.Add(new DistanceReadableFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Rotatable))
                {
                    item.Features.Add(new RotatableFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Readable))
                {
                    item.Features.Add(new ReadableFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.LookThrough))
                {
                    item.Features.Add(new LookThroughFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.Animation))
                {
                    item.Features.Add(new AnimationFeature());
                }

                if (itemFlags.HasFlag(ItemFlags.ForceUse))
                {
                    item.Features.Add(new ForceUseFeature());
                }

                while (propertyReader.PeekChar() != -1)
                {
                    ItemAttribute attribute  = (ItemAttribute)propertyReader.ReadByte();
                    ushort        dataLength = propertyReader.ReadUInt16();
                    switch (attribute)
                    {
                    case ItemAttribute.Id:
                        ushort serverId = propertyReader.ReadUInt16();
                        if (serverId > 30000 && serverId < 30100)
                        {
                            serverId -= 30000;
                        }
                        item.Id = serverId;
                        break;

                    case ItemAttribute.SpriteId:
                        item.SpriteId = propertyReader.ReadUInt16();
                        break;

                    case ItemAttribute.Speed:
                        item.Speed = propertyReader.ReadUInt16();
                        break;

                    case ItemAttribute.TopOrder:
                        // TODO: item.TileStackOrder = propertyReader.ReadTileStackOrder();
                        propertyReader.Skip(dataLength);
                        //propertyReader.ReadByte();
                        break;

                    case ItemAttribute.WareId:
                        // TODO: This should probably use a service to have a reference (e.g: item.WriteOnceItem [IItem])
                        item.WriteOnceItemId = propertyReader.ReadUInt16();
                        break;

                    case ItemAttribute.Name:
                        // TODO: item.Name = propertyReader.ReadString();
                        propertyReader.Skip(dataLength);
                        //propertyReader.ReadString();
                        break;

                    case ItemAttribute.SpriteHash:
                        // TODO: item.SpriteHash = propertyReader.ReadBytes(datalen);
                        propertyReader.Skip(dataLength);
                        //propertyReader.ReadBytes(dataLength);
                        break;

                    case ItemAttribute.Light2:
                        // TODO: item.LightLevel = propertyReader.ReadUInt16();
                        // TODO: item.LightColor = propertyReader.ReadUInt16();
                        propertyReader.Skip(dataLength);
                        //propertyReader.ReadUInt16();
                        //propertyReader.ReadUInt16();
                        break;

                    case ItemAttribute.MinimapColor:
                        // TODO: item.MinimapColor = propertyReader.ReadUInt16();
                        propertyReader.Skip(dataLength);
                        //propertyReader.ReadUInt16();
                        break;

                    case ItemAttribute.Unknown1:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown2:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown3:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown4:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown5:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown6:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown7:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown8:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown9:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown10:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown11:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown12:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown13:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown14:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown15:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown16:
                        throw new NotImplementedException();

                    case ItemAttribute.Description:
                        throw new NotImplementedException();

                    case ItemAttribute.Slot:
                        throw new NotImplementedException();

                    case ItemAttribute.MaxItems:
                        throw new NotImplementedException();

                    case ItemAttribute.Weight:
                        throw new NotImplementedException();

                    case ItemAttribute.Weapon:
                        throw new NotImplementedException();

                    case ItemAttribute.Ammo:
                        throw new NotImplementedException();

                    case ItemAttribute.Armor:
                        throw new NotImplementedException();

                    case ItemAttribute.Magiclevel:
                        throw new NotImplementedException();

                    case ItemAttribute.MagicFieldType:
                        throw new NotImplementedException();

                    case ItemAttribute.Writeable:
                        throw new NotImplementedException();

                    case ItemAttribute.Rotateable:
                        throw new NotImplementedException();

                    case ItemAttribute.Decay:
                        throw new NotImplementedException();

                    case ItemAttribute.Unknown17:
                        propertyReader.Skip(dataLength);
                        break;

                    case ItemAttribute.Unknown18:
                        propertyReader.Skip(dataLength);
                        break;

                    case ItemAttribute.Light:
                        throw new NotImplementedException();

                    case ItemAttribute.Decay2:
                        throw new NotImplementedException();

                    case ItemAttribute.Weapon2:
                        throw new NotImplementedException();

                    case ItemAttribute.Ammo2:
                        throw new NotImplementedException();

                    case ItemAttribute.Armor2:
                        throw new NotImplementedException();

                    case ItemAttribute.Writeable2:
                        throw new NotImplementedException();

                    case ItemAttribute.Writeable3:
                        throw new NotImplementedException();

                    default:
                        // TODO: Review whether this is necessary propertyReader.Skip(dataLength);
                        throw new ArgumentOutOfRangeException(nameof(attribute), attribute, "OTBI attribute is not supported.");
                    }
                }

                yield return(item);

                childNode = childNode.Next;
            }
        }
コード例 #37
0
 public Task <GetItemsResponse> GetItemsByLikes(ItemFlags flags, ItemStatus status, string likes) => GetItems(flags, status, false, null, null, likes, false);
コード例 #38
0
        // Methods
        public ItemAction(byte[] data)
            : base(data)
        {
            this.superiorType = SuperiorItemType.NotApplicable;
            this.charClass = CharacterClass.NotApplicable;
            this.level = -1;
            this.usedSockets = -1;
            this.use = -1;
            this.graphic = -1;
            this.color = -1;
            this.stats = new List<StatBase>();
            this.unknown1 = -1;
            this.runewordID = -1;
            this.runewordParam = -1;
            BitReader br = new BitReader(data, 1);
            this.action = (ItemActionType) br.ReadByte();
            br.SkipBytes(1);
            this.category = (ItemCategory) br.ReadByte();
            this.uid = br.ReadUInt32();
            if (data[0] == 0x9d)
            {
                br.SkipBytes(5);
            }
            this.flags = (ItemFlags) br.ReadUInt32();
            this.version = (ItemVersion) br.ReadByte();
            this.unknown1 = br.ReadByte(2);
            this.destination = (ItemDestination) br.ReadByte(3);
            if (this.destination == ItemDestination.Ground)
            {
                this.x = br.ReadUInt16();
                this.y = br.ReadUInt16();
            }
            else
            {
                this.location = (EquipmentLocation) br.ReadByte(4);
                this.x = br.ReadByte(4);
                this.y = br.ReadByte(3);
                this.container = (ItemContainer) br.ReadByte(4);
            }
            if ((this.action == ItemActionType.AddToShop) || (this.action == ItemActionType.RemoveFromShop))
            {
                int num = ((int) this.container) | 0x80;
                if ((num & 1) == 1)
                {
                    num--;
                    this.y += 8;
                }
                this.container = (ItemContainer) num;
            }
            else if (this.container == ItemContainer.Unspecified)
            {
                if (this.location == EquipmentLocation.NotApplicable)
                {
                    if ((this.Flags & ItemFlags.InSocket) == ItemFlags.InSocket)
                    {
                        this.container = ItemContainer.Item;
                        this.y = -1;
                    }
                    else if ((this.action == ItemActionType.PutInBelt) || (this.action == ItemActionType.RemoveFromBelt))
                    {
                        this.container = ItemContainer.Belt;
                        this.y = this.x / 4;
                        this.x = this.x % 4;
                    }
                }
                else
                {
                    this.x = -1;
                    this.y = -1;
                }
            }
            if ((this.flags & ItemFlags.Ear) == ItemFlags.Ear)
            {
                this.charClass = (CharacterClass) br.ReadByte(3);
                this.level = br.ReadByte(7);
                this.name = br.ReadString(7, '\0', 0x10);
                this.baseItem = BaseItem.Get(ItemType.Ear);
            }
            else
            {
                this.baseItem = BaseItem.GetByID(this.category, br.ReadUInt32());
                if (this.baseItem.Type == ItemType.Gold)
                {
                    this.stats.Add(new SignedStat(BaseStat.Get(StatType.Quantity), br.ReadInt32(br.ReadBoolean(1) ? 0x20 : 12)));
                }
                else
                {
                    this.usedSockets = br.ReadByte(3);
                    if ((this.flags & (ItemFlags.Compact | ItemFlags.Gamble)) == ItemFlags.None)
                    {
                        BaseStat stat;
                        int num2;
                        this.level = br.ReadByte(7);
                        this.quality = (ItemQuality) br.ReadByte(4);
                        if (br.ReadBoolean(1))
                        {
                            this.graphic = br.ReadByte(3);
                        }
                        if (br.ReadBoolean(1))
                        {
                            this.color = br.ReadInt32(11);
                        }
                        if ((this.flags & ItemFlags.Identified) == ItemFlags.Identified)
                        {
                            switch (this.quality)
                            {
                                case ItemQuality.Inferior:
                                    this.prefix = new ItemAffix(ItemAffixType.InferiorPrefix, br.ReadByte(3));
                                    break;

                                case ItemQuality.Superior:
                                    this.prefix = new ItemAffix(ItemAffixType.SuperiorPrefix, 0);
                                    this.superiorType = (SuperiorItemType) br.ReadByte(3);
                                    break;

                                case ItemQuality.Magic:
                                    this.prefix = new ItemAffix(ItemAffixType.MagicPrefix, br.ReadUInt16(11));
                                    this.suffix = new ItemAffix(ItemAffixType.MagicSuffix, br.ReadUInt16(11));
                                    break;

                                case ItemQuality.Set:
                                    this.setItem = BaseSetItem.Get(br.ReadUInt16(12));
                                    break;

                                case ItemQuality.Rare:
                                case ItemQuality.Crafted:
                                    this.prefix = new ItemAffix(ItemAffixType.RarePrefix, br.ReadByte(8));
                                    this.suffix = new ItemAffix(ItemAffixType.RareSuffix, br.ReadByte(8));
                                    break;

                                case ItemQuality.Unique:
                                    if (this.baseItem.Code != "std")
                                    {
                                        try
                                        {
                                            this.uniqueItem = BaseUniqueItem.Get(br.ReadUInt16(12));
                                        }
                                        catch{}
                                    }
                                    break;
                            }
                        }
                        if ((this.quality == ItemQuality.Rare) || (this.quality == ItemQuality.Crafted))
                        {
                            this.magicPrefixes = new List<MagicPrefixType>();
                            this.magicSuffixes = new List<MagicSuffixType>();
                            for (int i = 0; i < 3; i++)
                            {
                                if (br.ReadBoolean(1))
                                {
                                    this.magicPrefixes.Add((MagicPrefixType) br.ReadUInt16(11));
                                }
                                if (br.ReadBoolean(1))
                                {
                                    this.magicSuffixes.Add((MagicSuffixType) br.ReadUInt16(11));
                                }
                            }
                        }
                        if ((this.Flags & ItemFlags.Runeword) == ItemFlags.Runeword)
                        {
                            this.runewordID = br.ReadUInt16(12);
                            this.runewordParam = br.ReadUInt16(4);
                            num2 = -1;
                            if (this.runewordParam == 5)
                            {
                                num2 = this.runewordID - (this.runewordParam * 5);
                                if (num2 < 100)
                                {
                                    num2--;
                                }
                            }
                            else if (this.runewordParam == 2)
                            {
                                num2 = ((this.runewordID & 0x3ff) >> 5) + 2;
                            }
                            br.ByteOffset -= 2;
                            this.runewordParam = br.ReadUInt16();
                            this.runewordID = num2;
                            if (num2 == -1)
                            {
                                throw new Exception("Unknown Runeword: " + this.runewordParam);
                            }
                            this.runeword = BaseRuneword.Get(num2);
                        }
                        if ((this.Flags & ItemFlags.Personalized) == ItemFlags.Personalized)
                        {
                            this.name = br.ReadString(7, '\0', 0x10);
                        }
                        if (this.baseItem is BaseArmor)
                        {
                            stat = BaseStat.Get(StatType.ArmorClass);
                            this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits) - stat.SaveAdd));
                        }
                        if ((this.baseItem is BaseArmor) || (this.baseItem is BaseWeapon))
                        {
                            stat = BaseStat.Get(StatType.MaxDurability);
                            num2 = br.ReadInt32(stat.SaveBits);
                            this.stats.Add(new SignedStat(stat, num2));
                            if (num2 > 0)
                            {
                                stat = BaseStat.Get(StatType.Durability);
                                this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits)));
                            }
                        }
                        if ((this.Flags & (ItemFlags.None | ItemFlags.Socketed)) == (ItemFlags.None | ItemFlags.Socketed))
                        {
                            stat = BaseStat.Get(StatType.Sockets);
                            this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits)));
                        }
                        if (this.baseItem.Stackable)
                        {
                            if (this.baseItem.Useable)
                            {
                                this.use = br.ReadByte(5);
                            }
                            this.stats.Add(new SignedStat(BaseStat.Get(StatType.Quantity), br.ReadInt32(9)));
                        }
                        if ((this.Flags & ItemFlags.Identified) == ItemFlags.Identified)
                        {
                            StatBase base2;
                            int num4 = (this.Quality == ItemQuality.Set) ? br.ReadByte(5) : -1;
                            this.mods = new List<StatBase>();
                            while ((base2 = ReadStat(br)) != null)
                            {
                                this.mods.Add(base2);
                            }
                            if ((this.flags & ItemFlags.Runeword) == ItemFlags.Runeword)
                            {
                                while ((base2 = ReadStat(br)) != null)
                                {
                                    this.mods.Add(base2);
                                }
                            }
                            if (num4 > 0)
                            {
                                this.setBonuses = new List<StatBase>[5];
                                for (int j = 0; j < 5; j++)
                                {
                                    if ((num4 & (((int) 1) << j)) != 0)
                                    {
                                        this.setBonuses[j] = new List<StatBase>();
                                        while ((base2 = ReadStat(br)) != null)
                                        {
                                            this.setBonuses[j].Add(base2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #39
0
 // Insert a menu at the given position. The value of the position
 // depends on the value of Flags. See the article for a detailed
 // description.
 public bool InsertMenu(int Pos, ItemFlags Flags, int ID, String Item)
 {
     return(apiInsertMenu(m_SysMenu, Pos, (Int32)Flags, ID, Item) == 0);
 }
コード例 #40
0
 public Item(string name, ItemProp[] details, ItemFlags flags = ItemFlags.AllOperationsAvailable)
 {
     this.name    = name;
     this.details = details;
     this.flags   = flags;
 }
コード例 #41
0
ファイル: Stealing.cs プロジェクト: StoryOfTheBard/UOLegends
            private Item TryStealItem(Item toSteal, ref bool caught)
            {
                Item stolen = null;

                object root = toSteal.RootParent;

                if (!IsEmptyHanded(m_Thief))
                {
                    m_Thief.SendLocalizedMessage(1005584);                       // Both hands must be free to steal.
                }
                else if (root is Mobile && ((Mobile)root).Player && IsInnocentTo(m_Thief, (Mobile)root) && !IsInGuild(m_Thief))
                {
                    m_Thief.SendLocalizedMessage(1005596);                       // You must be in the thieves guild to steal from other players.
                }
                else if (SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild(m_Thief) && m_Thief.Kills > 0)
                {
                    m_Thief.SendLocalizedMessage(502706);                       // You are currently suspended from the thieves guild.
                }
                else if (root is BaseVendor && ((BaseVendor)root).IsInvulnerable)
                {
                    m_Thief.SendLocalizedMessage(1005598);                       // You can't steal from shopkeepers.
                }
                else if (root is PlayerVendor)
                {
                    m_Thief.SendLocalizedMessage(502709);                       // You can't steal from vendors.
                }
                else if (!m_Thief.CanSee(toSteal))
                {
                    m_Thief.SendLocalizedMessage(500237);                       // Target can not be seen.
                }
                else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, toSteal, false, true))
                {
                    m_Thief.SendLocalizedMessage(1048147);                       // Your backpack can't hold anything else.
                }
                #region Sigils
                else if (toSteal is Sigil)
                {
                    PlayerState pl      = PlayerState.Find(m_Thief);
                    Faction     faction = (pl == null ? null : pl.Faction);

                    Sigil sig = (Sigil)toSteal;

                    if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
                    {
                        m_Thief.SendLocalizedMessage(502703);    // You must be standing next to an item to steal it.
                    }
                    else if (root != null)                       // not on the ground
                    {
                        m_Thief.SendLocalizedMessage(502710);    // You can't steal that!
                    }
                    else if (faction != null)
                    {
                        if (!m_Thief.CanBeginAction(typeof(IncognitoSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010581);                               //	You cannot steal the sigil when you are incognito
                        }
                        else if (DisguiseGump.IsDisguised(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1010583);                               //	You cannot steal the sigil while disguised
                        }
                        else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010582);                               //	You cannot steal the sigil while polymorphed
                        }
                        else if (TransformationSpell.UnderTransformation(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1061622);                               // You cannot steal the sigil while in that form.
                        }
                        else if (pl.IsLeaving)
                        {
                            m_Thief.SendLocalizedMessage(1005589);                               // You are currently quitting a faction and cannot steal the town sigil
                        }
                        else if (sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction)
                        {
                            m_Thief.SendLocalizedMessage(1005590);                               //	You cannot steal your own sigil
                        }
                        else if (sig.IsPurifying)
                        {
                            m_Thief.SendLocalizedMessage(1005592);                               // You cannot steal this sigil until it has been purified
                        }
                        else if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, 80.0, 80.0))
                        {
                            if (Sigil.ExistsOn(m_Thief))
                            {
                                m_Thief.SendLocalizedMessage(1010258);                                   //	The sigil has gone back to its home location because you already have a sigil.
                            }
                            else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true))
                            {
                                m_Thief.SendLocalizedMessage(1010259);                                   //	The sigil has gone home because your backpack is full
                            }
                            else
                            {
                                if (sig.IsBeingCorrupted)
                                {
                                    sig.GraceStart = DateTime.Now;                                     // begin grace period
                                }
                                m_Thief.SendLocalizedMessage(1010586);                                 // YOU STOLE THE SIGIL!!!   (woah, call down now)

                                if (sig.LastMonolith != null)
                                {
                                    sig.LastMonolith.Sigil = null;
                                }

                                sig.LastStolen = DateTime.Now;

                                return(sig);
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(1005594);                               //	You do not have enough skill to steal the sigil
                        }
                    }
                    else
                    {
                        m_Thief.SendLocalizedMessage(1005588);                           //	You must join a faction to do that
                    }
                }
                #endregion
                //ARTEGORDONMOD
                // allow stealing of rares on the ground or in containers
                else if ((toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(root)) && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                //ARTEGORDONMOD
                // allow stealing of containers
                else if (Core.AOS && toSteal is Container && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                else if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
                {
                    m_Thief.SendLocalizedMessage(502703);                       // You must be standing next to an item to steal it.
                }
                else if (toSteal.Parent is Mobile)
                {
                    m_Thief.SendLocalizedMessage(1005585);                       // You cannot steal items which are equiped.
                }
                else if (root == m_Thief)
                {
                    m_Thief.SendLocalizedMessage(502704);                       // You catch yourself red-handed.
                }
                else if (root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player)
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                else if (root is Mobile && !m_Thief.CanBeHarmful((Mobile)root))
                {
                }
                else if (root is Corpse)
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                else
                {
                    double w = toSteal.Weight + toSteal.TotalWeight;

                    if (w > 10)
                    {
                        m_Thief.SendMessage("That is too heavy to steal.");
                    }
                    else
                    {
                        if (toSteal.Stackable && toSteal.Amount > 1)
                        {
                            //ARTEGORDON
                            // fix for zero-weight stackables
                            int maxAmount = toSteal.Amount;
                            if (toSteal.Weight > 0)
                            {
                                maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);
                            }

                            if (maxAmount < 1)
                            {
                                maxAmount = 1;
                            }
                            else if (maxAmount > toSteal.Amount)
                            {
                                maxAmount = toSteal.Amount;
                            }

                            int amount = Utility.RandomMinMax(1, maxAmount);

                            if (amount >= toSteal.Amount)
                            {
                                int pileWeight = (int)Math.Ceiling(toSteal.Weight * toSteal.Amount);
                                pileWeight *= 10;

                                if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5))
                                {
                                    stolen = toSteal;
                                }
                            }
                            else
                            {
                                int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount);
                                pileWeight *= 10;

                                if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5))
                                {
                                    stolen          = toSteal.Dupe(amount);
                                    toSteal.Amount -= amount;
                                }
                            }
                        }
                        else
                        {
                            int iw = (int)Math.Ceiling(w);
                            iw *= 10;

                            // ARTEGORDONMOD
                            // Begin mod for ArtifactRarity difficulty scaling
                            // add in an additional difficulty factor for objects with ArtifactRarity
                            // with rarity=1 requiring a minimum of 100 stealing, and rarity 12 requiring a minimum of 118
                            // Note, this is completely independent of weight
                            Type   ptype;
                            string value = BaseXmlSpawner.GetBasicPropertyValue(toSteal, "ArtifactRarity", out ptype);

                            if (ptype == typeof(int) && value != null)
                            {
                                int rarity = 0;
                                try{
                                    rarity = int.Parse(value);
                                } catch {}

                                // rarity difficulty scaling
                                if (rarity > 0)
                                {
                                    iw = (int)Math.Ceiling(120 + rarity * 1.5);
                                }
                            }
                            // End mod for ArtifactRarity difficulty scaling


                            if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5))
                            {
                                stolen = toSteal;
                            }
                        }

                        if (stolen != null)
                        {
                            // ARTEGORDONMOD
                            // Begin mod for stealable rares and other locked down items

                            // set the taken flag to trigger release from any controlling spawner
                            ItemFlags.SetTaken(stolen, true);
                            // clear the stealable flag so that the item can only be stolen once if it is later locked down.
                            ItemFlags.SetStealable(stolen, false);
                            // release it if it was locked down
                            stolen.Movable = true;

                            // End mod for stealable rares and other locked down items

                            m_Thief.SendLocalizedMessage(502724);                               // You succesfully steal the item.
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(502723);                               // You fail to steal the item.
                        }
                        caught = (m_Thief.Skills[SkillName.Stealing].Value < Utility.Random(150));
                    }
                }

                return(stolen);
            }
コード例 #42
0
ファイル: Extensions.cs プロジェクト: KroneckerX/WCell
		public static bool HasAnyFlag(this ItemFlags flags, ItemFlags otherFlags)
		{
			return (flags & otherFlags) != 0;
		}
コード例 #43
0
ファイル: Honesty.cs プロジェクト: Nyght-Hex/ServUO
        private static void GenerateHonestyItems()
        {
            CheckChests();

            bool initial = _Items.Count == 0;
            long ticks   = Core.TickCount;

            if (initial)
            {
                Utility.PushColor(ConsoleColor.Yellow);
                Console.Write("Honesty Items generating:");
                Utility.PopColor();
            }

            try
            {
                var count   = MaxGeneration - _Items.Count;
                var spawned = new Item[count];

                for (var i = 0; i < spawned.Length; i++)
                {
                    var item = spawned[i] = Loot.RandomArmorOrShieldOrWeapon();

                    if (item == null || item.Deleted)
                    {
                        --i;

                        continue;
                    }

                    item.HonestyItem = true;

                    lock (_ItemsLock)
                    {
                        if (!_Items.Contains(item))
                        {
                            _Items.Add(item);
                        }
                    }
                }

                var locs = new Dictionary <Map, Point3D?[]>();

                if (TrammelGeneration)
                {
                    locs[Map.Trammel] = new Point3D?[spawned.Length];
                }

                locs[Map.Felucca] = new Point3D?[spawned.Length];

                Parallel.For(
                    0,
                    spawned.Length,
                    i =>
                {
                    var map = TrammelGeneration && Utility.RandomBool() ? Map.Trammel : Map.Felucca;

                    locs[map][i] = GetValidLocation(map);
                });

                foreach (var kv in locs)
                {
                    var map    = kv.Key;
                    var points = kv.Value;

                    for (var i = 0; i < spawned.Length; i++)
                    {
                        var loc = points[i];

                        if (loc == null || loc == Point3D.Zero)
                        {
                            continue;
                        }

                        var item = spawned[i];

                        if (item == null || item.Deleted)
                        {
                            continue;
                        }

                        ItemFlags.SetTaken(item, false);

                        item.MoveToWorld(loc.Value, map);

                        spawned[i] = null;
                    }
                }

                foreach (var item in spawned.Where(item => item != null && !item.Deleted))
                {
                    item.Delete();
                }
            }
            catch (Exception e)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine(" Failed!");
                Console.WriteLine(e);
                Utility.PopColor();
            }

            if (initial)
            {
                Utility.PushColor(ConsoleColor.Green);
                Console.WriteLine(" Done, took {0} milliseconds!", Core.TickCount - ticks);
                Utility.PopColor();
            }
        }
コード例 #44
0
        private static void GenerateHonestyItems()
        {
            CheckChests();

            Utility.PushColor(ConsoleColor.Yellow);
            Console.WriteLine("[Honesty]: Generating...");
            Utility.PopColor();

            var sw = new Stopwatch();
            var s  = 0.0;

            if (UseSpawnArea)
            {
                if (_FeluccaArea == null)
                {
                    Utility.PushColor(ConsoleColor.Yellow);
                    Console.Write("[Honesty]: Felucca - Reticulating splines...");
                    Utility.PopColor();

                    sw.Restart();

                    _FeluccaArea = SpawnArea.Instantiate(Map.Felucca.DefaultRegion, _Filter, ValidateSpawnPoint, true);

                    sw.Stop();

                    s += sw.Elapsed.TotalSeconds;

                    Utility.PushColor(ConsoleColor.Green);
                    Console.WriteLine("done ({0:F2} seconds)", sw.Elapsed.TotalSeconds);
                    Utility.PopColor();
                }

                if (_TrammelArea == null && TrammelGeneration)
                {
                    Utility.PushColor(ConsoleColor.Yellow);
                    Console.Write("[Honesty]: Trammel - Reticulating splines...");
                    Utility.PopColor();

                    sw.Restart();

                    _TrammelArea = SpawnArea.Instantiate(Map.Trammel.DefaultRegion, _Filter, ValidateSpawnPoint, true);

                    sw.Stop();

                    s += sw.Elapsed.TotalSeconds;

                    Utility.PushColor(ConsoleColor.Green);
                    Console.WriteLine("done ({0:F2} seconds)", sw.Elapsed.TotalSeconds);
                    Utility.PopColor();
                }
            }

            try
            {
                Map     facet;
                Point3D loc;
                Item    item;

                var count = MaxGeneration - _Items.Count;

                if (count > 0)
                {
                    Utility.PushColor(ConsoleColor.Yellow);
                    Console.Write("[Honesty]: Creating {0:#,0} lost items...", count);
                    Utility.PopColor();

                    sw.Restart();

                    var spawned = new Item[count];

                    for (var i = 0; i < spawned.Length; i++)
                    {
                        try
                        {
                            item = Loot.RandomArmorOrShieldOrWeapon();

                            if (item != null && !item.Deleted)
                            {
                                spawned[i] = item;
                            }
                        }
                        catch
                        { }
                    }

                    for (var i = 0; i < spawned.Length; i++)
                    {
                        item = spawned[i];

                        if (item == null)
                        {
                            continue;
                        }

                        try
                        {
                            if (UseSpawnArea)
                            {
                                var area = _TrammelArea != null && Utility.RandomBool() ? _TrammelArea : _FeluccaArea;
                                facet = area.Facet;

                                loc = area.GetRandom();
                            }
                            else
                            {
                                facet = TrammelGeneration && Utility.RandomBool() ? Map.Trammel : Map.Felucca;
                                loc   = GetRandom(facet);
                            }

                            if (loc == Point3D.Zero)
                            {
                                continue;
                            }

                            RunicReforging.GenerateRandomItem(item, 0, 100, 1000);

                            item.AttachSocket(new HonestyItemSocket());
                            item.HonestyItem = true;

                            _Items.Add(item);

                            ItemFlags.SetTaken(item, false);

                            item.OnBeforeSpawn(loc, facet);
                            item.MoveToWorld(loc, facet);
                            item.OnAfterSpawn();
                        }
                        catch
                        {
                            item.Delete();
                        }
                        finally
                        {
                            spawned[i] = null;
                        }
                    }

                    sw.Stop();

                    s += sw.Elapsed.TotalSeconds;

                    Utility.PushColor(ConsoleColor.Green);
                    Console.WriteLine("done ({0:F2} seconds)", sw.Elapsed.TotalSeconds);
                    Utility.PopColor();
                }
            }
            catch (Exception e)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine(e);
                Utility.PopColor();
            }

            Utility.PushColor(ConsoleColor.Yellow);
            Console.Write("[Honesty]:");
            Utility.PopColor();
            Utility.PushColor(ConsoleColor.Green);
            Console.WriteLine(" Generation completed in {0:F2} seconds.", s);
            Utility.PopColor();
        }
コード例 #45
0
            private Item TryStealItem(Item toSteal, ref bool caught)
            {
                Item stolen = null;

                object root = toSteal.RootParent;

                StealableArtifactsSpawner.StealableInstance si = null;
                if (toSteal.Parent == null || !toSteal.Movable)
                {
                    si = StealableArtifactsSpawner.GetStealableInstance(toSteal);
                }

                if (!IsEmptyHanded(m_Thief))
                {
                    m_Thief.SendLocalizedMessage(1005584);                     // Both hands must be free to steal.
                }
                else if (root is Mobile && ((Mobile)root).Player && !IsInGuild(m_Thief))
                {
                    m_Thief.SendLocalizedMessage(1005596);                     // You must be in the thieves guild to steal from other players.
                }
                else if (SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild(m_Thief) && m_Thief.Kills > 0)
                {
                    m_Thief.SendLocalizedMessage(502706);                     // You are currently suspended from the thieves guild.
                }
                else if (root is BaseVendor && ((BaseVendor)root).IsInvulnerable)
                {
                    m_Thief.SendLocalizedMessage(1005598);                     // You can't steal from shopkeepers.
                }
                else if (root is PlayerVendor)
                {
                    m_Thief.SendLocalizedMessage(502709);                     // You can't steal from vendors.
                }
                else if (!m_Thief.CanSee(toSteal))
                {
                    m_Thief.SendLocalizedMessage(500237);                     // Target can not be seen.
                }
                else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, toSteal, false, true))
                {
                    m_Thief.SendLocalizedMessage(1048147);                     // Your backpack can't hold anything else.
                }
                #region Sigils
                else if (toSteal is Sigil)
                {
                    PlayerState pl      = PlayerState.Find(m_Thief);
                    Faction     faction = (pl == null ? null : pl.Faction);

                    Sigil sig = (Sigil)toSteal;

                    if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
                    {
                        m_Thief.SendLocalizedMessage(502703);  // You must be standing next to an item to steal it.
                    }
                    else if (root != null)                     // not on the ground
                    {
                        m_Thief.SendLocalizedMessage(502710);  // You can't steal that!
                    }
                    else if (faction != null)
                    {
                        if (!m_Thief.CanBeginAction(typeof(IncognitoSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010581);                             //	You cannot steal the sigil when you are incognito
                        }
                        else if (DisguiseTimers.IsDisguised(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1010583);                             //	You cannot steal the sigil while disguised
                        }
                        else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010582);                             //	You cannot steal the sigil while polymorphed
                        }
                        else if (TransformationSpellHelper.UnderTransformation(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1061622);                             // You cannot steal the sigil while in that form.
                        }
                        else if (AnimalForm.UnderTransformation(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1063222);                             // You cannot steal the sigil while mimicking an animal.
                        }
                        else if (pl.IsLeaving)
                        {
                            m_Thief.SendLocalizedMessage(1005589);                             // You are currently quitting a faction and cannot steal the town sigil
                        }
                        else if (sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction)
                        {
                            m_Thief.SendLocalizedMessage(1005590);                             //	You cannot steal your own sigil
                        }
                        else if (sig.IsPurifying)
                        {
                            m_Thief.SendLocalizedMessage(1005592);                             // You cannot steal this sigil until it has been purified
                        }
                        else if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, 80.0, 80.0))
                        {
                            if (Sigil.ExistsOn(m_Thief))
                            {
                                m_Thief.SendLocalizedMessage(1010258);
                                //	The sigil has gone back to its home location because you already have a sigil.
                            }
                            else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true))
                            {
                                m_Thief.SendLocalizedMessage(1010259);                                 //	The sigil has gone home because your backpack is full
                            }
                            else
                            {
                                if (sig.IsBeingCorrupted)
                                {
                                    sig.GraceStart = DateTime.UtcNow;                                     // begin grace period
                                }

                                m_Thief.SendLocalizedMessage(1010586);                                 // YOU STOLE THE SIGIL!!!   (woah, calm down now)

                                if (sig.LastMonolith != null && sig.LastMonolith.Sigil != null)
                                {
                                    sig.LastMonolith.Sigil = null;
                                    sig.LastStolen         = DateTime.UtcNow;
                                }

                                return(sig);
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(1005594);                             //	You do not have enough skill to steal the sigil
                        }
                    }
                    else
                    {
                        m_Thief.SendLocalizedMessage(1005588);                         //	You must join a faction to do that
                    }
                }
                #endregion
                #region VvV Sigils
                else if (toSteal is VvVSigil && ViceVsVirtueSystem.Instance != null)
                {
                    VvVPlayerEntry entry = ViceVsVirtueSystem.Instance.GetPlayerEntry <VvVPlayerEntry>(m_Thief);

                    VvVSigil sig = (VvVSigil)toSteal;

                    if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
                    {
                        m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it.
                    }
                    else if (root != null)                    // not on the ground
                    {
                        m_Thief.SendLocalizedMessage(502710); // You can't steal that!
                    }
                    else if (entry != null)
                    {
                        if (!m_Thief.CanBeginAction(typeof(IncognitoSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010581); //	You cannot steal the sigil when you are incognito
                        }
                        else if (DisguiseTimers.IsDisguised(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1010583); //	You cannot steal the sigil while disguised
                        }
                        else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010582); //	You cannot steal the sigil while polymorphed
                        }
                        else if (TransformationSpellHelper.UnderTransformation(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1061622); // You cannot steal the sigil while in that form.
                        }
                        else if (AnimalForm.UnderTransformation(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1063222); // You cannot steal the sigil while mimicking an animal.
                        }
                        else if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, 100.0, 120.0))
                        {
                            if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true))
                            {
                                m_Thief.SendLocalizedMessage(1010259); //	The sigil has gone home because your backpack is full
                            }
                            else
                            {
                                m_Thief.SendLocalizedMessage(1010586); // YOU STOLE THE SIGIL!!!   (woah, calm down now)

                                sig.OnStolen(entry);

                                return(sig);
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(1005594); //	You do not have enough skill to steal the sigil
                        }
                    }
                    else
                    {
                        m_Thief.SendLocalizedMessage(1155415); //	Only participants in Vice vs Virtue may use this item.
                    }
                }
                #endregion

                else if (si == null && (toSteal.Parent == null || !toSteal.Movable) && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage(502710);                     // You can't steal that!
                }
                else if ((toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(root)) && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage(502710);                     // You can't steal that!
                }
                else if (Core.AOS && si == null && toSteal is Container && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage(502710);                     // You can't steal that!
                }
                else if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
                {
                    m_Thief.SendLocalizedMessage(502703);                     // You must be standing next to an item to steal it.
                }
                else if (si != null && m_Thief.Skills[SkillName.Stealing].Value < 100.0)
                {
                    m_Thief.SendLocalizedMessage(1060025, "", 0x66D);                     // You're not skilled enough to attempt the theft of this item.
                }
                else if (toSteal.Parent is Mobile)
                {
                    m_Thief.SendLocalizedMessage(1005585);                     // You cannot steal items which are equiped.
                }
                else if (root == m_Thief)
                {
                    m_Thief.SendLocalizedMessage(502704);                     // You catch yourself red-handed.
                }
                else if (root is Mobile && ((Mobile)root).IsStaff())
                {
                    m_Thief.SendLocalizedMessage(502710);                     // You can't steal that!
                }
                else if (root is Mobile && !m_Thief.CanBeHarmful((Mobile)root))
                {
                }
                else if (root is Corpse)
                {
                    m_Thief.SendLocalizedMessage(502710);                     // You can't steal that!
                }
                else
                {
                    double w = toSteal.Weight + toSteal.TotalWeight;

                    if (w > 10)
                    {
                        m_Thief.SendMessage("That is too heavy to steal.");
                    }
                    else
                    {
                        if (toSteal.Stackable && toSteal.Amount > 1)
                        {
                            int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);

                            if (maxAmount < 1)
                            {
                                maxAmount = 1;
                            }
                            else if (maxAmount > toSteal.Amount)
                            {
                                maxAmount = toSteal.Amount;
                            }

                            int amount = Utility.RandomMinMax(1, maxAmount);

                            if (amount >= toSteal.Amount)
                            {
                                int pileWeight = (int)Math.Ceiling(toSteal.Weight * toSteal.Amount);
                                pileWeight *= 10;

                                if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5))
                                {
                                    stolen = toSteal;
                                }
                            }
                            else
                            {
                                int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount);
                                pileWeight *= 10;

                                if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5))
                                {
                                    stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount);

                                    if (stolen == null)
                                    {
                                        stolen = toSteal;
                                    }
                                }
                            }
                        }
                        else
                        {
                            int iw = (int)Math.Ceiling(w);
                            iw *= 10;

                            if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5))
                            {
                                stolen = toSteal;
                            }
                        }

                        // Non-movable stealable items cannot result in the stealer getting caught
                        if (stolen != null && stolen.Movable)
                        {
                            caught = (m_Thief.Skills[SkillName.Stealing].Value < Utility.Random(150));
                        }
                        else
                        {
                            caught = false;
                        }

                        if (stolen != null)
                        {
                            m_Thief.SendLocalizedMessage(502724);                             // You succesfully steal the item.

                            ItemFlags.SetTaken(stolen, true);
                            ItemFlags.SetStealable(stolen, false);
                            stolen.Movable = true;

                            if (si != null)
                            {
                                toSteal.Movable = true;
                                si.Item         = null;
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(502723);                             // You fail to steal the item.
                        }
                    }
                }

                return(stolen);
            }
コード例 #46
0
ファイル: Extensions.cs プロジェクト: pallmall/WCell
		public static bool HasFlag(this ItemFlags flags, ItemFlags toCheck)
		{
			return (flags & toCheck) != ItemFlags.None;
		}
コード例 #47
0
ファイル: ItemWeapon.cs プロジェクト: dreamsxin/ZeldaOracle
 //-----------------------------------------------------------------------------
 // Accessors
 //-----------------------------------------------------------------------------
 // Gets if the item has the specified flags.
 public bool HasFlag(ItemFlags flags)
 {
     return this.flags.HasFlag(flags);
 }
コード例 #48
0
ファイル: StealingHandler.cs プロジェクト: tflynt91/TrueUO
        private static Item TryStealItem(Item toSteal, double skill)
        {
            Item   stolen = null;
            double w      = toSteal.Weight + toSteal.TotalWeight;

            if (w <= 10)
            {
                if (toSteal.Stackable && toSteal.Amount > 1)
                {
                    int maxAmount = (int)((skill / 10.0) / toSteal.Weight);

                    if (maxAmount < 1)
                    {
                        maxAmount = 1;
                    }
                    else if (maxAmount > toSteal.Amount)
                    {
                        maxAmount = toSteal.Amount;
                    }

                    int amount = Utility.RandomMinMax(1, maxAmount);

                    if (amount >= toSteal.Amount)
                    {
                        int pileWeight = (int)Math.Ceiling(toSteal.Weight * toSteal.Amount);
                        pileWeight *= 10;

                        double chance = (skill - (pileWeight - 22.5)) / ((pileWeight + 27.5) - (pileWeight - 22.5));

                        if (chance >= Utility.RandomDouble())
                        {
                            stolen = toSteal;
                        }
                    }
                    else
                    {
                        int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount);
                        pileWeight *= 10;

                        double chance = (skill - (pileWeight - 22.5)) / ((pileWeight + 27.5) - (pileWeight - 22.5));

                        if (chance >= Utility.RandomDouble())
                        {
                            stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount);

                            if (stolen == null)
                            {
                                stolen = toSteal;
                            }
                        }
                    }
                }
                else
                {
                    int iw = (int)Math.Ceiling(w);
                    iw *= 10;

                    double chance = (skill - (iw - 22.5)) / ((iw + 27.5) - (iw - 22.5));

                    if (chance >= Utility.RandomDouble())
                    {
                        stolen = toSteal;
                    }
                }

                if (stolen != null)
                {
                    ItemFlags.SetTaken(stolen, true);
                    ItemFlags.SetStealable(stolen, false);
                    stolen.Movable = true;
                }
            }

            return(stolen);
        }
コード例 #49
0
        public static void AddToMenu(Menu menu, ItemFlags itemFlags)
        {
            try
            {
                _menu = menu;
                _itemFlags = itemFlags;

                foreach (var item in
                    Items.Where(
                        i =>
                            i.CombatFlags.HasFlag(ObjectManager.Player.IsMeele ? CombatFlags.Melee : CombatFlags.Ranged) &&
                            ((i.Flags & (_itemFlags)) != 0)))
                {
                    if (item.Flags.HasFlag(ItemFlags.Offensive) || item.Flags.HasFlag(ItemFlags.Flee))
                    {
                        var itemMenu = _menu.AddSubMenu(new Menu(item.DisplayName, _menu.Name + "." + item.Name));

                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".min-enemies-range", Global.Lang.Get("MI_MinEnemiesRange"))
                                .SetValue(new Slider(1, 0, 5)));

                        if (item.Flags.HasFlag(ItemFlags.Flee))
                        {
                            itemMenu.AddItem(
                                new MenuItem(itemMenu.Name + ".flee", Global.Lang.Get("MI_UseFlee")).SetValue(true));
                        }
                        if (item.Flags.HasFlag(ItemFlags.Offensive))
                        {
                            itemMenu.AddItem(
                                new MenuItem(itemMenu.Name + ".combo", Global.Lang.Get("MI_UseCombo")).SetValue(true));
                        }
                    }
                }

                menu.AddItem(new MenuItem(menu.Name + ".enabled", Global.Lang.Get("G_Enabled")).SetValue(false));
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
コード例 #50
0
 // Get the value of a menu item flag.
 private bool GetFlag(ItemFlags flag)
 {
     return((flags & flag) != 0);
 }
コード例 #51
0
 // Superseded function.
 public bool AppendMenu(int id, string item, ItemFlags flags)
 {
     return apiAppendMenu(hSystemMenu, (int)flags, id, item) == 0;
 }
コード例 #52
0
        public override void Attack(CreatureEntity aEnemy, bool onlyRemote)
        {
            try {
                NWCreature self  = (NWCreature)fSelf;
                NWCreature enemy = (NWCreature)aEnemy;

                int dist = MathHelper.Distance(self.Location, aEnemy.Location);

                bool shooting = false;
                int  highestDamage;
                Item weapon = null;

                if (self.Entry.Flags.Contains(CreatureFlags.esMind) && (self.Entry.Flags.Contains(CreatureFlags.esUseItems)))
                {
                    bool canShoot = self.CanShoot(enemy);

                    BestWeaponSigns bw = new BestWeaponSigns();
                    if (canShoot)
                    {
                        bw.Include(BestWeaponSigns.bwsCanShoot);
                    }
                    if (onlyRemote)
                    {
                        bw.Include(BestWeaponSigns.bwsOnlyShoot);
                    }

                    highestDamage = self.CheckEquipment((float)dist, bw);

                    weapon = self.GetItemByEquipmentKind(BodypartType.bp_RHand);
                    ItemFlags ifs = (weapon != null) ? weapon.Flags : new ItemFlags();

                    shooting = (canShoot && weapon != null && (ifs.HasIntersect(ItemFlags.if_ThrowWeapon, ItemFlags.if_ShootWeapon)));
                }
                else
                {
                    highestDamage = self.DamageBase;
                }

                int     skDamage      = 0;
                SkillID sk            = self.GetAttackSkill(dist, ref skDamage);
                bool    attackBySkill = (sk != SkillID.Sk_None && (skDamage > highestDamage || AuxUtils.Chance(15)));

                if (attackBySkill)
                {
                    EffectExt ext = new EffectExt();
                    ext.SetParam(EffectParams.ep_Creature, aEnemy);
                    self.UseSkill(sk, ext);
                }
                else
                {
                    if (shooting)
                    {
                        self.ShootTo(enemy, weapon);
                    }
                    else
                    {
                        if (!onlyRemote)
                        {
                            if (dist == 1)
                            {
                                self.AttackTo(AttackKind.akMelee, enemy, null, null);
                            }
                            else
                            {
                                ExtPoint next = self.GetStep(aEnemy.Location);
                                if (!next.IsEmpty)
                                {
                                    StepTo(next.X, next.Y);
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Write("BeastBrain.attack(): " + ex.Message);
            }
        }
コード例 #53
0
ファイル: Item.cs プロジェクト: jhurliman/d3research
 public ItemType(string name, int hash, int parentType, int flags)
 {
     Name = name;
     Hash = hash;
     ParentType = parentType;
     Flags = (ItemFlags)flags;
 }
コード例 #54
0
ファイル: ItemEntity.cs プロジェクト: hoodaly/client
        protected override void UpdateAttribute(string name, dynamic value)
        {
            AttributeList.Add(name);
            switch (name)
            {
            case "position":
                DroppedItem.Transformation.Position = new Position(float.Parse(value.x.ToString()), float.Parse(value.y.ToString()), short.Parse(value.plane.ToString()));
                break;

            case "item":
                if (!Enum.TryParse(value.type.ToString(), out ItemType type))
                {
                    // not fully specified!
                    Debugging.Debug.Error("Received invalid ItemType '{0}'", value.type);
                    AttributeList.RemoveAt(AttributeList.Count - 1);
                    break;
                }
                if (!Enum.TryParse(value.model.ToString(), out ItemModel model))
                {
                    // not fully specified!
                    Debugging.Debug.Error("Received invalid ItemModel '{0}'", value.model);
                    AttributeList.RemoveAt(AttributeList.Count - 1);
                    break;
                }
                string    item_name = value.name.ToString();
                ItemFlags flags     = 0;
                foreach (object flag_string in value.flags)
                {
                    if (Enum.TryParse(flag_string.ToString(), out ItemFlags flag))
                    {
                        flags |= flag;
                    }
                }

                List <ItemStat> itemStats = new List <ItemStat>();
                foreach (object stat_string in value.stats)
                {
                    string[] stat_string_parts = stat_string.ToString().Split(':');
                    bool     success           = true;
                    success &= Enum.TryParse(stat_string_parts[0], out ItemStatIdentifier statId);
                    success &= byte.TryParse(stat_string_parts[1], out var p1);
                    success &= byte.TryParse(stat_string_parts[2], out var p2);
                    if (success)
                    {
                        itemStats.Add(new ItemStat(statId, p1, p2));
                    }
                }

                Dye[] colors = new Dye[4];
                int   i      = 0;
                foreach (object color in value.color)
                {
                    if (Enum.TryParse(color.ToString(), out Dye dye))
                    {
                        colors[i++] = dye;
                    }
                }
                ItemColor itemColor = new ItemColor(colors[0], colors[1], colors[2], colors[3]);

                Item             = new Item(type, (uint)model, item_name, flags, itemColor, itemStats);
                DroppedItem.Item = Item;
                break;
            }
            if (FullySpecified)
            {
                Game.Zone.AddAgent(DroppedItem);
            }
        }
コード例 #55
0
ファイル: SystemMenu.cs プロジェクト: kusarius/LinguaTest
 // Superseded function.
 public bool AppendMenu(int ID, String Item, ItemFlags Flags)
 {
     return (apiAppendMenu(m_SysMenu, (int)Flags, ID, Item) == 0);
 }
コード例 #56
0
ファイル: Honesty.cs プロジェクト: ChawDinky/ServUO
        private static void GenerateHonestyItems()
        {
            try
            {
                var count = MaxGeneration - _Items.Count;

                var spawned = new Item[count];

                for (var i = 0; i < spawned.Length; i++)
                {
                    var item = spawned[i] = Loot.RandomArmorOrShieldOrWeapon();

                    if (item == null || item.Deleted)
                    {
                        --i;

                        continue;
                    }

                    item.HonestyItem = true;

                    lock (_ItemsLock)
                    {
                        if (!_Items.Contains(item))
                        {
                            _Items.Add(item);
                        }
                    }
                }

                var locs = new Dictionary <Map, Point3D?[]>();

                if (TrammelGeneration)
                {
                    locs[Map.Trammel] = new Point3D?[spawned.Length];
                }

                locs[Map.Felucca] = new Point3D?[spawned.Length];

                Parallel.For(
                    0,
                    spawned.Length,
                    i =>
                {
                    var map = TrammelGeneration && Utility.RandomBool() ? Map.Trammel : Map.Felucca;

                    locs[map][i] = GetValidLocation(map);
                });

                foreach (var kv in locs)
                {
                    var map    = kv.Key;
                    var points = kv.Value;

                    for (var i = 0; i < spawned.Length;)
                    {
                        var loc = points[i];

                        if (loc == null || loc == Point3D.Zero)
                        {
                            continue;
                        }

                        var item = spawned[i];

                        if (item == null || item.Deleted)
                        {
                            continue;
                        }

                        item.HonestyRegion = _Regions[Utility.Random(_Regions.Length)];

                        if (!String.IsNullOrWhiteSpace(item.HonestyRegion))
                        {
                            var attempts = BaseVendor.AllVendors.Count / 10;

                            BaseVendor m;

                            do
                            {
                                m = BaseVendor.AllVendors[Utility.Random(BaseVendor.AllVendors.Count)];
                            }while ((m == null || m.Map != map || !m.Region.IsPartOf(item.HonestyRegion)) && --attempts >= 0);

                            item.HonestyOwner = m;
                        }

                        ItemFlags.SetTaken(item, false);

                        item.MoveToWorld(loc.Value, map);

                        spawned[i] = null;
                    }
                }

                foreach (var item in spawned.Where(item => item != null && !item.Deleted))
                {
                    item.Delete();
                }
            }
            catch (Exception e)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine(e);
                Utility.PopColor();
            }
        }
コード例 #57
0
ファイル: ItemManager.cs プロジェクト: aikoy/LeagueSharp-Dev
        public static void AddToMenu(Menu menu, ItemFlags itemFlags)
        {
            try
            {
                _menu = menu;
                _itemFlags = itemFlags;

                foreach (var item in
                    Items.Where(
                        i =>
                            i.CombatFlags.HasFlag(ObjectManager.Player.IsMelee ? CombatFlags.Melee : CombatFlags.Ranged) &&
                            ((i.Flags & _itemFlags) != 0)))
                {
                    if (item.Flags.HasFlag(ItemFlags.Offensive) || item.Flags.HasFlag(ItemFlags.Flee))
                    {
                        var itemMenu = _menu.AddSubMenu(new Menu(item.DisplayName, _menu.Name + "." + item.Name));

                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".min-enemies-range", "Min. Enemies in Range").SetValue(
                                new Slider(1, 0, 5)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".player-health-below", "Player Health % <=").SetValue(
                                new Slider(100)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".player-health-above", "Player Health % >=").SetValue(
                                new Slider(0)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".target-health-below", "Target Health % <=").SetValue(
                                new Slider(90)));
                        itemMenu.AddItem(
                            new MenuItem(itemMenu.Name + ".target-health-above", "Target Health % >=").SetValue(
                                new Slider(0)));

                        if (item.Flags.HasFlag(ItemFlags.Flee))
                        {
                            itemMenu.AddItem(new MenuItem(itemMenu.Name + ".flee", "Use Flee").SetValue(true));
                        }
                        if (item.Flags.HasFlag(ItemFlags.Offensive))
                        {
                            itemMenu.AddItem(new MenuItem(itemMenu.Name + ".combo", "Use Combo").SetValue(true));
                        }
                    }
                }

                var muramanaMenu = _menu.AddSubMenu(new Menu("Muramana", _menu.Name + ".muramana"));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".min-enemies-range", "Min. Enemies in Range").SetValue(
                        new Slider(1, 0, 5)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".player-mana-above", "Player Mana % >=").SetValue(new Slider(30)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".player-health-below", "Player Health % <=").SetValue(
                        new Slider(100)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".player-health-above", "Player Health % >=").SetValue(
                        new Slider(0)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".target-health-below", "Target Health % <=").SetValue(
                        new Slider(100)));
                muramanaMenu.AddItem(
                    new MenuItem(muramanaMenu.Name + ".target-health-above", "Target Health % >=").SetValue(
                        new Slider(0)));

                muramanaMenu.AddItem(new MenuItem(muramanaMenu.Name + ".combo", "Use Combo").SetValue(true));

                menu.AddItem(new MenuItem(menu.Name + ".enabled", "Enabled").SetValue(false));
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
コード例 #58
0
ファイル: ItemFixture.cs プロジェクト: Micky5991/Inventory
        public void SettingWeightChangableFlagWillBeInterpretedCorrectly(ItemFlags flags, bool weightChangable)
        {
            this.SetupServiceProvider(new ItemMeta(this.DefaultRealMeta.Handle, typeof(RealItem), this.DefaultRealMeta.DisplayName, this.DefaultRealMeta.DefaultWeight, flags));

            this.Item.WeightChangable.Should().Be(weightChangable);
        }
コード例 #59
0
ファイル: ImageList.cs プロジェクト: carrie901/mono
				internal ImageListItem(Image value, int imageCount) : this(value)
				{
					this.Flags = ItemFlags.ImageStrip;
					this.ImageCount = imageCount;
				}
コード例 #60
0
ファイル: ItemFlags.cs プロジェクト: otbr/OpenTibia
 public static bool Is(this ItemFlags flags, ItemFlags flag)
 {
     return((flags & flag) == flag);
 }