public static void Send(Client cli, NonPlayerCharacterClass knubotTarget, AOItem[] items)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(cli.Character.Id);
            packetWriter.PushInt(0x7864401d);
            packetWriter.PushIdentity(cli.Character.Type, cli.Character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushShort(2);
            packetWriter.PushIdentity(knubotTarget.Type, knubotTarget.Id);
            packetWriter.PushInt(items.Length);
            foreach (AOItem item in items)
            {
                packetWriter.PushInt(item.LowID);
                packetWriter.PushInt(item.HighID);
                packetWriter.PushInt(item.Quality);
                packetWriter.PushInt(0x499602d2); // 1234567890  ???????
            }
            packetWriter.PushInt(0);

            byte[] packet = packetWriter.Finish();

            cli.SendCompressed(packet);
        }
Beispiel #2
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);
            }
        }
 /// <summary>
 /// Add item to main inventory
 /// </summary>
 /// <param name="it">AOItem to add to inventory</param>
 /// <returns>Resulting InventoryEntry</returns>
 public InventoryEntry AddItem(AOItem it)
 {
     return AddItem(0x6f, 0, it);
 }
        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;
        }
Beispiel #6
0
 /// <summary>
 /// Add item to main inventory
 /// </summary>
 /// <param name="it">AOItem to add to inventory</param>
 /// <returns>Resulting InventoryEntry</returns>
 public InventoryEntry AddItem(AOItem it)
 {
     return(AddItem(0x6f, 0, it));
 }
Beispiel #7
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);
        }
Beispiel #8
0
 public KnuBotTradeEventArgs(Character sender, AOItem item)
 {
     this.Sender = sender;
     this.Item = item;
 }
