public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { if (Effect == 0) { if (EffectValue != 0) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.SendPacket(session.Character.GenerateRest()); } session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(12, 1, session.Character.CharacterId, EffectValue)); } else if (EffectValue == 0) { if (packetsplit?.Length > 9 && byte.TryParse(packetsplit[8], out byte TypeEquip) && short.TryParse(packetsplit[9], out short SlotEquip)) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.SendPacket(session.Character.GenerateRest()); } if (Option != 0) { bool isUsed = false; switch (inv.ItemVNum) { case 1219: ItemInstance equip = session.Character.Inventory.LoadBySlotAndType(SlotEquip, (InventoryType)TypeEquip); if (equip?.IsFixed == true) { equip.IsFixed = false; session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3003)); session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(17, 1, session.Character.CharacterId, SlotEquip)); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_UNFIXED"), 12)); isUsed = true; } break; case 1365: case 9039: ItemInstance specialist = session.Character.Inventory.LoadBySlotAndType(SlotEquip, (InventoryType)TypeEquip); if (specialist?.Rare == -2) { specialist.Rare = 0; session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SP_RESURRECTED"), 0)); session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(13, 1, session.Character.CharacterId, 1)); session.Character.SpPoint = 10000; if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.SendPacket(session.Character.GenerateSpPoint()); session.SendPacket(specialist.GenerateInventoryAdd()); isUsed = true; } break; } if (!isUsed) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_NOT_FIXED"), 11)); } else { session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } else { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^0^1^{TypeEquip}^{SlotEquip} {Language.Instance.GetMessageFromKey("QNA_ITEM")}"); } } } } else { Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType())); } }
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.FirstOrDefault(s => s.MateType == MateType.Partner && s.PetId == (option - 1)); } short slot = inv.Slot; InventoryType equipment = InventoryType.Wear; switch (option) { case 1: equipment = InventoryType.FirstPartnerInventory; break; case 2: equipment = InventoryType.SecondPartnerInventory; break; case 3: equipment = InventoryType.ThirdPartnerInventory; break; } InventoryType itemToWearType = inv.Type; if (inv == null) { return; } if (ItemValidTime > 0 && inv.IsBound) { inv.ItemDeleteTime = DateTime.Now.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.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp; if (EquipmentSlot == EquipmentType.Sp && inv.Rare == -2) { session.SendPacket(UserInterfaceHelper.Instance.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 <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Specialist) != null) { session.SendPacket(UserInterfaceHelper.Instance.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) { SpecialistInstance sp = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, equipment); if (sp != null && sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement) { session.SendPacket(UserInterfaceHelper.Instance.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) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10)); return; } switch (EquipmentSlot) { case EquipmentType.Armor: if (ItemSubType == 4) { mate.ArmorInstance = inv; break; } else { goto default; } case EquipmentType.MainWeapon: if (ItemSubType == 12) { mate.WeaponInstance = inv; break; } else { goto default; } case EquipmentType.Gloves: mate.GlovesInstance = inv; break; case EquipmentType.Boots: mate.BootsInstance = inv; break; case EquipmentType.Sp: if (ItemSubType == 4) { 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 { // move from wear to equipment and back session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, equipment, itemToWearType, inv.Slot); session.SendPacket(currentlyEquippedItem.GenerateInventoryAdd()); session.Character.EquipmentBCards = session.Character.EquipmentBCards.Replace(o => o.ItemVNum != currentlyEquippedItem.ItemVNum); switch (currentlyEquippedItem.Slot) { case (byte)EquipmentType.Armor: session.Character.Inventory.Armor = null; break; case (byte)EquipmentType.MainWeapon: session.Character.Inventory.PrimaryWeapon = null; break; case (byte)EquipmentType.SecondaryWeapon: session.Character.Inventory.SecondaryWeapon = null; break; } } inv.Item.BCards.ForEach(s => session.Character.EquipmentBCards.Add(s)); if (inv is WearableInstance wearableInstance) { if (wearableInstance.EquipmentOptions != null) { switch (wearableInstance.Item.ItemType) { case ItemType.Armor: case ItemType.Weapon: switch (wearableInstance.Slot) { case (byte)EquipmentType.Armor: session.Character.Inventory.Armor = wearableInstance; break; case (byte)EquipmentType.MainWeapon: session.Character.Inventory.PrimaryWeapon = wearableInstance; break; case (byte)EquipmentType.SecondaryWeapon: session.Character.Inventory.SecondaryWeapon = wearableInstance; break; } EquipmentOptionHelper.Instance.ShellToBCards(wearableInstance.EquipmentOptions, wearableInstance.ItemVNum).ForEach(s => session.Character.EquipmentBCards.Add(s)); break; case ItemType.Jewelery: EquipmentOptionHelper.Instance.CellonToBCards(wearableInstance.EquipmentOptions, wearableInstance.ItemVNum).ForEach(s => session.Character.EquipmentBCards.Add(s)); 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()); switch (EquipmentSlot) { case EquipmentType.Fairy: WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>((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)); break; case EquipmentType.Amulet: session.SendPacket(session.Character.GenerateEff(39)); inv.BoundCharacterId = session.Character.CharacterId; break; } } else if (mate != null) { session.SendPacket(mate.GenerateScPacket()); } break; } }
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.Instance.RandomNumber(0, probabilities); int currentrnd = 0; foreach (RollGeneratedItemDTO rollitem in roll) { currentrnd += rollitem.Probability; if (currentrnd >= rnd) { Item i = ServerManager.Instance.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.Instance.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)) { Mate mate = session.Character.Mates.Find(s => s.MateTransportId == PetId); box.HoldingVNum = mate.NpcMonsterVNum; box.SpLevel = mate.Level; box.SpDamage = mate.Attack; box.SpDefence = mate.Defence; session.Character.Mates.Remove(mate); session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED"))); session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear()); session.SendPackets(session.Character.GenerateScP()); session.SendPackets(session.Character.GenerateScN()); session.CurrentMapInstance?.Broadcast(mate.GenerateOut()); } } else { NpcMonster heldMonster = ServerManager.Instance.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.Instance.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.Instance.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.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD"))); } } else { //TODO ADD MINILAND SENDPACKET } } 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.Instance.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.Instance.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.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)); } } } } break; default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType())); break; } }
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); } short slot = inv.Slot; InventoryType equipment = InventoryType.Wear; switch (Option) { case 1: equipment = InventoryType.FirstPartnerInventory; break; case 2: equipment = InventoryType.SecondPartnerInventory; break; case 3: equipment = InventoryType.ThirdPartnerInventory; break; } InventoryType itemToWearType = inv.Type; if (inv == null) { return; } if (ItemValidTime > 0 && inv.IsBound) { inv.ItemDeleteTime = DateTime.Now.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.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) { ItemInstance sp = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, equipment); if (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 ((EquipmentSlot != EquipmentType.Gloves && EquipmentSlot != EquipmentType.Boots) || LevelMinimum > mate.Level) { 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}"); session.Character.EquipmentBCards.AddRange(inv.Item.BCards); 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, 42)); inv.BoundCharacterId = session.Character.CharacterId; } } else if (mate != null) { session.SendPacket(mate.GenerateScPacket()); } break; } }
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; } }
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; } }
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; } }
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}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}"); } } } } else { //u_i 2 2000000 0 21 0 0 if (inv.Item.ItemSubType == 3) { OpenBoxItem(session, inv); } else if (inv.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 (mate.IsTeamMember) { session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_STORE_YOUR_TEAMMEM"), 10)); } else { inv.HoldingVNum = mate.NpcMonsterVNum; inv.SpLevel = mate.Level; inv.SpDamage = mate.Attack; inv.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.GetNpcMonster(inv.HoldingVNum); if (heldMonster != null) { Mate mate = new Mate(session.Character, heldMonster, 1, MateType.Pet) { Attack = inv.SpDamage, Defence = inv.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 6969: if (EffectValue == 1 || EffectValue == 2) { var box = session.Character.Inventory.LoadBySlotAndType(inv.Slot, InventoryType.Equipment); if (box != null) { if (box.HoldingVNum == 0) { session.SendPacket($"wopen 44 {inv.Slot} 1"); } else { List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum); if (newInv.Any()) { ItemInstance itemInstance = newInv.First(); var specialist = session.Character.Inventory.LoadBySlotAndType( itemInstance.Slot, itemInstance.Type); if (specialist != null) { specialist.FirstPartnerSkillRank = box.FirstPartnerSkillRank; specialist.SecondPartnerSkillRank = box.SecondPartnerSkillRank; specialist.ThirdPartnerSkillRank = box.ThirdPartnerSkillRank; specialist.FirstPartnerSkill = box.FirstPartnerSkill; specialist.SecondPartnerSkill = box.SecondPartnerSkill; specialist.ThirdPartnerSkill = box.ThirdPartnerSkill; } short slot = inv.Slot; if (slot != -1) { if (specialist != null) { session.SendPacket(session.Character.GenerateSay( $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name}", 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)); } } } } 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; } if (inv.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; } if (inv.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) { if (inv.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; } }
public void RarifyItem(ClientSession session, RarifyMode mode, RarifyProtection protection, bool isCommand = false) { double raren2 = 80; double raren1 = 70; double rare0 = 60; double rare1 = 40; double rare2 = 30; double rare3 = 15; double rare4 = 10; double rare5 = 5; double rare6 = 3; double rare7 = 2; double rare8 = 1; const short goldprice = 500; const double reducedpricefactor = 0.5; const double reducedchancefactor = 1.1; const byte cella = 5; const int cellaVnum = 1014; const int scrollVnum = 1218; double rnd; if (session != null && !session.HasCurrentMapInstance) { return; } if (mode != RarifyMode.Drop || Item.ItemType == ItemType.Shell) { raren2 = 0; raren1 = 0; rare0 = 0; rnd = ServerManager.Instance.RandomNumber(0, 80); } else { rnd = ServerManager.Instance.RandomNumber(0, 1000) / 10D; } if (protection == RarifyProtection.RedAmulet) { raren2 = raren1 * reducedchancefactor; raren1 = raren1 * reducedchancefactor; rare0 = rare0 * reducedchancefactor; rare1 = rare1 * reducedchancefactor; rare2 = rare2 * reducedchancefactor; rare3 = rare3 * reducedchancefactor; rare4 = rare4 * reducedchancefactor; rare5 = rare5 * reducedchancefactor; rare6 = rare6 * reducedchancefactor; rare7 = rare7 * reducedchancefactor; rare8 = rare8 * reducedchancefactor; } if (session != null) { switch (mode) { case RarifyMode.Free: break; case RarifyMode.Reduced: // TODO: Reduced Item Amount if (session.Character.Gold < (long)(goldprice * reducedpricefactor)) { return; } if (session.Character.Inventory.CountItem(cellaVnum) < cella * reducedpricefactor) { return; } session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella * reducedpricefactor)); session.Character.Gold -= (long)(goldprice * reducedpricefactor); session.SendPacket(session.Character.GenerateGold()); break; case RarifyMode.Normal: // TODO: Normal Item Amount if (session.Character.Gold < goldprice) { return; } if (session.Character.Inventory.CountItem(cellaVnum) < cella) { return; } if (protection == RarifyProtection.Scroll && !isCommand && session.Character.Inventory.CountItem(scrollVnum) < 1) { return; } if (protection == RarifyProtection.Scroll && !isCommand) { session.Character.Inventory.RemoveItemAmount(scrollVnum); session.SendPacket("shop_end 2"); } session.Character.Gold -= goldprice; session.Character.Inventory.RemoveItemAmount(cellaVnum, cella); session.SendPacket(session.Character.GenerateGold()); break; case RarifyMode.Drop: break; default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } } if (Item.IsHeroic && protection == RarifyProtection.Scroll) { if (rnd < rare8 && !(protection == RarifyProtection.Scroll && Rare >= 8)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(8); } Rare = 8; SetRarityPoint(); ItemInstance inventory = session?.Character.Inventory.GetItemInstanceById(Id); if (inventory != null) { session.SendPacket(inventory.GenerateInventoryAdd()); } return; } } if (rnd < rare7 && !(protection == RarifyProtection.Scroll && Rare >= 7)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(7); } Rare = 7; SetRarityPoint(); } else if (rnd < rare6 && !(protection == RarifyProtection.Scroll && Rare >= 6)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(6); } Rare = 6; SetRarityPoint(); } else if (rnd < rare5 && !(protection == RarifyProtection.Scroll && Rare >= 5)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(5); } Rare = 5; SetRarityPoint(); } else if (rnd < rare4 && !(protection == RarifyProtection.Scroll && Rare >= 4)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(4); } Rare = 4; SetRarityPoint(); } else if (rnd < rare3 && !(protection == RarifyProtection.Scroll && Rare >= 3)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(3); } Rare = 3; SetRarityPoint(); } else if (rnd < rare2 && !(protection == RarifyProtection.Scroll && Rare >= 2)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(2); } Rare = 2; SetRarityPoint(); } else if (rnd < rare1 && !(protection == RarifyProtection.Scroll && Rare >= 1)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(1); } Rare = 1; SetRarityPoint(); } else if (rnd < rare0 && !(protection == RarifyProtection.Scroll && Rare >= 0)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(0); } Rare = 0; SetRarityPoint(); } else if (rnd < raren1 && !(protection == RarifyProtection.Scroll && Rare >= -1)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(-1); } Rare = -1; SetRarityPoint(); } else if (rnd < raren2 && !(protection == RarifyProtection.Scroll && Rare >= -2)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(-2); } Rare = -2; SetRarityPoint(); } else { if (mode != RarifyMode.Drop && session != null) { if (protection == RarifyProtection.None) { session.Character.DeleteItemByItemInstanceId(Id); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0)); } else { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0)); session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY); } } } if (mode != RarifyMode.Drop && session != null) { ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id); if (inventory != null) { session.SendPacket(inventory.GenerateInventoryAdd()); } } }