예제 #1
0
        public string generateEqRareUpgradeForPacket()
        {
            short WeaponRare    = 0;
            short WeaponUpgrade = 0;
            short ArmorRare     = 0;
            short ArmorUpgrade  = 0;

            for (short i = 0; i < 15; i++)
            {
                Inventory inv = EquipmentList.LoadBySlotAndType(i, (short)InventoryType.Equipment);
                if (inv != null)
                {
                    Item iteminfo = ServerManager.GetItem(inv.InventoryItem.ItemVNum);

                    if (iteminfo.EquipmentSlot == (short)EquipmentType.Armor)
                    {
                        ArmorRare    = inv.InventoryItem.Rare;
                        ArmorUpgrade = inv.InventoryItem.Upgrade;
                    }
                    else if (iteminfo.EquipmentSlot == (short)EquipmentType.MainWeapon)
                    {
                        WeaponRare    = inv.InventoryItem.Rare;
                        WeaponUpgrade = inv.InventoryItem.Upgrade;
                    }
                }
            }
            return(String.Format("{0}{1} {2}{3}", WeaponUpgrade, WeaponRare, ArmorUpgrade, ArmorRare));
        }
예제 #2
0
        public string GenerateEquipment()
        {
            //equip 86 0 0.4903.6.8.0 2.340.0.0.0 3.4931.0.5.0 4.4845.3.5.0 5.4912.7.9.0 6.4848.1.0.0 7.4849.3.0.0 8.4850.2.0.0 9.227.0.0.0 10.281.0.0.0 11.347.0.0.0 13.4150.0.0.0 14.4076.0.0.0
            string eqlist        = String.Empty;
            short  WeaponRare    = 0;
            short  WeaponUpgrade = 0;
            short  ArmorRare     = 0;
            short  ArmorUpgrade  = 0;

            for (short i = 0; i < 15; i++)
            {
                Inventory inv = EquipmentList.LoadBySlotAndType(i, (short)InventoryType.Equipment);
                if (inv != null)
                {
                    Item iteminfo = ServerManager.GetItem(inv.InventoryItem.ItemVNum);
                    if (iteminfo.EquipmentSlot == (short)EquipmentType.Armor)
                    {
                        ArmorRare    = inv.InventoryItem.Rare;
                        ArmorUpgrade = inv.InventoryItem.Upgrade;
                    }
                    else if (iteminfo.EquipmentSlot == (short)EquipmentType.MainWeapon)
                    {
                        WeaponRare    = inv.InventoryItem.Rare;
                        WeaponUpgrade = inv.InventoryItem.Upgrade;
                    }
                    eqlist += String.Format(" {0}.{1}.{2}.{3}.{4}", i, iteminfo.VNum, inv.InventoryItem.Rare, iteminfo.Colored ? inv.InventoryItem.Color : inv.InventoryItem.Upgrade, 0);
                }
            }
            return(String.Format("equip {0}{1} {2}{3}{4}", WeaponUpgrade, WeaponRare, ArmorUpgrade, ArmorRare, eqlist));
        }
예제 #3
0
        public override void Use(ClientSession session, ref Inventory Inv)
        {
            if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750)
            {
                return;
            }
            else
            {
                session.Character.LastPotion = DateTime.Now;
            }
            Item item = ServerManager.GetItem(Inv.ItemInstance.ItemVNum);

            switch (Effect)
            {
            default:
                if (session.Character.Hp <= 0)
                {
                    return;
                }
                if (session.Character.IsSitting == false)
                {
                    session.Character.SnackAmount = 0;
                    session.Character.SnackHp     = 0;
                    session.Character.SnackMp     = 0;
                }
                int amount = session.Character.SnackAmount;
                if (amount < 5)
                {
                    Thread workerThread = new Thread(() => Regenerate(session, item));
                    workerThread.Start();
                    Inv.ItemInstance.Amount--;
                    if (Inv.ItemInstance.Amount > 0)
                    {
                        session.Client.SendPacket(session.Character.GenerateInventoryAdd(Inv.ItemInstance.ItemVNum, Inv.ItemInstance.Amount, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                    }
                    else
                    {
                        session.Character.InventoryList.DeleteFromSlotAndType(Inv.Slot, Inv.Type);
                        session.Client.SendPacket(session.Character.GenerateInventoryAdd(1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                    }
                }
                else
                {
                    if (session.Character.Gender == 1)
                    {
                        session.Client.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1));
                    }
                    else
                    {
                        session.Client.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1));
                    }
                }
                if (amount == 0)
                {
                    Thread workerThread2 = new Thread(() => Sync(session, item));
                    workerThread2.Start();
                }
                break;
            }
        }
예제 #4
0
        public string GetProgressMessage(byte index, int amount)
        {
            string type          = null;
            string objectiveName = null;

            switch ((QuestType)Quest.QuestType)
            {
            case QuestType.Capture1:
            case QuestType.Capture2:
                type          = "capturing";
                objectiveName = ServerManager.GetNpcMonster((short)GetObjectiveByIndex(index).Data).Name;
                break;

            case QuestType.Collect1:
            case QuestType.Collect2:
            case QuestType.Collect3:
            case QuestType.Collect4:
                objectiveName = ServerManager.GetItem((short)GetObjectiveByIndex(index).Data).Name;
                type          = "collecting";
                break;

            case QuestType.Hunt:
                type          = "hunting";
                objectiveName = ServerManager.GetNpcMonster((short)GetObjectiveByIndex(index).Data).Name;
                break;
            }
            if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(objectiveName) && GetObjectives()[index - 1] < GetObjectiveByIndex(index).Objective)
            {
                return($"say 2 {CharacterId} 11 [{objectiveName}] {type}: {GetObjectives()[index - 1] + amount}/{GetObjectiveByIndex(index).Objective}");
            }
            return("");
        }
예제 #5
0
        public static void SetRarityPoint(ref Inventory inv)
        {
            if (inv == null)
            {
                return;
            }
            Item iteminfo = ServerManager.GetItem(inv.InventoryItem.ItemVNum);

            if (iteminfo.EquipmentSlot == (byte)EquipmentType.MainWeapon || iteminfo.EquipmentSlot == (byte)EquipmentType.SecondaryWeapon)
            {
                int    point = ServersData.RarityPoint(inv.InventoryItem.Rare, iteminfo.LevelMinimum);
                Random rnd   = new Random();
                inv.InventoryItem.Concentrate   = 0;
                inv.InventoryItem.HitRate       = 0;
                inv.InventoryItem.DamageMinimum = 0;
                inv.InventoryItem.DamageMaximum = 0;
                for (int i = 0; i < point; i++)
                {
                    int rndn = rnd.Next(0, 3);
                    if (rndn == 0)
                    {
                        inv.InventoryItem.Concentrate++;
                        inv.InventoryItem.HitRate++;
                    }
                    else
                    {
                        inv.InventoryItem.DamageMinimum++;
                        inv.InventoryItem.DamageMaximum++;
                    }
                }
            }
            else if (iteminfo.EquipmentSlot == (byte)EquipmentType.Armor)
            {
                int    point = ServersData.RarityPoint(inv.InventoryItem.Rare, iteminfo.LevelMinimum);
                Random rnd   = new Random();
                inv.InventoryItem.DefenceDodge         = 0;
                inv.InventoryItem.DistanceDefenceDodge = 0;
                inv.InventoryItem.DistanceDefence      = 0;
                inv.InventoryItem.MagicDefence         = 0;
                inv.InventoryItem.CloseDefence         = 0;
                for (int i = 0; i < point; i++)
                {
                    int rndn = rnd.Next(0, 3);
                    if (rndn == 0)
                    {
                        inv.InventoryItem.DefenceDodge++;
                        inv.InventoryItem.DistanceDefenceDodge++;
                    }
                    else
                    {
                        inv.InventoryItem.DistanceDefence++;
                        inv.InventoryItem.MagicDefence++;
                        inv.InventoryItem.CloseDefence++;
                    }
                }
            }
        }