Beispiel #9
0
        public static void Convertitems()
        {

            SqlWrapper sql = new SqlWrapper();
            DataTable dt_items = sql.ReadDatatable("SELECT * FROM Items order by aoid asc");

            Stream sf = new FileStream("items.dat", FileMode.Create);

            ZOutputStream ds = new ZOutputStream(sf, zlibConst.Z_BEST_COMPRESSION);
            MemoryStream sm = new MemoryStream();

            //DeflateStream sm = new DeflateStream(sf, CompressionMode.Compress);



            BinaryFormatter bf = new BinaryFormatter();

            Console.WriteLine("Processing data... This will take a while!");
            List<AOItem> ITEMS = new List<AOItem>();
            int count = dt_items.Rows.Count;
            int oldperc = 0;
            int countall = 0;
            byte[] buffer = BitConverter.GetBytes(maxnum);
            sm.Write(buffer, 0, buffer.Length);
            if (File.Exists("items2.dat"))
            {
                ItemHandler.CacheAllItems("items2.dat");
                foreach (AOItem aoi in ItemHandler.ItemList)
                {
                    ITEMS.Add(aoi);
                    if (ITEMS.Count == maxnum)
                    {
                        bf.Serialize(sm, ITEMS);
                        sm.Flush();
                        ITEMS.Clear();
                        countall += maxnum;
                    }
                }
            }
            else
            {
                foreach (DataRow itemrow in dt_items.Rows)
                {
                    AOItem _item = new AOItem();
                    _item.LowID = (Int32)itemrow[0];
                    _item.HighID = (Int32)itemrow[0];
                    _item.Quality = (Int32)itemrow[2];
                    _item.ItemType = (Int32)itemrow[3];

                    DataTable dt_itemevents = sql.ReadDatatable("SELECT * FROM item_events WHERE itemid=" + _item.LowID + " ORDER BY eventid asc");

                    foreach (DataRow eventrow in dt_itemevents.Rows)
                    {
                        AOEvents aoe = new AOEvents();
                        aoe.EventType = (Int32)eventrow[2];
                        int eventid = (Int32)eventrow["eventid"];

                        DataTable dt_itemeventfunctions = sql.ReadDatatable("SELECT * FROM item_functions WHERE itemid=" + _item.LowID + " AND eventid=" + eventid + " ORDER BY functionid asc");

                        foreach (DataRow eventfunctionrow in dt_itemeventfunctions.Rows)
                        {
                            int eventfuncid = (Int32)eventfunctionrow["functionid"];
                            AOFunctions aof = new AOFunctions();
                            aof.FunctionType = (Int32)eventfunctionrow[3];
                            aof.Target = (Int32)eventfunctionrow[4];
                            aof.TickCount = (Int32)eventfunctionrow[5];
                            aof.TickInterval = (uint)(Int32)eventfunctionrow[6];

                            DataTable functionargs = sql.ReadDatatable("SELECT * FROM item_function_arguments WHERE functionid=" + eventfuncid + " AND eventid=" + eventid + " AND itemid=" + _item.LowID + " ORDER BY attrid asc");

                            foreach (DataRow attrs in functionargs.Rows)
                            {
                                if (!(attrs["argvalint"] is DBNull))
                                {
                                    aof.Arguments.Add((Int32)attrs["argvalint"]);
                                }
                                else
                                    if (!(attrs["argvalsingle"] is DBNull))
                                    {
                                        aof.Arguments.Add((Single)(float)attrs["argvalsingle"]);
                                    }
                                    else
                                        if (!(attrs["argvalstring"] is DBNull))
                                        {
                                            string s = attrs["argvalstring"].ToString();
                                            aof.Arguments.Add(s);
                                        }
                                        else
                                            throw (new NotSupportedException("No Argument value given, all NULL: " + _item.LowID));
                            }

                            DataTable reqs = sql.ReadDatatable("SELECT * from  item_function_reqs WHERE functionid=" + eventfuncid + " AND eventid=" + eventid + " AND itemid=" + _item.LowID + " ORDER BY reqid asc");

                            foreach (DataRow rrow in reqs.Rows)
                            {
                                AORequirements aor = new AORequirements();
                                aor.Statnumber = (Int32)rrow["attrnum"];
                                aor.Value = (Int32)rrow["attrval"];
                                aor.Target = (Int32)rrow["target"];
                                aor.Operator = (Int32)rrow["operator"];
                                aor.ChildOperator = (Int32)rrow["child_op"];
                                aof.Requirements.Add(aor);
                            }

                            aoe.Functions.Add(aof);
                        }

                        _item.Events.Add(aoe);
                    }

                    DataTable dt_actions = sql.ReadDatatable("SELECT * FROM item_actions WHERE itemid=" + _item.LowID);

                    foreach (DataRow acrow in dt_actions.Rows)
                    {
                        AOActions aoa = new AOActions();
                        aoa.ActionType = (Int32)acrow["actionnum"];

                        DataTable reqs = sql.ReadDatatable("SELECT * FROM item_action_reqs WHERE itemid=" + _item.LowID + " AND actionid=" + ((Int32)acrow["actionid"]) + " ORDER BY reqid ASC");

                        foreach (DataRow rrow in reqs.Rows)
                        {
                            AORequirements aor = new AORequirements();
                            aor.Statnumber = (Int32)rrow["attrnum"];
                            aor.Value = (Int32)rrow["attrval"];
                            aor.Target = (Int32)rrow["target"];
                            aor.Operator = (Int32)rrow["operator"];
                            aor.ChildOperator = (Int32)rrow["child_op"];
                            aoa.Requirements.Add(aor);
                        }
                        _item.Actions.Add(aoa);
                    }

                    DataTable dtdef = sql.ReadDatatable("SELECT * FROM item_defense_attributes where itemid=" + _item.LowID + " ORDER BY defenseid asc");

                    foreach (DataRow defrow in dtdef.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)defrow["num"];
                        aoia.Value = (Int32)defrow["value"];
                        _item.Defend.Add(aoia);
                    }

                    DataTable dtatt = sql.ReadDatatable("select * FROM item_attack_attributes where itemid=" + _item.LowID + " ORDER BY attackid asc");
                    foreach (DataRow defrow in dtatt.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)defrow["num"];
                        aoia.Value = (Int32)defrow["value"];
                        _item.Defend.Add(aoia);
                    }

                    DataTable attributes = sql.ReadDatatable("SELECT * FROM item_attributes WHERE itemid=" + _item.LowID + " ORDER BY attributeid asc");
                    foreach (DataRow atrow in attributes.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)atrow["num"];
                        aoia.Value = (Int32)atrow["value"];
                        _item.Stats.Add(aoia);
                    }


                    ITEMS.Add(_item);

                    int perc = Convert.ToInt32(Math.Floor((double)(ITEMS.Count + countall) / count * 100.0));
                    if (perc != oldperc)
                    {
                        Console.Write("\rDone " + perc.ToString().PadLeft(3) + "%");
                        oldperc = perc;
                    }
                    if (ITEMS.Count == maxnum)
                    {
                        bf.Serialize(sm, ITEMS);
                        sm.Flush();
                        ITEMS.Clear();
                        countall += maxnum;
                    }
                }
            }
            bf.Serialize(sm, ITEMS);
            sm.Seek(0, SeekOrigin.Begin);
            Console.WriteLine();
            CopyStream(sm, ds);
            sm.Close();
            ds.Close();
        }
