Exemple #1
0
 protected override void ReadPacket(BinaryReader reader)
 {
     GridFrom = (MirGridType)reader.ReadByte();
     GridTo   = (MirGridType)reader.ReadByte();
     IDFrom   = reader.ReadUInt64();
     IDTo     = reader.ReadUInt64();
 }
Exemple #2
0
        public void Show(MirGridType grid, UserItem item)
        {
            if (item.Slots.Length == 0)
            {
                GameScene.SelectedItem = null;
                Visible = false;
                return;
            }

            GameScene.SelectedItem = item;

            Index = 20 + (GameScene.SelectedItem.Slots.Length - 1);

            BindGrid();

            CloseButton.Location = new Point(Size.Width - 23, 3);

            switch (grid)
            {
            case MirGridType.Inventory:
                Location = new Point(
                    GameScene.Scene.InventoryDialog.Location.X + ((GameScene.Scene.InventoryDialog.Size.Width - Size.Width) / 2),
                    GameScene.Scene.InventoryDialog.Location.Y + GameScene.Scene.InventoryDialog.Size.Height + 5);
                break;

            case MirGridType.Equipment:
                Location = new Point(
                    GameScene.Scene.CharacterDialog.Location.X + ((GameScene.Scene.CharacterDialog.Size.Width - Size.Width) / 2),
                    GameScene.Scene.CharacterDialog.Location.Y + GameScene.Scene.CharacterDialog.Size.Height + 5);
                break;
            }

            Visible = true;
        }
Exemple #3
0
 protected override void ReadPacket(BinaryReader reader)
 {
     Grid     = (MirGridType)reader.ReadByte();
     UniqueID = reader.ReadUInt64();
     To       = reader.ReadInt32();
     GridTo   = (MirGridType)reader.ReadByte();
 }
Exemple #4
0
        public void MoveItem(MirGridType G, int F, int T)
        {
            UserItem[] Array;
            switch (G)
            {
            case MirGridType.Inventory:
                Array = Inventory;
                break;

            case MirGridType.Storage:
                Array = Storage;
                break;

            default:
                return;
            }

            if (F >= 0 && T >= 0 && F < Array.Length && T < Array.Length)
            {
                UserItem I = Array[T];
                Array[T] = Array[F];
                Array[F] = I;
            }
            //Stacking
        }
Exemple #5
0
        public void EquipItem(MirGridType G, int U, int T)
        {
            if (!CanUseItem || T < 0 || T >= Equipment.Length)
            {
                return;
            }

            UserItem[] Array;
            switch (G)
            {
            case MirGridType.Inventory:
                Array = Inventory;
                break;

            case MirGridType.Storage:
                Array = Storage;
                break;

            default:
                return;
            }


            int      Index = -1;
            UserItem Temp  = null;

            for (int I = 0; I < Array.Length; I++)
            {
                Temp = Array[I];
                if (Temp != null && Temp.UniqueID == U)
                {
                    Index = I;
                    break;
                }
            }


            if (Temp == null || Index == -1)
            {
                //Send Fail
                return;
            }

            if (CanEquipItem(Temp, T))
            {
                Array[Index] = Equipment[T];
                Equipment[T] = Temp;
                RefreshAll();
                QueuePacket(new S.UpdateUserStats {
                    Details = GetStats()
                });
                //Broadcast Change in Details
            }
        }
Exemple #6
0
        public void ItemError(string source, MirGridType from, MirGridType to, int slotFrom, int slotTo)
        {
            string task = string.Empty;

            task = string.Format("Item Moved Error - from {0}:{1} to {2}:{3}", from, slotFrom, to, slotTo);

            Action action = new Action {
                Source = source, Task = task
            };

            RecordAction(action);
        }
Exemple #7
0
        //TOADD
        //ItemSplit
        //ItemMerge

        public void ItemCombined(string source, UserItem fromItem, UserItem toItem, int slotFrom, int slotTo, MirGridType grid)
        {
            string task = string.Empty;
            if (fromItem != null && toItem != null)
            {
                task = string.Format("Item Combined - {0} with {1} from {2} to {3} in {4} ({5})", fromItem.Info.Name, toItem.Info.Name, slotFrom, slotTo, grid, toItem.UniqueID);
            }

            Action action = new Action { Source = source, Task = task };

            RecordAction(action);
        }
Exemple #8
0
        public void ItemMoved(string source, UserItem item, MirGridType from, MirGridType to, int slotFrom, int slotTo)
        {
            string task = string.Empty;

            if (item != null)
            {
                task = string.Format("Item Moved - {0} from {1}:{2} to {3}:{4} ({5})", item.Info.Name, from, slotFrom, to, slotTo, item.UniqueID);
            }

            Action action = new Action { Source = source, Task = task };

            RecordAction(action);
        }
Exemple #9
0
        public void ItemMoved(string source, UserItem item, MirGridType from, MirGridType to, int slotFrom, int slotTo, string info = "")
        {
            string task = string.Empty;

            if (item != null)
            {
                task = string.Format("Item Moved - {0} from {1}:{2} to {3}:{4} ({5})", item.Info.Name, from, slotFrom, to, slotTo, item.UniqueID);
            }

            Action action = new Action {
                Source = source, Task = task, AddedInfo = info
            };

            RecordAction(action);
        }