예제 #6
0
        public override void Use(ClientSession Session, ref Inventory Inv)
        {
            switch (Effect)
            {
            case 650:     //wings

                if (Session.Character.UseSp)
                {
                    Item iteminfo = ServerManager.GetItem(Inv.ItemInstance.ItemVNum);
                    SpecialistInstance specialistInstance = Session.Character.EquipmentList.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, (byte)InventoryType.Equipment);
                    specialistInstance.Design       = (byte)iteminfo.EffectValue; // change item design in instance
                    Session.Character.MorphUpgrade2 = iteminfo.EffectValue;       // change item design in session
                    Session.Client.SendPacket(Session.Character.GenerateCMode());
                    Session.Client.SendPacket(Session.Character.GenerateStat());
                    Session.Client.SendPacket(Session.Character.GenerateStatChar());
                    Inv.ItemInstance.Amount--;     // subtract item amount
                    if (Inv.ItemInstance.Amount > 0)
                    {
                        Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(Inv.ItemInstance.ItemVNum, Inv.ItemInstance.Amount, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                    }
                    else
                    {
                        Session.Character.InventoryList.DeleteFromSlotAndType(Inv.Slot, Inv.Type);
                        Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                    }
                }
                else
                {
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            default:
                //Item iteminfo = ServerManager.GetItem(Inv.ItemInstance.ItemVNum);
                //if (iteminfo.Morph != 0 && iteminfo.Speed != 0)
                //{
                //    if (Session.Character.IsVehicled == false)
                //    {
                //        Session.Client.SendPacket($"delay 3000 3 #u_i^1^{Session.Character.CharacterId}^{Inv.Type}^{Inv.Slot}^2");
                //        Session.Character.IsVehicled = true;
                //        Session.Client.SendPacket("pinit 0");
                //        Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode());
                //        // change speed
                //        Session.Client.SendPacket(Session.Character.GenerateCond());
                //    }
                //    else
                //    {
                //        Session.Client.SendPacket("pinit 0");
                //        Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode());
                //        // revert speed change
                //        Session.Client.SendPacket(Session.Character.GenerateCond());
                //    }
                //}
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
                break;
            }
        }
예제 #7
0
        public Inventory CreateItem(InventoryItem newItem, Character character)
        {
            short Slot = -1;
            IEnumerable <InventoryItem> slotfree = null;
            Inventory inv = null;

            if (ServerManager.GetItem(newItem.ItemVNum).Type != 0)
            {
                slotfree = character.LoadBySlotAllowed(newItem.ItemVNum, newItem.Amount);
                inv      = getFirstSlot(slotfree);
            }
            bool      modified     = false;
            Inventory newInventory = null;

            if (inv != null)
            {
                Slot           = inv.Slot;
                newItem.Amount = (short)(newItem.Amount + inv.InventoryItem.Amount);
                modified       = true;
            }
            else
            {
                Slot = getFirstPlace(ServerManager.GetItem(newItem.ItemVNum).Type, character.BackPack, newItem);
            }
            if (Slot != -1)
            {
                if (modified == false)
                {
                    newInventory = new Inventory()
                    {
                        CharacterId     = character.CharacterId,
                        InventoryItemId = newItem.InventoryItemId,
                        Slot            = Slot,
                        Type            = ServerManager.GetItem(newItem.ItemVNum).Type,
                        InventoryItem   = newItem,
                        InventoryId     = generateInventoryId(),
                    }
                }
                ;
                else
                {
                    newInventory = new Inventory()
                    {
                        CharacterId     = character.CharacterId,
                        InventoryItemId = newItem.InventoryItemId,
                        Slot            = Slot,
                        Type            = ServerManager.GetItem(newItem.ItemVNum).Type,
                        InventoryItem   = newItem,
                        InventoryId     = inv.InventoryId,
                    }
                };
                InsertOrUpdate(ref newInventory);
            }
            return(newInventory);
        }
예제 #8
0
        public string GenerateEq()
        {
            int       color = HairColor;
            Inventory head  = EquipmentList.LoadBySlotAndType((short)EquipmentType.Hat, (short)InventoryType.Equipment);

            if (head != null && ServerManager.GetItem(head.InventoryItem.ItemVNum).Colored)
            {
                color = head.InventoryItem.Color;
            }

            return(String.Format("eq {0} {1} {2} {3} {4} {5} {6} {7}", CharacterId, (Authority == 2 ? 2 : 0), Gender, HairStyle, color, Class, generateEqListForPacket(), generateEqRareUpgradeForPacket()));
        }
예제 #9
0
        public override void Use(ClientSession session, ref Inventory inv)
        {
            if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750)
            {
                return;
            }
            else
            {
                session.Character.LastPotion = DateTime.Now;
            }
            Item item = ServerManager.GetItem(inv.ItemInstance.ItemVNum);

            switch (Effect)
            {
            default:
                if (session.Character.Hp == session.Character.HPLoad() && session.Character.Mp == session.Character.MPLoad())
                {
                    return;
                }
                if (session.Character.Hp <= 0)
                {
                    return;
                }
                inv.ItemInstance.Amount--;
                if (inv.ItemInstance.Amount > 0)
                {
                    session.Client.SendPacket(session.Character.GenerateInventoryAdd(inv.ItemInstance.ItemVNum, inv.ItemInstance.Amount, inv.Type, inv.Slot, 0, 0, 0, 0));
                }
                else
                {
                    session.Character.InventoryList.DeleteFromSlotAndType(inv.
                                                                          Slot, inv.Type);
                    session.Client.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, inv.Type, inv.Slot, 0, 0, 0, 0));
                }
                session.Character.Mp += item.Mp;
                session.Character.Hp += item.Hp;
                if (session.Character.Mp > session.Character.MPLoad())
                {
                    session.Character.Mp = (int)session.Character.MPLoad();
                }
                if (session.Character.Hp > session.Character.HPLoad())
                {
                    session.Character.Hp = (int)session.Character.HPLoad();
                }

                if (session.Character.Hp < session.Character.HPLoad() || session.Character.Mp < session.Character.MPLoad())
                {
                    session.CurrentMap?.Broadcast(session.Character.GenerateRc(item.Hp));
                }
                session.Client.SendPacket(session.Character.GenerateStat());
                break;
            }
        }
예제 #10
0
        public string GeneratePairy()
        {
            Inventory fairy = EquipmentList.LoadBySlotAndType((short)EquipmentType.Fairy, (short)InventoryType.Equipment);

            if (fairy != null)
            {
                return(String.Format("pairy 1 {0} 4 {1} {2} {3}", CharacterId, ServerManager.GetItem(fairy.InventoryItem.ItemVNum).Element, fairy.InventoryItem.ElementRate, ServerManager.GetItem(fairy.InventoryItem.ItemVNum).Morph));
            }
            else
            {
                return(String.Format("pairy 1 {0} 0 0 0 40", CharacterId));
            }
        }
예제 #11
0
        public bool JoinGroup(ClientSession session)
        {
            if (Sessions.Count > 0 && session.Character.IsBlockedByCharacter(Sessions.FirstOrDefault().Character.CharacterId))
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(
                        Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                return(false);
            }
            if (Raid != null)
            {
                var entries = Raid.DailyEntries - session.Character.GeneralLogs.CountLinq(s => s.LogType == "InstanceEntry" && short.Parse(s.LogData) == Raid.Id && s.Timestamp.Date == DateTime.Today);
                if (Raid.DailyEntries > 0 && entries <= 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("INSTANCE_NO_MORE_ENTRIES"), 0));
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("INSTANCE_NO_MORE_ENTRIES"), 10));
                    return(false);
                }
                if (Raid.RequiredItems != null)
                {
                    foreach (Gift requiredItem in Raid.RequiredItems)
                    {
                        if (ServerManager.GetItem(requiredItem.VNum).Type == InventoryType.Equipment &&
                            !session.Character.Inventory.Any(s => s.ItemVNum == requiredItem.VNum && s.Type == InventoryType.Wear))
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                   string.Format(Language.Instance.GetMessageFromKey("ITEM_NOT_EQUIPPED"),
                                                                 ServerManager.GetItem(requiredItem.VNum).Name), 0));
                            return(false);
                        }
                    }
                }
            }

            session.Character.Group = this;
            Sessions.Add(session);
            if (GroupType == GroupType.Group)
            {
                if (Sessions.Find(c => c.Character.IsCoupleOfCharacter(session.Character.CharacterId)) is ClientSession couple)
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO {
                        CardId = 319
                    }, true);
                    couple.Character.AddStaticBuff(new StaticBuffDTO {
                        CardId = 319
                    }, true);
                }
            }

            return(true);
        }
예제 #12
0
        public string GenerateIn()
        {
            int       Color = HairColor;
            Inventory head  = EquipmentList.LoadBySlotAndType((short)EquipmentType.Hat, (short)InventoryType.Equipment);

            if (head != null && ServerManager.GetItem(head.InventoryItem.ItemVNum).Colored)
            {
                Color = head.InventoryItem.Color;
            }
            Inventory fairy = EquipmentList.LoadBySlotAndType((short)EquipmentType.Fairy, (short)InventoryType.Equipment);


            return(String.Format("in 1 {0} - {1} {2} {3} {4} {5} {6} {7} {8} {9} {17} {10} {11} {12} -1 {25} {22} 0 {23} 0 {19} {18} -1 - {13} {16} {20} 0 {21} {14} 0 {15} {26} {24}", Name, CharacterId, MapX, MapY, Direction, (Authority == 2 ? 2 : 0), Gender, HairStyle, Color, Class, (int)((Hp / HPLoad()) * 100), (int)((Mp / MPLoad()) * 100), _rested, (GetDigniteIco() == 1) ? GetReputIco() : -GetDigniteIco(), 0, ArenaWinner, _invisible, generateEqListForPacket(), generateEqRareUpgradeForPacket(), (UseSp ? Morph : 0), (UseSp ? MorphUpgrade : 0), (UseSp ? MorphUpgrade2 : 0), fairy != null ? ServerManager.GetItem(fairy.InventoryItem.ItemVNum).Element : 0, fairy != null ? ServerManager.GetItem(fairy.InventoryItem.ItemVNum).Morph : 0, Size, fairy != null ? 2 : 0, Compliment));
        }
예제 #13
0
        public void SumItem(ClientSession Session, WearableInstance itemToSum)
        {
            short[] upsuccess = { 100, 100, 85, 70, 50, 20 };
            int[]   goldprice = { 1500, 3000, 6000, 12000, 24000, 48000 };
            short[] sand      = { 5, 10, 15, 20, 25, 30 };
            int     sandVnum  = 1027;
            Item    iteminfo  = ServerManager.GetItem(this.ItemVNum);
            Item    iteminfo2 = ServerManager.GetItem(itemToSum.ItemVNum);

            if ((this.Upgrade + itemToSum.Upgrade) < 6 && ((((iteminfo2.EquipmentSlot == (byte)EquipmentType.Gloves) && (iteminfo.EquipmentSlot == (byte)EquipmentType.Gloves)) || ((iteminfo.EquipmentSlot == (byte)EquipmentType.Boots) && (iteminfo2.EquipmentSlot == (byte)EquipmentType.Boots)))))
            {
                if (Session.Character.Gold < goldprice[this.Upgrade])
                {
                    return;
                }
                Session.Character.Gold = Session.Character.Gold - (goldprice[this.Upgrade]);
                if (Session.Character.InventoryList.CountItem(sandVnum) < sand[this.Upgrade])
                {
                    return;
                }
                Session.Character.InventoryList.RemoveItemAmount(sandVnum, (byte)(sand[this.Upgrade]));

                Random r   = new Random();
                int    rnd = r.Next(100);
                if (rnd <= upsuccess[this.Upgrade + itemToSum.Upgrade])
                {
                    this.Upgrade         += (byte)(itemToSum.Upgrade + 1);
                    this.DarkResistance  += (byte)(itemToSum.DarkResistance + iteminfo2.DarkResistance);
                    this.LightResistance += (byte)(itemToSum.LightResistance + iteminfo2.LightResistance);
                    this.WaterResistance += (byte)(itemToSum.WaterResistance + iteminfo2.WaterResistance);
                    this.FireResistance  += (byte)(itemToSum.FireResistance + iteminfo2.FireResistance);
                    Session.Character.DeleteItemByItemInstanceId(itemToSum.ItemInstanceId);
                    Session.Client.SendPacket($"pdti 10 {this.ItemVNum} 1 27 {this.Upgrade} 0");
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SUM_SUCCESS"), 0));
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SUM_SUCCESS"), 12));
                    Session.Client.SendPacket($"guri 19 1 {Session.Character.CharacterId} 1324");
                    Session.Client.SendPacket(Session.Character.GenerateGold());
                    Session.Character.GenerateStartupInventory();
                }
                else
                {
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SUM_FAILED"), 0));
                    Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SUM_FAILED"), 11));
                    Session.Client.SendPacket($"guri 19 1 {Session.Character.CharacterId} 1332");
                    Session.Character.DeleteItemByItemInstanceId(itemToSum.ItemInstanceId);
                    Session.Character.DeleteItemByItemInstanceId(this.ItemInstanceId);
                }
                Session.Client.SendPacket("shop_end 1");
            }
        }