Beispiel #10
0
 public void KnuBotTrade(Character character, AOItem item)
 {
     this.OnKnuBotTradeEvent(new KnuBotTradeEventArgs(character, item));
 }
Beispiel #11
0
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        public AOItem ShallowCopy()
        {
            AOItem it = new AOItem();
            it.LowID = this.LowID;
            it.HighID = this.HighID;

            foreach (AOItemAttribute ai in Attack)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Attack.Add(z);
            }

            foreach (AOItemAttribute ai in Defend)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Defend.Add(z);
            }

            foreach (AOItemAttribute ai in Stats)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Stats.Add(z);
            }

            foreach (AOEvents ev in Events)
            {
                AOEvents newEV = new AOEvents();
                foreach (AOFunctions aof in ev.Functions)
                {
                    AOFunctions newAOF = new AOFunctions();
                    foreach (AORequirements aor in aof.Requirements)
                    {
                        AORequirements newAOR = new AORequirements();
                        newAOR.ChildOperator = aor.ChildOperator;
                        newAOR.Operator = aor.Operator;
                        newAOR.Statnumber = aor.Statnumber;
                        newAOR.Target = aor.Target;
                        newAOR.Value = aor.Value;
                        newAOF.Requirements.Add(newAOR);
                    }

                    foreach (object ob in aof.Arguments)
                    {
                        if (ob.GetType() == typeof (string))
                        {
                            string z = (string) ob;
                            newAOF.Arguments.Add(z);
                        }
                        if (ob.GetType() == typeof (int))
                        {
                            int i = (int) ob;
                            newAOF.Arguments.Add(i);
                        }
                        if (ob.GetType() == typeof (Single))
                        {
                            Single s = (Single) ob;
                            newAOF.Arguments.Add(s);
                        }
                    }
                    newAOF.dolocalstats = aof.dolocalstats;
                    newAOF.FunctionType = aof.FunctionType;
                    newAOF.Target = aof.Target;
                    newAOF.TickCount = aof.TickCount;
                    newAOF.TickInterval = aof.TickInterval;
                    newEV.Functions.Add(newAOF);
                }
                newEV.EventType = ev.EventType;
                it.Events.Add(newEV);
            }


            it.Flags = this.Flags;
            it.Instance = Instance;
            it.ItemType = ItemType;
            it.MultipleCount = this.MultipleCount;
            it.Nothing = Nothing;
            it.Quality = Quality;

            return it;
        }
        public static void Send(Client client, AOItem item, int page, int placement)
        {
            // tell the client to remove (07) the item modifiers (AC, skills and so on)
            PacketWriter unequipPacketWriter = new PacketWriter();
            PacketWriter action97PacketWriter = new PacketWriter();

            //if (placement == 6)
            switch (placement)
            {
                case 6: // Right Hand
                    // Action 97
                    action97PacketWriter.PushByte(0xdf);
                    action97PacketWriter.PushByte(0xdf);
                    action97PacketWriter.PushShort(0xa);
                    action97PacketWriter.PushShort(0x1);
                    action97PacketWriter.PushShort(0);
                    action97PacketWriter.PushInt(3086);
                    action97PacketWriter.PushInt(client.Character.Id);
                    action97PacketWriter.PushInt(0x5E477770);
                    action97PacketWriter.PushInt(50000);
                    action97PacketWriter.PushInt(client.Character.Id);
                    action97PacketWriter.PushByte(0);
                    action97PacketWriter.PushInt(0x61);
                    action97PacketWriter.PushInt(0);
                    action97PacketWriter.PushInt(0);
                    action97PacketWriter.PushInt(0);
                    action97PacketWriter.PushInt(0);
                    action97PacketWriter.PushInt(0x6);
                    action97PacketWriter.PushShort(0);

                    byte[] action97Reply = action97PacketWriter.Finish();
                    client.SendCompressed(action97Reply);

                    break;

                default:
                    unequipPacketWriter.PushByte(0xdf);
                    unequipPacketWriter.PushByte(0xdf);
                    unequipPacketWriter.PushShort(0xa);
                    unequipPacketWriter.PushShort(0x1);
                    unequipPacketWriter.PushShort(0);
                    unequipPacketWriter.PushInt(3086);
                    unequipPacketWriter.PushInt(client.Character.Id);
                    unequipPacketWriter.PushInt(0x35505644);
                    unequipPacketWriter.PushInt(50000);
                    unequipPacketWriter.PushInt(client.Character.Id);
                    unequipPacketWriter.PushByte(0);
                    unequipPacketWriter.PushInt(item.LowID);
                    unequipPacketWriter.PushInt(item.HighID);
                    unequipPacketWriter.PushInt(item.Quality);
                    unequipPacketWriter.PushInt(1);
                    unequipPacketWriter.PushInt(7);
                    unequipPacketWriter.PushInt(page);
                    unequipPacketWriter.PushInt(placement);
                    unequipPacketWriter.PushInt(0);
                    unequipPacketWriter.PushInt(0);

                    byte[] unequipReply = unequipPacketWriter.Finish();
                    client.SendCompressed(unequipReply);
                    break;
            }
        }
