Пример #1
0
        public void AddItem(AOItem item)
        {
            int  nextfree = Low;
            bool free     = false;

            while (nextfree < Low + Spots)
            {
                free = true;
                foreach (InventoryEntry ie in Entries)
                {
                    if (nextfree == ie.Placement)
                    {
                        free = false;
                        break;
                    }
                }
                if (free)
                {
                    break;
                }

                nextfree++;
            }
            if (free)
            {
                InventoryEntry newentry = new InventoryEntry();
                newentry.Placement = nextfree;
                newentry.Item      = item.ShallowCopy();
                Entries.Add(newentry);
            }
        }
        public void AddItem(AOItem item)
        {
            int nextfree = Low;
            bool free = false;
            while (nextfree < Low + Spots)
            {
                free = true;
                foreach (InventoryEntry ie in Entries)
                {
                    if (nextfree == ie.Placement)
                    {
                        free = false;
                        break;
                    }
                }
                if (free)
                    break;

                nextfree++;
            }
            if (free)
            {
                InventoryEntry newentry = new InventoryEntry();
                newentry.Placement = nextfree;
                newentry.Item = item.ShallowCopy();
                Entries.Add(newentry);
            }
        }
        /// <summary>
        /// Add a Item to a Inventory page/place
        /// </summary>
        /// <param name="container">Number of Inventory page</param>
        /// <param name="place">Desired place</param>
        /// <param name="item">item to add</param>
        /// <returns>Success</returns>
        public InventoryEntry AddItem(int container, int place, AOItem item)
        {
            // Container ID's:
            // (x) 0065 Weaponpage 
            // (x) 0066 Armorpage
            // (x) 0067 Implantpage
            // (x) 0068 Inventory (places 64-93)
            // (x) 0069 Bank
            // ( ) 006B Backpack - this will take some time
            // ( ) 006C (KnuBot) Trade Window
            // ( ) 006E Overflow window
            // (x) 006F Trade Window/Next free spot in 0x68
            // (x) 0073 Socialpage
            // ( ) 0767 Shop Inventory
            // ( ) 0790 Playershop Inventory
            // (x) DEAD Bank (why FC, why???)

            switch (container)
            {
                // Equipment pages
                case 0x65:
                case 0x66:
                case 0x67:
                case 0x73:
                    {
                        if (GetInventoryEntryAt(container, place) == null)
                        {
                            InventoryEntry newentry = new InventoryEntry();
                            newentry.Item = item.ShallowCopy();
                            newentry.Placement = place;

                            GetPage(container).Entries.Add(newentry);
                            return newentry;
                        }
                        return null;
                    }
                // Look for next free main inventory spot
                case 0x6f:
                    {
                        int nextfree = 64;
                        while (nextfree < 94)
                        {
                            if (GetInventoryEntryAt(0x68, nextfree) == null)
                            {
                                InventoryEntry newentry = new InventoryEntry();
                                newentry.Item = item.ShallowCopy();
                                newentry.Placement = nextfree;

                                GetPage(0x68).Entries.Add(newentry);
                                return newentry;
                            }
                            nextfree++;
                        }
                        return null;
                    }
                // Bank
                case 0xDEAD:
                case 0x69: // 0x69 probably not needed
                    {
                        container = 0x69;
                        int nextfree = 0;
                        while (nextfree < 102)
                        {
                            if (GetInventoryEntryAt(container, nextfree) == null)
                            {
                                InventoryEntry newentry = new InventoryEntry();
                                newentry.Item = item.ShallowCopy();
                                newentry.Placement = nextfree;

                                GetPage(container).Entries.Add(newentry);
                                return newentry;
                            }
                            nextfree++;
                        }
                        return null;
                    }

            }
            return null;
        }