예제 #14
0
        public Inventory moveInventory(short type, short slot, short desttype, short destslot)
        {
            Inventory inv      = LoadBySlotAndType(slot, type);
            Item      iteminfo = ServerManager.GetItem(inv.InventoryItem.ItemVNum);
            Inventory invdest  = LoadBySlotAndType(destslot, desttype);

            if (invdest == null && ((desttype == 6 && iteminfo.ItemType == 4) || (desttype == 7 && iteminfo.ItemType == 2) || slot == 0))
            {
                inv.Slot = destslot;
                inv.Type = desttype;
                InsertOrUpdate(ref inv);
            }

            return(inv);
        }
예제 #15
0
        public bool getFreePlaceAmount(List <InventoryItem> item, int backPack)
        {
            short[] place = new short[10];
            for (byte k = 0; k < place.Count(); k++)
            {
                place[k] = (short)(48 + (backPack * 12));
                for (short i = 0; i < 48 + (backPack * 12); i++)
                {
                    Inventory result = LoadBySlotAndType(i, k);
                    if (result != null && result.Type == 0)
                    {
                        place[k]--;
                    }
                    else if (result != null)
                    {
                        bool test = false;
                        // If an item stuck
                        foreach (InventoryItem itemins in item)
                        {
                            if (ServerManager.GetItem(itemins.ItemVNum).Type != 0 && itemins.Amount + result.InventoryItem.Amount <= 99)
                            {
                                test = true;
                            }
                        }
                        if (!test)
                        {
                            place[k]--;
                        }
                    }
                }
            }
            bool test2 = true;

            foreach (InventoryItem itemins in item)
            {
                if (place[ServerManager.GetItem(itemins.ItemVNum).Type] == 0)
                {
                    test2 = false;
                }
            }
            return(test2);
        }
예제 #16
0
        internal void UseItemHandler(ref Inventory inv, ClientSession session, short effect, int effectValue)
        {
            Item item = ServerManager.GetItem(inv.InventoryItem.ItemVNum);

            switch (effect)
            {
            default:
                int amount = session.Character.SnackAmount;
                if (amount < 5)
                {
                    Thread workerThread = new Thread(() => regen(session, item));
                    workerThread.Start();
                    inv.InventoryItem.Amount--;
                    if (inv.InventoryItem.Amount > 0)
                    {
                        session.Client.SendPacket(session.Character.GenerateInventoryAdd(inv.InventoryItem.ItemVNum, inv.InventoryItem.Amount, inv.Type, inv.Slot, inv.InventoryItem.Rare, inv.InventoryItem.Design, inv.InventoryItem.Upgrade));
                    }
                    else
                    {
                        session.Character.InventoryList.DeleteFromSlotAndType(inv.Slot, inv.Type);
                        session.Client.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, inv.Type, inv.Slot, 0, 0, 0));
                    }
                }
                else
                {
                    if (session.Character.Gender == 1)
                    {
                        session.Client.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1));
                    }
                    else
                    {
                        session.Client.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1));
                    }
                }
                if (amount == 0)
                {
                    Thread workerThread2 = new Thread(() => sync(session, item));
                    workerThread2.Start();
                }
                break;
            }
        }