Beispiel #13
0
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        public AOItem ShallowCopy()
        {
            AOItem it = new AOItem();

            it.LowID  = this.LowID;
            it.HighID = this.HighID;

            foreach (AOItemAttribute ai in Attack)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Attack.Add(z);
            }

            foreach (AOItemAttribute ai in Defend)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Defend.Add(z);
            }

            foreach (AOItemAttribute ai in Stats)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Stats.Add(z);
            }

            foreach (AOEvents ev in Events)
            {
                AOEvents newEV = new AOEvents();
                foreach (AOFunctions aof in ev.Functions)
                {
                    AOFunctions newAOF = new AOFunctions();
                    foreach (AORequirements aor in aof.Requirements)
                    {
                        AORequirements newAOR = new AORequirements();
                        newAOR.ChildOperator = aor.ChildOperator;
                        newAOR.Operator      = aor.Operator;
                        newAOR.Statnumber    = aor.Statnumber;
                        newAOR.Target        = aor.Target;
                        newAOR.Value         = aor.Value;
                        newAOF.Requirements.Add(newAOR);
                    }

                    foreach (object ob in aof.Arguments.Values)
                    {
                        if (ob.GetType() == typeof(string))
                        {
                            string z = (string)ob;
                            newAOF.Arguments.Values.Add(z);
                        }
                        if (ob.GetType() == typeof(int))
                        {
                            int i = (int)ob;
                            newAOF.Arguments.Values.Add(i);
                        }
                        if (ob.GetType() == typeof(Single))
                        {
                            Single s = (Single)ob;
                            newAOF.Arguments.Values.Add(s);
                        }
                    }
                    newAOF.dolocalstats = aof.dolocalstats;
                    newAOF.FunctionType = aof.FunctionType;
                    newAOF.Target       = aof.Target;
                    newAOF.TickCount    = aof.TickCount;
                    newAOF.TickInterval = aof.TickInterval;
                    newEV.Functions.Add(newAOF);
                }
                newEV.EventType = ev.EventType;
                it.Events.Add(newEV);
            }


            it.Flags         = this.Flags;
            it.Instance      = Instance;
            it.ItemType      = ItemType;
            it.MultipleCount = this.MultipleCount;
            it.Nothing       = Nothing;
            it.Quality       = Quality;

            return(it);
        }