Exemple #10
0
        public void UseItem(MirGridType G, int U)
        {
            if (!CanUseItem)
            {
                //Send Fail
                return;
            }

            UserItem Temp  = null;
            int      Index = -1;

            for (int I = 0; I < Inventory.Length; I++)
            {
                Temp = Inventory[I];
                if (Temp != null && Temp.UniqueID == U)
                {
                    Index = I;
                    break;
                }
            }

            if (Temp == null || Index == -1)
            {
                //Send Fail (?)
                return;
            }

            switch (Temp.Info.ItemType)
            {
            case MirItemType.Potion:
                Interlocked.Add(ref PotHealthAmount, Temp.Info.Health);
                Interlocked.Add(ref PotManaAmount, Temp.Info.Mana);
                break;

            default:
                return;
            }
            if (Temp.Amount > 1)
            {
                Temp.Amount--;
            }
            else
            {
                Inventory[Index] = null;
            }
        }
Exemple #11
0
        public void ItemMoved(string source, UserItem item, MirGridType from, MirGridType to, int slotFrom, int slotTo)
        {
            string task     = string.Empty;
            ulong  uniqueID = 0;

            if (item != null)
            {
                task = string.Format("Item Moved - {0} from {1}:{2} to {3}:{4}", item.Info.Name, from, slotFrom, to, slotTo);

                uniqueID = item.UniqueID;
            }

            Action action = new Action {
                Source = source, Task = task, UniqueID = uniqueID
            };

            RecordAction(action);
        }
Exemple #12
0
        public bool CanRemoveItem(MirGridType G, UserItem I)
        {
            UserItem[] Array;
            switch (G)
            {
            case MirGridType.Inventory:
                Array = Inventory;
                break;

            case MirGridType.Storage:
                Array = Storage;
                break;

            default:
                return(false);
            }

            return(Array.Count(O => O == null) > 0);
        }
Exemple #13
0
        public void DropItem(MirGridType G, int U)
        {
            UserItem[] Array;
            switch (G)
            {
            case MirGridType.Inventory:
                Array = Inventory;
                break;

            case MirGridType.Storage:
                Array = Storage;
                break;

            default:
                return;
            }

            UserItem Temp  = null;
            int      Index = -1;

            for (int I = 0; I < Inventory.Length; I++)
            {
                Temp = Inventory[I];
                if (Temp != null && Temp.UniqueID == U)
                {
                    Index = I;
                    break;
                }
            }

            if (Temp == null || Index == -1)
            {
                //Send Fail (?)
                return;
            }

            Array[Index] = null;
            DropItem(Temp);
        }
        public void EquipSlotItem(MirGridType grid, ulong id, int to, MirGridType gridTo)
        {
            S.EquipSlotItem p = new S.EquipSlotItem { Grid = grid, UniqueID = id, To = to, GridTo = gridTo, Success = false };

            UserItem Item = null;

            switch (gridTo)
            {
                case MirGridType.Mount:
                    Item = Info.Equipment[(int)EquipmentSlot.Mount];
                    break;
                case MirGridType.Fishing:
                    Item = Info.Equipment[(int)EquipmentSlot.Weapon];
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (Item == null || Item.Slots == null)
            {
                Enqueue(p);
                return;
            }

            if (gridTo == MirGridType.Fishing && (Item.Info.Shape != 49 && Item.Info.Shape != 50))
            {
                Enqueue(p);
                return;
            }

            if (to < 0 || to >= Item.Slots.Length)
            {
                Enqueue(p);
                return;
            }

            if (Item.Slots[to] != null)
            {
                Enqueue(p);
                return;
            }

            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }


            int index = -1;
            UserItem temp = null;

            for (int i = 0; i < array.Length; i++)
            {
                temp = array[i];
                if (temp == null || temp.UniqueID != id) continue;
                index = i;
                break;
            }

            if (temp == null || index == -1)
            {
                Enqueue(p);
                return;
            }

            if ((temp.SoulBoundId != -1) && (temp.SoulBoundId != Info.Index))
            {
                Enqueue(p);
                return;
            }


            if (CanUseItem(temp))
            {
                if (temp.Info.NeedIdentify && !temp.Identified)
                {
                    temp.Identified = true;
                    Enqueue(new S.RefreshItem { Item = temp });
                }
                //if ((temp.Info.BindOnEquip) && (temp.SoulBoundId == -1))
                //{
                //    temp.SoulBoundId = Info.Index;
                //    Enqueue(new S.RefreshItem { Item = temp });
                //}
                //if (UnlockCurse && Info.Equipment[to].Cursed)
                //    UnlockCurse = false;

                Item.Slots[to] = temp;
                array[index] = null;

                p.Success = true;
                Enqueue(p);
                RefreshStats();

                Report.ItemMoved("EquipSlotItem", temp, grid, gridTo, index, to);

                return;
            }

            Enqueue(p);
        }
        public void EquipItem(MirGridType grid, ulong id, int to)
        {
            S.EquipItem p = new S.EquipItem { Grid = grid, UniqueID = id, To = to, Success = false };
            if (to < 0 || to >= Info.Equipment.Length)
            {
                Enqueue(p);
                return;
            }
            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || NPCPage.Key != NPCObject.StorageKey)
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            int index = -1;
            UserItem temp = null;

            for (int i = 0; i < array.Length; i++)
            {
                temp = array[i];
                if (temp == null || temp.UniqueID != id) continue;
                index = i;
                break;
            }

            if (temp == null || index == -1)
            {
                Enqueue(p);
                return;
            }

            if (CanEquipItem(temp, to))
            {
                array[index] = Info.Equipment[to];
                Info.Equipment[to] = temp;
                p.Success = true;
                Enqueue(p);
                RefreshStats();
                Broadcast(GetUpdateInfo());
                return;
            }
            Enqueue(p);
        }