Пример #4
0
        /// <summary>
        /// Add a Item to a Inventory page/place
        /// </summary>
        /// <param name="container">Number of Inventory page</param>
        /// <param name="place">Desired place</param>
        /// <param name="item">item to add</param>
        /// <returns>Success</returns>
        public InventoryEntry AddItem(int container, int place, AOItem item)
        {
            // Container ID's:
            // (x) 0065 Weaponpage
            // (x) 0066 Armorpage
            // (x) 0067 Implantpage
            // (x) 0068 Inventory (places 64-93)
            // (x) 0069 Bank
            // ( ) 006B Backpack - this will take some time
            // ( ) 006C (KnuBot) Trade Window
            // ( ) 006E Overflow window
            // (x) 006F Trade Window/Next free spot in 0x68
            // (x) 0073 Socialpage
            // ( ) 0767 Shop Inventory
            // ( ) 0790 Playershop Inventory
            // (x) DEAD Bank (why FC, why???)

            switch (container)
            {
            // Equipment pages
            case 0x65:
            case 0x66:
            case 0x67:
            case 0x73:
            {
                if (GetInventoryEntryAt(container, place) == null)
                {
                    InventoryEntry newentry = new InventoryEntry();
                    newentry.Item      = item.ShallowCopy();
                    newentry.Placement = place;

                    GetPage(container).Entries.Add(newentry);
                    return(newentry);
                }
                return(null);
            }

            // Look for next free main inventory spot
            case 0x6f:
            {
                int nextfree = 64;
                while (nextfree < 94)
                {
                    if (GetInventoryEntryAt(0x68, nextfree) == null)
                    {
                        InventoryEntry newentry = new InventoryEntry();
                        newentry.Item      = item.ShallowCopy();
                        newentry.Placement = nextfree;

                        GetPage(0x68).Entries.Add(newentry);
                        return(newentry);
                    }
                    nextfree++;
                }
                return(null);
            }

            // Bank
            case 0xDEAD:
            case 0x69:     // 0x69 probably not needed
            {
                container = 0x69;
                int nextfree = 0;
                while (nextfree < 102)
                {
                    if (GetInventoryEntryAt(container, nextfree) == null)
                    {
                        InventoryEntry newentry = new InventoryEntry();
                        newentry.Item      = item.ShallowCopy();
                        newentry.Placement = nextfree;

                        GetPage(container).Entries.Add(newentry);
                        return(newentry);
                    }
                    nextfree++;
                }
                return(null);
            }
            }
            return(null);
        }
Пример #5
0
        /// <summary>
        /// Returns a interpolated version of the items
        /// </summary>
        /// <param name="lowID">low ID</param>
        /// <param name="highID">high ID</param>
        /// <param name="_QL">Quality level</param>
        /// <returns>interpolated AOItem</returns>
        public static AOItem interpolate(int lowID, int highID, int _QL)
        {
            AOItem low  = GetItemTemplate(lowID);
            AOItem high = GetItemTemplate(highID);
            AOItem interp;

            if (_QL < low.Quality)
            {
                _QL = low.Quality;
            }

            if (_QL > high.Quality)
            {
                _QL = high.Quality;
            }

            interp       = high.ShallowCopy();
            interp.LowID = low.LowID;
            if (_QL < high.Quality)
            {
                interp = low.ShallowCopy();
            }
            interp.HighID  = high.HighID;
            interp.Quality = _QL;
            if ((_QL == low.Quality) || (_QL == high.Quality))
            {
                return(interp);
            }
            int attnum = 0;

            // Effecting all attributes, even flags, it doesnt matter, High and low have always the same
            Single ival;
            Single factor = ((_QL - low.Quality) / (Single)(high.Quality - low.Quality));

            while (attnum < low.Stats.Count)
            {
                ival = (factor * (high.Stats[attnum].Value - low.Stats[attnum].Value)) + low.Stats[attnum].Value;
                interp.Stats[attnum].Value = Convert.ToInt32(ival); // Had to go int64 cos of the flags
                attnum++;
            }

            // TODO Requirements need interpolation too
            int    evnum = 0;
            int    fnum;
            int    anum;
            Single fval;

            while (evnum < interp.Events.Count)
            {
                fnum = 0;
                while (fnum < interp.Events[evnum].Functions.Count)
                {
                    anum = 0;
                    while (anum < interp.Events[evnum].Functions[fnum].Arguments.Values.Count)
                    {
                        if (high.Events[evnum].Functions[fnum].Arguments.Values[anum] is int)
                        {
                            ival = (factor *
                                    ((int)high.Events[evnum].Functions[fnum].Arguments.Values[anum] -
                                     (int)low.Events[evnum].Functions[fnum].Arguments.Values[anum])) +
                                   (int)low.Events[evnum].Functions[fnum].Arguments.Values[anum];
                            interp.Events[evnum].Functions[fnum].Arguments.Values[anum] = Convert.ToInt32(ival);
                        }
                        if (high.Events[evnum].Functions[fnum].Arguments.Values[anum] is Single)
                        {
                            fval = (factor *
                                    ((Single)high.Events[evnum].Functions[fnum].Arguments.Values[anum] -
                                     (Single)low.Events[evnum].Functions[fnum].Arguments.Values[anum])) +
                                   (Single)low.Events[evnum].Functions[fnum].Arguments.Values[anum];
                            interp.Events[evnum].Functions[fnum].Arguments.Values[anum] = fval;
                        }
                        anum++;
                    }
                    fnum++;
                }
                evnum++;
            }
            return(interp);
        }