Beispiel #14
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);
        }
        public static void Send(Client cli, AOItem it, int page, int placement)
        {
            PacketWriter equippacket = new PacketWriter();
            PacketWriter action167packet = new PacketWriter();
            PacketWriter action131packet = new PacketWriter();

            //if (placement == 6)
            switch (placement)
            {
                case 6: // Right Hand
                    /*
                    // ContainerAddItem Reply
                    equippacket.PushByte(0xdf);
                    equippacket.PushByte(0xdf);
                    equippacket.PushShort(0xa);
                    equippacket.PushShort(0x1);
                    equippacket.PushShort(0);
                    equippacket.PushInt(3086);
                    equippacket.PushInt(cli.Character.ID);
                    equippacket.PushInt(0x47537A24);
                    equippacket.PushInt(50000);
                    equippacket.PushInt(cli.Character.ID);
                    equippacket.PushByte(0);
                    equippacket.PushInt(0x60);
                    equippacket.PushInt(0x40);
                    equippacket.PushInt(50000);
                    equippacket.PushInt(cli.Character.ID);
                    equippacket.PushInt(0x6);
                    
                    byte[] reply = equippacket.Finish();
                    cli.SendCompressed(reply);
                    */
                    // Action 167 Reply
                    action167packet.PushByte(0xDF);
                    action167packet.PushByte(0xDF);
                    action167packet.PushShort(0xA);
                    action167packet.PushShort(0x1);
                    action167packet.PushShort(0);
                    action167packet.PushInt(3086);
                    action167packet.PushInt(cli.Character.Id);
                    action167packet.PushInt(0x5E477770);
                    action167packet.PushInt(50000);
                    action167packet.PushInt(cli.Character.Id);
                    action167packet.PushByte(0);
                    action167packet.PushInt(0xA7);
                    action167packet.PushInt(0);
                    action167packet.PushInt(0);
                    action167packet.PushInt(0);
                    action167packet.PushInt(0);
                    action167packet.PushInt(0);
                    action167packet.PushShort(0);

                    byte[] replyAction167 = action167packet.Finish();
                    cli.SendCompressed(replyAction167);

                    // Action 131 Reply
                    action131packet.PushByte(0xDF);
                    action131packet.PushByte(0xDF);
                    action131packet.PushShort(0xA);
                    action131packet.PushShort(0x1);
                    action131packet.PushShort(0);
                    action131packet.PushInt(3086);
                    action131packet.PushInt(cli.Character.Id);
                    action131packet.PushInt(0x5E477770);
                    action131packet.PushInt(50000);
                    action131packet.PushInt(cli.Character.Id);
                    action131packet.PushByte(0);
                    action131packet.PushInt(0x83);
                    action131packet.PushInt(0);
                    action131packet.PushInt(0xC74A);
                    action131packet.PushInt(0x4598815B);
                    action131packet.PushInt(0);
                    action131packet.PushInt(0x06);
                    action131packet.PushShort(0);

                    byte[] replyAction131 = action131packet.Finish();
                    cli.SendCompressed(replyAction131);

                    break;

                default:
                    // Default Template Action
                    equippacket.PushByte(0xdf);
                    equippacket.PushByte(0xdf);
                    equippacket.PushShort(0xa);
                    equippacket.PushShort(0x1);
                    equippacket.PushShort(0);
                    equippacket.PushInt(3086);
                    equippacket.PushInt(cli.Character.Id);
                    equippacket.PushInt(0x35505644);
                    equippacket.PushInt(50000);
                    equippacket.PushInt(cli.Character.Id);
                    equippacket.PushByte(0);
                    equippacket.PushInt(it.LowID);
                    equippacket.PushInt(it.HighID);
                    equippacket.PushInt(it.Quality);
                    equippacket.PushInt(1);
                    if ((placement >= 49) && (placement <= 63))
                    {
                        equippacket.PushInt(7);
                    }
                    else
                    {
                        equippacket.PushInt(6);
                    }
                    equippacket.PushInt(page);
                    equippacket.PushInt(placement);
                    equippacket.PushInt(0);
                    equippacket.PushInt(0);

                    byte[] defaultReply = equippacket.Finish();
                    if (!((placement >= 49) && (placement <= 63)))
                    {
                        cli.SendCompressed(defaultReply);
                    }
                    break;
            }
        }