Exemple #16
0
        public void RemoveItem(MirGridType G, int U, int T)
        {
            if (!CanUseItem)
            {
                return;
            }

            UserItem[] Array;
            switch (G)
            {
            case MirGridType.Inventory:
                Array = Inventory;
                break;

            case MirGridType.Storage:
                Array = Storage;
                break;

            default:
                return;
            }

            if (T < 0 || T >= Array.Length)
            {
                return;
            }

            UserItem Temp  = null;
            int      Index = -1;

            for (int I = 0; I < Equipment.Length; I++)
            {
                Temp = Equipment[I];
                if (Temp != null && Temp.UniqueID == U)
                {
                    Index = I;
                    break;
                }
            }

            if (Temp == null || Index == -1)
            {
                //Send Fail
                return;
            }

            if (!CanRemoveItem(G, Temp))
            {
                return;
            }
            Equipment[Index] = null;

            if (Array[T] == null)
            {
                Array[T] = Temp;
            }
            else
            {
                for (int I = 0; I < Array.Length; I++)
                {
                    if (Array[I] == null)
                    {
                        Array[I] = Temp;
                        break;
                    }
                }
            }


            RefreshAll();
            QueuePacket(new S.UpdateUserStats {
                Details = GetStats()
            });
        }
Exemple #17
0
 public static void MoveItem(MirGridType G, int F, int T)
 {
     Network.Enqueue(new MoveItem {
         Grid = G, From = F, To = T
     });
 }
Exemple #18
0
 protected override void ReadPacket(BinaryReader BReader)
 {
     Grid     = (MirGridType)BReader.ReadByte();
     UniqueID = BReader.ReadInt32();
 }
Exemple #19
0
 protected override void ReadPacket(BinaryReader reader)
 {
     GridFrom = (MirGridType)reader.ReadByte();
     GridTo = (MirGridType)reader.ReadByte();
     IDFrom = reader.ReadUInt64();
     IDTo = reader.ReadUInt64();
     Success = reader.ReadBoolean();
 }
Exemple #20
0
        protected override void ReadPacket(BinaryReader reader)
        {
            if (reader.ReadBoolean())
                Item = new UserItem(reader);

            Grid = (MirGridType)reader.ReadByte();
        }
Exemple #21
0
        public void ItemMoved(UserItem item, MirGridType from, MirGridType to, int slotFrom, int slotTo, string info = "", [CallerMemberName] string source = "")
        {
            string message = $"Item Moved - {(item != null ? item.Info.Name : "Empty")} from {from}:{slotFrom} to {to}:{slotTo} ({item?.UniqueID}) {info}";

            LogMessage(message, source);
        }
Exemple #22
0
        public void ItemCombined(UserItem fromItem, UserItem toItem, int slotFrom, int slotTo, MirGridType grid, [CallerMemberName] string source = "")
        {
            string message = $"Item Combined - {fromItem.Info.Name} with {toItem.Info.Name} from {slotFrom} to {slotTo} in {grid} ({toItem.UniqueID})";

            LogMessage(message, source);
        }
Exemple #23
0
        public void ItemSplit(UserItem item, UserItem newItem, MirGridType grid, [CallerMemberName] string source = "")
        {
            string message = $"Item Split - {item.Info.Name} from x{item.Count + newItem.Count} to x{item.Count} in {grid} - Created new item ({newItem.UniqueID}) x {newItem.Count}";

            LogMessage(message, source);
        }
Exemple #24
0
        public void ItemError(MirGridType from, MirGridType to, int slotFrom, int slotTo, [CallerMemberName] string source = "")
        {
            string message = $"Item Moved Error - from {from}:{slotFrom} to {to}:{slotTo}";

            LogMessage(message, source);
        }
Exemple #25
0
        public void RemoveItem(MirGridType grid, ulong id, int to)
        {
            S.RemoveItem p = new S.RemoveItem { Grid = grid, UniqueID = id, To = to, Success = false };
            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (to < 0 || to >= array.Length) return;

            UserItem temp = null;
            int index = -1;

            for (int i = 0; i < Info.Equipment.Length; i++)
            {
                temp = Info.Equipment[i];
                if (temp == null || temp.UniqueID != id) continue;
                index = i;
                break;
            }

            if (temp == null || index == -1)
            {
                Enqueue(p);
                return;
            }
            if (temp.Cursed && !UnlockCurse)
            {
                Enqueue(p);
                return;
            }

            if (!CanRemoveItem(grid, temp)) return;
            Info.Equipment[index] = null;
            if (temp.Cursed)
                UnlockCurse = false;
            if (array[to] == null)
            {
                array[to] = temp;
                p.Success = true;
                Enqueue(p);
                RefreshStats();
                Broadcast(GetUpdateInfo());
                return;
            }

            Enqueue(p);
        }