예제 #17
0
        public bool OpenBoxItem(ClientSession session, ItemInstance box)
        {
            if (box != null)
            {
                List <RollGeneratedItemDTO> roll = box.Item.RollGeneratedItems.Where(s =>
                                                                                     s.MinimumOriginalItemRare <= box.Rare &&
                                                                                     s.MaximumOriginalItemRare >= box.Rare &&
                                                                                     s.OriginalItemDesign == box.Design).ToList();
                int probabilities = roll.Sum(s => s.Probability);
                int rnd           = ServerManager.RandomNumber(0, probabilities);
                int currentrnd    = 0;
                foreach (RollGeneratedItemDTO rollitem in roll)
                {
                    currentrnd += rollitem.Probability;
                    if (currentrnd >= rnd)
                    {
                        Item  i       = ServerManager.GetItem(rollitem.ItemGeneratedVNum);
                        sbyte rare    = 0;
                        byte  upgrade = 0;
                        if (i.ItemType == ItemType.Armor || i.ItemType == ItemType.Weapon ||
                            i.ItemType == ItemType.Shell)
                        {
                            rare = box.Rare;
                        }

                        if (i.ItemType == ItemType.Shell)
                        {
                            upgrade = (byte)ServerManager.RandomNumber(75, 91);
                        }

                        session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, rare,
                                                  upgrade);
                        session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}");
                        session.Character.Inventory.RemoveItemFromInventory(box.Id);
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #18
0
        public List <String> GenerateStartupInventory()
        {
            List <String> inventoriesStringPacket = new List <String>();
            String        inv0 = "inv 0", inv1 = "inv 1", inv2 = "inv 2", inv6 = "inv 6", inv7 = "inv 7";

            foreach (Inventory inv in InventoryList.Inventory)
            {
                Item item = ServerManager.GetItem(inv.InventoryItem.ItemVNum);
                switch (inv.Type)
                {
                case (short)InventoryType.Costume:
                    inv7 += String.Format(" {0}.{1}.{2}.{3}", inv.Slot, inv.InventoryItem.ItemVNum, inv.InventoryItem.Rare, inv.InventoryItem.Upgrade);
                    break;

                case (short)InventoryType.Wear:
                    inv0 += String.Format(" {0}.{1}.{2}.{3}", inv.Slot, inv.InventoryItem.ItemVNum, inv.InventoryItem.Rare, item.Colored ? inv.InventoryItem.Color : inv.InventoryItem.Upgrade);
                    break;

                case (short)InventoryType.Main:
                    inv1 += String.Format(" {0}.{1}.{2}.0", inv.Slot, inv.InventoryItem.ItemVNum, inv.InventoryItem.Amount);
                    break;

                case (short)InventoryType.Etc:
                    inv2 += String.Format(" {0}.{1}.{2}.0", inv.Slot, inv.InventoryItem.ItemVNum, inv.InventoryItem.Amount);
                    break;

                case (short)InventoryType.Sp:
                    inv6 += String.Format(" {0}.{1}.{2}.{3}", inv.Slot, inv.InventoryItem.ItemVNum, inv.InventoryItem.Rare, inv.InventoryItem.Upgrade);
                    break;

                case (short)InventoryType.Equipment:
                    break;
                }
            }
            inventoriesStringPacket.Add(inv0 as String);
            inventoriesStringPacket.Add(inv1 as String);
            inventoriesStringPacket.Add(inv2 as String);
            inventoriesStringPacket.Add(inv6 as String);
            inventoriesStringPacket.Add(inv7 as String);
            return(inventoriesStringPacket);
        }
예제 #19
0
        public string GenerateInventoryAdd(short vnum, short amount, short type, short slot, short rare, short color, short upgrade)
        {
            Item item = ServerManager.GetItem(vnum);

            switch (type)
            {
            case (short)InventoryType.Costume:
                return(String.Format("ivn 7 {0}.{1}.{2}.{3}", slot, vnum, rare, upgrade));

            case (short)InventoryType.Wear:
                return(String.Format("ivn 0 {0}.{1}.{2}.{3}", slot, vnum, rare, item != null ? (item.Colored ? color : upgrade) : upgrade));

            case (short)InventoryType.Main:
                return(String.Format("ivn 1 {0}.{1}.{2}", slot, vnum, amount));

            case (short)InventoryType.Etc:
                return(String.Format("ivn 2 {0}.{1}.{2}", slot, vnum, amount));

            case (short)InventoryType.Sp:
                return(String.Format("ivn 6 {0}.{1}.{2}.{3}", slot, vnum, rare, upgrade));
            }
            return(String.Empty);
        }
예제 #20
0
파일: BoxItem.cs 프로젝트: Prosecutor/test
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 0:
                if (Option == 0)
                {
                    if (packetsplit.Length == 9)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            if (box.Item.ItemSubType == 3)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_OPEN_BOX")}");
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_STORE_PET")}");
                            }
                            else
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                            }
                        }
                    }
                }
                else
                {
                    //u_i 2 2000000 0 21 0 0
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.Item.ItemSubType == 3)
                        {
                            List <RollGeneratedItemDTO> roll = box.Item.RollGeneratedItems.Where(s => s.MinimumOriginalItemRare <= box.Rare &&
                                                                                                 s.MaximumOriginalItemRare >= box.Rare &&
                                                                                                 s.OriginalItemDesign == box.Design).ToList();
                            int probabilities = roll.Sum(s => s.Probability);
                            int rnd           = ServerManager.RandomNumber(0, probabilities);
                            int currentrnd    = 0;
                            foreach (RollGeneratedItemDTO rollitem in roll)
                            {
                                currentrnd += rollitem.Probability;
                                if (currentrnd >= rnd)
                                {
                                    Item  i       = ServerManager.GetItem(rollitem.ItemGeneratedVNum);
                                    sbyte rare    = 0;
                                    byte  upgrade = 0;
                                    if (i.ItemType == ItemType.Armor || i.ItemType == ItemType.Weapon || i.ItemType == ItemType.Shell)
                                    {
                                        rare = box.Rare;
                                    }
                                    if (i.ItemType == ItemType.Shell)
                                    {
                                        upgrade = (byte)ServerManager.RandomNumber(50, 81);
                                    }
                                    session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, (byte)rare, upgrade);
                                    session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}");
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                    return;

                                    //newInv = session.Character.Inventory.AddNewToInventory(rollitem.ItemGeneratedVNum, amount: rollitem.ItemGeneratedAmount, Design: design, Rare: rare);
                                    //if (newInv.Count > 0)
                                    //{
                                    //    short Slot = inv.Slot;
                                    //    if (Slot != -1)
                                    //    {
                                    //        session.SendPacket(session.Character.GenerateSay(
                                    //            $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.FirstOrDefault(s => s != null)?.Item?.Name} x {rollitem.ItemGeneratedAmount}",
                                    //            12));
                                    //        newInv.Where(s => s != null).ToList()
                                    //            .ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    //        session.Character.Inventory
                                    //            .RemoveItemAmountFromInventory(box.Id);
                                    //    }
                                    //}
                                }
                            }
                        }
                        else if (box.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1 && int.TryParse(packetsplit[0], out int PetId) && session.Character.Mates.Find(s => s.MateTransportId == PetId) is Mate mate)
                            {
                                box.HoldingVNum = mate.NpcMonsterVNum;
                                box.SpLevel     = mate.Level;
                                box.SpDamage    = mate.Attack;
                                box.SpDefence   = mate.Defence;
                                session.Character.Mates.Remove(mate);
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                session.SendPacket(UserInterfaceHelper.GeneratePClear());
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            }
                        }
                        else
                        {
                            NpcMonster heldMonster = ServerManager.GetNpc(box.HoldingVNum);
                            if (heldMonster != null)
                            {
                                Mate mate = new Mate(session.Character, heldMonster, 1, MateType.Pet)
                                {
                                    Attack  = box.SpDamage,
                                    Defence = box.SpDefence
                                };
                                if (session.Character.AddPet(mate))
                                {
                                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                                }
                            }
                        }
                    }
                }
                break;

            case 1:
                if (Option == 0)
                {
                    session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                }
                else
                {
                    NpcMonster heldMonster = ServerManager.GetNpc((short)EffectValue);
                    if (session.CurrentMapInstance == session.Character.Miniland && heldMonster != null)
                    {
                        Mate mate = new Mate(session.Character, heldMonster, LevelMinimum, ItemSubType == 1 ? MateType.Partner : MateType.Pet);
                        if (session.Character.AddPet(mate))
                        {
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 12));
                    }
                }

                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance specialist   = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(itemInstance.Slot, itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.SlDamage          = box.SlDamage;
                                    specialist.SlDefence         = box.SlDefence;
                                    specialist.SlElement         = box.SlElement;
                                    specialist.SlHP              = box.SlHP;
                                    specialist.SpDamage          = box.SpDamage;
                                    specialist.SpDark            = box.SpDark;
                                    specialist.SpDefence         = box.SpDefence;
                                    specialist.SpElement         = box.SpElement;
                                    specialist.SpFire            = box.SpFire;
                                    specialist.SpHP              = box.SpHP;
                                    specialist.SpLevel           = box.SpLevel;
                                    specialist.SpLight           = box.SpLight;
                                    specialist.SpStoneUpgrade    = box.SpStoneUpgrade;
                                    specialist.SpWater           = box.SpWater;
                                    specialist.Upgrade           = box.Upgrade;
                                    specialist.EquipmentSerialId = box.EquipmentSerialId;
                                    specialist.XP = box.XP;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name} + {specialist.Upgrade}", 12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance fairy        = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(itemInstance.Slot, itemInstance.Type);
                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (fairy != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {fairy.Item.Name} ({fairy.ElementRate}%)", 12));
                                        newInv.ForEach(s => session.SendPacket(fairy.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv[0].Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
예제 #21
0
        public void BuyValidate(ClientSession clientSession, KeyValuePair <long, MapShop> shop, short slot, byte amount)
        {
            PersonalShopItem itemshop = clientSession.CurrentMap.ShopUserList[shop.Key].Items.FirstOrDefault(i => i.Slot.Equals(slot));

            if (itemshop == null)
            {
                return;
            }

            itemshop.Amount -= amount;
            if (itemshop.Amount <= 0)
            {
                clientSession.CurrentMap.ShopUserList[shop.Key].Items.Remove(itemshop);
            }

            ClientSession shopOwnerSession = Sessions.FirstOrDefault(s => s.Character.CharacterId.Equals(shop.Value.OwnerId));

            if (shopOwnerSession == null)
            {
                return;
            }

            shopOwnerSession.Character.Gold += itemshop.Price * amount;
            shopOwnerSession.Client.SendPacket(shopOwnerSession.Character.GenerateGold());
            shopOwnerSession.Client.SendPacket(shopOwnerSession.Character.GenerateShopMemo(1,
                                                                                           string.Format(Language.Instance.GetMessageFromKey("BUY_ITEM"), shopOwnerSession.Character.Name, ServerManager.GetItem(itemshop.ItemVNum).Name, amount)));
            clientSession.CurrentMap.ShopUserList[shop.Key].Sell += itemshop.Price * amount;
            shopOwnerSession.Client.SendPacket($"sell_list {shop.Value.Sell} {slot}.{amount}.{itemshop.Amount}");

            Inventory inv = shopOwnerSession.Character.InventoryList.AmountMinusFromSlotAndType(amount, itemshop.InvSlot, itemshop.InvType);

            if (inv != null)
            {
                // Send reduced-amount to owners inventory
                shopOwnerSession.Client.SendPacket(shopOwnerSession.Character.GenerateInventoryAdd(inv.InventoryItem.ItemVNum, inv.InventoryItem.Amount, inv.Type,
                                                                                                   inv.Slot, inv.InventoryItem.Rare, inv.InventoryItem.Design, inv.InventoryItem.Upgrade));
            }
            else
            {
                // Send empty slot to owners inventory
                shopOwnerSession.Client.SendPacket(shopOwnerSession.Character.GenerateInventoryAdd(-1, 0, itemshop.InvType, itemshop.InvSlot, 0, 0, 0));
            }
        }
예제 #22
0
        public bool CanAddItem(short itemVnum)
        {
            InventoryType type = ServerManager.GetItem(itemVnum).Type;

            return(CanAddItem(type));
        }
        public void Reorder(ClientSession Session, InventoryType inventoryType)
        {
            List <Inventory> templist = new List <Inventory>();

            switch (inventoryType)
            {
            case InventoryType.Costume:
                templist = Inventory.Where(s => s.Type == InventoryType.Costume).OrderBy(s => s.ItemInstance.ItemVNum).ToList();
                break;

            case InventoryType.Sp:
                templist = Inventory.Where(s => s.Type == InventoryType.Sp).OrderBy(s => ServerManager.GetItem(s.ItemInstance.ItemVNum).LevelJobMinimum).ToList();
                break;
            }
            short i = 0;

            foreach (Inventory invtemp in templist)
            {
                Inventory temp  = new GameObject.Inventory();
                Inventory temp2 = new GameObject.Inventory();
                if (invtemp.Slot != i)
                {
                    MoveItem(inventoryType, invtemp.Slot, 1, i, out temp, out temp2);

                    if (temp2 == null || temp == null)
                    {
                        return;
                    }
                    Session.SendPacket(Session.Character.GenerateInventoryAdd(temp2.ItemInstance.ItemVNum, temp2.ItemInstance.Amount, inventoryType, temp2.Slot, temp2.ItemInstance.Rare, temp2.ItemInstance.Design, temp2.ItemInstance.Upgrade, 0));
                    Session.SendPacket(Session.Character.GenerateInventoryAdd(temp.ItemInstance.ItemVNum, temp.ItemInstance.Amount, inventoryType, temp.Slot, temp.ItemInstance.Rare, temp.ItemInstance.Design, temp.ItemInstance.Upgrade, 0));
                }
                i++;
            }
        }
예제 #24
0
        public void UpgradeSp(ClientSession Session, UpgradeProtection protect)
        {
            short[] upsuccess = { 100, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 30 };
            short[] upfail    = { 20, 25, 25, 30, 35, 40, 40, 40, 40, 40, 45, 43, 40, 37, 29 };

            int[]   goldprice       = { 200000, 200000, 200000, 200000, 200000, 500000, 500000, 500000, 500000, 500000, 1000000, 1000000, 1000000, 1000000, 1000000 };
            short[] feather         = { 3, 5, 8, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70 };
            short[] fullmoon        = { 1, 3, 5, 7, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 };
            short[] soul            = { 2, 4, 6, 8, 10, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 };
            short   featherVnum     = 2282;
            short   fullmoonVnum    = 1030;
            short   greenSoulVnum   = 2283;
            short   redSoulVnum     = 2284;
            short   blueSoulVnum    = 2285;
            short   dragonSkinVnum  = 2511;
            short   dragonBloodVnum = 2512;
            short   dragonHeartVnum = 2513;
            short   blueScrollVnum  = 1363;
            short   redScrollVnum   = 1364;

            if (!Session.HasCurrentMap)
            {
                return;
            }
            if (IsFixed)
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                return;
            }
            if (Session.Character.Inventory.CountItem(fullmoonVnum) < fullmoon[Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(fullmoonVnum).Name, fullmoon[Upgrade])), 10));
                return;
            }
            if (Session.Character.Inventory.CountItem(featherVnum) < feather[Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(featherVnum).Name, feather[Upgrade])), 10));
                return;
            }
            if (Session.Character.Gold < goldprice[Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                return;
            }

            if (Upgrade < 5)
            {
                if (SpLevel > 20)
                {
                    if (Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(greenSoulVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(greenSoulVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(greenSoulVnum, soul[Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonSkinVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(dragonSkinVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonSkinVnum, soul[Upgrade]);
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 21), 11));
                    return;
                }
            }
            else if (Upgrade < 10)
            {
                if (SpLevel > 40)
                {
                    if (Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(redSoulVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(redSoulVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(redSoulVnum, soul[Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonBloodVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(dragonBloodVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonBloodVnum, soul[Upgrade]);
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 41), 11));
                    return;
                }
            }
            else if (Upgrade < 15)
            {
                if (SpLevel > 50)
                {
                    if (Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(blueSoulVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueSoulVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected && Upgrade > 9)
                        {
                            if (Session.Character.Inventory.CountItem(redScrollVnum) < 1)
                            {
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(redScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(blueSoulVnum, soul[Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonHeartVnum) < soul[Upgrade])
                        {
                            return;
                        }
                        if (protect == UpgradeProtection.Protected && Upgrade > 9)
                        {
                            if (Session.Character.Inventory.CountItem(redScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(redScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(redScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonHeartVnum, soul[Upgrade]);
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 51), 11));
                    return;
                }
            }

            Session.Character.Gold -= goldprice[Upgrade];

            // remove feather and fullmoon before upgrading
            Session.Character.Inventory.RemoveItemAmount(featherVnum, feather[Upgrade]);
            Session.Character.Inventory.RemoveItemAmount(fullmoonVnum, fullmoon[Upgrade]);

            WearableInstance wearable  = Session.Character.Inventory.LoadByItemInstance <WearableInstance>(Id);
            ItemInstance     inventory = Session.Character.Inventory.GetItemInstanceById(Id);
            int rnd = ServerManager.RandomNumber();

            if (rnd <= upfail[Upgrade])
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                }
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED"), 11));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED"), 0));
            }
            else if (rnd <= upsuccess[Upgrade])
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                }
                Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3005), Session.Character.MapX, Session.Character.MapY);
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_SUCCESS"), 12));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_SUCCESS"), 0));
                wearable.Upgrade++;
                Session.SendPacket(Session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, wearable.Design, wearable.Upgrade, SpStoneUpgrade));
            }
            else
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED_SAVED"), 11));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED_SAVED"), 0));
                }
                else
                {
                    wearable.Rare = -2;
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_DESTROYED"), 11));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_DESTROYED"), 0));
                    Session.SendPacket(Session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, wearable.Design, wearable.Upgrade, SpStoneUpgrade));
                }
            }
            Session.SendPacket(Session.Character.GenerateGold());
            Session.SendPacket(Session.Character.GenerateEq());
            Session.SendPacket("shop_end 1");
        }
