public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { try { 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; } } catch { } }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character)); switch (Effect) { // Honour Medals case 69: session.Character.Reputation += ReputPrice; session.SendPacket(session.Character.GenerateFd()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; // SP Potions case 150: case 151: session.Character.SpAdditionPoint += EffectValue; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; // Specialist Medal case 204: session.Character.SpPoint += EffectValue; session.Character.SpAdditionPoint += EffectValue * 3; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; // Raid Seals case 301: if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId)) { //TODO you are in group return; } ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main); session.Character.Inventory.RemoveItemFromInventory(raidSeal.Id); ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequiredItems?.Any(obj => obj?.VNum == raidSeal.ItemVNum) == true)?.Copy(); if (raid != null) { Group group = new Group() { GroupType = GroupType.BigTeam, Raid = raid }; group.JoinGroup(session.Character.CharacterId); ServerManager.Instance.AddGroup(group); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 0)); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 10)); if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10)); } session.SendPacket(session.Character.GenerateRaid(2, false)); session.SendPacket(session.Character.GenerateRaid(0, false)); session.SendPacket(session.Character.GenerateRaid(1, false)); session.SendPacket(group.GenerateRdlst()); } break; case 1169: { if (session?.Character != null) { if (session.Character.Miniland == session.Character.MapInstance) { ServerManager.Instance.JoinMiniland(session, session); } else { ServerManager.Shout($"GRACIAS POR USAR SERVICIOS HEAT!"); ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY); session.SendPacket(StaticPacketHelper.Cancel(2)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } } break; case 1574: if (EffectValue == 1574) { int rnd = ServerManager.RandomNumber(0, 1); if (rnd < 1) { short[] vnums = { //ID's of the Items, you will get 4129, 4130, 4131, 4132 }; //This Code counts the Items, you inserted byte[] counts = { 1, 1, 1, 1 }; int item = ServerManager.RandomNumber(0, 4); session.Character.GiftAdd(vnums[item], counts[item]); } //This Code, deltes the Item from the Inventory session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket("msg 5 Success! You recieved your Items."); } break; // Partner Suits/Skins case 305: Mate mate = session.Character.Mates.Find(s => s.MateTransportId == int.Parse(packetsplit[3])); if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0) { mate.Skin = Morph; session.SendPacket(mate.GenerateCMode(mate.Skin)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Fairy Booster case 250: if (!session.Character.Buff.ContainsKey(131)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 131 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Fairy booster 2 case 253: if (!session.Character.Buff.ContainsKey(131)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 131 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // exp/job booster case 251: if (!session.Character.Buff.ContainsKey(121)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 121 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; //sp job booster case 1362: if (!session.Character.Buff.ContainsKey(146)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 146 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Ice oil case 252: if (!session.Character.Buff.ContainsKey(340)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 340 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 16), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Valentin Buff case 254: if (!session.Character.Buff.ContainsKey(109)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 109 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3410), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Buff exp 20% case 256: if (!session.Character.Buff.ContainsKey(119)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 119 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4756), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Ancella fate case 258: if (!session.Character.Buff.ContainsKey(393)) { session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 393 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4756), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Speedbooster case 260: if (!session.Character.IsVehicled || session.Character.Buff.Any(s => s.Card.CardId == 336)) { return; } session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(885), session.Character.MapX, session.Character.MapY); session.Character.Speed += 5; switch (session.Character.Morph) { case 2517: // Nossi M case 2518: // Nossi F case 2522: // Roller M case 2523: // Roller F // Removes <= lv 4 debuffs List <BuffType> bufftodisable = new List <BuffType> { BuffType.Bad }; session.Character.DisableBuffs(bufftodisable, 4); break; } Observable.Timer(TimeSpan.FromSeconds(session.Character.BuffRandomTime * 0.1D)).Subscribe(o => { session.Character.Speed -= 5; session.Character.LoadSpeed(); switch (session.Character.Morph) { case 2526: // White male unicorn case 2527: // White female unicorn case 2528: // Pink male unicorn case 2529: // Pink female unicorn case 2530: // Black male unicorn case 2531: // Black Female Unicorn case 2928: // Male UFO case 2929: // Female UFO case 3679: // Male squelettic dragon case 3680: // Female squelettic dragon ServerManager.Instance.TeleportOnRandomPlaceInMap(session, session.Character.MapInstanceId, true); break; case 2432: // Magic broom case 2433: // Magic broom F case 2520: // VTT M case 2521: // VTT F switch (session.Character.Direction) { case 0: // -y ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, session.Character.PositionX, (short)(session.Character.PositionY - 5)); break; case 1: // +x ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX + 5), session.Character.PositionY); break; case 2: // +y ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, session.Character.PositionX, (short)(session.Character.PositionY + 5)); break; case 3: // -x ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), session.Character.PositionY); break; case 4: ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY - 5)); // -x -y break; case 5: // +x +y ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY - 5)); break; case 6: // +x -y ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX + 5), (short)(session.Character.PositionY + 5)); break; case 7: // -x +y ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY + 5)); break; } break; } }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; // Rainbow Pearl/Magic Eraser case 666: if (EffectValue == 1 && byte.TryParse(packetsplit[9], out byte islot)) { ItemInstance wearInstance = session.Character.Inventory.LoadBySlotAndType(islot, InventoryType.Equipment); if (wearInstance != null && (wearInstance.Item.ItemType == ItemType.Weapon || wearInstance.Item.ItemType == ItemType.Armor) && wearInstance.ShellEffects.Count != 0 && wearInstance.Item.IsHeroic) { wearInstance.ShellEffects.Clear(); DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearInstance.EquipmentSerialId); if (wearInstance.EquipmentSerialId == Guid.Empty) { wearInstance.EquipmentSerialId = Guid.NewGuid(); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_DELETE"), 0)); } } else { session.SendPacket("guri 18 0"); } break; // Atk/Def/HP/Exp potions case 6600: session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; // Ancelloan's Blessing case 208: if (!session.Character.Buff.ContainsKey(121)) { session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 121 }); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Divorce letter case 6969: // this is imaginary number I = √(-1) var rel = session.Character.CharacterRelations.FirstOrDefault(s => s.RelationType == CharacterRelationType.Spouse); if (rel != null) { session.Character.DeleteRelation(rel.CharacterId == session.Character.CharacterId ? rel.RelatedCharacterId : rel.CharacterId); session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("DIVORCED"))); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Cupid's arrow case 34: // this is imaginary number I = √(-1) // Cupid's arrow if (packetsplit != null && packetsplit.Length > 3) { if (long.TryParse(packetsplit[3], out long characterId)) { if (session.Character.CharacterRelations.Any(s => s.RelationType == CharacterRelationType.Spouse)) { session.SendPacket($"info {Language.Instance.GetMessageFromKey("ALREADY_MARRIED")}"); return; } ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterId(characterId); if (otherSession != null) { otherSession.SendPacket(UserInterfaceHelper.GenerateDialog( $"#fins^-34^{session.Character.CharacterId} #fins^-69^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("MARRY_REQUEST"), session.Character.Name)}")); session.Character.FriendRequestCharacters.Add(characterId); session.Character.Inventory.RemoveItemFromInventory(inv.Id, 1); session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 319 }); } } } break; case 100: { } break; case 5836: { session.SendPacket($"gb 0 {session.Account.BankGold / 1000} {session.Character.Gold} 0 0"); session.SendPacket($"s_memo 6 [Account balance]: {session.Account.BankGold} gold; [Owned]: {session.Character.Gold} gold\nWe will do our best. Thank you for using the services of Cuarry Bank."); } break; // Faction Egg case 570: if (session.Character.Faction == (FactionType)EffectValue) { return; } if (EffectValue < 3) { session.SendPacket(session.Character.Family == null ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}" : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"), 0)); } else { session.SendPacket(session.Character.Family != null ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}" : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_FAMILY"), 0)); } break; // SP Wings case 650: ItemInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Wear); if (session.Character.UseSp && specialistInstance != null) { if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}"); } else { void disposeBuff(short vNum) { if (session.Character.BuffObservables.ContainsKey(vNum)) { session.Character.BuffObservables[vNum].Dispose(); session.Character.BuffObservables.Remove(vNum); } session.Character.RemoveBuff(vNum); } disposeBuff(387); disposeBuff(395); disposeBuff(396); disposeBuff(397); disposeBuff(398); disposeBuff(410); disposeBuff(411); disposeBuff(444); specialistInstance.Design = (byte)EffectValue; session.Character.MorphUpgrade2 = EffectValue; session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateStat()); session.SendPacket(session.Character.GenerateStatChar()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0)); } break; // Self-Introduction case 203: if (!session.Character.IsVehicled && Option == 0) { session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 2, session.Character.CharacterId, 1)); } break; // Magic Lamp case 651: if (session.Character.Inventory.All(i => i.Type != InventoryType.Wear)) { if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}"); } else { session.Character.ChangeSex(); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; // Vehicles case 1000: if (EffectValue != 0 || ServerManager.Instance.ChannelId == 51 || session.CurrentMapInstance?.MapInstanceType == MapInstanceType.EventGameInstance) { return; } if (session.Character.HasShopOpened) { return; } if (Morph > 0) { if (Option == 0 && !session.Character.IsVehicled) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest()); } session.Character.LastDelay = DateTime.Now; session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2")); } else { if (!session.Character.IsVehicled && Option != 0) { DateTime delay = DateTime.Now.AddSeconds(-4); if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2)) { session.Character.Speed = Speed; session.Character.IsVehicled = true; session.Character.VehicleSpeed = Speed; session.Character.MorphUpgrade = 0; session.Character.MorphUpgrade2 = 0; session.Character.Morph = Morph + (byte)session.Character.Gender; session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4809), session.Character.MapX, session.Character.MapY); session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateCond()); session.Character.LastSpeedChange = DateTime.Now; } } else if (session.Character.IsVehicled) { session.Character.Mates?.Where(s => s.IsTeamMember).ToList().ForEach(x => { x.PositionX = session.Character.PositionX; x.PositionY = session.Character.PositionY; session.CurrentMapInstance?.Broadcast(x.GenerateIn()); }); session.Character.RemoveVehicle(); } } } break; // Sealed Vessel case 1002: if (EffectValue == 69) { int rnd = ServerManager.RandomNumber(0, 1000); if (rnd < 5) { short[] vnums = { 5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716 }; byte[] counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; int item = ServerManager.RandomNumber(0, 17); session.Character.GiftAdd(vnums[item], counts[item]); } else if (rnd < 30) { short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 }; session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 9)], 1); } else { short[] vnums = { 1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303, 2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162 }; byte[] counts = { 10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; int item = ServerManager.RandomNumber(0, 42); session.Character.GiftAdd(vnums[item], counts[item]); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else if (session.HasCurrentMapInstance && session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4)) { short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 }; short vnum = vnums[ServerManager.RandomNumber(0, 20)]; NpcMonster npcmonster = ServerManager.GetNpc(vnum); if (npcmonster == null) { return; } MapMonster monster = new MapMonster { MonsterVNum = vnum, MapY = session.Character.MapY, MapX = session.Character.MapX, MapId = session.Character.MapInstance.Map.MapId, Position = session.Character.Direction, IsMoving = true, MapMonsterId = session.CurrentMapInstance.GetNextMonsterId(), ShouldRespawn = false }; monster.Initialize(session.CurrentMapInstance); session.CurrentMapInstance.AddMonster(monster); session.CurrentMapInstance.Broadcast(monster.GenerateIn()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Golden Bazaar Medal case 1003: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalGold }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Silver Bazaar Medal case 1004: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalSilver }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Pet Slot Expansion case 1006: if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}"); } else if (session.Character.MaxMateCount < 30) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10)); session.SendPacket(session.Character.GenerateScpStc()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Pet Basket case 1007: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBasket }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket("ib 1278 1"); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Partner's Backpack case 1008: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBackPack }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Backpack Expansion case 1009: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BackPack }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Sealed Tarot Card case 1005: session.Character.GiftAdd((short)(VNum - Effect), 1); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; // Tarot Card Game case 1894: if (EffectValue == 0) { for (int i = 0; i < 5; i++) { session.Character.GiftAdd((short)(Effect + ServerManager.RandomNumber(0, 10)), 1); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Sealed Tarot Card case 2152: session.Character.GiftAdd((short)(VNum + Effect), 1); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; default: switch (VNum) { case 5841: int rnd = ServerManager.RandomNumber(0, 1000); short[] vnums = null; if (rnd < 900) { vnums = new short[] { 4356, 4357, 4358, 4359 }; } else { vnums = new short[] { 4360, 4361, 4362, 4363 }; } session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 4)], 1); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()) + $" ItemVNum: {VNum} Effect: {Effect} EffectValue: {EffectValue}"); break; } break; } }
public void ApplyBCards(object session, object sender = null) { //Console.WriteLine($"BCardId: {BCardId} Type: {(BCardType.CardType)Type} SubType: {SubType} CardId: {CardId?.ToString() ?? "null"} ItemVNum: {ItemVNum?.ToString() ?? "null"} SkillVNum: {SkillVNum?.ToString() ?? "null"} SessionType: {session?.GetType().ToString() ?? "null"} SenderType: {sender?.GetType().ToString() ?? "null"}"); switch ((BCardType.CardType)Type) { case BCardType.CardType.Buff: { if (ServerManager.RandomNumber() < FirstData) { Character senderCharacter = sender is ClientSession senderSession ? senderSession.Character : sender as Character; if (session is Character character) { short cardId = (short)SecondData; // If either Berserk Spirit or Strong Berserk Spirit is active // then don't add Weak Berserk Spirit if (cardId == 601 && character.Buff?.Any(s => s?.Card?.CardId == 602 || s?.Card?.CardId == 603) == true) { break; } if (senderCharacter != null) { // TODO: Get anti stats from BCard character.AddBuff(new Buff((short)SecondData, senderCharacter.Level, senderCharacter)); } else { character.AddBuff(new Buff((short)SecondData, character.Level)); } } else if (session is MapMonster mapMonster) { if (senderCharacter != null) { mapMonster.AddBuff(new Buff((short)SecondData, senderCharacter.Level, senderCharacter)); } else { mapMonster.AddBuff(new Buff((short)SecondData, mapMonster.Monster.Level)); } } } } break; case BCardType.CardType.Move: { if (session is Character character) { character.LastSpeedChange = DateTime.Now; character.Session.SendPacket(character.GenerateCond()); } } break; case BCardType.CardType.Summons: { if (session is Character character) { if (character.MapInstance != null) { List <MonsterToSummon> monsterList = new List <MonsterToSummon>(); if (SubType == (byte)AdditionalTypes.Summons.Summons / 10) { int aliveTime = ServerManager.GetNpc((short)SecondData).RespawnTime; for (int i = 0; i < FirstData; i++) { MapCell mapCell = new MapCell { X = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionX), Y = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionY), }; monsterList.Add(new MonsterToSummon((short)SecondData, mapCell, -1, true, false, false, true, false, -1, character, aliveTime, false)); } } if (monsterList.Any()) { EventHelper.Instance.RunEvent(new EventContainer(character.MapInstance, EventActionType.SPAWNMONSTERS, monsterList)); } } } } break; case BCardType.CardType.SpecialAttack: break; case BCardType.CardType.SpecialDefence: break; case BCardType.CardType.AttackPower: break; case BCardType.CardType.Target: break; case BCardType.CardType.Critical: break; case BCardType.CardType.SpecialCritical: break; case BCardType.CardType.Element: break; case BCardType.CardType.IncreaseDamage: break; case BCardType.CardType.Defence: break; case BCardType.CardType.DodgeAndDefencePercent: break; case BCardType.CardType.Block: break; case BCardType.CardType.Absorption: break; case BCardType.CardType.ElementResistance: break; case BCardType.CardType.EnemyElementResistance: break; case BCardType.CardType.Damage: break; case BCardType.CardType.GuarantedDodgeRangedAttack: break; case BCardType.CardType.Morale: break; case BCardType.CardType.Casting: break; case BCardType.CardType.Reflection: break; case BCardType.CardType.DrainAndSteal: break; case BCardType.CardType.HealingBurningAndCasting: { Character senderCharacter = sender is ClientSession senderSession ? senderSession.Character : sender as Character; if (senderCharacter != null) { #region Character if (session is Character character) { void HealingBurningAndCastingAction() { if (!character.IsAlive || character.MapInstance == null || character.Session == null) { return; } int amount = 0; if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreHP / 10 || SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseHP / 10) { if (FirstData > 0) { if (IsLevelScaled) { amount = senderCharacter.Level * FirstData; } else { amount = FirstData; } if (character.Hp + amount > character.HPMax) { amount = character.HPMax - character.Hp; } character.Hp += amount; character.MapInstance.Broadcast(character.GenerateRc(amount)); } else { if (IsLevelScaled) { amount = senderCharacter.Level * (FirstData - 1); } else { amount = FirstData; } amount *= -1; if (character.Hp - amount < 1) { amount = character.Hp - 1; } character.GetDamage(amount); character.MapInstance.Broadcast(character.GenerateDm(amount)); } character.Session.SendPacket(character.GenerateStat()); } else if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreMP / 10 || SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseMP / 10) { if (FirstData > 0) { if (IsLevelScaled) { amount = senderCharacter.Level * FirstData; } else { amount = FirstData; } if (character.Mp + amount > character.MPMax) { amount = character.MPMax - character.Mp; } character.Mp += amount; } else { if (IsLevelScaled) { amount = senderCharacter.Level * (FirstData - 1); } else { amount = FirstData; } amount *= -1; if (character.Mp - amount < 1) { amount = character.Mp - 1; } character.DecreaseMp(amount); } character.Session.SendPacket(character.GenerateStat()); } } HealingBurningAndCastingAction(); if (ThirdData > 0 && CardId != null) { IDisposable disposable = Observable.Interval(TimeSpan.FromSeconds(ThirdData * 2)) .Subscribe(s => HealingBurningAndCastingAction()); character.DisposeBCard(BCardId); character.BCardDisposables[BCardId] = disposable; } } #endregion #region MapMonster else if (session is MapMonster mapMonster) { void HealingBurningAndCastingAction() { if (!mapMonster.IsAlive || mapMonster.MapInstance == null) { return; } int amount = 0; if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreHP / 10 || SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseHP / 10) { if (FirstData > 0) { if (IsLevelScaled) { amount = senderCharacter.Level * FirstData; } else { amount = FirstData; } if (mapMonster.CurrentHp + amount > mapMonster.MaxHp) { amount = mapMonster.MaxHp - mapMonster.CurrentHp; } mapMonster.CurrentHp += amount; mapMonster.MapInstance.Broadcast(mapMonster.GenerateRc(amount)); } else { if (IsLevelScaled) { amount = senderCharacter.Level * (FirstData - 1); } else { amount = FirstData; } amount *= -1; if (mapMonster.CurrentHp - amount < 1) { amount = mapMonster.CurrentHp - 1; } mapMonster.CurrentHp -= amount; mapMonster.MapInstance.Broadcast(mapMonster.GenerateDm(amount)); } } if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreMP / 10 || SubType == (byte)AdditionalTypes.HealingBurningAndCasting.DecreaseMP / 10) { if (FirstData > 0) { if (IsLevelScaled) { amount = senderCharacter.Level * FirstData; } else { amount = FirstData; } if (mapMonster.CurrentMp + amount > mapMonster.MaxMp) { amount = mapMonster.MaxMp - mapMonster.CurrentMp; } mapMonster.CurrentMp += amount; } else { if (IsLevelScaled) { amount = senderCharacter.Level * (FirstData - 1); } else { amount = FirstData; } amount *= -1; if (mapMonster.CurrentMp - amount < 1) { amount = mapMonster.CurrentMp - 1; } mapMonster.CurrentMp -= amount; } } } HealingBurningAndCastingAction(); if (ThirdData > 0 && CardId != null) { IDisposable disposable = Observable.Interval(TimeSpan.FromSeconds(ThirdData * 2)) .Subscribe(s => HealingBurningAndCastingAction()); mapMonster.DisposeBCard(BCardId); mapMonster.BCardDisposables[BCardId] = disposable; } } #endregion } } break; case BCardType.CardType.HPMP: { if (SubType == (byte)AdditionalTypes.HPMP.DecreaseRemainingMP / 10) { if (FirstData < 0) { double multiplier = (FirstData * -1) / 100D; if (session is Character character) { character.DecreaseMp((int)(character.Mp * multiplier)); character.Session?.SendPacket(character.GenerateStat()); } else if (session is MapMonster mapMonster) { mapMonster.DecreaseMp((int)(mapMonster.CurrentMp * multiplier)); } } } } break; case BCardType.CardType.SpecializationBuffResistance: { if (SubType == (byte)AdditionalTypes.SpecializationBuffResistance.RemoveGoodEffects / 10) { if (session is Character character) { if (FirstData < 0) { if (ServerManager.RandomNumber() < (FirstData * -1)) { character.Buff?.GetAllItems()?.Where(s => s?.Card?.BuffType == BuffType.Bad && s.Card.Level < SecondData)? .ToList()?.ForEach(s => character.RemoveBuff(s.Card.CardId)); } } else { if (ServerManager.RandomNumber() < FirstData) { character.Buff?.GetAllItems()?.Where(s => s?.Card?.BuffType == BuffType.Good && s.Card.Level < SecondData)? .ToList()?.ForEach(s => character.RemoveBuff(s.Card.CardId)); } } } } } break; case BCardType.CardType.SpecialEffects: { if (SubType == (byte)AdditionalTypes.SpecialEffects.ShadowAppears / 10) { if (session is Character character) { character.NumberOfShadows = FirstData; character.ShadowsDistance = SecondData; character.MapInstance?.Broadcast(character.GenerateSpeed()); } } } break; case BCardType.CardType.Capture: { if (session is MapMonster mapMonster && sender is ClientSession senderSession) { NpcMonster mateNpc = ServerManager.GetNpc(mapMonster.MonsterVNum); if (mateNpc != null) { if (mapMonster.Monster.Catch) { if (mapMonster.IsAlive && mapMonster.CurrentHp <= (int)((double)mapMonster.MaxHp / 2)) { if (mapMonster.Monster.Level < senderSession.Character.Level) { // TODO: Find a new algorithm int[] chance = { 100, 80, 60, 40, 20, 0 }; if (ServerManager.RandomNumber() < chance[ServerManager.RandomNumber(0, 5)]) { Mate mate = new Mate(senderSession.Character, mateNpc, (byte)(mapMonster.Monster.Level - 15 > 0 ? mapMonster.Monster.Level - 15 : 1), MateType.Pet); if (senderSession.Character.CanAddMate(mate)) { senderSession.Character.AddPetWithSkill(mate); senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CATCH_SUCCESS"), 0)); senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, senderSession.Character.CharacterId, 197)); senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)((float)mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100), 0, -1, 0)); mapMonster.SetDeathStatement(); senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.Out(UserType.Monster, mapMonster.MapMonsterId)); } else { senderSession.SendPacket(senderSession.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_SLOT_FULL"), 10)); senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } else { senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CATCH_FAIL"), 0)); senderSession.CurrentMapInstance?.Broadcast(StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)((float)mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100), 0, -1, 0)); } } else { senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("LEVEL_LOWER_THAN_MONSTER"), 0)); senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } else { senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CURRENT_HP_TOO_HIGH"), 0)); senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } else { senderSession.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_CANT_BE_CAPTURED"), 0)); senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } } } break; case BCardType.CardType.SpecialDamageAndExplosions: break; case BCardType.CardType.SpecialEffects2: { if (SubType == (byte)AdditionalTypes.SpecialEffects2.TeleportInRadius / 10) { if (session is Character character) { character.Teleport((short)FirstData); } } } break; case BCardType.CardType.CalculatingLevel: break; case BCardType.CardType.Recovery: break; case BCardType.CardType.MaxHPMP: { if (session is Character character) { if (SubType == (byte)AdditionalTypes.MaxHPMP.IncreasesMaximumHP / 10) { character.HPLoad(); character.Session?.SendPacket(character.GenerateStat()); } else if (SubType == (byte)AdditionalTypes.MaxHPMP.IncreasesMaximumMP / 10) { character.MPLoad(); character.Session?.SendPacket(character.GenerateStat()); } } } break; case BCardType.CardType.MultAttack: break; case BCardType.CardType.MultDefence: break; case BCardType.CardType.TimeCircleSkills: break; case BCardType.CardType.RecoveryAndDamagePercent: break; case BCardType.CardType.Count: break; case BCardType.CardType.NoDefeatAndNoDamage: break; case BCardType.CardType.SpecialActions: { Character senderCharacter = sender is ClientSession senderSession ? senderSession.Character : sender as Character; if (SubType == (byte)AdditionalTypes.SpecialActions.PushBack / 10) { if (senderCharacter != null) { if (session is Character character) { if (character.ResistForcedMovementChance <= 0 || ServerManager.RandomNumber() < character.ResistForcedMovementChance) { character.PushBack((short)FirstData, senderCharacter); } } else if (session is MapMonster mapMonster) { mapMonster.PushBack((short)FirstData, senderCharacter); } } } else if (SubType == (byte)AdditionalTypes.SpecialActions.FocusEnemies / 10) { if (senderCharacter != null) { if (session is Character character) { if (character.ResistForcedMovementChance <= 0 || ServerManager.RandomNumber() < character.ResistForcedMovementChance) { character.Focus((short)FirstData, senderCharacter); } } else if (session is MapMonster mapMonster) { mapMonster.Focus((short)FirstData, senderCharacter); } } } else if (SubType == (byte)AdditionalTypes.SpecialActions.Hide / 10) { if (session is Character character) { character.SetInvisible(true); } } } break; case BCardType.CardType.Transform: break; case BCardType.CardType.Mode: break; case BCardType.CardType.NoCharacteristicValue: break; case BCardType.CardType.LightAndShadow: { if (SubType == (byte)AdditionalTypes.LightAndShadow.RemoveBadEffects / 10) { if (session is Character character) { character.Buff?.GetAllItems()?.Where(s => s?.Card?.BuffType == BuffType.Bad && s.Card.Level < FirstData)? .ToList()?.ForEach(s => character.RemoveBuff(s.Card.CardId)); } } } break; case BCardType.CardType.Item: break; case BCardType.CardType.DebuffResistance: break; case BCardType.CardType.SpecialBehaviour: break; case BCardType.CardType.Quest: break; case BCardType.CardType.SecondSPCard: { if (session is Character character) { if (character.MapInstance != null) { List <MonsterToSummon> monsterList = new List <MonsterToSummon>(); if (SubType == (byte)AdditionalTypes.SecondSPCard.PlantBomb / 10) { MapMonster bomb = character.MapInstance.Monsters.FirstOrDefault(m => m?.Owner?.CharacterId == character.CharacterId && m.MonsterVNum == (short)SecondData); if (bomb == null) { for (int i = 0; i < FirstData; i++) { monsterList.Add(new MonsterToSummon((short)SecondData, new MapCell { X = character.PositionX, Y = character.PositionY }, -1, false, false, false, false, false, -1, character, 0, false)); } } else { bomb.Explode(); break; } } else if (SubType == (byte)AdditionalTypes.SecondSPCard.PlantSelfDestructionBomb / 10) { int aliveTime = ServerManager.GetNpc((short)SecondData).RespawnTime; for (int i = 0; i < FirstData; i++) { MapCell mapCell = new MapCell { X = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionX), Y = (short)(ServerManager.RandomNumber(-1, 2) + character.PositionY), }; monsterList.Add(new MonsterToSummon((short)SecondData, mapCell, -1, true, false, false, true, false, -1, character, aliveTime, true)); } } if (monsterList.Any()) { EventHelper.Instance.RunEvent(new EventContainer(character.MapInstance, EventActionType.SPAWNMONSTERS, monsterList)); } } } } break; case BCardType.CardType.SPCardUpgrade: break; case BCardType.CardType.HugeSnowman: break; case BCardType.CardType.Drain: break; case BCardType.CardType.BossMonstersSkill: break; case BCardType.CardType.LordHatus: break; case BCardType.CardType.LordCalvinas: break; case BCardType.CardType.SESpecialist: { if (SubType == (byte)AdditionalTypes.SESpecialist.LowerHPStrongerEffect / 10) { Character senderCharacter = sender is ClientSession senderSession ? senderSession.Character : sender as Character; if (senderCharacter != null) { if (session is Character character) { double percentage = (character.Hp * 100) / character.HPMax; if (percentage < 35) { character.AddBuff(new Buff(274, senderCharacter.Level, senderCharacter)); } else if (percentage < 67) { character.AddBuff(new Buff(273, senderCharacter.Level, senderCharacter)); } else { character.AddBuff(new Buff(272, senderCharacter.Level, senderCharacter)); } } } } } break; case BCardType.CardType.FourthGlacernonFamilyRaid: break; case BCardType.CardType.SummonedMonsterAttack: break; case BCardType.CardType.BearSpirit: { if (session is Character character) { if (SubType == (byte)AdditionalTypes.BearSpirit.IncreaseMaximumHP / 10) { character.HPLoad(); character.Session?.SendPacket(character.GenerateStat()); } else if (SubType == (byte)AdditionalTypes.BearSpirit.IncreaseMaximumMP / 10) { character.MPLoad(); character.Session?.SendPacket(character.GenerateStat()); } } } break; case BCardType.CardType.SummonSkill: break; case BCardType.CardType.InflictSkill: break; case BCardType.CardType.HideBarrelSkill: break; case BCardType.CardType.FocusEnemyAttentionSkill: break; case BCardType.CardType.TauntSkill: break; case BCardType.CardType.FireCannoneerRangeBuff: break; case BCardType.CardType.VulcanoElementBuff: break; case BCardType.CardType.DamageConvertingSkill: break; case BCardType.CardType.MeditationSkill: { if (session is Character character) { if (SkillVNum.HasValue && SubType.Equals((byte)AdditionalTypes.MeditationSkill.CausingChance / 10) && ServerManager.RandomNumber() < FirstData) { Skill skill = ServerManager.GetSkill(SkillVNum.Value); Skill newSkill = ServerManager.GetSkill((short)SecondData); Observable.Timer(TimeSpan.FromMilliseconds(100)).Subscribe(observer => { foreach (QuicklistEntryDTO quicklistEntry in character.QuicklistEntries.Where(s => s.Pos.Equals(skill.CastId))) { character.Session.SendPacket($"qset {quicklistEntry.Q1} {quicklistEntry.Q2} {quicklistEntry.Type}.{quicklistEntry.Slot}.{newSkill.CastId}.0"); } character.Session.SendPacket($"mslot {newSkill.CastId} -1"); }); character.SkillComboCount++; character.LastSkillComboUse = DateTime.Now; if (skill.CastId > 10) { Observable.Timer(TimeSpan.FromMilliseconds((skill.GetCooldown(character) * 100) + 500)).Subscribe(observer => character.Session.SendPacket(StaticPacketHelper.SkillReset(skill.CastId))); } } switch (SubType) { case 2: character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(4); break; case 3: character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(8); break; case 4: character.MeditationDictionary[(short)SecondData] = DateTime.Now.AddSeconds(12); break; } } } break; case BCardType.CardType.FalconSkill: break; case BCardType.CardType.AbsorptionAndPowerSkill: break; case BCardType.CardType.LeonaPassiveSkill: break; case BCardType.CardType.FearSkill: break; case BCardType.CardType.SniperAttack: break; case BCardType.CardType.FrozenDebuff: break; case BCardType.CardType.JumpBackPush: break; case BCardType.CardType.FairyXPIncrease: break; case BCardType.CardType.SummonAndRecoverHP: break; case BCardType.CardType.TeamArenaBuff: break; case BCardType.CardType.ArenaCamera: break; case BCardType.CardType.DarkCloneSummon: break; case BCardType.CardType.AbsorbedSpirit: break; case BCardType.CardType.AngerSkill: break; case BCardType.CardType.MeteoriteTeleport: break; case BCardType.CardType.StealBuff: break; case BCardType.CardType.Unknown: break; case BCardType.CardType.EffectSummon: break; default: Logger.Warn($"Card Type {Type} Not Found!"); 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) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment); if (box != null) { 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 BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment); if (box != null) { if (box.HoldingVNum == 0) { if (packetsplit.Length == 1) { int PetId; if (int.TryParse(packetsplit[0], out PetId)) { Mate mate = session.Character.Mates.FirstOrDefault(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 { Mate mate = new Mate(session.Character, (short)box.HoldingVNum, 1, MateType.Pet); mate.Attack = box.SpDamage; mate.Defence = box.SpDefence; if (session.Character.AddPet(mate)) { session.Character.Inventory.RemoveItemAmountFromInventory(1, 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 { if (session.CurrentMapInstance == session.Character.Miniland) { Mate mate = new Mate(session.Character, (short)EffectValue, LevelMinimum, ItemSubType == 1 ? MateType.Partner : MateType.Pet); if (session.Character.AddPet(mate)) { session.Character.Inventory.RemoveItemAmountFromInventory(1, 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) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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.Any()) { SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(newInv.First().Slot, newInv.First().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.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.RemoveItemAmountFromInventory(1, box.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)); } } } } if (EffectValue == 3) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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.Any()) { WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(newInv.First().Slot, newInv.First().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.RemoveItemAmountFromInventory(1, box.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)); } } } } if (EffectValue == 4) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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.Any()) { short Slot = inv.Slot; if (Slot != -1) { session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.First().Item.Name} x 1)", 12)); newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd())); session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)); } } } } break; default: Logger.Log.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) { if (packetsplit == null) { return; } void releasePet(MateType mateType, Guid itemToRemoveId) { if (int.TryParse(packetsplit[3], out int mateTransportId)) { Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == mateType); if (mate != null) { if (!mate.IsTeamMember) { session.Character.Mates.Remove(mate); session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED"))); session.SendPacket(UserInterfaceHelper.GeneratePClear()); session.SendPackets(session.Character.GenerateScP()); session.SendPackets(session.Character.GenerateScN()); session.CurrentMapInstance?.Broadcast(mate.GenerateOut()); session.Character.Inventory.RemoveItemFromInventory(itemToRemoveId); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0)); } } } } switch (Effect) { case 11: if (int.TryParse(packetsplit[3], out int mateTransportId)) { Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId); if (mate == null || mate.Level >= session.Character.Level - 5) { return; } mate.Level++; session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 16), mate.PositionX, mate.PositionY); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 3406), mate.PositionX, mate.PositionY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; case 13: if (int.TryParse(packetsplit[3], out mateTransportId) && session.Character.Mates.Any(s => s.MateTransportId == mateTransportId)) { session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 1, mateTransportId, 2)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; case 14: if (int.TryParse(packetsplit[3], out mateTransportId)) { Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Pet); if (mate?.CanPickUp == false) { session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 12)); session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5001)); mate.CanPickUp = true; session.SendPackets(session.Character.GenerateScP()); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_CAN_PICK_UP"), 10)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } break; case 17: if (int.TryParse(packetsplit[3], out mateTransportId)) { Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId); if (mate?.IsSummonable == false) { mate.IsSummonable = true; session.SendPackets(session.Character.GenerateScP()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 10)); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 0)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } break; case 1000: releasePet(MateType.Pet, inv.Id); break; case 1001: releasePet(MateType.Partner, inv.Id); 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) { 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; //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) { 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)); } } } } 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; //Need change rewards value for all boxes /* case 185: // Hatus raid box * int rnd8 = ServerManager.RandomNumber(0, 1000); * int random8 = ServerManager.RandomNumber(0, 7); * short[] vnums8 = null; * if (rnd8 < 900) * { * vnums8 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * else * { * vnums8 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * session.Character.GiftAdd(vnums8[ServerManager.RandomNumber(0, 7)], 1, (byte)random8); * session.Character.Inventory.RemoveItemFromInventory(inv.Id); * break; * * case 882: // Morcos raid box * int rnd7 = ServerManager.RandomNumber(0, 1000); * int random = ServerManager.RandomNumber(0, 7); * short[] vnums7 = null; * if (rnd7 < 900) * { * vnums7 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * else * { * vnums7 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * session.Character.GiftAdd(vnums7[ServerManager.RandomNumber(0, 7)], 1, (byte)random); * session.Character.Inventory.RemoveItemFromInventory(inv.Id); * break; * * case 942: // Calvina raid box * int rnd10 = ServerManager.RandomNumber(0, 1000); * int random10 = ServerManager.RandomNumber(0, 7); * short[] vnums10 = null; * if (rnd10 < 900) * { * vnums10 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * else * { * vnums10 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * session.Character.GiftAdd(vnums10[ServerManager.RandomNumber(0, 7)], 1, (byte)random10); * session.Character.Inventory.RemoveItemFromInventory(inv.Id); * break; * * case 999: // Berios raid box * int rnd9 = ServerManager.RandomNumber(0, 1000); * int random9 = inv.Item. * short[] vnums9 = null; * if (rnd9 < 900) * { * vnums9 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * else * { * vnums9 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 }; * } * session.Character.GiftAdd(vnums9[ServerManager.RandomNumber(0, 7)], 1, (byte)random9); * session.Character.Inventory.RemoveItemFromInventory(inv.Id); * break;*/ default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue)); break; } }
public static void NRun(ClientSession Session, NRunPacket packet) { if (!Session.HasCurrentMapInstance) { return; } MapNpc npc = Session.CurrentMapInstance.Npcs.Find(s => s.MapNpcId == packet.NpcId); TeleporterDTO tp; MapNpcDTO npcTp; switch (packet.Runner) { case 1: if (packet.Type > 4 || packet.Type < 1) { return; } if (Session.Character.Class != (byte)ClassType.Adventurer) { Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0)); return; } if (Session.Character.Level < 15 || Session.Character.JobLevel < 20) { Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0)); return; } if (packet.Type == (byte)Session.Character.Class || packet.Type > 3 && Session.Account.Authority < AuthorityType.GameMaster || packet.Type < 0) { return; } if (Session.Character.Inventory.All(i => i.Type != InventoryType.Wear)) { Session.Character.Inventory.AddNewToInventory((short)(4 + (packet.Type * 14)), type: InventoryType.Wear); Session.Character.Inventory.AddNewToInventory((short)(81 + (packet.Type * 13)), type: InventoryType.Wear); switch (packet.Type) { case 1: Session.Character.Inventory.AddNewToInventory(68, type: InventoryType.Wear); Session.Character.Inventory.AddNewToInventory(2082, 10); break; case 2: Session.Character.Inventory.AddNewToInventory(78, type: InventoryType.Wear); Session.Character.Inventory.AddNewToInventory(2083, 10); break; case 3: Session.Character.Inventory.AddNewToInventory(86, type: InventoryType.Wear); break; } Session.CurrentMapInstance?.Broadcast(Session.Character.GenerateEq()); Session.SendPacket(Session.Character.GenerateEquipment()); Session.Character.ChangeClass((ClassType)packet.Type); } else { Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; case 2: Session.SendPacket("wopen 1 0"); break; case 4: Mate mate = Session.Character.Mates.Find(s => s.MateTransportId == packet.NpcId); switch (packet.Type) { case 2: if (mate != null) { if (Session.Character.Level >= mate.Level) { Mate teammate = Session.Character.Mates.Where(s => s.IsTeamMember).FirstOrDefault(s => s.MateType == mate.MateType); if (teammate != null) { teammate.IsTeamMember = false; teammate.MapX = teammate.PositionX; teammate.MapY = teammate.PositionY; } mate.IsTeamMember = true; } else { Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_HIGHER_LEVEL"), 0)); } } break; case 3: if (mate != null && Session.Character.Miniland == Session.Character.MapInstance) { mate.IsTeamMember = false; mate.MapX = mate.PositionX; mate.MapY = mate.PositionY; } break; case 4: if (mate != null) { if (Session.Character.Miniland == Session.Character.MapInstance) { mate.IsTeamMember = false; mate.MapX = mate.PositionX; mate.MapY = mate.PositionY; } else { Session.SendPacket($"qna #n_run^4^5^3^{mate.MateTransportId} {Language.Instance.GetMessageFromKey("ASK_KICK_PET")}"); } break; } break; case 5: if (mate != null) { Session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 10, $"#n_run^4^6^3^{mate.MateTransportId}")); } break; case 6: if (mate != null && Session.Character.Miniland != Session.Character.MapInstance) { mate.IsTeamMember = false; Session.CurrentMapInstance.Broadcast(mate.GenerateOut()); Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_KICKED"), mate.Name), 11)); Session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_KICKED"), mate.Name), 0)); } break; case 7: if (mate != null) { if (Session.Character.Mates.Any(s => s.MateType == mate.MateType && s.IsTeamMember)) { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ALREADY_PET_IN_TEAM"), 11)); Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ALREADY_PET_IN_TEAM"), 0)); } else { Session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 10, $"#n_run^4^9^3^{mate.MateTransportId}")); } } break; case 9: if (mate != null && Session.Character.Level >= mate.Level) { mate.PositionX = (short)(Session.Character.PositionX + (mate.MateType == MateType.Partner ? -1 : 1)); mate.PositionY = (short)(Session.Character.PositionY + 1); mate.IsTeamMember = true; Session.CurrentMapInstance?.Broadcast(mate.GenerateIn()); } else { Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_HIGHER_LEVEL"), 0)); } break; } Session.SendPacket(Session.Character.GeneratePinit()); Session.SendPackets(Session.Character.GeneratePst()); break; case 10: Session.SendPacket("wopen 3 0"); break; case 12: Session.SendPacket($"wopen {packet.Type} 0"); break; case 14: Session.SendPacket("wopen 27 0"); string recipelist = "m_list 2"; if (npc != null) { List <Recipe> tps = npc.Recipes; recipelist = tps.Where(s => s.Amount > 0).Aggregate(recipelist, (current, s) => current + $" {s.ItemVNum}"); recipelist += " -100"; Session.SendPacket(recipelist); } break; case 15: if (npc != null) { if (packet.Value == 2) { Session.SendPacket($"qna #n_run^15^1^1^{npc.MapNpcId} {Language.Instance.GetMessageFromKey("ASK_CHANGE_SPAWNLOCATION")}"); } else { switch (npc.MapId) { case 1: Session.Character.SetRespawnPoint(1, 79, 116); break; case 20: Session.Character.SetRespawnPoint(20, 9, 92); break; case 145: Session.Character.SetRespawnPoint(145, 13, 110); break; } Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("RESPAWNLOCATION_CHANGED"), 0)); } } break; case 16: tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type); if (tp != null) { if (Session.Character.Gold >= 1000 * packet.Type && packet.Type > 0) { Session.Character.Gold -= 1000 * packet.Type; Session.SendPacket(Session.Character.GenerateGold()); ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); } } break; case 17: double currentRunningSeconds = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds; double timeSpanSinceLastPortal = currentRunningSeconds - Session.Character.LastPortal; if (!(timeSpanSinceLastPortal >= 4) || !Session.HasCurrentMapInstance || ServerManager.Instance.ChannelId == 51 || Session.CurrentMapInstance.MapInstanceId == ServerManager.Instance.ArenaInstance.MapInstanceId || Session.CurrentMapInstance.MapInstanceId == ServerManager.Instance.FamilyArenaInstance.MapInstanceId) { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10)); return; } if (packet.Type < 0) { Logger.Log.Debug($"Admin: user {Session.Character.Name} tried an Gold Bug: NRun"); return; } if (Session.Character.Gold >= 500 * (1 + packet.Type)) { Session.Character.LastPortal = currentRunningSeconds; Session.Character.Gold -= 500 * (1 + packet.Type); Session.SendPacket(Session.Character.GenerateGold()); MapCell pos = packet.Type == 0 ? ServerManager.Instance.ArenaInstance.Map.GetRandomPosition() : ServerManager.Instance.FamilyArenaInstance.Map.GetRandomPosition(); ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, packet.Type == 0 ? ServerManager.Instance.ArenaInstance.MapInstanceId : ServerManager.Instance.FamilyArenaInstance.MapInstanceId, pos.X, pos.Y); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); } break; case 18: Session.SendPacket(Session.Character.GenerateNpcDialog(17)); break; case 26: tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type); if (tp != null) { if (Session.Character.Gold >= 5000 * packet.Type && packet.Type > 0) { Session.Character.Gold -= 5000 * packet.Type; ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); } } break; case 45: tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type); if (tp != null) { if (Session.Character.Gold >= 500) { Session.Character.Gold -= 500; Session.SendPacket(Session.Character.GenerateGold()); ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); } } break; case 132: tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type); if (tp != null) { ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } break; case 150: if (npc == null || !npc.EffectActivated && ServerManager.Instance.LodTimes || Session.Character.Level < ServerManager.Instance.MinLodLevel) { return; } if (Session.Character?.Family == null) { Session.SendPacket( UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NEED_FAMILY"), 0)); break; } if (Session.Character?.Family?.LandOfDeath != null) { ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, Session.Character.Family.LandOfDeath.MapInstanceId, 153, 145); } break; case 301: tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type); if (tp != null) { ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } break; case 1600: Session.SendPacket(Session.Character.OpenFamilyWarehouse()); break; case 1601: Session.SendPackets(Session.Character.OpenFamilyWarehouseHist()); break; case 1602: if (Session.Character.Family?.FamilyLevel >= 3 && Session.Character.Family.WarehouseSize < 21) { if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head) { if (500000 >= Session.Character.Gold) { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); return; } Session.Character.Family.WarehouseSize = 21; Session.Character.Gold -= 500000; Session.SendPacket(Session.Character.GenerateGold()); FamilyDTO fam = Session.Character.Family; DAOFactory.FamilyDAO.InsertOrUpdate(ref fam); ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10)); Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1)); } } break; case 1603: if (Session.Character.Family?.FamilyLevel >= 7 && Session.Character.Family.WarehouseSize < 49) { if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head) { if (2000000 >= Session.Character.Gold) { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); return; } Session.Character.Family.WarehouseSize = 49; Session.Character.Gold -= 2000000; Session.SendPacket(Session.Character.GenerateGold()); FamilyDTO fam = Session.Character.Family; DAOFactory.FamilyDAO.InsertOrUpdate(ref fam); ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10)); Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1)); } } break; case 1604: if (Session.Character.Family?.FamilyLevel >= 5 && Session.Character.Family.MaxSize < 70) { if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head) { if (5000000 >= Session.Character.Gold) { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); return; } Session.Character.Family.MaxSize = 70; Session.Character.Gold -= 5000000; Session.SendPacket(Session.Character.GenerateGold()); FamilyDTO fam = Session.Character.Family; DAOFactory.FamilyDAO.InsertOrUpdate(ref fam); ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10)); Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1)); } } break; case 1605: if (Session.Character.Family?.FamilyLevel >= 9 && Session.Character.Family.MaxSize < 100) { if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head) { if (10000000 >= Session.Character.Gold) { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); return; } Session.Character.Family.MaxSize = 100; Session.Character.Gold -= 10000000; Session.SendPacket(Session.Character.GenerateGold()); FamilyDTO fam = Session.Character.Family; DAOFactory.FamilyDAO.InsertOrUpdate(ref fam); ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10)); Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1)); } } break; case 23: if (packet.Type == 0) { if (Session.Character.Group?.CharacterCount == 3) { foreach (ClientSession s in Session.Character.Group.Characters.GetAllItems()) { if (s.Character.Family != null) { Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("GROUP_MEMBER_ALREADY_IN_FAMILY"))); return; } } } if (Session.Character.Group == null || Session.Character.Group.CharacterCount != 3) { Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FAMILY_GROUP_NOT_FULL"))); return; } Session.SendPacket(UserInterfaceHelper.GenerateInbox($"#glmk^ {14} 1 {Language.Instance.GetMessageFromKey("CREATE_FAMILY").Replace(' ', '^')}")); } else { if (Session.Character.Family == null) { Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("NOT_IN_FAMILY"))); return; } if (Session.Character.Family != null && Session.Character.FamilyCharacter != null && Session.Character.FamilyCharacter.Authority != FamilyAuthority.Head) { Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("NOT_FAMILY_HEAD"))); return; } Session.SendPacket($"qna #glrm^1 {Language.Instance.GetMessageFromKey("DISMISS_FAMILY")}"); } break; case 60: StaticBonusDTO medal = Session.Character.StaticBonusList.Find(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver); byte Medal = 0; int Time = 0; if (medal != null) { Medal = medal.StaticBonusType == StaticBonusType.BazaarMedalGold ? (byte)MedalType.Gold : (byte)MedalType.Silver; Time = (int)(medal.DateEnd - DateTime.Now).TotalHours; } Session.SendPacket($"wopen 32 {Medal} {Time}"); break; case 5002: npcTp = DAOFactory.MapNpcDAO.LoadAll().Where(n => n.NpcVNum == 540).FirstOrDefault(); if (npcTp != null) { if (ServerManager.Instance.ChannelId == 51) { Session.SendPacket("it 3"); string connection = CommunicationServiceClient.Instance.RetrieveOriginWorld(Session.Account.AccountId); if (string.IsNullOrWhiteSpace(connection)) { return; } Session.Character.MapId = npcTp.MapId; Session.Character.MapX = npcTp.MapX; Session.Character.MapY = npcTp.MapY; int port = Convert.ToInt32(connection.Split(':')[1]); Session.Character.ChangeChannel(connection.Split(':')[0], port, 3); } else { ServerManager.Instance.ChangeMap(Session.Character.CharacterId, npcTp.MapId, npcTp.MapX, npcTp.MapY); } } break; case 5001: if (npc != null) { MapInstance map = null; switch (Session.Character.Faction) { case FactionType.None: Session.SendPacket(UserInterfaceHelper.GenerateInfo("You need to be part of a faction to join Act 4")); return; case FactionType.Angel: map = ServerManager.GetAllMapInstances().Find(s => s.MapInstanceType.Equals(MapInstanceType.Act4ShipAngel)); break; case FactionType.Demon: map = ServerManager.GetAllMapInstances().Find(s => s.MapInstanceType.Equals(MapInstanceType.Act4ShipDemon)); break; } if (map == null /* || npc.EffectActivated*/) { Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_NOTARRIVED"), 0)); return; } if (3000 > Session.Character.Gold) { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); return; } Session.Character.Gold -= 3000; MapCell pos = map.Map.GetRandomPosition(); ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, map.MapInstanceId, pos.X, pos.Y); } break; case 5004: if (npc != null) { ServerManager.Instance.ChangeMap(Session.Character.CharacterId, 261, 113, 160); } break; case 5011: if (npc != null) { ServerManager.Instance.ChangeMap(Session.Character.CharacterId, 170, 127, 46); } break; case 5012: tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type); if (tp != null) { ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } break; default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), packet.Runner)); 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 != null && packetsplit.Length == 9) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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 BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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; List <ItemInstance> newInv = null; foreach (RollGeneratedItemDTO rollitem in roll) { if (newInv != null) { continue; } currentrnd += rollitem.Probability; if (currentrnd < rnd) { continue; } newInv = session.Character.Inventory.AddNewToInventory(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, Rare: box.Rare, Upgrade: rollitem.ItemGeneratedUpgrade); if (!newInv.Any()) { continue; } short slot = inv.Slot; if (slot == -1) { continue; } session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.First().Item.Name} x {rollitem.ItemGeneratedAmount})", 12)); session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}"); newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd())); session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id); } } else if (box.HoldingVNum == 0) { if (packetsplit != null && packetsplit.Length == 1) { if (int.TryParse(packetsplit[0], out int petId)) { Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == petId); if (mate != null) { 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.RemoveItemAmountFromInventory(1, 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.RemoveItemAmountFromInventory(1, 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) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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.Any()) { ItemInstance itemInstance = newInv.First(); SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(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.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.RemoveItemAmountFromInventory(1, box.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)); } } } } if (EffectValue == 3) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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.Any()) { ItemInstance itemInstance = newInv.First(); WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(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.RemoveItemAmountFromInventory(1, box.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)); } } } } if (EffectValue == 4) { BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(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.Any()) { short slot = inv.Slot; if (slot != -1) { session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.First().Item.Name} x 1)", 12)); newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd())); session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)); } } } } break; default: Logger.Log.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) { inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character)); switch (Effect) { case 0: switch (VNum) { case 1428: session.SendPacket("guri 18 1"); break; case 1429: session.SendPacket("guri 18 0"); break; case 1430: if (packetsplit == null) { return; } if (packetsplit.Length < 9) { // MODIFIED PACKET return; } if (!short.TryParse(packetsplit[9], out short eqSlot) || !Enum.TryParse(packetsplit[8], out InventoryType eqType)) { return; } WearableInstance eq = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(eqSlot, eqType); if (eq == null) { // PACKET MODIFIED return; } if (eq.Item.ItemType != ItemType.Armor && eq.Item.ItemType != ItemType.Weapon) { return; } eq.EquipmentOptions.Clear(); eq.ShellRarity = null; session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_ERASED"), 0)); session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(17, 1, session.Character.CharacterId)); break; case 1904: short[] items = { 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1972, 1973 }; for (int i = 0; i < 5; i++) { session.Character.GiftAdd(items[ServerManager.Instance.RandomNumber(0, items.Length)], 1); } session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; case 5916: session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 340, CharacterId = session.Character.CharacterId, RemainingTime = 7200 }); session.Character.RemoveBuff(339); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; case 5929: session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 340, CharacterId = session.Character.CharacterId, RemainingTime = 600 }); session.Character.RemoveBuff(339); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; default: IEnumerable <RollGeneratedItemDTO> roll = DAOFactory.RollGeneratedItemDAO.Where(s => s.OriginalItemVNum == VNum); IEnumerable <RollGeneratedItemDTO> rollGeneratedItemDtos = roll as IList <RollGeneratedItemDTO> ?? roll.ToList(); if (!rollGeneratedItemDtos.Any()) { return; } int probabilities = rollGeneratedItemDtos.Sum(s => s.Probability); int rnd = ServerManager.Instance.RandomNumber(0, probabilities); int currentrnd = 0; foreach (RollGeneratedItemDTO rollitem in rollGeneratedItemDtos) { if (rollitem.Probability == 10000) { session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount); continue; } currentrnd += rollitem.Probability; if (currentrnd < rnd) { continue; } if (rollitem.IsSuperReward) { CommunicationServiceClient.Instance.SendMessageToCharacter(new SCSCharacterMessage { DestinationCharacterId = null, SourceCharacterId = session.Character.CharacterId, SourceWorldId = ServerManager.Instance.WorldId, Message = Language.Instance.GetMessageFromKey("SUPER_REWARD"), Type = MessageType.Shout }); } session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, 0, rollitem.ItemGeneratedUpgrade); break; } session.Character.Inventory.RemoveItemAmount(VNum); break; } break; // sp point potions case 150: case 151: session.Character.SpAdditionPoint += EffectValue; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0)); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; case 204: session.Character.SpPoint += EffectValue; session.Character.SpAdditionPoint += EffectValue * 3; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0)); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; case 250: if (session.Character.Buff.Any(s => s.Card.CardId == 131)) { //TODO ADD MESSAGE ALREADY GOT BUFF return; } session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 131 }); session.CurrentMapInstance.Broadcast(session.Character.GeneratePairy()); session.SendPacket(session.Character.GeneratePairy()); break; case 208: if (session.Character.Buff.Any(s => s.Card.CardId == 121)) { //TODO ADD MESSAGE ALREADY GOT BUFF return; } session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 121, CharacterId = session.Character.CharacterId, RemainingTime = 3600 }); break; case 301: if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId)) { //TODO you are in group return; } ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main); ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequieredItems.Any(obj => obj.VNum == raidSeal.ItemVNum))?.GetClone(); if (raid != null) { session.Character.Inventory.RemoveItemAmountFromInventory(1, raidSeal.Id); Group group = new Group(GroupType.Team); group.Raid = raid; group.JoinGroup(session.Character.CharacterId); ServerManager.Instance.AddGroup(group); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 0)); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 10)); if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10)); } session.SendPacket(session.Character.GenerateRaid(2, false)); session.SendPacket(session.Character.GenerateRaid(0, false)); session.SendPacket(session.Character.GenerateRaid(1, false)); session.SendPacket(group.GenerateRdlst()); } break; case 305: if (packetsplit == null || packetsplit.Length < 3) { return; } Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == int.Parse(packetsplit[3])); if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0) { mate.Skin = Morph; session.SendPacket(mate.GenerateCMode(mate.Skin)); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } break; //Atk/Def/HP/Exp potions case 6600: session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; // Divorce letter case 6969: // this is imaginary number I = √(-1) CharacterRelationDTO rel = session.Character.CharacterRelations.FirstOrDefault(s => s.RelationType == CharacterRelationType.Spouse); if (rel != null) { session.Character.DeleteRelation(rel.CharacterId == session.Character.CharacterId ? rel.RelatedCharacterId : rel.CharacterId); session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("DIVORCED"))); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } break; // Cupid's arrow case 34: // this is imaginary number I = √(-1) if (packetsplit != null && packetsplit.Length > 3) { if (long.TryParse(packetsplit[3], out long characterId)) { if (session.Character.CharacterRelations.Any(s => s.RelationType == CharacterRelationType.Spouse)) { session.SendPacket($"info {Language.Instance.GetMessageFromKey("ALREADY_MARRIED")}"); return; } if (session.Character.IsFriendOfCharacter(characterId)) { ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterId(characterId); if (otherSession != null) { otherSession.SendPacket(UserInterfaceHelper.Instance.GenerateDialog( $"#fins^-34^{session.Character.CharacterId} #fins^-69^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("MARRY_REQUEST"), session.Character.Name)}")); session.Character.FriendRequestCharacters.Add(characterId); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket($"info {Language.Instance.GetMessageFromKey("NOT_FRIEND")}"); } } } break; case 570: if (session.Character.Faction == (FactionType)EffectValue) { return; } session.SendPacket(session.Character.Family == null ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}" : UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"), 0)); break; // wings case 650: if (session.Character.UseSp && session.Character.SpInstance != null) { if (option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte) inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}"); } else { session.Character.SpInstance.Design = (byte)EffectValue; session.Character.MorphUpgrade2 = EffectValue; session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateStat()); session.SendPacket(session.Character.GenerateStatChar()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0)); } break; // presentation messages case 203: if (!session.Character.IsVehicled) { if (option == 0) { session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(10, 2, session.Character.CharacterId, 1)); } } break; // magic lamps case 651: if (session.Character.Inventory.All(i => i.Value.Type != InventoryType.Wear)) { if (option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}"); } else { session.Character.ChangeSex(); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; // vehicles case 1000: if (session.Character.HasShopOpened) { return; } if (Morph > 0) { if (option == 0 && !session.Character.IsVehicled) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest()); } session.Character.LastDelay = DateTime.Now; session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2")); } else { if (!session.Character.IsVehicled && option != 0) { DateTime delay = DateTime.Now.AddSeconds(-4); if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2)) { session.Character.Speed = Speed; session.Character.IsVehicled = true; session.Character.VehicleSpeed = Speed; session.Character.MorphUpgrade = 0; session.Character.MorphUpgrade2 = 0; session.Character.Morph = Morph + (byte)session.Character.Gender; session.Character.Mates?.ForEach(x => session.CurrentMapInstance?.Broadcast(x.GenerateOut())); session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY); session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateCond()); session.Character.LastSpeedChange = DateTime.Now; } } else if (session.Character.IsVehicled) { session.Character.Mates?.ForEach(x => { x.PositionX = session.Character.PositionX; x.PositionY = session.Character.PositionY; session.CurrentMapInstance?.Broadcast(x.GenerateIn()); }); session.Character.RemoveVehicle(); } } } break; case 1002: // TODO REVIEW THIS /* * if (EffectValue == 69) * { * int rnd = ServerManager.Instance.RandomNumber(0, 1000); * if (rnd < 5) * { * short[] vnums = * { * 5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, * 4715, 4716 * }; * byte[] counts = {1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; * int item = ServerManager.Instance.RandomNumber(0, 17); * * session.Character.GiftAdd(vnums[item], counts[item]); * } * else if (rnd < 30) * { * short[] vnums = {361, 362, 363, 366, 367, 368, 371, 372, 373}; * session.Character.GiftAdd(vnums[ServerManager.Instance.RandomNumber(0, 9)], 1); * } * else * { * short[] vnums = * { * 1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514, * 2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303, * 2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162 * }; * byte[] counts = * { * 10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20, * 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 * }; * int item = ServerManager.Instance.RandomNumber(0, 42); * session.Character.GiftAdd(vnums[item], counts[item]); * } * session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); * } */ if (session.HasCurrentMapInstance) { if (session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4)) { short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 }; short vnum = vnums[ServerManager.Instance.RandomNumber(0, 20)]; NpcMonster npcmonster = ServerManager.Instance.GetNpc(vnum); if (npcmonster == null) { return; } MapMonster monster = new MapMonster { MonsterVNum = vnum, MapY = session.Character.MapY, MapX = session.Character.MapX, MapId = session.Character.MapInstance.Map.MapId, Position = (byte)session.Character.Direction, IsMoving = true, MapMonsterId = session.CurrentMapInstance.GetNextMonsterId(), ShouldRespawn = false }; monster.Initialize(session.CurrentMapInstance); session.CurrentMapInstance.AddMonster(monster); session.CurrentMapInstance.Broadcast(monster.GenerateIn()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } break; case 69: session.Character.GetReput(ReputPrice); session.SendPacket(session.Character.GenerateFd()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; case 789: session.Character.GiftAdd((short)inv.Item.EffectValue, 1); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; case 790: break; case 1003: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalGold }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1004: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalSilver }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1005: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BackPack }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1006: if (option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}"); } else { if (session.Character.MaxMateCount < 30) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10)); session.SendPacket(session.Character.GenerateScpStc()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } break; case 1007: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBasket }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket("ib 1278 1"); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1008: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBackPack }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; default: Logger.Log.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) { if (packetsplit == null) { return; } int x1; switch (Effect) { case 11: if (int.TryParse(packetsplit[3], out x1)) { Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1); if (mate == null || mate.Level >= session.Character.Level - 5) { return; } mate.Level++; session.Character.Inventory.RemoveItemAmount(inv.ItemVNum); session.CurrentMapInstance?.Broadcast(mate.GenerateEff(8), mate.PositionX, mate.PositionY); session.CurrentMapInstance?.Broadcast(mate.GenerateEff(198), mate.PositionX, mate.PositionY); } break; case 13: if (int.TryParse(packetsplit[3], out x1)) { if (session.Character.Mates.Any(s => s.MateTransportId == x1)) { session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(10, 1, x1, 2)); } } break; case 14: if (int.TryParse(packetsplit[3], out x1)) { Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1 && s.MateType == MateType.Pet); if (mate != null) { if (!mate.CanPickUp) { session.Character.Inventory.RemoveItemAmount(inv.ItemVNum); session.CurrentMapInstance.Broadcast(mate.GenerateEff(5)); session.CurrentMapInstance.Broadcast(mate.GenerateEff(5002)); mate.CanPickUp = true; session.SendPackets(session.Character.GenerateScP()); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_CAN_PICK_UP"), 10)); } } } break; case 17: if (int.TryParse(packetsplit[3], out x1)) { Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1); if (mate != null) { if (!mate.IsSummonable) { session.Character.Inventory.RemoveItemAmount(inv.ItemVNum, 1); mate.IsSummonable = true; session.SendPackets(session.Character.GenerateScP()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 10)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 0)); } } } break; case 1000: if (int.TryParse(packetsplit[3], out x1)) { Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1 && s.MateType == MateType.Pet); if (mate != null) { if (!mate.IsTeamMember) { session.Character.Mates.Remove(mate); session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED"))); session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear()); session.SendPackets(session.Character.GenerateScP()); session.SendPackets(session.Character.GenerateScN()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.CurrentMapInstance?.Broadcast(mate.GenerateOut()); } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0)); } } } break; case 1001: if (int.TryParse(packetsplit[3], out x1)) { Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1 && s.MateType == MateType.Partner); if (mate != null) { if (!mate.IsTeamMember) { session.Character.Mates.Remove(mate); session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED"))); session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear()); session.SendPackets(session.Character.GenerateScP()); session.SendPackets(session.Character.GenerateScN()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.CurrentMapInstance?.Broadcast(mate.GenerateOut()); } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0)); } } } break; default: Logger.Log.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) { inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character)); switch (Effect) { // Honour Medals case 69: session.Character.Reputation += ReputPrice; session.SendPacket(session.Character.GenerateFd()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; // SP Potions case 150: case 151: session.Character.SpAdditionPoint += EffectValue; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; // Specialist Medal case 204: session.Character.SpPoint += EffectValue; session.Character.SpAdditionPoint += EffectValue * 3; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; // Raid Seals case 301: if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId)) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_OPEN_GROUP"), 12)); return; } ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main); session.Character.Inventory.RemoveItemFromInventory(raidSeal.Id); ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequiredItems?.Any(obj => obj?.VNum == raidSeal.ItemVNum) == true)?.Copy(); if (raid != null) { Group group = new Group { GroupType = GroupType.BigTeam, Raid = raid }; group.JoinGroup(session.Character.CharacterId); ServerManager.Instance.AddGroup(group); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 0)); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 10)); if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10)); } session.SendPacket(session.Character.GenerateRaid(2)); session.SendPacket(session.Character.GenerateRaid(0)); session.SendPacket(session.Character.GenerateRaid(1)); session.SendPacket(group.GenerateRdlst()); } break; // Partner Suits/Skins case 305: Mate mate = session.Character.Mates.Find(s => s.MateTransportId == int.Parse(packetsplit[3])); if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0) { mate.Skin = Morph; session.SendPacket(mate.GenerateCMode(mate.Skin)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Fairy Booster case 250: if (!session.Character.Buff.ContainsKey(131)) { session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 131 }); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0)); session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3014), session.Character.MapX, session.Character.MapY); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Rainbow Pearl/Magic Eraser case 666: if (EffectValue == 1 && byte.TryParse(packetsplit[9], out byte islot)) { ItemInstance wearInstance = session.Character.Inventory.LoadBySlotAndType(islot, InventoryType.Equipment); if (wearInstance != null && (wearInstance.Item.ItemType == ItemType.Weapon || wearInstance.Item.ItemType == ItemType.Armor) && wearInstance.ShellEffects.Count != 0 && !wearInstance.Item.IsHeroic) { wearInstance.ShellEffects.Clear(); DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearInstance.EquipmentSerialId); if (wearInstance.EquipmentSerialId == Guid.Empty) { wearInstance.EquipmentSerialId = Guid.NewGuid(); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_DELETE"), 0)); } } else { session.SendPacket("guri 18 0"); } break; // Atk/Def/HP/Exp potions case 6600: session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; // Ancelloan's Blessing case 208: if (!session.Character.Buff.ContainsKey(121)) { session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 121 }); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; case 2081: if (!session.Character.Buff.ContainsKey(146)) { session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 146 }); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; // Divorce letter case 6969: // this is imaginary number I = √(-1) break; // Cupid's arrow case 34: // this is imaginary number I = √(-1) break; case 100: { } break; // Faction Egg case 570: if (session.Character.Faction == (FactionType)EffectValue) { return; } if (EffectValue < 3) { session.SendPacket(session.Character.Family == null ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}" : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"), 0)); } else { session.SendPacket(session.Character.Family != null ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}" : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_FAMILY"), 0)); } break; // SP Wings case 650: ItemInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Wear); if (session.Character.UseSp && specialistInstance != null) { if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}"); } else { void disposeBuff(short vNum) { if (session.Character.BuffObservables.ContainsKey(vNum)) { session.Character.BuffObservables[vNum].Dispose(); session.Character.BuffObservables.Remove(vNum); } session.Character.RemoveBuff(vNum); } disposeBuff(387); disposeBuff(395); disposeBuff(396); disposeBuff(397); disposeBuff(398); disposeBuff(410); disposeBuff(411); disposeBuff(444); specialistInstance.Design = (byte)EffectValue; session.Character.MorphUpgrade2 = EffectValue; session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateStat()); session.SendPacket(session.Character.GenerateStatChar()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0)); } break; // Self-Introduction case 203: if (!session.Character.IsVehicled && Option == 0) { session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 2, session.Character.CharacterId, 1)); } break; // Magic Lamp case 651: if (session.Character.Inventory.All(i => i.Type != InventoryType.Wear)) { if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}"); } else { session.Character.ChangeSex(); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; // Vehicles case 1000: if (EffectValue != 0 || ServerManager.Instance.ChannelId == 51 || session.CurrentMapInstance?.MapInstanceType == MapInstanceType.EventGameInstance) { return; } if (Morph > 0) { if (Option == 0 && !session.Character.IsVehicled) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest()); } session.Character.LastDelay = DateTime.Now; session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2")); } else { if (!session.Character.IsVehicled && Option != 0) { DateTime delay = DateTime.Now.AddSeconds(-4); if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2)) { session.Character.Speed = Speed; session.Character.IsVehicled = true; session.Character.VehicleSpeed = Speed; session.Character.MorphUpgrade = 0; session.Character.MorphUpgrade2 = 0; session.Character.Morph = Morph + (byte)session.Character.Gender; session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 196), session.Character.MapX, session.Character.MapY); session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateCond()); session.Character.LastSpeedChange = DateTime.Now; } } else if (session.Character.IsVehicled) { session.Character.RemoveVehicle(); } } } break; // Sealed Vessel case 1002: if (EffectValue == 69) { int rnd = ServerManager.RandomNumber(0, 1000); if (rnd < 5) { short[] vnums = { 5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716 }; byte[] counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; int item = ServerManager.RandomNumber(0, 17); session.Character.GiftAdd(vnums[item], counts[item]); } else if (rnd < 30) { short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 }; session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 9)], 1); } else { short[] vnums = { 1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303, 2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162 }; byte[] counts = { 10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; int item = ServerManager.RandomNumber(0, 42); session.Character.GiftAdd(vnums[item], counts[item]); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else if (session.HasCurrentMapInstance && session.CurrentMapInstance.MapInstanceType == MapInstanceType.BaseMapInstance && (session.Character.LastVessel.AddSeconds(1) <= DateTime.Now || session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.FastVessels))) { short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 }; short vnum = vnums[ServerManager.RandomNumber(0, 20)]; NpcMonster npcmonster = ServerManager.GetNpc(vnum); if (npcmonster == null) { return; } MapMonster monster = new MapMonster { MonsterVNum = vnum, MapY = session.Character.MapY, MapX = session.Character.MapX, MapId = session.Character.MapInstance.Map.MapId, Position = session.Character.Direction, IsMoving = true, MapMonsterId = session.CurrentMapInstance.GetNextMonsterId(), ShouldRespawn = false }; monster.Initialize(session.CurrentMapInstance); session.CurrentMapInstance.AddMonster(monster); session.CurrentMapInstance.Broadcast(monster.GenerateIn()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.Character.LastVessel = DateTime.Now; } break; // Golden Bazaar Medal case 1003: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalGold }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Silver Bazaar Medal case 1004: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalSilver }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Pet Slot Expansion case 1006: if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}"); } else if (session.Character.MaxMateCount < 30) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10)); session.SendPacket(session.Character.GenerateScpStc()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Pet Basket case 1007: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBasket }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket("ib 1278 1"); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Partner's Backpack case 1008: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBackPack }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Backpack Expansion case 1009: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BackPack }); session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; // Sealed Tarot Card case 1005: session.Character.GiftAdd((short)(VNum - Effect), 1); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; // Tarot Card Game case 1894: if (EffectValue == 0) { for (int i = 0; i < 5; i++) { session.Character.GiftAdd((short)(Effect + ServerManager.RandomNumber(0, 10)), 1); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Sealed Tarot Card case 2152: session.Character.GiftAdd((short)(VNum + Effect), 1); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; default: switch (VNum) { case 5841: int rnd = ServerManager.RandomNumber(0, 1000); short[] vnums = null; if (rnd < 900) { vnums = new short[] { 4356, 4357, 4358, 4359 }; } else { vnums = new short[] { 4360, 4361, 4362, 4363 }; } session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 4)], 1); session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue)); break; } break; } }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character)); switch (Effect) { // sp point potions case 150: case 151: session.Character.SpAdditionPoint += EffectValue; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0)); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; case 204: session.Character.SpPoint += EffectValue; session.Character.SpAdditionPoint += EffectValue * 3; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0)); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); break; case 301: if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId)) { //TODO you are in group return; } ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main); session.Character.Inventory.RemoveItemAmountFromInventory(1, raidSeal.Id); ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequieredItems.Any(obj => obj.VNum == raidSeal.ItemVNum)).GetClone(); if (raid != null) { Group group = new Group(GroupType.Team); group.Raid = raid; group.JoinGroup(session.Character.CharacterId); ServerManager.Instance.AddGroup(group); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 0)); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 10)); if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10)); } session.SendPacket(session.Character.GenerateRaid(2, false)); session.SendPacket(session.Character.GenerateRaid(0, false)); session.SendPacket(session.Character.GenerateRaid(1, false)); session.SendPacket(group.GenerateRdlst()); } break; case 305: Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == int.Parse(packetsplit[3])); if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0) { mate.Skin = Morph; session.SendPacket(mate.GenerateCMode(mate.Skin)); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } break; //Atk/Def/HP/Exp potions case 6600: session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; case 208: session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.Character.AddStaticBuff(new StaticBuffDTO() { CardId = 121 }); break; // Divorce letter case 6969: // this is imaginary number I = √(-1) break; // Cupid's arrow case 34: // this is imaginary number I = √(-1) break; case 570: if (session.Character.Faction == EffectValue) { return; } session.SendPacket(session.Character.Family == null ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}" : UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"), 0)); break; // wings case 650: SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear); if (session.Character.UseSp && specialistInstance != null) { if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}"); } else { specialistInstance.Design = (byte)EffectValue; session.Character.MorphUpgrade2 = EffectValue; session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateStat()); session.SendPacket(session.Character.GenerateStatChar()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket( UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0)); } break; // presentation messages case 203: if (!session.Character.IsVehicled) { if (Option == 0) { session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(10, 2, session.Character.CharacterId, 1)); } } break; // magic lamps case 651: if (session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear)) { if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}"); } else { session.Character.ChangeSex(); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; // vehicles case 1000: if (Morph > 0) { if (Option == 0 && !session.Character.IsVehicled) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest()); } session.Character.LastDelay = DateTime.Now; session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2")); } else { if (!session.Character.IsVehicled && Option != 0) { DateTime delay = DateTime.Now.AddSeconds(-4); if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2)) { session.Character.Speed = Speed; session.Character.IsVehicled = true; session.Character.VehicleSpeed = Speed; session.Character.MorphUpgrade = 0; session.Character.MorphUpgrade2 = 0; session.Character.Morph = Morph + (byte)session.Character.Gender; session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY); session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateCond()); session.Character.LastSpeedChange = DateTime.Now; } } else if (session.Character.IsVehicled) { session.Character.RemoveVehicle(); } } } break; case 1002: if (EffectValue == 69) { int rnd = ServerManager.Instance.RandomNumber(0, 1000); if (rnd < 5) { short[] vnums = { 5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716 }; byte[] counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; int item = ServerManager.Instance.RandomNumber(0, 17); session.Character.GiftAdd(vnums[item], counts[item]); } else if (rnd < 30) { short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 }; session.Character.GiftAdd(vnums[ServerManager.Instance.RandomNumber(0, 9)], 1); } else { short[] vnums = { 1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303, 2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162 }; byte[] counts = { 10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; int item = ServerManager.Instance.RandomNumber(0, 42); session.Character.GiftAdd(vnums[item], counts[item]); } session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } else { if (session.HasCurrentMapInstance) { if (session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4)) { short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 }; short vnum = vnums[ServerManager.Instance.RandomNumber(0, 20)]; NpcMonster npcmonster = ServerManager.Instance.GetNpc(vnum); if (npcmonster == null) { return; } MapMonster monster = new MapMonster { MonsterVNum = vnum, MapY = session.Character.MapY, MapX = session.Character.MapX, MapId = session.Character.MapInstance.Map.MapId, Position = (byte)session.Character.Direction, IsMoving = true, MapMonsterId = session.CurrentMapInstance.GetNextMonsterId(), ShouldRespawn = false }; monster.Initialize(session.CurrentMapInstance); session.CurrentMapInstance.AddMonster(monster); session.CurrentMapInstance.Broadcast(monster.GenerateIn()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } } break; case 69: session.Character.Reput += ReputPrice; session.SendPacket(session.Character.GenerateFd()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; case 1003: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalGold }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1004: if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalSilver }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1005: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BackPack }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1006: if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}"); } else { if (session.Character.MaxMateCount < 30) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10)); session.SendPacket(session.Character.GenerateScpStc()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } break; case 1007: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBasket }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket("ib 1278 1"); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; case 1008: if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack)) { session.Character.StaticBonusList.Add(new StaticBonusDTO { CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.PetBackPack }); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); session.SendPacket(session.Character.GenerateExts()); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12)); } break; default: Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType())); break; } }
public void ApplyBCards(object session, object sender = null, short buffLevel = 0) { Type type = session.GetType(); // int counterBuff = 0; switch ((BCardType.CardType)Type) { case BCardType.CardType.Buff: { if (type == typeof(Character) && session is Character character) { Buff buff = null; if (sender != null) { Type sType = sender.GetType(); if (sType == typeof(Character) && sender is Character sendingCharacter) { buff = new Buff((short)((short)SecondData + buffLevel), sendingCharacter.Level); //Todo: Get anti stats from BCard } } else { buff = new Buff((short)((short)SecondData + buffLevel), character.Level); } int anti = 0; if (buff?.Card.BuffType == BuffType.Bad) { anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedAllNegativeEffect)?.Value ?? 0; switch (SecondData) { case 1: anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType .ReducedBleedingAndMinorBleeding) ?.Value ?? 0; anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedAllBleedingType) ?.Value ?? 0; break; case 7: anti += character.ShellEffectArmor ?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedStun)?.Value ?? 0; anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedAllStun)?.Value ?? 0; break; case 21: anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedMinorBleeding)?.Value ?? 0; anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType .ReducedBleedingAndMinorBleeding) ?.Value ?? 0; anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedAllBleedingType) ?.Value ?? 0; break; case 27: anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedFreeze)?.Value ?? 0; break; case 42: anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedAllBleedingType) ?.Value ?? 0; break; case 66: anti += character.ShellEffectArmor?.FirstOrDefault(s => s.Effect == (byte)ShellArmorEffectType.ReducedAllStun)?.Value ?? 0; break; } } if (ServerManager.RandomNumber() < FirstData / 100D * (100 - anti)) { character.AddBuff(buff); } } else if (type == typeof(MapMonster)) { if (ServerManager.RandomNumber() < FirstData && session is MapMonster mapMonster) { mapMonster.AddBuff(new Buff((short)((short)SecondData + buffLevel), mapMonster.Monster.Level)); } } else if (type == typeof(MapNpc)) { } else if (type == typeof(Mate)) { } } break; case BCardType.CardType.Move: { if (type == typeof(Character) && session is Character character) { character.LastSpeedChange = DateTime.UtcNow; character.Session.SendPacket(character.GenerateCond()); } } break; case BCardType.CardType.Summons: { if (type == typeof(Character)) { // jajamaru spawn if (session is Character character && character.MapInstance != null) { List <MonsterToSummon> summonParameters = new List <MonsterToSummon>(); for (int i = 0; i < FirstData; i++) { short x, y; byte t = 0; do { x = (short)(ServerManager.RandomNumber(-3, 3) + character.PositionX); y = (short)(ServerManager.RandomNumber(-3, 3) + character.PositionY); t++; } while (!character.MapInstance.Map.IsBlockedZone(x, y) && t < byte.MaxValue); summonParameters.Add(new MonsterToSummon((short)SecondData, new MapCell { X = x, Y = y }, -1, true)); } if (ServerManager.RandomNumber() <= Math.Abs(ThirdData) || ThirdData == 0) { switch (SubType) { case 2: EventHelper.Instance.RunEvent(new EventContainer( character.Session.CurrentMapInstance, EventActionType.SpawnMonsters, summonParameters)); break; } } } } else if (type == typeof(MapMonster)) { if (session is MapMonster mapMonster && mapMonster.MapInstance != null) { List <MonsterToSummon> summonParameters = new List <MonsterToSummon>(); for (int i = 0; i < FirstData; i++) { short x, y; byte t = 0; do { x = (short)(ServerManager.RandomNumber(-3, 3) + mapMonster.MapX); y = (short)(ServerManager.RandomNumber(-3, 3) + mapMonster.MapY); t++; } while (!mapMonster.MapInstance.Map.IsBlockedZone(x, y) && t < byte.MaxValue); summonParameters.Add(new MonsterToSummon((short)SecondData, new MapCell { X = x, Y = y }, -1, true)); } if (ServerManager.RandomNumber() <= Math.Abs(ThirdData) || ThirdData == 0) { switch (SubType) { case 2: EventHelper.Instance.RunEvent(new EventContainer(mapMonster.MapInstance, EventActionType.SpawnMonsters, summonParameters)); break; default: if (mapMonster.OnDeathEvents.All(s => s.EventActionType != EventActionType.SpawnMonsters)) { mapMonster.OnDeathEvents.Add(new EventContainer(mapMonster.MapInstance, EventActionType.SpawnMonsters, summonParameters)); } break; } } } } else if (type == typeof(MapNpc)) { } else if (type == typeof(Mate)) { } } break; case BCardType.CardType.SpecialAttack: break; case BCardType.CardType.SpecialDefence: break; case BCardType.CardType.AttackPower: break; case BCardType.CardType.Target: break; case BCardType.CardType.Critical: break; case BCardType.CardType.SpecialCritical: break; case BCardType.CardType.Element: break; case BCardType.CardType.IncreaseDamage: break; case BCardType.CardType.Defence: break; case BCardType.CardType.DodgeAndDefencePercent: break; case BCardType.CardType.Block: break; case BCardType.CardType.Absorption: break; case BCardType.CardType.ElementResistance: break; case BCardType.CardType.EnemyElementResistance: break; case BCardType.CardType.Damage: break; case BCardType.CardType.GuarantedDodgeRangedAttack: break; case BCardType.CardType.Morale: break; case BCardType.CardType.Casting: break; case BCardType.CardType.Reflection: break; case BCardType.CardType.DrainAndSteal: break; case BCardType.CardType.HealingBurningAndCasting: { if (type == typeof(Character)) { if (session is Character character && character.Hp > 0) { int bonus; if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreHP / 10) { if (IsLevelScaled) { bonus = character.Level * FirstData; } else { bonus = FirstData; } if (character.Hp + bonus <= character.HPLoad()) { character.Hp += bonus; } else { bonus = (int)character.HPLoad() - character.Hp; character.Hp = (int)character.HPLoad(); } character.Session.CurrentMapInstance?.Broadcast(character.Session, character.GenerateRc(bonus)); } if (SubType == (byte)AdditionalTypes.HealingBurningAndCasting.RestoreMP / 10) { if (IsLevelScaled) { bonus = character.Level * FirstData; } else { bonus = FirstData; } if (character.Mp + bonus <= character.MPLoad()) { character.Mp += bonus; } else { character.Mp = (int)character.MPLoad(); } } character.Session.SendPacket(character.GenerateStat()); } } else if (type == typeof(MapMonster)) { if (ServerManager.RandomNumber() < FirstData && session is MapMonster mapMonster) { mapMonster.AddBuff(new Buff((short)SecondData, mapMonster.Monster.Level)); } } else if (type == typeof(MapNpc)) { } else if (type == typeof(Mate)) { } } break; case BCardType.CardType.Hpmp: if (type == typeof(Character)) { if (session is Character c) { switch (SubType) { case (byte)AdditionalTypes.Hpmp.RestoreDecreasedMP / 10: { int bonus = (int)(FirstData * c.MPLoad() / 100); c.Mp = c.Mp + bonus > 1 ? c.Mp + bonus : c.Mp = 1; } break; } } } break; case BCardType.CardType.SpecialisationBuffResistance: { switch (SubType) { case (byte)AdditionalTypes.SpecialisationBuffResistance.RemoveBadEffects / 10: { if (session is Character c && /*&& sender is ClientSession senderSession*/ ServerManager.RandomNumber() < Math.Abs(FirstData)) { c.DisableBuffs(FirstData > 0 ? BuffType.Good : BuffType.Bad, SecondData); } } break; } } break; case BCardType.CardType.SpecialEffects: break; case BCardType.CardType.Capture: { if (type == typeof(MapMonster) && session is MapMonster mapMonster && sender is ClientSession senderSession) { NpcMonster mateNpc = ServerManager.GetNpcMonster(mapMonster.MonsterVNum); if (mateNpc != null) { if (mapMonster.Monster.Catch) { if (mapMonster.IsAlive && mapMonster.CurrentHp <= (int)((double)mapMonster.MaxHp / 2)) { if (mapMonster.Monster.Level < senderSession.Character.Level) { // TODO: find a new algorithm int[] chance = { 100, 80, 60, 40, 20, 0 }; if (ServerManager.RandomNumber() < chance[ServerManager.RandomNumber(0, 5)]) { Mate mate = new Mate(senderSession.Character, mateNpc, (byte)(mapMonster.Monster.Level - 15 > 0 ? mapMonster.Monster.Level - 15 : 1), MateType.Pet); if (senderSession.Character.CanAddMate(mate)) { senderSession.Character.AddPetWithSkill(mate); senderSession.SendPacket( UserInterfaceHelper.GenerateMsg( Language.Instance.GetMessageFromKey("CATCH_SUCCESS"), 0)); senderSession.CurrentMapInstance?.Broadcast( StaticPacketHelper.GenerateEff(UserType.Player, senderSession.Character.CharacterId, 197)); senderSession.CurrentMapInstance?.Broadcast( StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)(mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100 ), 0, -1, 0)); mapMonster.SetDeathStatement(); senderSession.CurrentMapInstance?.Broadcast( StaticPacketHelper.Out(UserType.Monster, mapMonster.MapMonsterId)); } else { senderSession.SendPacket( senderSession.Character.GenerateSay( Language.Instance.GetMessageFromKey("PET_SLOT_FULL"), 10)); senderSession.SendPacket( StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } else { senderSession.SendPacket( UserInterfaceHelper.GenerateMsg( Language.Instance.GetMessageFromKey("CATCH_FAIL"), 0)); senderSession.CurrentMapInstance?.Broadcast( StaticPacketHelper.SkillUsed(UserType.Player, senderSession.Character.CharacterId, 3, mapMonster.MapMonsterId, -1, 0, 15, -1, -1, -1, true, (int)(mapMonster.CurrentHp / (float)mapMonster.MaxHp * 100), 0, -1, 0)); } } else { senderSession.SendPacket(UserInterfaceHelper.GenerateMsg( Language.Instance.GetMessageFromKey("LEVEL_LOWER_THAN_MONSTER"), 0)); senderSession.SendPacket( StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } else { senderSession.SendPacket(UserInterfaceHelper.GenerateMsg( Language.Instance.GetMessageFromKey("CURRENT_HP_TOO_HIGH"), 0)); senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } else { senderSession.SendPacket(UserInterfaceHelper.GenerateMsg( Language.Instance.GetMessageFromKey("MONSTER_CANT_BE_CAPTURED"), 0)); senderSession.SendPacket(StaticPacketHelper.Cancel(2, mapMonster.MapMonsterId)); } } } } break; case BCardType.CardType.SpecialDamageAndExplosions: break; case BCardType.CardType.SpecialEffects2: if (type == typeof(Character)) { if (session is Character c) { short destinationX = c.PositionX; short destinationY = c.PositionY; switch (SubType) { case (byte)AdditionalTypes.SpecialEffects2.TeleportInRadius / 10: { switch (c.Direction) { case 0: // -y destinationY -= (short)FirstData; break; case 1: // +x destinationX += (short)FirstData; break; case 2: // +y destinationY += (short)FirstData; break; case 3: // -x destinationX -= (short)FirstData; break; case 4: // -x -y destinationX -= (short)FirstData; destinationY -= (short)FirstData; break; case 5: // +x +y destinationX += (short)FirstData; destinationY += (short)FirstData; break; case 6: // +x -y destinationX += (short)FirstData; destinationY -= (short)FirstData; break; case 7: // -x +y destinationX -= (short)FirstData; destinationY += (short)FirstData; break; } ServerManager.Instance.TeleportForward(c.Session, c.MapInstanceId, destinationX, destinationY); } break; } } } break; case BCardType.CardType.CalculatingLevel: break; case BCardType.CardType.Recovery: break; case BCardType.CardType.MaxHpmp: break; case BCardType.CardType.MultAttack: break; case BCardType.CardType.MultDefence: break; case BCardType.CardType.TimeCircleSkills: break; case BCardType.CardType.RecoveryAndDamagePercent: break; case BCardType.CardType.Count: break; case BCardType.CardType.NoDefeatAndNoDamage: break; case BCardType.CardType.SpecialActions: { switch (SubType) { case (byte)AdditionalTypes.SpecialActions.RunAway / 10: if (session is MapMonster m) { m.MapInstance.Broadcast(StaticPacketHelper.Say(UserType.Monster, m.MapMonsterId, 0, "!!!")); m.RemoveTarget(); for (int i = 0; i < 10; i++) { Observable.Timer(TimeSpan.FromSeconds(i)).Subscribe(o => { m.MapX++; m.MapY++; m.IgnoreTargetsUntil = DateTime.UtcNow.AddSeconds(10); m.RemoveTarget(); }); } } break; } } break; case BCardType.CardType.Mode: break; case BCardType.CardType.NoCharacteristicValue: break; case BCardType.CardType.LightAndShadow: { switch (SubType) { case (byte)AdditionalTypes.LightAndShadow.RemoveBadEffects / 10: { if (session is Character c /*&& sender is ClientSession senderSession*/) { c.DisableBuffs(BuffType.Bad, FirstData); } } break; } } break; case BCardType.CardType.Item: break; case BCardType.CardType.DebuffResistance: break; case BCardType.CardType.SpecialBehaviour: break; case BCardType.CardType.Quest: break; case BCardType.CardType.SecondSpCard: break; case BCardType.CardType.SpCardUpgrade: break; case BCardType.CardType.HugeSnowman: break; case BCardType.CardType.Drain: break; case BCardType.CardType.BossMonstersSkill: break; case BCardType.CardType.LordHatus: break; case BCardType.CardType.LordCalvinas: break; case BCardType.CardType.SeSpecialist: break; case BCardType.CardType.FourthGlacernonFamilyRaid: break; case BCardType.CardType.SummonedMonsterAttack: break; case BCardType.CardType.BearSpirit: break; case BCardType.CardType.SummonSkill: break; case BCardType.CardType.InflictSkill: break; case BCardType.CardType.HideBarrelSkill: break; case BCardType.CardType.FocusEnemyAttentionSkill: break; case BCardType.CardType.TauntSkill: break; case BCardType.CardType.FireCannoneerRangeBuff: break; case BCardType.CardType.VulcanoElementBuff: break; case BCardType.CardType.DamageConvertingSkill: break; case BCardType.CardType.MeditationSkill: { if (type == typeof(Character) && session is Character character) { if (SkillVNum.HasValue && SubType.Equals((byte)AdditionalTypes.MeditationSkill.CausingChance / 10) && ServerManager.RandomNumber() < FirstData) { Skill skill = ServerManager.GetSkill(SkillVNum.Value); Skill newSkill = ServerManager.GetSkill((short)SecondData); Observable.Timer(TimeSpan.FromMilliseconds(100)).Subscribe(observer => { foreach (QuicklistEntryDTO quicklistEntry in character.QuicklistEntries.Where(s => s.Morph == character.Morph && s.Pos.Equals(skill.CastId))) { character.Session.SendPacket( $"qset {quicklistEntry.Q1} {quicklistEntry.Q2} {quicklistEntry.Type}.{quicklistEntry.Slot}.{newSkill.CastId}.0"); } character.Session.SendPacket($"mslot {newSkill.CastId} -1"); }); character.SkillComboCount++; character.LastSkillComboUse = DateTime.UtcNow; if (skill.CastId > 10) { // HACK this way Observable.Timer(TimeSpan.FromMilliseconds((skill.Cooldown * 100) + 500)) .Subscribe(observer => character.Session.SendPacket(StaticPacketHelper.SkillReset(skill.CastId))); } } switch (SubType) { case 2: character.MeditationDictionary[(short)SecondData] = DateTime.UtcNow.AddSeconds(4); break; case 3: character.MeditationDictionary[(short)SecondData] = DateTime.UtcNow.AddSeconds(8); break; case 4: character.MeditationDictionary[(short)SecondData] = DateTime.UtcNow.AddSeconds(12); break; } } } break; case BCardType.CardType.FalconSkill: { if (session is Character c) { switch (SubType) { case (byte)AdditionalTypes.FalconSkill.Hide: c.Invisible = true; c.Mates.Where(s => s.IsTeamMember).ToList().ForEach(s => c.Session.CurrentMapInstance?.Broadcast(s.GenerateOut())); c.Session.CurrentMapInstance?.Broadcast(c.GenerateInvisible()); c.Session.SendPacket(c.GenerateEq()); break; } } } break; case BCardType.CardType.AbsorptionAndPowerSkill: break; case BCardType.CardType.LeonaPassiveSkill: break; case BCardType.CardType.FearSkill: break; case BCardType.CardType.SniperAttack: break; case BCardType.CardType.FrozenDebuff: break; case BCardType.CardType.JumpBackPush: break; case BCardType.CardType.FairyXPIncrease: break; case BCardType.CardType.SummonAndRecoverHP: break; case BCardType.CardType.TeamArenaBuff: break; case BCardType.CardType.ArenaCamera: break; case BCardType.CardType.DarkCloneSummon: break; case BCardType.CardType.AbsorbedSpirit: break; case BCardType.CardType.AngerSkill: break; case BCardType.CardType.MeteoriteTeleport: if (type == typeof(Character)) { if (session is Character character) { switch (SubType) { case ((byte)AdditionalTypes.MeteoriteTeleport.TeleportYouAndGroupToSavedLocation / 10): if (character.TeleportSet == false) { character.TeleportX = character.PositionX; character.TeleportY = character.PositionY; character.TeleportMap = character.MapId; character.MapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, character.CharacterId, 4497)); character.TeleportSet = true; Observable.Timer(TimeSpan.FromSeconds(40)).Subscribe(o => character.TeleportSet = false); } else { if (character.MapInstance.IsPvp) { if (character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance) { character.TeleportSet = false; return; } character.MapInstance.Broadcast($"tp 1 {character.CharacterId} {character.TeleportX} {character.TeleportY} 0"); character.PositionX = character.TeleportX; character.PositionY = character.TeleportY; character.TeleportSet = false; } else { if (character.MapId == character.TeleportMap) { if (character.MapInstance.MapInstanceType == MapInstanceType.CaligorInstance) { character.TeleportSet = false; return; } character.MapInstance.Broadcast($"tp 1 {character.CharacterId} {character.TeleportX} {character.TeleportY} 0"); character.PositionX = character.TeleportX; character.PositionY = character.TeleportY; character.TeleportSet = false; } else { character.TeleportSet = false; } } } break; case (byte)AdditionalTypes.MeteoriteTeleport.CauseMeteoriteFall / 10: { int amount = 10 + (character.Level / FirstData); for (int i = 0; i < amount; i++) { Observable.Timer(TimeSpan.FromMilliseconds(i * 500)).Subscribe(o => character.SpawnMeteorite()); } } break; } } } break; case BCardType.CardType.StealBuff: break; case BCardType.CardType.Unknown: break; case BCardType.CardType.EffectSummon: break; default: Logger.Warn($"Card Type {Type} not defined!"); 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 || EquipmentSlot == EquipmentType.Wings)) { 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 (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 { 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); 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) { 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.Where(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; } }