Exemple #26
0
        public void MoveItem(MirGridType grid, int from, int to)
        {
            S.MoveItem p = new S.MoveItem { Grid = grid, From = from, To = to, Success = false };
            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (from >= 0 && to >= 0 && from < array.Length && to < array.Length)
            {
                UserItem i = array[to];
                array[to] = array[from];
                array[from] = i;

                p.Success = true;
                Enqueue(p);
                return;
            }

            Enqueue(p);
        }
Exemple #27
0
        public CharacterDialog(MirGridType gridType, UserObject actor)
        {
            Actor    = actor;
            GridType = gridType;

            Index    = gridType == MirGridType.HeroEquipment ? 505 : 504;
            Library  = Libraries.Title;
            Location = new Point(Settings.ScreenWidth - 264, 0);
            Movable  = true;
            Sort     = true;

            BeforeDraw += (o, e) => RefreshInterface();

            CharacterPage = new MirImageControl
            {
                Index    = 340,
                Parent   = this,
                Library  = Libraries.Prguse,
                Location = new Point(8, 90),
            };
            CharacterPage.AfterDraw += (o, e) =>
            {
                if (Libraries.StateItems == null)
                {
                    return;
                }
                ItemInfo RealItem = null;
                if (Grid[(int)EquipmentSlot.Armour].Item != null)
                {
                    if (actor.WingEffect == 1 || actor.WingEffect == 2)
                    {
                        int wingOffset = actor.WingEffect == 1 ? 2 : 4;

                        int genderOffset = actor.Gender == MirGender.Male ? 0 : 1;

                        Libraries.Prguse2.DrawBlend(1200 + wingOffset + genderOffset, DisplayLocation, Color.White, true, 1F);
                    }

                    RealItem = Functions.GetRealItem(Grid[(int)EquipmentSlot.Armour].Item.Info, actor.Level, actor.Class, GameScene.ItemInfoList);
                    Libraries.StateItems.Draw(RealItem.Image, DisplayLocation, Color.White, true, 1F);
                }
                if (Grid[(int)EquipmentSlot.Weapon].Item != null)
                {
                    RealItem = Functions.GetRealItem(Grid[(int)EquipmentSlot.Weapon].Item.Info, actor.Level, actor.Class, GameScene.ItemInfoList);
                    Libraries.StateItems.Draw(RealItem.Image, DisplayLocation, Color.White, true, 1F);
                }

                if (Grid[(int)EquipmentSlot.Helmet].Item != null)
                {
                    Libraries.StateItems.Draw(Grid[(int)EquipmentSlot.Helmet].Item.Info.Image, DisplayLocation, Color.White, true, 1F);
                }
                else
                {
                    int hair = 441 + actor.Hair + (actor.Class == MirClass.Assassin ? 20 : 0) + (actor.Gender == MirGender.Male ? 0 : 40);

                    int offSetX = actor.Class == MirClass.Assassin ? (actor.Gender == MirGender.Male ? 6 : 4) : 0;
                    int offSetY = actor.Class == MirClass.Assassin ? (actor.Gender == MirGender.Male ? 25 : 18) : 0;

                    Libraries.Prguse.Draw(hair, new Point(DisplayLocation.X + offSetX, DisplayLocation.Y + offSetY), Color.White, true, 1F);
                }
            };

            StatusPage = new MirImageControl
            {
                Index    = 506,
                Parent   = this,
                Library  = Libraries.Title,
                Location = new Point(8, 90),
                Visible  = false,
            };
            StatusPage.BeforeDraw += (o, e) =>
            {
                ACLabel.Text      = string.Format("{0}-{1}", actor.Stats[Stat.MinAC], actor.Stats[Stat.MaxAC]);
                MACLabel.Text     = string.Format("{0}-{1}", actor.Stats[Stat.MinMAC], actor.Stats[Stat.MaxMAC]);
                DCLabel.Text      = string.Format("{0}-{1}", actor.Stats[Stat.MinDC], actor.Stats[Stat.MaxDC]);
                MCLabel.Text      = string.Format("{0}-{1}", actor.Stats[Stat.MinMC], actor.Stats[Stat.MaxMC]);
                SCLabel.Text      = string.Format("{0}-{1}", actor.Stats[Stat.MinSC], actor.Stats[Stat.MaxSC]);
                HealthLabel.Text  = string.Format("{0}/{1}", actor.HP, actor.Stats[Stat.HP]);
                ManaLabel.Text    = string.Format("{0}/{1}", actor.MP, actor.Stats[Stat.MP]);
                CritRLabel.Text   = string.Format("{0}%", actor.Stats[Stat.CriticalRate]);
                CritDLabel.Text   = string.Format("{0}", actor.Stats[Stat.CriticalDamage]);
                AttkSpdLabel.Text = string.Format("{0}", actor.Stats[Stat.AttackSpeed]);
                AccLabel.Text     = string.Format("+{0}", actor.Stats[Stat.Accuracy]);
                AgilLabel.Text    = string.Format("+{0}", actor.Stats[Stat.Agility]);
                LuckLabel.Text    = string.Format("{0}", actor.Stats[Stat.Luck]);
            };

            StatePage = new MirImageControl
            {
                Index    = 507,
                Parent   = this,
                Library  = Libraries.Title,
                Location = new Point(8, 90),
                Visible  = false
            };
            StatePage.BeforeDraw += (o, e) =>
            {
                ExpPLabel.Text      = string.Format("{0:0.##%}", actor.Experience / (double)actor.MaxExperience);
                BagWLabel.Text      = string.Format("{0}/{1}", actor.CurrentBagWeight, actor.Stats[Stat.BagWeight]);
                WearWLabel.Text     = string.Format("{0}/{1}", actor.CurrentWearWeight, actor.Stats[Stat.WearWeight]);
                HandWLabel.Text     = string.Format("{0}/{1}", actor.CurrentHandWeight, actor.Stats[Stat.HandWeight]);
                MagicRLabel.Text    = string.Format("+{0}", actor.Stats[Stat.MagicResist]);
                PoisonResLabel.Text = string.Format("+{0}", actor.Stats[Stat.PoisonResist]);
                HealthRLabel.Text   = string.Format("+{0}", actor.Stats[Stat.HealthRecovery]);
                ManaRLabel.Text     = string.Format("+{0}", actor.Stats[Stat.SpellRecovery]);
                PoisonRecLabel.Text = string.Format("+{0}", actor.Stats[Stat.PoisonRecovery]);
                HolyTLabel.Text     = string.Format("+{0}", actor.Stats[Stat.Holy]);
                FreezeLabel.Text    = string.Format("+{0}", actor.Stats[Stat.Freezing]);
                PoisonAtkLabel.Text = string.Format("+{0}", actor.Stats[Stat.PoisonAttack]);
            };


            SkillPage = new MirImageControl
            {
                Index    = 508,
                Parent   = this,
                Library  = Libraries.Title,
                Location = new Point(8, 90),
                Visible  = false
            };


            CharacterButton = new MirButton
            {
                Index        = 500,
                Library      = Libraries.Title,
                Location     = new Point(8, 70),
                Parent       = this,
                PressedIndex = 500,
                Size         = new Size(64, 20),
                Sound        = SoundList.ButtonA,
            };
            CharacterButton.Click += (o, e) => ShowCharacterPage();
            StatusButton           = new MirButton
            {
                Library      = Libraries.Title,
                Location     = new Point(70, 70),
                Parent       = this,
                PressedIndex = 501,
                Size         = new Size(64, 20),
                Sound        = SoundList.ButtonA
            };
            StatusButton.Click += (o, e) => ShowStatusPage();

            StateButton = new MirButton
            {
                Library      = Libraries.Title,
                Location     = new Point(132, 70),
                Parent       = this,
                PressedIndex = 502,
                Size         = new Size(64, 20),
                Sound        = SoundList.ButtonA
            };
            StateButton.Click += (o, e) => ShowStatePage();

            SkillButton = new MirButton
            {
                Library      = Libraries.Title,
                Location     = new Point(194, 70),
                Parent       = this,
                PressedIndex = 503,
                Size         = new Size(64, 20),
                Sound        = SoundList.ButtonA
            };
            SkillButton.Click += (o, e) => ShowSkillPage();

            CloseButton = new MirButton
            {
                HoverIndex   = 361,
                Index        = 360,
                Location     = new Point(241, 3),
                Library      = Libraries.Prguse2,
                Parent       = this,
                PressedIndex = 362,
                Sound        = SoundList.ButtonA,
            };
            CloseButton.Click += (o, e) => Hide();

            NameLabel = new MirLabel
            {
                DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
                Parent     = this,
                Location   = new Point(0, 12),
                Size       = new Size(264, 20),
                NotControl = true,
            };
            GuildLabel = new MirLabel
            {
                DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
                Parent     = this,
                Location   = new Point(0, 33),
                Size       = new Size(264, 30),
                NotControl = true,
            };
            ClassImage = new MirImageControl
            {
                Index      = 100,
                Library    = Libraries.Prguse,
                Location   = new Point(15, 33),
                Parent     = this,
                NotControl = true,
            };

            Grid = new MirItemCell[Enum.GetNames(typeof(EquipmentSlot)).Length];

            Grid[(int)EquipmentSlot.Weapon] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Weapon,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(123, 7),
            };


            Grid[(int)EquipmentSlot.Armour] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Armour,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(163, 7),
            };


            Grid[(int)EquipmentSlot.Helmet] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Helmet,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(203, 7),
            };



            Grid[(int)EquipmentSlot.Torch] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Torch,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(203, 134),
            };


            Grid[(int)EquipmentSlot.Necklace] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Necklace,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(203, 98),
            };


            Grid[(int)EquipmentSlot.BraceletL] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.BraceletL,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(8, 170),
            };

            Grid[(int)EquipmentSlot.BraceletR] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.BraceletR,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(203, 170),
            };

            Grid[(int)EquipmentSlot.RingL] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.RingL,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(8, 206),
            };

            Grid[(int)EquipmentSlot.RingR] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.RingR,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(203, 206),
            };


            Grid[(int)EquipmentSlot.Amulet] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Amulet,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(8, 242),
            };


            Grid[(int)EquipmentSlot.Boots] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Boots,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(48, 242),
            };

            Grid[(int)EquipmentSlot.Belt] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Belt,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(88, 242),
            };


            Grid[(int)EquipmentSlot.Stone] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Stone,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(128, 242),
            };

            Grid[(int)EquipmentSlot.Mount] = new MirItemCell
            {
                ItemSlot = (int)EquipmentSlot.Mount,
                GridType = gridType,
                Parent   = CharacterPage,
                Location = new Point(203, 62),
            };

            // STATS I
            HealthLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 20),
                NotControl = true,
                Text       = "0-0",
            };

            ManaLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 38),
                NotControl = true,
                Text       = "0-0",
            };

            ACLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 56),
                NotControl = true,
                Text       = "0-0",
            };

            MACLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 74),
                NotControl = true,
                Text       = "0-0",
            };
            DCLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 92),
                NotControl = true,
                Text       = "0-0"
            };
            MCLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 110),
                NotControl = true,
                Text       = "0/0"
            };
            SCLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 128),
                NotControl = true,
                Text       = "0/0"
            };
            //Breezer - New Labels
            CritRLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 146),
                NotControl = true
            };
            CritDLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 164),
                NotControl = true
            };
            AttkSpdLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 182),
                NotControl = true
            };
            AccLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 200),
                NotControl = true
            };
            AgilLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 218),
                NotControl = true
            };
            LuckLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatusPage,
                Location   = new Point(126, 236),
                NotControl = true
            };
            // STATS II
            ExpPLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 20),
                NotControl = true,
                Text       = "0-0",
            };

            BagWLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 38),
                NotControl = true,
                Text       = "0-0",
            };

            WearWLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 56),
                NotControl = true,
                Text       = "0-0",
            };

            HandWLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 74),
                NotControl = true,
                Text       = "0-0",
            };
            MagicRLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 92),
                NotControl = true,
                Text       = "0-0"
            };
            PoisonResLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 110),
                NotControl = true,
                Text       = "0/0"
            };
            HealthRLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 128),
                NotControl = true,
                Text       = "0/0"
            };
            //Breezer
            ManaRLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 146),
                NotControl = true
            };
            PoisonRecLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 164),
                NotControl = true
            };
            HolyTLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 182),
                NotControl = true
            };
            FreezeLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 200),
                NotControl = true
            };
            PoisonAtkLabel = new MirLabel
            {
                AutoSize   = true,
                Parent     = StatePage,
                Location   = new Point(126, 218),
                NotControl = true
            };

            Magics = new MagicButton[7];

            for (int i = 0; i < Magics.Length; i++)
            {
                Magics[i] = new MagicButton
                {
                    Parent    = SkillPage,
                    Visible   = false,
                    Location  = new Point(8, 8 + i * 33),
                    HeroMagic = gridType == MirGridType.HeroEquipment
                }
            }
            ;

            NextButton = new MirButton
            {
                Index        = 396,
                Location     = new Point(140, 250),
                Library      = Libraries.Prguse,
                Parent       = SkillPage,
                PressedIndex = 397,
                Sound        = SoundList.ButtonA,
            };
            NextButton.Click += (o, e) =>
            {
                if (StartIndex + 7 >= actor.Magics.Count)
                {
                    return;
                }

                StartIndex += 7;
                RefreshInterface();
            };

            BackButton = new MirButton
            {
                Index        = 398,
                Location     = new Point(90, 250),
                Library      = Libraries.Prguse,
                Parent       = SkillPage,
                PressedIndex = 399,
                Sound        = SoundList.ButtonA,
            };
            BackButton.Click += (o, e) =>
            {
                if (StartIndex - 7 < 0)
                {
                    return;
                }

                StartIndex -= 7;
                RefreshInterface();
            };
        }