예제 #25
0
        public void BuyValidate(ClientSession Session, KeyValuePair <long, MapShop> shop, short slot, short amount)
        {
            PersonalShopItem itemshop = Session.CurrentMap.ShopUserList[shop.Key].Items.FirstOrDefault(i => i.Slot.Equals(slot));

            Session.CurrentMap.ShopUserList[shop.Key].Items.FirstOrDefault(i => i.Slot.Equals(slot)).Amount -= amount;
            PersonalShopItem itemDelete = Session.CurrentMap.ShopUserList[shop.Key].Items.FirstOrDefault(i => i.Slot.Equals(slot));

            if (itemDelete.Amount <= 0)
            {
                Session.CurrentMap.ShopUserList[shop.Key].Items.Remove(itemDelete);
            }

            ClientSession session = sessions.FirstOrDefault(s => s.Character.CharacterId.Equals(shop.Value.OwnerId));
            {
                if (session != null)
                {
                    session.Character.Gold += itemshop.Price * amount;
                    session.Client.SendPacket(session.Character.GenerateGold());
                    session.Client.SendPacket(session.Character.GenerateShopMemo(1, String.Format(Language.Instance.GetMessageFromKey("BUY_ITEM"), session.Character.Name, ServerManager.GetItem(itemshop.ItemVNum).Name, amount)));
                    Session.CurrentMap.ShopUserList[shop.Key].Sell += itemshop.Price * amount;
                    session.Client.SendPacket(String.Format("sell_list {0} {1}.{2}.{3}", shop.Value.Sell, slot, amount, itemshop.Amount));
                    Inventory inv = session.Character.InventoryList.AmountMinusFromSlotAndType(amount, itemshop.InvSlot, itemshop.InvType);
                    if (inv != null)
                    {
                        session.Client.SendPacket(session.Character.GenerateInventoryAdd(inv.InventoryItem.ItemVNum, inv.InventoryItem.Amount, inv.Type, inv.Slot, inv.InventoryItem.Rare, inv.InventoryItem.Color, inv.InventoryItem.Upgrade));
                    }
                    else
                    {
                        session.Client.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, itemshop.InvType, itemshop.InvSlot, 0, 0, 0));
                    }
                }
            }
        }
예제 #26
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            default:
                bool delay = false;
                if (option == 255)
                {
                    delay  = true;
                    option = 0;
                }
                Mate mate = null;
                if (option != 0)
                {
                    if (session.Character.Mates.Count(s => s.MateType == MateType.Partner) == 1 && option == 2)
                    {
                        option = 1;
                    }

                    mate = session.Character.Mates.Find(s =>
                                                        s.MateType == MateType.Partner && s.PartnerSlot == (option - 1));
                }
                short         slot      = inv.Slot;
                InventoryType equipment = InventoryType.Wear;

                if (option >= 1 && option <= 12)
                {
                    equipment = (InventoryType)(option + 12);     // partner inventories
                }

                InventoryType itemToWearType = inv.Type;

                if (inv == null)
                {
                    return;
                }
                if (ItemValidTime > 0 && !inv.IsBound)
                {
                    inv.ItemDeleteTime = DateTime.UtcNow.AddSeconds(ItemValidTime);
                }
                if (!inv.IsBound)
                {
                    if (!delay && ((EquipmentSlot == EquipmentType.Fairy && (MaxElementRate == 70 || MaxElementRate == 80)) || EquipmentSlot == EquipmentType.CostumeHat || EquipmentSlot == EquipmentType.CostumeSuit || EquipmentSlot == EquipmentType.WeaponSkin))
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)itemToWearType}^{slot}^1 {Language.Instance.GetMessageFromKey("ASK_BIND")}");
                        return;
                    }
                    if (delay)
                    {
                        inv.BoundCharacterId = session.Character.CharacterId;
                    }
                }

                double timeSpanSinceLastSpUsage = (DateTime.UtcNow - Process.GetCurrentProcess().StartTime.AddHours(-2).AddSeconds(-50)).TotalSeconds - session.Character.LastSp;

                if (EquipmentSlot == EquipmentType.Sp && inv.Rare == -2)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0));
                    return;
                }

                if (option == 0)
                {
                    if (EquipmentSlot == EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Specialist) != null)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0));
                        return;
                    }

                    if ((ItemType != ItemType.Weapon &&
                         ItemType != ItemType.Armor &&
                         ItemType != ItemType.Fashion &&
                         ItemType != ItemType.Jewelery &&
                         ItemType != ItemType.Specialist) ||
                        LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) ||
                        (ItemType != ItemType.Jewelery && EquipmentSlot != EquipmentType.Boots && EquipmentSlot != EquipmentType.Gloves && ((Class >> (byte)session.Character.Class) & 1) != 1) ||
                        (inv.BoundCharacterId != null && inv.BoundCharacterId != session.Character.CharacterId))
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }

                    if (session.Character.UseSp && session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, equipment) is ItemInstance sp && sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0));
                        return;
                    }

                    if (session.Character.UseSp && EquipmentSlot == EquipmentType.Sp)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10));
                        return;
                    }

                    if (session.Character.JobLevel < LevelJobMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10));
                        return;
                    }
                }
                else if (mate != null)
                {
                    if (mate.Level < LevelMinimum || mate.Level < inv.MinimumLevel)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }
                    var isRagnar   = mate.NpcMonsterVNum == 2603 || mate.NpcMonsterVNum == 2618;
                    var mateSpType = ServerManager.GetNpcMonster(mate.NpcMonsterVNum).SpecialistType;
                    var itemSpType = ServerManager.GetItem(VNum).SpecialistType;
                    switch (EquipmentSlot)
                    {
                    case EquipmentType.Armor:
                        if (ItemSubType == 4 && !inv.Item.IsHeroic && mateSpType == itemSpType)
                        {
                            mate.ArmorInstance = inv;
                            break;
                        }
                        else if (ItemSubType == 4 && isRagnar && !inv.Item.IsHeroic && itemSpType == PartnerSpecialistType.Close)
                        {
                            mate.ArmorInstance = inv;
                            break;
                        }
                        else
                        {
                            goto default;
                        }

                    case EquipmentType.MainWeapon:
                        if (ItemSubType == 12 && !inv.Item.IsHeroic && mateSpType == itemSpType)
                        {
                            mate.WeaponInstance = inv;
                            break;
                        }
                        else if (ItemSubType == 4 && isRagnar && !inv.Item.IsHeroic && itemSpType == PartnerSpecialistType.Close)
                        {
                            mate.WeaponInstance = inv;
                            break;
                        }
                        else
                        {
                            goto default;
                        }

                    case EquipmentType.Gloves:
                        if (!inv.Item.IsHeroic)
                        {
                            mate.GlovesInstance = inv;
                        }
                        else
                        {
                            goto default;
                        }
                        break;

                    case EquipmentType.Boots:
                        if (!inv.Item.IsHeroic)
                        {
                            mate.BootsInstance = inv;
                        }
                        else
                        {
                            goto default;
                        }
                        break;

                    case EquipmentType.Sp:
                        if (ItemSubType == 4 && mateSpType == itemSpType)
                        {
                            mate.SpInstance = inv;
                            break;
                        }
                        else if (ItemSubType == 4 && isRagnar && itemSpType == PartnerSpecialistType.RagnarOnly)
                        {
                            mate.SpInstance = inv;
                            break;
                        }
                        else
                        {
                            goto default;
                        }

                    default:
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }
                }

                ItemInstance currentlyEquippedItem = session.Character.Inventory.LoadBySlotAndType((short)EquipmentSlot, equipment);

                if (currentlyEquippedItem == null)
                {
                    // move from equipment to wear
                    session.Character.Inventory.MoveInInventory(inv.Slot, itemToWearType, equipment);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInventoryRemove(itemToWearType, slot));
                }
                else
                {
                    GameLogger.Instance.LogEquipmentUnwear(ServerManager.Instance.ChannelId, session.Character.Name,
                                                           session.Character.CharacterId, currentlyEquippedItem);

                    // move from wear to equipment and back
                    session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, equipment, itemToWearType, inv.Slot);
                    session.SendPacket(currentlyEquippedItem.GenerateInventoryAdd());
                    session.Character.EquipmentBCards.RemoveAll(o => o.ItemVNum == currentlyEquippedItem.ItemVNum);
                }

                GameLogger.Instance.LogEquipmentWear(ServerManager.Instance.ChannelId, session.Character.Name,
                                                     session.Character.CharacterId, inv);

                session.Character.EquipmentBCards.AddRange(inv.Item.BCards);

                switch (inv.Item.ItemType)
                {
                case ItemType.Armor:
                    session.Character.ShellEffectArmor.Clear();

                    foreach (ShellEffectDTO dto in inv.ShellEffects)
                    {
                        session.Character.ShellEffectArmor.Add(dto);
                    }
                    break;

                case ItemType.Weapon:
                    switch (inv.Item.EquipmentSlot)
                    {
                    case EquipmentType.MainWeapon:
                        session.Character.ShellEffectMain.Clear();

                        foreach (ShellEffectDTO dto in inv.ShellEffects)
                        {
                            session.Character.ShellEffectMain.Add(dto);
                        }
                        break;

                    case EquipmentType.SecondaryWeapon:
                        session.Character.ShellEffectSecondary.Clear();

                        foreach (ShellEffectDTO dto in inv.ShellEffects)
                        {
                            session.Character.ShellEffectSecondary.Add(dto);
                        }
                        break;
                    }
                    break;
                }

                if (option == 0)
                {
                    session.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());

                    if (EquipmentSlot == EquipmentType.Fairy)
                    {
                        ItemInstance fairy = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Fairy, equipment);
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXPData(fairy.ElementRate + fairy.Item.ElementRate)), 10));
                    }

                    if (EquipmentSlot == EquipmentType.Amulet)
                    {
                        session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 39));
                        inv.BoundCharacterId = session.Character.CharacterId;
                    }
                }
                else if (mate != null)
                {
                    session.SendPacket(mate.GenerateScPacket());
                }
                break;
            }
        }