Exemple #28
0
 protected override void ReadPacket(BinaryReader reader)
 {
     Grid = (MirGridType)reader.ReadByte();
     From = reader.ReadInt32();
     To = reader.ReadInt32();
 }
Exemple #29
0
 protected override void ReadPacket(BinaryReader reader)
 {
     Grid = (MirGridType)reader.ReadByte();
     UniqueID = reader.ReadUInt64();
     Count = reader.ReadUInt32();
 }
Exemple #30
0
 protected override void ReadPacket(BinaryReader reader)
 {
     Grid = (MirGridType)reader.ReadByte();
     From = reader.ReadInt32();
     To   = reader.ReadInt32();
 }
Exemple #31
0
 protected override void ReadPacket(BinaryReader reader)
 {
     Grid = (MirGridType)reader.ReadByte();
     UniqueID = reader.ReadUInt64();
     To = reader.ReadInt32();
     Success = reader.ReadBoolean();
 }
Exemple #32
0
 public static void RemoveItem(MirGridType G, int U, int T)
 {
     Network.Enqueue(new RemoveItem {
         Grid = G, UniqueID = U, To = T
     });
 }
Exemple #33
0
        public void ItemError(string source, MirGridType from, MirGridType to, int slotFrom, int slotTo)
        {
            string task = string.Empty;

            task = string.Format("Item Moved Error - from {0}:{1} to {2}:{3}", from, slotFrom, to, slotTo);

            Action action = new Action { Source = source, Task = task };

            RecordAction(action);
        }
        public void EquipItem(MirGridType grid, ulong id, int to)
        {
            S.EquipItem p = new S.EquipItem { Grid = grid, UniqueID = id, To = to, Success = false };

            if (Fishing)
            {
                Enqueue(p);
                return;
            }

            if (to < 0 || to >= Info.Equipment.Length)
            {
                Enqueue(p);
                return;
            }

            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }


            int index = -1;
            UserItem temp = null;

            for (int i = 0; i < array.Length; i++)
            {
                temp = array[i];
                if (temp == null || temp.UniqueID != id) continue;
                index = i;
                break;
            }

            if (temp == null || index == -1)
            {
                Enqueue(p);
                return;
            }
            if ((Info.Equipment[to] != null) && (Info.Equipment[to].Cursed) && (!UnlockCurse))
            {
                Enqueue(p);
                return;
            }

            if ((temp.SoulBoundId != -1) && (temp.SoulBoundId != Info.Index))
            {
                Enqueue(p);
                return;
            }

            if (Info.Equipment[to] != null)
                if (Info.Equipment[to].WeddingRing != -1)
                {
                    Enqueue(p);
                    return;
                }


            if (CanEquipItem(temp, to))
            {
                if (temp.Info.NeedIdentify && !temp.Identified)
                {
                    temp.Identified = true;
                    Enqueue(new S.RefreshItem { Item = temp });
                }
                if ((temp.Info.Bind.HasFlag(BindMode.BindOnEquip)) && (temp.SoulBoundId == -1))
                {
                    temp.SoulBoundId = Info.Index;
                    Enqueue(new S.RefreshItem { Item = temp });
                }

                if ((Info.Equipment[to] != null) && (Info.Equipment[to].Cursed) && (UnlockCurse))
                    UnlockCurse = false;

                array[index] = Info.Equipment[to];

                Report.ItemMoved("RemoveItem", temp, MirGridType.Equipment, grid, to, index);

                Info.Equipment[to] = temp;

                Report.ItemMoved("EquipItem", temp, grid, MirGridType.Equipment, index, to);

                p.Success = true;
                Enqueue(p);
                RefreshStats();

                //Broadcast(GetUpdateInfo());
                return;
            }
            Enqueue(p);
        }
Exemple #35
0
 public ChatItem(BinaryReader reader)
 {
     UniqueID = reader.ReadUInt64();
     Title    = reader.ReadString();
     Grid     = (MirGridType)reader.ReadByte();
 }
        public void SplitItem(MirGridType grid, ulong id, uint count)
        {
            S.SplitItem1 p = new S.SplitItem1 { Grid = grid, UniqueID = id, Count = count, Success = false };
            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            UserItem temp = null;


            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == null || array[i].UniqueID != id) continue;
                temp = array[i];
                break;
            }

            if (temp == null || count >= temp.Count || FreeSpace(array) == 0)
            {
                Enqueue(p);
                return;
            }

            temp.Count -= count;

            temp = Envir.CreateFreshItem(temp.Info);
            temp.Count = count;

            p.Success = true;
            Enqueue(p);
            Enqueue(new S.SplitItem { Item = temp, Grid = grid });

            if (grid == MirGridType.Inventory && (temp.Info.Type == ItemType.Potion || temp.Info.Type == ItemType.Scroll || temp.Info.Type == ItemType.Amulet))
            {
                if (temp.Info.Type == ItemType.Potion || temp.Info.Type == ItemType.Scroll)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (array[i] != null) continue;
                        array[i] = temp;
                        RefreshBagWeight();
                        return;
                    }
                }
                else if (temp.Info.Type == ItemType.Amulet)
                {
                    for (int i = 4; i < 6; i++)
                    {
                        if (array[i] != null) continue;
                        array[i] = temp;
                        RefreshBagWeight();
                        return;
                    }
                }
            }

            for (int i = 6; i < array.Length; i++)
            {
                if (array[i] != null) continue;
                array[i] = temp;
                RefreshBagWeight();
                return;
            }
        }