예제 #27
0
        public override void Use(ClientSession session, ref Inventory inventory)
        {
            switch (Effect)
            {
            default:
                short slot = inventory.Slot;
                byte  type = inventory.Type;
                if (inventory == null)
                {
                    return;
                }

                Item iteminfo = ServerManager.GetItem(inventory.ItemInstance.ItemVNum);
                if (iteminfo == null)
                {
                    return;
                }

                if (iteminfo.ItemValidTime > 0 && inventory.ItemInstance.IsUsed == false)
                {
                    inventory.ItemInstance.ItemDeleteTime = DateTime.Now.AddSeconds(iteminfo.ItemValidTime);
                }
                inventory.ItemInstance.IsUsed = true;
                double timeSpanSinceLastSpUsage = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp;

                if (iteminfo.EquipmentSlot == (byte)EquipmentType.Sp && inventory.ItemInstance.Rare == -2)
                {
                    session.Client.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0));
                    return;
                }

                if (iteminfo.EquipmentSlot == (byte)EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown)
                {
                    session.Client.SendPacket(
                        session.Character.GenerateMsg(
                            string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"),
                                          session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)),
                            0));
                    return;
                }
                if ((iteminfo.ItemType != (byte)Domain.ItemType.Weapon &&
                     iteminfo.ItemType != (byte)Domain.ItemType.Armor &&
                     iteminfo.ItemType != (byte)Domain.ItemType.Fashion &&
                     iteminfo.ItemType != (byte)Domain.ItemType.Jewelery &&
                     iteminfo.ItemType != (byte)Domain.ItemType.Specialist) ||
                    iteminfo.LevelMinimum > (iteminfo.IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (iteminfo.Sex != 0 && iteminfo.Sex != session.Character.Gender + 1) ||
                    ((iteminfo.ItemType != (byte)Domain.ItemType.Jewelery && iteminfo.EquipmentSlot != (byte)EquipmentType.Boots && iteminfo.EquipmentSlot != (byte)EquipmentType.Gloves) && ((iteminfo.Class >> session.Character.Class) & 1) != 1))
                {
                    session.Client.SendPacket(
                        session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                    return;
                }

                if (session.Character.UseSp &&
                    iteminfo.EquipmentSlot == (byte)EquipmentType.Fairy &&
                    iteminfo.Element != ServerManager.GetItem(
                        session.Character.EquipmentList.LoadBySlotAndType <SpecialistInstance>(
                            (byte)EquipmentType.Sp,
                            (byte)InventoryType.Equipment).ItemVNum).Element&&
                    iteminfo.Element != ServerManager.GetItem(
                        session.Character.EquipmentList.LoadBySlotAndType <SpecialistInstance>(
                            (byte)EquipmentType.Sp,
                            (byte)InventoryType.Equipment).ItemVNum).SecondaryElement)
                {
                    session.Client.SendPacket(
                        session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0));
                    return;
                }

                if (session.Character.UseSp && iteminfo.EquipmentSlot == (byte)EquipmentType.Sp)
                {
                    session.Client.SendPacket(
                        session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10));
                    return;
                }

                if (session.Character.JobLevel < iteminfo.LevelJobMinimum)
                {
                    session.Client.SendPacket(
                        session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10));
                    return;
                }

                Inventory equip = session.Character.EquipmentList.LoadInventoryBySlotAndType(iteminfo.EquipmentSlot, (byte)InventoryType.Equipment);
                if (iteminfo.EquipmentSlot == (byte)EquipmentType.Amulet)
                {
                    session.Client.SendPacket(session.Character.GenerateEff(39));
                }
                if (equip == null)

                {
                    session.Character.EquipmentList.AddToInventoryWithSlotAndType(inventory.ItemInstance as ItemInstance, (byte)InventoryType.Equipment, iteminfo.EquipmentSlot);
                    session.Client.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, type, slot, 0, 0, 0, 0));
                    session.Character.InventoryList.DeleteFromSlotAndType(inventory.Slot, inventory.Type);

                    session.Client.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMap?.Broadcast(session.Character.GenerateEq());
                    session.Client.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMap?.Broadcast(session.Character.GeneratePairy());
                }
                else
                {
                    session.Character.InventoryList.DeleteFromSlotAndType(inventory.Slot, inventory.Type);
                    session.Character.EquipmentList.DeleteFromSlotAndType(equip.Slot, equip.Type);

                    session.Client.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, inventory.Type, inventory.Slot, 0, 0, 0, 0));

                    session.Character.EquipmentList.AddToInventoryWithSlotAndType(inventory.ItemInstance as ItemInstance, (byte)InventoryType.Equipment, iteminfo.EquipmentSlot);
                    session.Character.InventoryList.AddToInventoryWithSlotAndType(equip.ItemInstance as ItemInstance, type, slot);

                    session.Client.SendPacket(
                        session.Character.GenerateInventoryAdd(equip.ItemInstance.ItemVNum,
                                                               equip.ItemInstance.Amount, type, slot,
                                                               equip.ItemInstance.Rare, equip.ItemInstance.Design,
                                                               equip.ItemInstance.Upgrade, 0));

                    session.Client.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMap?.Broadcast(session.Character.GenerateEq());
                    session.Client.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMap?.Broadcast(session.Character.GeneratePairy());
                }

                if (iteminfo.EquipmentSlot == (byte)EquipmentType.Fairy)
                {
                    WearableInstance fairy = session.Character.EquipmentList.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Fairy, (byte)InventoryType.Equipment);
                    session.Client.SendPacket(session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, ServersData.LoadFairyXpData((fairy.ElementRate + fairy.Item.ElementRate))), 10));
                }
                break;
            }
        }
예제 #28
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (session.Character.IsVehicled && Effect != 888)
            {
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10));
                return;
            }

            if (inv.ItemVNum == 333 || inv.ItemVNum == 334) // Sealed Jajamaru Specialist Card & Sealed Princess Sakura Bead
            {
                return;
            }

            switch (Effect)
            {
            case 0:
                if (Option == 0)
                {
                    if (packetsplit?.Length == 9)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            if (box.Item.ItemSubType == 3)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_OPEN_BOX")}");
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_STORE_PET")}");
                            }
                            else
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                            }
                        }
                    }
                }
                else
                {
                    //u_i 2 2000000 0 21 0 0
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.Item.ItemSubType == 3)
                        {
                            List <RollGeneratedItemDTO> roll = box.Item.RollGeneratedItems.Where(s => s.MinimumOriginalItemRare <= box.Rare &&
                                                                                                 s.MaximumOriginalItemRare >= box.Rare &&
                                                                                                 s.OriginalItemDesign == box.Design).ToList();
                            int probabilities = roll.Sum(s => s.Probability);
                            int rnd           = ServerManager.RandomNumber(0, probabilities);
                            int currentrnd    = 0;
                            foreach (RollGeneratedItemDTO rollitem in roll.OrderBy(s => ServerManager.RandomNumber()))
                            {
                                currentrnd += rollitem.Probability;
                                if (currentrnd >= rnd)
                                {
                                    Item  i       = ServerManager.GetItem(rollitem.ItemGeneratedVNum);
                                    sbyte rare    = 0;
                                    byte  upgrade = 0;
                                    if (i.ItemType == ItemType.Armor || i.ItemType == ItemType.Weapon || i.ItemType == ItemType.Shell || i.ItemType == ItemType.Box)
                                    {
                                        rare = box.Rare;
                                    }
                                    if (i.ItemType == ItemType.Shell)
                                    {
                                        if (rare < 1)
                                        {
                                            rare = 1;
                                        }
                                        else if (rare > 7)
                                        {
                                            rare = 7;
                                        }
                                        upgrade = (byte)ServerManager.RandomNumber(50, 81);
                                    }
                                    if (rollitem.IsRareRandom)
                                    {
                                        rnd = ServerManager.RandomNumber(0, 100);

                                        for (int j = ItemHelper.RareRate.Length - 1; j >= 0; j--)
                                        {
                                            if (rnd < ItemHelper.RareRate[j])
                                            {
                                                rare = (sbyte)j;
                                                break;
                                            }
                                        }
                                        if (rare < 1)
                                        {
                                            rare = 1;
                                        }
                                    }
                                    session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, (byte)rare, upgrade, rollitem.ItemGeneratedDesign);
                                    session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}");
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                    return;
                                }
                            }
                        }
                        else if (box.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1 && int.TryParse(packetsplit[0], out int PetId) && session.Character.Mates.Find(s => s.MateTransportId == PetId) is Mate mate)
                            {
                                if (ItemSubType == 0 && mate.MateType != MateType.Pet || ItemSubType == 1 && mate.MateType != MateType.Partner)
                                {
                                    return;
                                }
                                if (mate.MateType == MateType.Partner && mate.GetInventory().Count > 0)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                                    return;
                                }
                                box.HoldingVNum = mate.NpcMonsterVNum;
                                box.SpLevel     = mate.Level;
                                box.SpDamage    = mate.Attack;
                                box.SpDefence   = mate.Defence;
                                session.Character.Mates.Remove(mate);
                                if (mate.MateType == MateType.Partner)
                                {
                                    byte i = 0;
                                    session.Character.Mates.Where(s => s.MateType == MateType.Partner).ToList().ForEach(s =>
                                    {
                                        s.GetInventory().ForEach(item => item.Type = (InventoryType)(13 + i));
                                        s.PetId = i;
                                        i++;
                                    });
                                }
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                session.SendPacket(UserInterfaceHelper.GeneratePClear());
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            }
                        }
                        else
                        {
                            NpcMonster heldMonster = ServerManager.GetNpcMonster(box.HoldingVNum);
                            if (heldMonster != null)
                            {
                                Mate mate = new Mate(session.Character, heldMonster, box.SpLevel, ItemSubType == 0 ? MateType.Pet : MateType.Partner)
                                {
                                    Attack  = box.SpDamage,
                                    Defence = box.SpDefence
                                };
                                if (session.Character.AddPet(mate))
                                {
                                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                                }
                            }
                        }
                    }
                }
                break;

            case 1:
                if (Option == 0)
                {
                    session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                }
                else
                {
                    NpcMonster heldMonster = ServerManager.GetNpcMonster((short)EffectValue);
                    if (session.CurrentMapInstance == session.Character.Miniland && heldMonster != null)
                    {
                        Mate mate = new Mate(session.Character, heldMonster, LevelMinimum, ItemSubType == 1 ? MateType.Partner : MateType.Pet);
                        if (session.Character.AddPet(mate))
                        {
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 12));
                    }
                }

                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance specialist   = session.Character.Inventory.LoadBySlotAndType(itemInstance.Slot, itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.SlDamage          = box.SlDamage;
                                    specialist.SlDefence         = box.SlDefence;
                                    specialist.SlElement         = box.SlElement;
                                    specialist.SlHP              = box.SlHP;
                                    specialist.SpDamage          = box.SpDamage;
                                    specialist.SpDark            = box.SpDark;
                                    specialist.SpDefence         = box.SpDefence;
                                    specialist.SpElement         = box.SpElement;
                                    specialist.SpFire            = box.SpFire;
                                    specialist.SpHP              = box.SpHP;
                                    specialist.SpLevel           = box.SpLevel;
                                    specialist.SpLight           = box.SpLight;
                                    specialist.SpStoneUpgrade    = box.SpStoneUpgrade;
                                    specialist.SpWater           = box.SpWater;
                                    specialist.Upgrade           = box.Upgrade;
                                    specialist.EquipmentSerialId = box.EquipmentSerialId;
                                    specialist.XP = box.XP;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {specialist.Item.Name} + {specialist.Upgrade}", 12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance fairy        = session.Character.Inventory.LoadBySlotAndType(itemInstance.Slot, itemInstance.Type);
                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (fairy != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {fairy.Item.Name} ({fairy.ElementRate}%)", 12));
                                        newInv.ForEach(s => session.SendPacket(fairy.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {newInv[0].Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 5)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Count > 0)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")} {newInv[0].Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;

            case 888:
                if (session.Character.IsVehicled)
                {
                    if (!session.Character.Buff.Any(s => s.Card.CardId == 336))
                    {
                        if (inv.ItemDeleteTime == null)
                        {
                            inv.ItemDeleteTime = DateTime.Now.AddHours(LevelMinimum);
                        }
                        session.Character.VehicleItem.BCards.ForEach(s => s.ApplyBCards(session.Character.BattleEntity, session.Character.BattleEntity));
                        session.CurrentMapInstance.Broadcast($"eff 1 {session.Character.CharacterId} 885");
                    }
                }
                break;

            case 4801:

                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
예제 #29
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            default:
                bool delay = false;
                if (Option == 255)
                {
                    delay  = true;
                    Option = 0;
                }
                Mate mate = null;
                if (Option != 0)
                {
                    mate = session.Character.Mates.Find(s => s.MateType == MateType.Partner && s.PetId == Option - 1);
                    if (mate == null || mate.IsTemporalMate)
                    {
                        return;
                    }
                }
                short         slot      = inv.Slot;
                InventoryType equipment = InventoryType.Wear;
                if (Option > 0)
                {
                    equipment = (InventoryType)(12 + Option);
                }

                InventoryType itemToWearType = inv.Type;

                if (inv == null)
                {
                    return;
                }
                if (ItemValidTime > 0 && !inv.IsBound)
                {
                    inv.ItemDeleteTime = DateTime.Now.AddSeconds(ItemValidTime);
                }
                else if (!inv.IsBound && ItemType == ItemType.Jewelery && new int[] { 3951, 3952, 3953, 3954, 3955, 7427 }.Contains(EffectValue))
                {
                    inv.ItemDeleteTime = DateTime.Now.AddSeconds(3600);
                }
                if (!inv.IsBound)
                {
                    switch (inv.Item.Effect)
                    {
                    case 790:         // Tarot
                    case 932:         // Attack amulet
                    case 933:         // defense amulet
                        inv.BoundCharacterId = session.Character.CharacterId;
                        break;
                    }

                    if (!delay && ((EquipmentSlot == EquipmentType.Fairy && (MaxElementRate == 70 || MaxElementRate == 80)) || EquipmentSlot == EquipmentType.CostumeHat || EquipmentSlot == EquipmentType.CostumeSuit || EquipmentSlot == EquipmentType.WeaponSkin))
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)itemToWearType}^{slot}^1 {Language.Instance.GetMessageFromKey("ASK_BIND")}");
                        return;
                    }
                    if (delay)
                    {
                        inv.BoundCharacterId = session.Character.CharacterId;
                    }
                }

                double timeSpanSinceLastSpUsage = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp;

                if (EquipmentSlot == EquipmentType.Sp && inv.Rare == -2)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0));
                    return;
                }

                if (Option == 0)
                {
                    if (EquipmentSlot == EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Specialist) != null)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0));
                        return;
                    }

                    if ((ItemType != ItemType.Weapon &&
                         ItemType != ItemType.Armor &&
                         ItemType != ItemType.Fashion &&
                         ItemType != ItemType.Jewelery &&
                         ItemType != ItemType.Specialist) ||
                        LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) ||
                        (ItemType != ItemType.Jewelery && EquipmentSlot != EquipmentType.Boots && EquipmentSlot != EquipmentType.Gloves && ((Class >> (byte)session.Character.Class) & 1) != 1))
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }

                    if (session.Character.UseSp)
                    {
                        if (session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, equipment) is ItemInstance sp && sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0));
                            return;
                        }
                    }

                    if (ItemType == ItemType.Weapon || ItemType == ItemType.Armor)
                    {
                        if (inv.BoundCharacterId.HasValue && inv.BoundCharacterId.Value != session.Character.CharacterId)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                            return;
                        }
                    }

                    if (session.Character.UseSp && EquipmentSlot == EquipmentType.Sp)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10));
                        return;
                    }

                    if (session.Character.JobLevel < LevelJobMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10));
                        return;
                    }
                }
                else if (mate != null)
                {
                    if (inv.Item.EquipmentSlot == EquipmentType.MainWeapon || inv.Item.EquipmentSlot == EquipmentType.SecondaryWeapon || inv.Item.EquipmentSlot == EquipmentType.Armor)
                    {
                        switch (mate.Monster.AttackClass)
                        {
                        case 0:
                            if (inv.ItemVNum != 990 && inv.ItemVNum != 997)
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                                return;
                            }
                            break;

                        case 1:
                            if (inv.ItemVNum != 991 && inv.ItemVNum != 996)
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                                return;
                            }
                            break;

                        case 2:
                            if (inv.ItemVNum != 992 && inv.ItemVNum != 995)
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                                return;
                            }
                            break;
                        }
                    }

                    if (mate.Level < LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }

                    Item partnerEquipment = ServerManager.GetItem(inv.ItemVNum);

                    bool isBadEquipment = false;

                    switch (partnerEquipment.EquipmentSlot)
                    {
                    case EquipmentType.MainWeapon:
                    {
                        if (partnerEquipment.ItemSubType != 12)
                        {
                            isBadEquipment = true;
                        }
                        else
                        {
                            mate.WeaponInstance = inv;
                        }
                    }
                    break;

                    case EquipmentType.Armor:
                    {
                        if (partnerEquipment.ItemSubType != 4)
                        {
                            isBadEquipment = true;
                        }
                        else
                        {
                            mate.ArmorInstance = inv;
                        }
                    }
                    break;

                    case EquipmentType.Gloves:
                    {
                        mate.GlovesInstance = inv;
                    }
                    break;

                    case EquipmentType.Boots:
                    {
                        mate.BootsInstance = inv;
                    }
                    break;

                    case EquipmentType.Sp:
                    {
                        if (mate.IsUsingSp)
                        {
                            return;
                        }

                        if (partnerEquipment.ItemSubType != 4 ||
                            !PartnerHelper.CanWearSp(mate.NpcMonsterVNum, inv.ItemVNum))
                        {
                            isBadEquipment = true;
                        }
                        else
                        {
                            if (!mate.CanUseSp())
                            {
                                int spRemainingCooldown = mate.GetSpRemainingCooldown();
                                session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("STAY_TIME"), spRemainingCooldown), 11));
                                session.SendPacket($"psd {spRemainingCooldown}");
                                return;
                            }

                            mate.Sp = new PartnerSp(inv);
                        }
                    }
                    break;
                    }

                    if (isBadEquipment)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }
                }

                ItemInstance currentlyEquippedItem = session.Character.Inventory.LoadBySlotAndType((short)EquipmentSlot, equipment);

                if (currentlyEquippedItem == null)
                {
                    // move from equipment to wear
                    session.Character.Inventory.MoveInInventory(inv.Slot, itemToWearType, equipment);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInventoryRemove(itemToWearType, slot));
                }
                else
                {
                    Logger.LogUserEvent("EQUIPMENT_TAKEOFF", session.GenerateIdentity(), $"IIId: {currentlyEquippedItem.Id} ItemVnum: {currentlyEquippedItem.ItemVNum} Upgrade: {currentlyEquippedItem.Upgrade} Rare: {currentlyEquippedItem.Rare}");

                    // move from wear to equipment and back
                    session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, equipment, itemToWearType, inv.Slot);
                    session.SendPacket(currentlyEquippedItem.GenerateInventoryAdd());
                    session.Character.EquipmentBCards.RemoveAll(o => o.ItemVNum == currentlyEquippedItem.ItemVNum);
                }

                Logger.LogUserEvent("EQUIPMENT_WEAR", session.GenerateIdentity(), $"IIId: {inv.Id} ItemVnum: {inv.ItemVNum} Upgrade: {inv.Upgrade} Rare: {inv.Rare}");

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequiredItems?.Any(obj => obj?.VNum == VNum) == true)?.Copy();
                if (raid?.DailyEntries > 0)
                {
                    var entries = raid.DailyEntries - session.Character.GeneralLogs.CountLinq(s => s.LogType == "InstanceEntry" && short.Parse(s.LogData) == raid.Id && s.Timestamp.Date == DateTime.Today);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("INSTANCE_ENTRIES"), entries), 10));
                }

                if (mate == null)
                {
                    session.Character.EquipmentBCards.AddRange(inv.Item.BCards);

                    switch (inv.Item.ItemType)
                    {
                    case ItemType.Armor:
                        session.Character.ShellEffectArmor.Clear();

                        foreach (ShellEffectDTO dto in inv.ShellEffects)
                        {
                            session.Character.ShellEffectArmor.Add(dto);
                        }
                        break;

                    case ItemType.Weapon:
                        switch (inv.Item.EquipmentSlot)
                        {
                        case EquipmentType.MainWeapon:
                            session.Character.ShellEffectMain.Clear();

                            foreach (ShellEffectDTO dto in inv.ShellEffects)
                            {
                                session.Character.ShellEffectMain.Add(dto);
                            }
                            break;

                        case EquipmentType.SecondaryWeapon:
                            session.Character.ShellEffectSecondary.Clear();

                            foreach (ShellEffectDTO dto in inv.ShellEffects)
                            {
                                session.Character.ShellEffectSecondary.Add(dto);
                            }
                            break;
                        }
                        break;
                    }
                }
                else
                {
                    mate.BattleEntity.BCards.AddRange(inv.Item.BCards);
                }

                if (Option == 0)
                {
                    session.SendPackets(session.Character.GenerateStatChar());
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());

                    if (EquipmentSlot == EquipmentType.Fairy)
                    {
                        ItemInstance fairy = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Fairy, equipment);
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXPData(fairy.ElementRate + fairy.Item.ElementRate)), 10));
                    }

                    if (EquipmentSlot == EquipmentType.Amulet)
                    {
                        session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 39));
                        inv.BoundCharacterId = session.Character.CharacterId;
                        if (inv.ItemDeleteTime > DateTime.Now || inv.DurabilityPoint > 0)
                        {
                            session.Character.AddBuff(new Buff(62, session.Character.Level), session.Character.BattleEntity);
                        }
                    }
                }
                else if (mate != null)
                {
                    session.SendPacket(mate.GenerateScPacket());
                }
                break;
            }
        }