Exemple #37
0
        //TOADD
        //ItemSplit
        //ItemMerge

        public void ItemCombined(string source, UserItem fromItem, UserItem toItem, int slotFrom, int slotTo, MirGridType grid)
        {
            string task = string.Empty;

            if (fromItem != null && toItem != null)
            {
                task = string.Format("Item Combined - {0} with {1} from {2} to {3} in {4} ({5})", fromItem.Info.Name, toItem.Info.Name, slotFrom, slotTo, grid, toItem.UniqueID);
            }

            Action action = new Action {
                Source = source, Task = task
            };

            RecordAction(action);
        }
        public void MergeItem(MirGridType gridFrom, MirGridType gridTo, ulong fromID, ulong toID)
        {
            S.MergeItem p = new S.MergeItem { GridFrom = gridFrom, GridTo = gridTo, IDFrom = fromID, IDTo = toID, Success = false };

            UserItem[] arrayFrom;

            switch (gridFrom)
            {
                case MirGridType.Inventory:
                    arrayFrom = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    arrayFrom = Account.Storage;
                    break;
                case MirGridType.Equipment:
                    arrayFrom = Info.Equipment;
                    break;
                case MirGridType.Fishing:
                    if (Info.Equipment[(int)EquipmentSlot.Weapon] == null || (Info.Equipment[(int)EquipmentSlot.Weapon].Info.Shape != 49 && Info.Equipment[(int)EquipmentSlot.Weapon].Info.Shape != 50))
                    {
                        Enqueue(p);
                        return;
                    }
                    arrayFrom = Info.Equipment[(int)EquipmentSlot.Weapon].Slots;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            UserItem[] arrayTo;
            switch (gridTo)
            {
                case MirGridType.Inventory:
                    arrayTo = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    arrayTo = Account.Storage;
                    break;
                case MirGridType.Equipment:
                    arrayTo = Info.Equipment;
                    break;
                case MirGridType.Fishing:
                    if (Info.Equipment[(int)EquipmentSlot.Weapon] == null || (Info.Equipment[(int)EquipmentSlot.Weapon].Info.Shape != 49 && Info.Equipment[(int)EquipmentSlot.Weapon].Info.Shape != 50))
                    {
                        Enqueue(p);
                        return;
                    }
                    arrayTo = Info.Equipment[(int)EquipmentSlot.Weapon].Slots;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            UserItem tempFrom = null;
            int index = -1;

            for (int i = 0; i < arrayFrom.Length; i++)
            {
                if (arrayFrom[i] == null || arrayFrom[i].UniqueID != fromID) continue;
                index = i;
                tempFrom = arrayFrom[i];
                break;
            }

            if (tempFrom == null || tempFrom.Info.StackSize == 1 || index == -1)
            {
                Enqueue(p);
                return;
            }


            UserItem tempTo = null;

            for (int i = 0; i < arrayTo.Length; i++)
            {
                if (arrayTo[i] == null || arrayTo[i].UniqueID != toID) continue;
                tempTo = arrayTo[i];
                break;
            }

            if (tempTo == null || tempTo.Info != tempFrom.Info || tempTo.Count == tempTo.Info.StackSize)
            {
                Enqueue(p);
                return;
            }

            if (tempTo.Info.Type != ItemType.Amulet && (gridFrom == MirGridType.Equipment || gridTo == MirGridType.Equipment))
            {
                Enqueue(p);
                return;
            }

            if(tempTo.Info.Type != ItemType.Bait && (gridFrom == MirGridType.Fishing || gridTo == MirGridType.Fishing))
            {
                Enqueue(p);
                return;
            }

            if (tempFrom.Count <= tempTo.Info.StackSize - tempTo.Count)
            {
                tempTo.Count += tempFrom.Count;
                arrayFrom[index] = null;
            }
            else
            {
                tempFrom.Count -= tempTo.Info.StackSize - tempTo.Count;
                tempTo.Count = tempTo.Info.StackSize;
            }

            p.Success = true;
            Enqueue(p);
            RefreshStats();
        }
        private bool CanRemoveItem(MirGridType grid, UserItem item)
        {
            //Item  Stuck

            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    array = Account.Storage;
                    break;
                default:
                    return false;
            }

            if (RidingMount && item.Info.Type != ItemType.Torch)
            {
                return false;
            }

            return FreeSpace(array) > 0;
        }
Exemple #40
0
 public static void DropItem(MirGridType G, int U)
 {
     Network.Enqueue(new DropItem {
         Grid = G, UniqueID = U
     });
 }
        public void RemoveSlotItem(MirGridType grid, ulong id, int to, MirGridType gridTo)
        {
            S.RemoveSlotItem p = new S.RemoveSlotItem { Grid = grid, UniqueID = id, To = to, GridTo = gridTo, Success = false };
            UserItem[] array;
            switch (gridTo)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (to < 0 || to >= array.Length) return;

            UserItem temp = null;
            UserItem slotTemp = null;
            int index = -1;

            switch (grid)
            {
                case MirGridType.Mount:
                    temp = Info.Equipment[(int)EquipmentSlot.Mount];
                    break;
                case MirGridType.Fishing:
                    temp = Info.Equipment[(int)EquipmentSlot.Weapon];
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (temp == null || temp.Slots == null)
            {
                Enqueue(p);
                return;
            }

            if (grid == MirGridType.Fishing && (temp.Info.Shape != 49 && temp.Info.Shape != 50))
            {
                Enqueue(p);
                return;
            }

            for (int i = 0; i < temp.Slots.Length; i++)
            {
                slotTemp = temp.Slots[i];
                if (slotTemp == null || slotTemp.UniqueID != id) continue;
                index = i;
                break;
            }

            if (slotTemp == null || index == -1)
            {
                Enqueue(p);
                return;
            }

            if (slotTemp.Cursed && !UnlockCurse)
            {
                Enqueue(p);
                return;
            }

            if (slotTemp.WeddingRing != -1)
            {
                Enqueue(p);
                return;
            }

            if (!CanRemoveItem(gridTo, slotTemp)) return;

            temp.Slots[index] = null;

            if (slotTemp.Cursed)
                UnlockCurse = false;

            if (array[to] == null)
            {
                array[to] = slotTemp;
                p.Success = true;
                Enqueue(p);
                RefreshStats();
                Broadcast(GetUpdateInfo());

                Report.ItemMoved("RemoveSlotItem", temp, grid, gridTo, index, to);

                return;
            }

            Enqueue(p);
        }
        public void MoveItem(MirGridType grid, int from, int to)
        {
            S.MoveItem p = new S.MoveItem { Grid = grid, From = from, To = to, Success = false };
            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                case MirGridType.Trade:
                    array = Info.Trade;
                    TradeItem();
                    break;
                case MirGridType.Refine:
                    array = Info.Refine;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (from >= 0 && to >= 0 && from < array.Length && to < array.Length)
            {
                if (array[from] == null)
                {
                    Report.ItemError("MoveItem", grid, grid, from, to);
                    ReceiveChat("Item Move Error - Please report the item you tried to move and the time", ChatType.System);
                    Enqueue(p);
                    return;
                }

                UserItem i = array[to];
                array[to] = array[from];

                Report.ItemMoved("MoveItem", array[to], grid, grid, from, to);

                array[from] = i;

                Report.ItemMoved("MoveItem", array[from], grid, grid, to, from);

                p.Success = true;
                Enqueue(p);
                return;
            }

            Enqueue(p);
        }