예제 #30
0
        public void UpgradeItem(ClientSession Session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false)
        {
            if (this.Upgrade < 10)
            {
                short[] upsuccess = { 100, 100, 100, 95, 80, 60, 40, 30, 20, 11 };
                short[] upfix     = { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };

                // short itempricevnum1 = 0; short itempricevnum2 = 0;
                int[]   goldprice = { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                short[] cella     = { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                short[] gem       = { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 };

                short  cellaVnum          = 1014;
                short  gemVnum            = 1015;
                short  gemFullVnum        = 1016;
                double reducedpricefactor = 0.5;
                short  normalScrollVnum   = 1218;
                short  goldScrollVnum     = 5369;

                if (this.IsFixed)
                {
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                    Session.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                case UpgradeMode.Free:
                    break;

                case UpgradeMode.Reduced:

                    // TODO: Reduced Item Amount
                    if (Session.Character.Gold < (long)(goldprice[this.Upgrade] * reducedpricefactor))
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (Session.Character.Inventory.CountItem(cellaVnum) < cella[this.Upgrade] * reducedpricefactor)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(cellaVnum).Name, cella[this.Upgrade] * reducedpricefactor)), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && Session.Character.Inventory.CountItem(goldScrollVnum) < 1)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(goldScrollVnum).Name, cella[this.Upgrade] * reducedpricefactor)), 10));
                        return;
                    }
                    if (this.Upgrade < 5)
                    {
                        if (Session.Character.Inventory.CountItem(gemVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemVnum, gem[this.Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(gemFullVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[this.Upgrade]);
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        Session.Character.Inventory.RemoveItemAmount(goldScrollVnum);
                        Session.SendPacket("shop_end 2");
                    }
                    Session.Character.Gold -= (long)(goldprice[this.Upgrade] * reducedpricefactor);
                    Session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella[this.Upgrade] * reducedpricefactor));
                    Session.SendPacket(Session.Character.GenerateGold());
                    break;

                case UpgradeMode.Normal:

                    // TODO: Normal Item Amount
                    if (Session.Character.Inventory.CountItem(cellaVnum) < cella[this.Upgrade])
                    {
                        return;
                    }
                    if (Session.Character.Gold < goldprice[this.Upgrade])
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && Session.Character.Inventory.CountItem(normalScrollVnum) < 1)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(normalScrollVnum).Name, 1)), 10));
                        return;
                    }
                    if (this.Upgrade < 5)
                    {
                        if (Session.Character.Inventory.CountItem(gemVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemVnum, (gem[this.Upgrade]));
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(gemFullVnum) < gem[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[this.Upgrade])), 10));
                            return;
                        }
                        Session.Character.Inventory.RemoveItemAmount(gemFullVnum, (gem[this.Upgrade]));
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        Session.Character.Inventory.RemoveItemAmount(normalScrollVnum);
                        Session.SendPacket("shop_end 2");
                    }
                    Session.Character.Inventory.RemoveItemAmount(cellaVnum, (cella[this.Upgrade]));
                    Session.Character.Gold -= goldprice[this.Upgrade];
                    Session.SendPacket(Session.Character.GenerateGold());
                    break;
                }
                WearableInstance wearable  = Session.Character.Inventory.LoadByItemInstance <WearableInstance>(this.Id);
                ItemInstance     inventory = Session.Character.Inventory.GetItemInstanceById(this.Id);

                int rnd = _random.Next(100);

                if (rnd <= upfix[this.Upgrade])
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                    wearable.IsFixed = true;
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                }
                else if (rnd <= upsuccess[this.Upgrade])
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3005), Session.Character.MapX, Session.Character.MapY);
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                    wearable.Upgrade++;
                    Session.SendPacket(Session.Character.GenerateInventoryAdd(this.ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, 0, wearable.Upgrade, 0));
                }
                else
                {
                    if (protection == UpgradeProtection.None)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                        Session.Character.DeleteItemByItemInstanceId(this.Id);
                    }
                    else
                    {
                        Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                    }
                }
            }
            else
            {
                Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
            }
            Session.SendPacket("shop_end 1");
        }