public void Sync(ClientSession session, Item item) { for (session.Character.MaxSnack = 0; session.Character.MaxSnack < 5; session.Character.MaxSnack++) { if (session.Character.Hp <= 0) { return; } session.Character.Hp += session.Character.SnackHp; session.Character.Mp += session.Character.SnackMp; if (session.Character.Mp > session.Character.MPLoad()) { session.Character.Mp = (int)session.Character.MPLoad(); } if (session.Character.Hp > session.Character.HPLoad()) { session.Character.Hp = (int)session.Character.HPLoad(); } if (session.Character.Hp < session.Character.HPLoad() || session.Character.Mp < session.Character.MPLoad()) { session.CurrentMap?.Broadcast(session, session.Character.GenerateRc(session.Character.SnackHp), ReceiverType.All); } if (session.IsConnected) { session.SendPacket(session.Character.GenerateStat()); } else { return; } Thread.Sleep(1800); } }
public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null) { if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750) { return; } else { session.Character.LastPotion = DateTime.Now; } switch (Effect) { default: if (session.Character.Hp == session.Character.HPLoad() && session.Character.Mp == session.Character.MPLoad()) { return; } if (session.Character.Hp <= 0) { return; } session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); if ((int)session.Character.HPLoad() - session.Character.Hp < Hp) { session.CurrentMap?.Broadcast(session.Character.GenerateRc((int)session.Character.HPLoad() - session.Character.Hp)); } else if ((int)session.Character.HPLoad() - session.Character.Hp > Hp) { session.CurrentMap?.Broadcast(session.Character.GenerateRc(Hp)); } session.Character.Mp += Mp; session.Character.Hp += Hp; if (session.Character.Mp > session.Character.MPLoad()) { session.Character.Mp = (int)session.Character.MPLoad(); } if (session.Character.Hp > session.Character.HPLoad()) { session.Character.Hp = (int)session.Character.HPLoad(); } if (inv.ItemVNum == 1242 || inv.ItemVNum == 5582) { session.CurrentMap?.Broadcast(session.Character.GenerateRc((int)session.Character.HPLoad() - session.Character.Hp)); session.Character.Hp = (int)session.Character.HPLoad(); } else if (inv.ItemVNum == 1243 || inv.ItemVNum == 5583) { session.Character.Mp = (int)session.Character.MPLoad(); } else if (inv.ItemVNum == 1244 || inv.ItemVNum == 5584) { session.CurrentMap?.Broadcast(session.Character.GenerateRc((int)session.Character.HPLoad() - session.Character.Hp)); session.Character.Hp = (int)session.Character.HPLoad(); session.Character.Mp = (int)session.Character.MPLoad(); } session.SendPacket(session.Character.GenerateStat()); break; } }
public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null) { if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750) { return; } else { session.Character.LastPotion = DateTime.Now; } Item item = inv.Item; switch (Effect) { default: if (session.Character.Hp <= 0) { return; } if (!session.Character.IsSitting) { session.Character.Rest(); session.Character.SnackAmount = 0; session.Character.SnackHp = 0; session.Character.SnackMp = 0; } int amount = session.Character.SnackAmount; if (amount < 5) { if (!session.Character.IsSitting) { return; } Thread workerThread = new Thread(() => Regenerate(session, item)); workerThread.Start(); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } else { if (session.Character.Gender == Domain.GenderType.Female) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1)); } else { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1)); } } if (amount == 0) { if (!session.Character.IsSitting) { return; } Thread workerThread2 = new Thread(() => Sync(session, item)); workerThread2.Start(); } break; } }
public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null) { switch (Effect) { default: Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString())); break; } }
public bool Broadcast(ClientSession client, String message, ReceiverType receiver, String CharacterName = "", long CharacterId = -1) { switch (receiver) { case ReceiverType.All: foreach (ClientSession session in sessions) { session.Client.SendPacket(message); } break; case ReceiverType.AllExceptMe: foreach (ClientSession session in sessions.Where(c => c != client)) { session.Client.SendPacket(message); } break; case ReceiverType.AllOnMap: foreach (ClientSession session in sessions.Where(s => s.Character != null && s.Character.MapId.Equals(client.Character.MapId))) { session.Client.SendPacket(message); } break; case ReceiverType.AllOnMapExceptMe: foreach (ClientSession session in sessions.Where(s => s.Character != null && s.Character.MapId.Equals(client.Character.MapId) && s.Character.CharacterId != client.Character.CharacterId)) { session.Client.SendPacket(message); } break; case ReceiverType.OnlyMe: client.Client.SendPacket(message); break; case ReceiverType.OnlySomeone: ClientSession session2 = sessions.FirstOrDefault(s => s.Character != null && s.Character.Name.Equals(CharacterName) || s.Character.CharacterId.Equals(CharacterId)); if (session2 != null) { session2.Client.SendPacket(message); return true; } return false; case ReceiverType.AllOnMapNoEmoBlocked: foreach (ClientSession session in sessions.Where(s => s.Character != null && s.Character.MapId.Equals(client.Character.MapId) && !s.Character.EmoticonsBlocked)) { session.Client.SendPacket(message); } break; } return true; }
public void Rarify(ClientSession session) { ItemInstance instance = GetItemInstance(); if (instance.Item.EquipmentSlot == EquipmentType.Armor || instance.Item.EquipmentSlot == EquipmentType.MainWeapon || instance.Item.EquipmentSlot == EquipmentType.SecondaryWeapon) { if (instance is WearableInstance) { ((WearableInstance)instance).RarifyItem(session, RarifyMode.Drop, RarifyProtection.None); } } }
public void Regenerate(ClientSession session, Item item, string[] packetsplit = null) { session.SendPacket(session.Character.GenerateEff(6000)); session.Character.SnackAmount++; session.Character.MaxSnack = 0; session.Character.SnackHp += item.Hp / 5; session.Character.SnackMp += item.Mp / 5; for (int i = 0; i < 5; i++) { Thread.Sleep(1800); } session.Character.SnackHp -= item.Hp / 5; session.Character.SnackMp -= item.Mp / 5; session.Character.SnackAmount--; }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { if (session.Character.IsVehicled) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10)); return; } if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.TalentArenaMapInstance) { return; } if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750) { return; } session.Character.LastPotion = DateTime.Now; Item item = inv.Item; switch (Effect) { default: if (session.Character.Hp <= 0) { return; } if (item.VNum == 2291 || item.VNum == 10035) { if (!session.Character.IsSitting) { session.Character.Rest(); } session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 6000)); session.Character.SpPoint += 1500; if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.SendPacket(session.Character.GenerateSpPoint()); return; } if (session.Character.FoodAmount < 0) { session.Character.FoodAmount = 0; } int amount = session.Character.FoodAmount; if (amount < 5) { if (item.BCards.Find(s => s.Type == (byte)BCardType.CardType.HPMP && s.SubType == (byte)AdditionalTypes.HPMP.ReceiveAdditionalHP / 10 && s.FirstData > 0) is BCard AdditionalHpBCard) { // MaxAdditionalHpPercent = AdditionalHp.SecondData; double AdditionalHp = 0; if (session.Character.BattleEntity.AdditionalHp + AdditionalHpBCard.FirstData <= session.Character.HPLoad() * 0.2) { AdditionalHp = AdditionalHpBCard.FirstData; } else if (session.Character.BattleEntity.AdditionalHp < session.Character.HPLoad() * 0.2) { AdditionalHp = session.Character.HPLoad() * 0.2 - session.Character.BattleEntity.AdditionalHp; } if (AdditionalHp > 0 && AdditionalHp <= AdditionalHpBCard.FirstData) { session.Character.FoodAmount++; session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 6000)); session.Character.BattleEntity.AdditionalHp += AdditionalHp; session.SendPacket(session.Character.GenerateAdditionalHpMp()); session.SendPacket(session.Character.GenerateStat()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); Observable.Timer(TimeSpan.FromMilliseconds(1800)).Subscribe(s => session.Character.FoodAmount--); } return; } if (item.BCards.Find(s => s.Type == (byte)BCardType.CardType.HPMP && s.SubType == (byte)AdditionalTypes.HPMP.ReceiveAdditionalMP / 10 && s.FirstData < 0) is BCard AdditionalMpBCard) { // MaxAdditionalMpPercent = AdditionalMp.SecondData; double AdditionalMp = 0; if (session.Character.BattleEntity.AdditionalMp + (-AdditionalMpBCard.FirstData) <= session.Character.MPLoad() * 0.2) { AdditionalMp = (-AdditionalMpBCard.FirstData); } else if (session.Character.BattleEntity.AdditionalMp < session.Character.MPLoad() * 0.2) { AdditionalMp = session.Character.MPLoad() * 0.2 - session.Character.BattleEntity.AdditionalMp; } if (AdditionalMp > 0 && AdditionalMp <= -AdditionalMpBCard.FirstData) { session.Character.FoodAmount++; session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 6000)); session.Character.BattleEntity.AdditionalMp += AdditionalMp; session.SendPacket(session.Character.GenerateAdditionalHpMp()); session.SendPacket(session.Character.GenerateStat()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); Observable.Timer(TimeSpan.FromMilliseconds(1800)).Subscribe(s => session.Character.FoodAmount--); } return; } } if (!session.Character.IsSitting) { session.Character.Rest(); } session.Character.Mates.Where(s => s.IsTeamMember).ToList().ForEach(m => session.CurrentMapInstance?.Broadcast(m.GenerateRest(true))); if (amount < 5) { if (!session.Character.IsSitting) { return; } Thread workerThread = new Thread(() => Regenerate(session, item)); workerThread.Start(); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(session.Character.Gender == GenderType.Female ? session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1) : session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1)); } if (amount == 0) { if (!session.Character.IsSitting) { return; } Thread workerThread2 = new Thread(() => Sync(session)); workerThread2.Start(); } break; } }
public CharacterScreenPacketHandler(ClientSession session) { _session = session; }
public CommandPacketHandler(ClientSession session) { _session = session; }
public void UpgradeItem(ClientSession session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false) { if (!session.HasCurrentMapInstance) { return; } if (Upgrade < 10) { short[] upfail; short[] upfix; int[] goldprice; short[] cella; short[] gem; if (Rare >= 8) { upfix = new short[] { 50, 40, 70, 65, 80, 90, 95, 97, 98, 99 }; upfail = new short[] { 50, 40, 60, 50, 60, 70, 75, 77, 83, 89 }; goldprice = new[] { 5000, 15000, 30000, 100000, 300000, 800000, 1500000, 4000000, 7000000, 10000000 }; cella = new short[] { 40, 100, 160, 240, 320, 440, 560, 760, 960, 1200 }; gem = new short[] { 2, 2, 4, 4, 6, 2, 2, 4, 4, 6 }; } else { upfix = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 14 }; upfail = new short[] { 0, 0, 0, 5, 20, 40, 60, 70, 80, 85 }; goldprice = new[] { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 }; cella = new short[] { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 }; gem = new short[] { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 }; } const short cellaVnum = 1014; const short gemVnum = 1015; const short gemFullVnum = 1016; const double reducedpricefactor = 0.5; const short normalScrollVnum = 1218; const short goldScrollVnum = 5369; if (IsFixed) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10)); session.SendPacket("shop_end 1"); return; } switch (mode) { case UpgradeMode.Free: break; case UpgradeMode.Reduced: // TODO: Reduced Item Amount if (session.Character.Gold < (long)(goldprice[Upgrade] * reducedpricefactor)) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); return; } if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade] * reducedpricefactor) { session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(cellaVnum).Name, cella[Upgrade] * reducedpricefactor), 10)); return; } if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(goldScrollVnum) < 1) { session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(goldScrollVnum).Name, cella[Upgrade] * reducedpricefactor), 10)); return; } if (Upgrade < 5) { if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade]) { session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemVnum).Name, gem[Upgrade]), 10)); return; } session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]); } else { if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade]) { session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemFullVnum).Name, gem[Upgrade]), 10)); return; } session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]); } if (protection == UpgradeProtection.Protected && !isCommand) { session.Character.Inventory.RemoveItemAmount(goldScrollVnum); session.SendPacket("shop_end 2"); } session.Character.Gold -= (long)(goldprice[Upgrade] * reducedpricefactor); session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella[Upgrade] * reducedpricefactor)); session.SendPacket(session.Character.GenerateGold()); break; case UpgradeMode.Normal: // TODO: Normal Item Amount if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade]) { return; } if (session.Character.Gold < goldprice[Upgrade]) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); return; } if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(normalScrollVnum) < 1) { session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(normalScrollVnum).Name, 1), 10)); return; } if (Upgrade < 5) { if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade]) { session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemVnum).Name, gem[Upgrade]), 10)); return; } session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]); } else { if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade]) { session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemFullVnum).Name, gem[Upgrade]), 10)); return; } session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]); } if (protection == UpgradeProtection.Protected && !isCommand) { session.Character.Inventory.RemoveItemAmount(normalScrollVnum); session.SendPacket("shop_end 2"); } session.Character.Inventory.RemoveItemAmount(cellaVnum, cella[Upgrade]); session.Character.Gold -= goldprice[Upgrade]; session.SendPacket(session.Character.GenerateGold()); break; } WearableInstance wearable = session.Character.Inventory.LoadByItemInstance <WearableInstance>(Id); ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id); int rnd = ServerManager.Instance.RandomNumber(); if (Rare == 8) { if (rnd < upfail[Upgrade]) { if (protection == UpgradeProtection.None) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0)); session.Character.DeleteItemByItemInstanceId(Id); } else { session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0)); } } else if (rnd < upfix[Upgrade]) { session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY); wearable.IsFixed = true; session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0)); } else { session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0)); wearable.Upgrade++; if (wearable.Upgrade > 4) { session.Character.Family?.InsertFamilyLog(FamilyLogType.ItemUpgraded, session.Character.Name, itemVNum: wearable.ItemVNum, upgrade: wearable.Upgrade); } session.SendPacket(wearable.GenerateInventoryAdd()); } } else { if (rnd < upfix[Upgrade]) { session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY); wearable.IsFixed = true; session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0)); } else if (rnd < upfail[Upgrade] + upfix[Upgrade]) { if (protection == UpgradeProtection.None) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0)); session.Character.DeleteItemByItemInstanceId(Id); } else { session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0)); } } else { session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0)); wearable.Upgrade++; if (wearable.Upgrade > 4) { session.Character.Family?.InsertFamilyLog(FamilyLogType.ItemUpgraded, session.Character.Name, itemVNum: wearable.ItemVNum, upgrade: wearable.Upgrade); } session.SendPacket(wearable.GenerateInventoryAdd()); } } session.SendPacket("shop_end 1"); } }
public void RequiereBroadcastFromUser(ClientSession client, string CharacterName, string methodName) { ClientSession session = sessions.FirstOrDefault(s => s.Character != null && s.Character.Name.Equals(CharacterName)); if (session != null) { Type t = session.Character.GetType(); MethodInfo method = t.GetMethod(methodName); string result = (string)method.Invoke(session.Character, null); client.Client.SendPacket(result); } }
public BattlePacketHandler(ClientSession session) { _session = session; }
public bool IsMemberOfGroup(ClientSession session) => Characters?.Any(s => s?.Character?.CharacterId == session.Character.CharacterId) == true;
public MapItem PutItem(InventoryType type, short slot, byte amount, ref ItemInstance inv, ClientSession session) { Logger.Debug($"type: {type} slot: {slot} amount: {amount}", session.SessionId); Guid random2 = Guid.NewGuid(); MapItem droppedItem = null; List<GridPos> Possibilities = new List<GridPos>(); for (short x = -2; x < 3; x++) { for (short y = -2; y < 3; y++) { Possibilities.Add(new GridPos() { x = x, y = y }); } } short mapX = 0; short mapY = 0; bool niceSpot = false; foreach (GridPos possibilitie in Possibilities.OrderBy(s => _random.Next())) { mapX = (short)(session.Character.MapX + possibilitie.x); mapY = (short)(session.Character.MapY + possibilitie.y); if (!IsBlockedZone(mapX, mapY)) { niceSpot = true; break; } } if (niceSpot) { if (amount > 0 && amount <= inv.Amount) { ItemInstance newItemInstance = inv.DeepCopy(); newItemInstance.Id = random2; newItemInstance.Amount = amount; droppedItem = new CharacterMapItem(mapX, mapY, newItemInstance); DroppedList[droppedItem.TransportId] = droppedItem; inv.Amount -= amount; } } return droppedItem; }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { if (Effect == 0) { if (EffectValue != 0) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.SendPacket(session.Character.GenerateRest()); } session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(12, 1, session.Character.CharacterId, EffectValue)); } else if (EffectValue == 0) { if (packetsplit == null || packetsplit.Length <= 9) { return; } if (!byte.TryParse(packetsplit[8], out byte TypeEquip) || !short.TryParse(packetsplit[9], out short SlotEquip)) { return; } if (session.Character.IsSitting) { session.Character.IsSitting = false; session.SendPacket(session.Character.GenerateRest()); } if (Option != 0) { bool isUsed = false; switch (inv.ItemVNum) { case 1219: WearableInstance equip = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(SlotEquip, (InventoryType)TypeEquip); if (equip != null && equip.IsFixed) { equip.IsFixed = false; session.SendPacket(session.Character.GenerateEff(3003)); session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(17, 1, session.Character.CharacterId, SlotEquip)); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_UNFIXED"), 12)); isUsed = true; } break; case 1365: case 9039: SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(SlotEquip, (InventoryType)TypeEquip); if (specialist != null && specialist.Rare == -2) { specialist.Rare = 0; session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SP_RESURRECTED"), 0)); session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(13, 1, session.Character.CharacterId, 1)); session.Character.SpPoint = 10000; if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.SendPacket(session.Character.GenerateSpPoint()); session.SendPacket(specialist.GenerateInventoryAdd()); isUsed = true; } break; } if (!isUsed) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_NOT_FIXED"), 11)); } else { session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^0^1^{TypeEquip}^{SlotEquip} {Language.Instance.GetMessageFromKey("QNA_ITEM")}"); } } } else { Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType())); } }
public string GeneraterRaidmbf(ClientSession session) => $"raidmbf {session?.CurrentMapInstance?.InstanceBag?.MonsterLocker.Initial} {session?.CurrentMapInstance?.InstanceBag?.MonsterLocker.Current} {session?.CurrentMapInstance?.InstanceBag?.ButtonLocker.Initial} {session?.CurrentMapInstance?.InstanceBag?.ButtonLocker.Current} {Raid?.InstanceBag?.Lives - Raid?.InstanceBag?.DeadList.Count} {Raid?.InstanceBag?.Lives} 25";
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { switch (Effect) { case 10: { switch (EffectValue) { case 1: if (session.Character.Inventory.CountItem(1036) < 1 || session.Character.Inventory.CountItem(1013) < 1) { return; } session.Character.Inventory.RemoveItemAmount(1036); session.Character.Inventory.RemoveItemAmount(1013); if (ServerManager.Instance.RandomNumber() < 25) { switch (ServerManager.Instance.RandomNumber(0, 2)) { case 0: session.Character.GiftAdd(1015, 1); break; case 1: session.Character.GiftAdd(1016, 1); break; } } break; case 2: if (session.Character.Inventory.CountItem(1038) < 1 || session.Character.Inventory.CountItem(1013) < 1) { return; } session.Character.Inventory.RemoveItemAmount(1038); session.Character.Inventory.RemoveItemAmount(1013); if (ServerManager.Instance.RandomNumber() < 25) { switch (ServerManager.Instance.RandomNumber(0, 4)) { case 0: session.Character.GiftAdd(1031, 1); break; case 1: session.Character.GiftAdd(1032, 1); break; case 2: session.Character.GiftAdd(1033, 1); break; case 3: session.Character.GiftAdd(1034, 1); break; } } break; case 3: if (session.Character.Inventory.CountItem(1037) < 1 || session.Character.Inventory.CountItem(1013) < 1) { return; } session.Character.Inventory.RemoveItemAmount(1037); session.Character.Inventory.RemoveItemAmount(1013); if (ServerManager.Instance.RandomNumber() < 25) { switch (ServerManager.Instance.RandomNumber(0, 17)) { case 0: case 1: case 2: case 3: case 4: session.Character.GiftAdd(1017, 1); break; case 5: case 6: case 7: case 8: session.Character.GiftAdd(1018, 1); break; case 9: case 10: case 11: session.Character.GiftAdd(1019, 1); break; case 12: case 13: session.Character.GiftAdd(1020, 1); break; case 14: session.Character.GiftAdd(1021, 1); break; case 15: session.Character.GiftAdd(1022, 1); break; case 16: session.Character.GiftAdd(1023, 1); break; } } break; } session.Character.GiftAdd(1014, (byte)ServerManager.Instance.RandomNumber(5, 11)); } break; default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType())); break; } }
public override void Use(ClientSession Session, ref ItemInstance inventory, bool DelayUsed = false, string[] packetsplit = null) { switch (Effect) { // wings case 650: SpecialistInstance specialistInstance = Session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear); if (Session.Character.UseSp && specialistInstance != null) { if (!DelayUsed) { Session.SendPacket($"qna #u_i^1^{Session.Character.CharacterId}^{(byte)inventory.Type}^{inventory.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}"); } else { specialistInstance.Design = (byte)EffectValue; Session.Character.MorphUpgrade2 = EffectValue; Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode()); Session.SendPacket(Session.Character.GenerateStat()); Session.SendPacket(Session.Character.GenerateStatChar()); inventory.Amount--; if (inventory.Amount > 0) { Session.SendPacket(Session.Character.GenerateInventoryAdd(inventory.ItemVNum, inventory.Amount, inventory.Type, inventory.Slot, 0, 0, 0, 0)); } else { Session.Character.Inventory.DeleteFromSlotAndType(inventory.Slot, inventory.Type); Session.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, inventory.Type, inventory.Slot, 0, 0, 0, 0)); } } } else { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0)); } break; // presentation messages case 203: if (this != null && !Session.Character.IsVehicled) { if (!DelayUsed) { Session.SendPacket(Session.Character.GenerateGuri(10, 2, 1)); } } break; // magic lamps case 651: if (!Session.Character.Inventory.GetAllItems().Where(i => i.Type == InventoryType.Wear).Any()) { if (!DelayUsed) { Session.SendPacket($"qna #u_i^1^{Session.Character.CharacterId}^{(byte)inventory.Type}^{inventory.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}"); } else { Session.Character.ChangeSex(); inventory.Amount--; if (inventory.Amount > 0) { Session.SendPacket(Session.Character.GenerateInventoryAdd(inventory.ItemVNum, inventory.Amount, inventory.Type, inventory.Slot, 0, 0, 0, 0)); } else { Session.Character.Inventory.DeleteFromSlotAndType(inventory.Slot, inventory.Type); Session.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, inventory.Type, inventory.Slot, 0, 0, 0, 0)); } } } else { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; // vehicles case 1000: if (!DelayUsed && !Session.Character.IsVehicled) { if (Session.Character.IsSitting) { Session.Character.IsSitting = false; Session.CurrentMap?.Broadcast(Session.Character.GenerateRest()); } Session.SendPacket(Session.Character.GenerateDelay(3000, 3, $"#u_i^1^{Session.Character.CharacterId}^{(byte)inventory.Type}^{inventory.Slot}^2")); } else { if (!Session.Character.IsVehicled) { 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.CurrentMap?.Broadcast(Session.Character.GenerateEff(196), Session.Character.MapX, Session.Character.MapY); Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode()); Session.SendPacket(Session.Character.GenerateCond()); } else { Session.Character.RemoveVehicle(); } } break; default: Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString())); break; } }
public void Broadcast(ClientSession client, PacketBase packet, ReceiverType receiver = ReceiverType.All, string characterName = "", long characterId = -1, int delay = 0) { Broadcast(client, PacketFactory.Deserialize(packet), receiver, characterName, characterId, delay); }
public void Broadcast(ClientSession client, string content, ReceiverType receiver = ReceiverType.All, string characterName = "", long characterId = -1) { try { SpreadBroadcastpacket(new BroadcastPacket(client, content, receiver, characterName, characterId)); } catch (Exception ex) { Logger.Error(ex); } }
private void NpcLife() { double time = (DateTime.UtcNow - LastEffect).TotalMilliseconds; if (time > EffectDelay) { if (IsMate || IsProtected) { MapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, MapNpcId, 825), MapX, MapY); } if (Effect > 0 && EffectActivated) { MapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, MapNpcId, Effect), MapX, MapY); } LastEffect = DateTime.UtcNow; } time = (DateTime.UtcNow - LastMove).TotalMilliseconds; if (IsMoving && Npc.Speed > 0 && time > _movetime) { _movetime = ServerManager.RandomNumber(400, 1600); byte point = (byte)ServerManager.RandomNumber(2, 4); byte fpoint = (byte)ServerManager.RandomNumber(0, 2); byte xpoint = (byte)ServerManager.RandomNumber(fpoint, point); byte ypoint = (byte)(point - xpoint); short mapX = FirstX; short mapY = FirstY; if (MapInstance.Map.GetFreePosition(ref mapX, ref mapY, xpoint, ypoint)) { double value = (xpoint + ypoint) / (double)(2 * Npc.Speed); Observable.Timer(TimeSpan.FromMilliseconds(1000 * value)).Subscribe(x => { MapX = mapX; MapY = mapY; }); LastMove = DateTime.UtcNow.AddSeconds(value); MapInstance.Broadcast(new BroadcastPacket(null, StaticPacketHelper.Move(UserType.Npc, MapNpcId, MapX, MapY, Npc.Speed), ReceiverType.All, xCoordinate: mapX, yCoordinate: mapY)); } } if (Target == -1) { if (IsHostile && Shop == null) { MapMonster monster = MapInstance.Monsters.Find(s => MapInstance == s.MapInstance && Map.GetDistance(new MapCell { X = MapX, Y = MapY }, new MapCell { X = s.MapX, Y = s.MapY }) < (Npc.NoticeRange > 5 ? Npc.NoticeRange / 2 : Npc.NoticeRange)); ClientSession session = MapInstance.Sessions.FirstOrDefault(s => MapInstance == s.Character.MapInstance && Map.GetDistance(new MapCell { X = MapX, Y = MapY }, new MapCell { X = s.Character.PositionX, Y = s.Character.PositionY }) < Npc.NoticeRange); if (monster != null && session != null) { Target = monster.MapMonsterId; } } } else if (Target != -1) { MapMonster monster = MapInstance.Monsters.Find(s => s.MapMonsterId == Target); if (monster == null || monster.CurrentHp < 1) { Target = -1; return; } NpcMonsterSkill npcMonsterSkill = null; if (ServerManager.RandomNumber(0, 10) > 8) { npcMonsterSkill = Npc.Skills.Where(s => (DateTime.UtcNow - s.LastSkillUse).TotalMilliseconds >= 100 * s.Skill.Cooldown).OrderBy(rnd => _random.Next()).FirstOrDefault(); } int hitmode = 0; bool onyxWings = false; int damage = DamageHelper.Instance.CalculateDamage(new BattleEntity(this), new BattleEntity(monster), npcMonsterSkill?.Skill, ref hitmode, ref onyxWings); if (monster.Monster.BCards.Find(s => s.Type == (byte)CardType.LightAndShadow && s.SubType == (byte)AdditionalTypes.LightAndShadow.InflictDamageToMP) is BCard card) { int reduce = damage / 100 * card.FirstData; if (monster.CurrentMp < reduce) { monster.CurrentMp = 0; } else { monster.CurrentMp -= reduce; } } int distance = Map.GetDistance(new MapCell { X = MapX, Y = MapY }, new MapCell { X = monster.MapX, Y = monster.MapY }); if (monster.CurrentHp > 0 && ((npcMonsterSkill != null && distance < npcMonsterSkill.Skill.Range) || distance <= Npc.BasicRange)) { if (((DateTime.UtcNow - LastEffect).TotalMilliseconds >= 1000 + (Npc.BasicCooldown * 200) && Npc.Skills.Count == 0) || npcMonsterSkill != null) { if (npcMonsterSkill != null) { npcMonsterSkill.LastSkillUse = DateTime.UtcNow; MapInstance.Broadcast(StaticPacketHelper.CastOnTarget(UserType.Npc, MapNpcId, 3, Target, npcMonsterSkill.Skill.CastAnimation, npcMonsterSkill.Skill.CastEffect, npcMonsterSkill.Skill.SkillVNum)); } if (npcMonsterSkill != null && npcMonsterSkill.Skill.CastEffect != 0) { MapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, MapNpcId, Effect)); } monster.CurrentHp -= damage; MapInstance.Broadcast(npcMonsterSkill != null ? StaticPacketHelper.SkillUsed(UserType.Npc, MapNpcId, 3, Target, npcMonsterSkill.SkillVNum, npcMonsterSkill.Skill.Cooldown, npcMonsterSkill.Skill.AttackAnimation, npcMonsterSkill.Skill.Effect, 0, 0, monster.CurrentHp > 0, (int)(monster.CurrentHp / (float)monster.Monster.MaxHP * 100), damage, hitmode, 0) : StaticPacketHelper.SkillUsed(UserType.Npc, MapNpcId, 3, Target, 0, Npc.BasicCooldown, 11, Npc.BasicSkill, 0, 0, monster.CurrentHp > 0, (int)(monster.CurrentHp / (float)monster.Monster.MaxHP * 100), damage, hitmode, 0)); LastEffect = DateTime.UtcNow; if (monster.CurrentHp < 1) { RemoveTarget(); monster.IsAlive = false; monster.LastMove = DateTime.UtcNow; monster.CurrentHp = 0; monster.CurrentMp = 0; monster.Death = DateTime.UtcNow; Target = -1; } } } else { if (IsMoving) { const short maxDistance = 5; int maxindex = Path.Count > Npc.Speed / 2 && Npc.Speed > 1 ? Npc.Speed / 2 : Path.Count; if (maxindex < 1) { maxindex = 1; } if ((Path.Count == 0 && distance >= 1 && distance < maxDistance) || (Path.Count >= maxindex && maxindex > 0 && Path[maxindex - 1] == null)) { short xoffset = (short)ServerManager.RandomNumber(-1, 1); short yoffset = (short)ServerManager.RandomNumber(-1, 1); //go to monster Path = BestFirstSearch.FindPathJagged(new GridPos { X = MapX, Y = MapY }, new GridPos { X = (short)(monster.MapX + xoffset), Y = (short)(monster.MapY + yoffset) }, MapInstance.Map.JaggedGrid); maxindex = Path.Count > Npc.Speed / 2 && Npc.Speed > 1 ? Npc.Speed / 2 : Path.Count; } if (DateTime.UtcNow > LastMove && Npc.Speed > 0 && Path.Count > 0) { short mapX = Path[maxindex - 1].X; short mapY = Path[maxindex - 1].Y; double waitingtime = Map.GetDistance(new MapCell { X = mapX, Y = mapY }, new MapCell { X = MapX, Y = MapY }) / (double)Npc.Speed; MapInstance.Broadcast(new BroadcastPacket(null, StaticPacketHelper.Move(UserType.Npc, MapNpcId, MapX, MapY, Npc.Speed), ReceiverType.All, xCoordinate: mapX, yCoordinate: mapY)); LastMove = DateTime.UtcNow.AddSeconds(waitingtime > 1 ? 1 : waitingtime); Observable.Timer(TimeSpan.FromMilliseconds((int)((waitingtime > 1 ? 1 : waitingtime) * 1000))).Subscribe(x => { MapX = mapX; MapY = mapY; }); Path.RemoveRange(0, maxindex); } if (Target != -1 && (MapId != monster.MapId || distance > maxDistance)) { RemoveTarget(); } } } } }
public LoginPacketHandler(ClientSession session) { _session = session; }
public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null) { switch (Effect) { case 10: { switch (EffectValue) { case 1: if (session.Character.Inventory.CountItem(1036) < 1 || session.Character.Inventory.CountItem(1013) < 1) { return; } session.Character.Inventory.RemoveItemAmount(1036); session.Character.Inventory.RemoveItemAmount(1013); if (ServerManager.RandomNumber() < 25) { switch (ServerManager.RandomNumber(0, 2)) { case 0: session.Character.GiftAdd(1015, 1); break; case 1: session.Character.GiftAdd(1016, 1); break; } } break; case 2: if (session.Character.Inventory.CountItem(1038) < 1 || session.Character.Inventory.CountItem(1013) < 1) { return; } session.Character.Inventory.RemoveItemAmount(1038); session.Character.Inventory.RemoveItemAmount(1013); if (ServerManager.RandomNumber() < 25) { switch (ServerManager.RandomNumber(0, 4)) { case 0: session.Character.GiftAdd(1031, 1); break; case 1: session.Character.GiftAdd(1032, 1); break; case 2: session.Character.GiftAdd(1033, 1); break; case 3: session.Character.GiftAdd(1034, 1); break; } } break; case 573: { int rnd = ServerManager.RandomNumber(0, 100); { short[] vnums = { 573 //15x }; byte[] counts = { 1 }; int item = ServerManager.RandomNumber(0, 1); session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 1)], 1, 8, 90); session.SendPacket($"rdi {vnums[item]} {counts[item]}"); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // Shell Armor case 585: { int rnd = ServerManager.RandomNumber(0, 100); { short[] vnums = { 585 //15x }; byte[] counts = { 1 }; int item = ServerManager.RandomNumber(0, 1); session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 1)], 1, 8, 90); session.SendPacket($"rdi {vnums[item]} {counts[item]}"); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; case 3: if (session.Character.Inventory.CountItem(1037) < 1 || session.Character.Inventory.CountItem(1013) < 1) { return; } session.Character.Inventory.RemoveItemAmount(1037); session.Character.Inventory.RemoveItemAmount(1013); if (ServerManager.RandomNumber() < 25) { switch (ServerManager.RandomNumber(0, 17)) { case 0: case 1: case 2: case 3: case 4: session.Character.GiftAdd(1017, 1); break; case 5: case 6: case 7: case 8: session.Character.GiftAdd(1018, 1); break; case 9: case 10: case 11: session.Character.GiftAdd(1019, 1); break; case 12: case 13: session.Character.GiftAdd(1020, 1); break; case 14: session.Character.GiftAdd(1021, 1); break; case 15: session.Character.GiftAdd(1022, 1); break; case 16: session.Character.GiftAdd(1023, 1); break; } } break; } session.Character.GiftAdd(1014, (byte)ServerManager.RandomNumber(5, 11)); } break; default: if (!OpenBoxItem(session, inv)) { Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue)); } break; } }
public abstract void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null);
//Both partly public void ChangeMap(long id) { ClientSession session = Sessions.FirstOrDefault(s => s.Character != null && s.Character.CharacterId == id); if (session != null) { session.CurrentMap.UnregisterSession(session); session.CurrentMap = ServerManager.GetMap(session.Character.MapId); session.CurrentMap.RegisterSession(session); session.Client.SendPacket(session.Character.GenerateCInfo()); session.Client.SendPacket(session.Character.GenerateCMode()); session.CurrentMap?.Broadcast(session, session.Character.GenerateEq(), ReceiverType.All); session.Client.SendPacket(session.Character.GenerateEquipment()); session.Client.SendPacket(session.Character.GenerateLev()); session.Client.SendPacket(session.Character.GenerateStat()); session.Client.SendPacket(session.Character.GenerateAt()); session.Client.SendPacket(session.Character.GenerateCond()); session.Client.SendPacket(session.Character.GenerateCMap()); session.Client.SendPacket(session.Character.GenerateStatChar()); session.Client.SendPacket($"gidx 1 {session.Character.CharacterId} -1 - 0"); // family session.Client.SendPacket("rsfp 0 -1"); //cond 2 // partner only send when partner present session.Client.SendPacket("pinit 0"); // partner initialization session.Client.SendPacket(session.Character.GeneratePairy()); session.CurrentMap?.Broadcast(session, session.Character.GeneratePairy(), ReceiverType.AllExceptMe); session.Client.SendPacket("act6"); // act6 1 0 14 0 0 0 14 0 0 0 foreach (String portalPacket in session.Character.GenerateGp()) { session.Client.SendPacket(portalPacket); } // wp 23 124 4 4 12 99 foreach (String monsterPacket in session.Character.GenerateIn3()) { session.Client.SendPacket(monsterPacket); } foreach (String npcPacket in session.Character.GenerateIn2()) { session.Client.SendPacket(npcPacket); } foreach (String ShopPacket in session.Character.GenerateNPCShopOnMap()) { session.Client.SendPacket(ShopPacket); } foreach (String droppedPacket in session.Character.GenerateDroppedItem()) { session.Client.SendPacket(droppedPacket); } foreach (String ShopPacket in session.Character.GenerateShopOnMap()) { session.Client.SendPacket(ShopPacket); } foreach (String ShopPacketChar in session.Character.GeneratePlayerShopOnMap()) { session.Client.SendPacket(ShopPacketChar); } ServerManager.Instance.Sessions.Where(s => s.Character != null && s.Character.MapId.Equals(session.Character.MapId) && s.Character.Name != session.Character.Name && !s.Character.InvisibleGm).ToList().ForEach(s => RequireBroadcastFromUser(session, s.Character.CharacterId, "GenerateIn")); if (session.Character.InvisibleGm == false) { session.CurrentMap?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe); } if (session.Character.Size != 10) { session.Client.SendPacket(session.Character.GenerateScal()); } if (session.CurrentMap.IsDancing == 2 && session.Character.IsDancing == 0) { session.CurrentMap?.Broadcast("dance 2"); } else if (session.CurrentMap.IsDancing == 0 && session.Character.IsDancing == 1) { session.Character.IsDancing = 0; session.CurrentMap?.Broadcast("dance"); } foreach (Group g in Groups) { foreach (ClientSession groupSession in g.Characters) { ClientSession chara = Sessions.FirstOrDefault(s => s.Character != null && s.Character.CharacterId == groupSession.Character.CharacterId && s.CurrentMap.MapId == groupSession.CurrentMap.MapId); if (chara != null) { groupSession.Client.SendPacket($"pidx 1 1.{chara.Character.CharacterId}"); } if (groupSession.Character.CharacterId == groupSession.Character.CharacterId) { session.CurrentMap?.Broadcast(groupSession, $"pidx 1 1.{groupSession.Character.CharacterId}", ReceiverType.All); } } } } }
public void ExchangeValidate(ClientSession Session, long charId) { ClientSession session = sessions.FirstOrDefault(s => s.Character.CharacterId.Equals(charId)); { if (session != null) { foreach (InventoryItem item in session.Character.ExchangeInfo.ExchangeList) { Inventory inv = session.Character.InventoryList.getInventoryByInventoryItemId(item.InventoryItemId); session.Character.InventoryList.DeleteByInventoryItemId(item.InventoryItemId); session.Client.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, inv.Type, inv.Slot, 0, 0, 0)); } foreach (InventoryItem item in Session.Character.ExchangeInfo.ExchangeList) { Inventory inv = session.Character.InventoryList.CreateItem(item, Session.Character); if (inv != null) { short Slot = inv.Slot; if (Slot != -1) session.Client.SendPacket(session.Character.GenerateInventoryAdd(inv.InventoryItem.ItemVNum, inv.InventoryItem.Amount, inv.Type, Slot, inv.InventoryItem.Rare, inv.InventoryItem.Color, inv.InventoryItem.Upgrade)); } } session.Character.Gold = session.Character.Gold - session.Character.ExchangeInfo.Gold + Session.Character.ExchangeInfo.Gold; session.Client.SendPacket(session.Character.GenerateGold()); } } }
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 NpcPacketHandler(ClientSession session) { _session = session; }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { /*if (session.Character.IsVehicled) * { * session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10)); * return; * }*/ if (session.CurrentMapInstance?.MapInstanceType != MapInstanceType.TalentArenaMapInstance && VNum == 2802) { return; } if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.TalentArenaMapInstance && VNum != 2802) { return; } Item item = inv.Item; switch (Effect) { default: if (session.Character.Hp <= 0) { return; } if (item.BCards.Find(s => s.Type == 25) is BCard Buff) { if (ServerManager.RandomNumber() < Buff.FirstData) { session.Character.AddBuff(new Buff((short)Buff.SecondData, session.Character.Level), session.Character.BattleEntity); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { if (session.Character.SnackAmount < 0) { session.Character.SnackAmount = 0; } int amount = session.Character.SnackAmount; if (amount < 5) { Thread workerThread = new Thread(() => Regenerate(session, item)); workerThread.Start(); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(session.Character.Gender == GenderType.Female ? session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1) : session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1)); } if (amount == 0) { Thread workerThread2 = new Thread(() => Sync(session)); workerThread2.Start(); } } break; } }
public abstract void Use(ClientSession Session, ref Inventory Inv, bool DelayUsed = false);
// Both partly public void ChangeMap(long id, short?mapId = null, short?mapX = null, short?mapY = null) { ClientSession session = GetSessionByCharacterId(id); if (session != null && session.Character != null && !session.Character.IsChangingMap) { try { session.Character.IsChangingMap = true; session.CurrentMap.UnregisterSession(session.Character.CharacterId); //cleanup sending queue to avoid sending uneccessary packets to it Task.Factory.StartNew(async() => { await session.ClearLowpriorityQueue(); }); //avoid cleaning new portals Task.Delay(100); if (mapId != null || mapX != null || mapY != null) { session.Character.MapId = (short)mapId; session.Character.MapX = (short)mapX; session.Character.MapY = (short)mapY; } session.CurrentMap = GetMap(session.Character.MapId); session.CurrentMap.RegisterSession(session); session.SendPacket(session.Character.GenerateCond()); session.SendPacket(session.Character.GenerateCInfo()); session.SendPacket(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateEq()); session.SendPacket(session.Character.GenerateEquipment()); session.SendPacket(session.Character.GenerateLev()); session.SendPacket(session.Character.GenerateStat()); session.SendPacket(session.Character.GenerateAt()); session.SendPacket(session.Character.GenerateCMap()); session.SendPacket(session.Character.GenerateStatChar()); session.SendPacket($"gidx 1 {session.Character.CharacterId} -1 - 0"); // family session.SendPacket("rsfp 0 -1"); // in 2 // send only when partner present cond 2 // send only when partner present session.SendPacket("pinit 0"); // clear party list session.SendPacket(session.Character.GeneratePairy()); session.SendPacket("act6"); // act6 1 0 14 0 0 0 14 0 0 0 Sessions.Where(s => s.Character != null && s.Character.MapId.Equals(session.Character.MapId) && s.Character.Name != session.Character.Name && !s.Character.InvisibleGm).ToList().ForEach(s => RequireBroadcastFromUser(session, s.Character.CharacterId, "GenerateIn")); session.SendPackets(session.Character.GenerateGp()); // wp 23 124 4 4 12 99 session.SendPackets(session.Character.GenerateIn3()); session.SendPackets(session.Character.GenerateIn2()); session.SendPackets(session.Character.GenerateNPCShopOnMap()); session.SendPackets(session.Character.GenerateDroppedItem()); session.SendPackets(session.Character.GenerateShopOnMap()); session.SendPackets(session.Character.GeneratePlayerShopOnMap()); if (!session.Character.InvisibleGm) { session.CurrentMap?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe); } if (session.Character.Size != 10) { session.SendPacket(session.Character.GenerateScal()); } if (session.CurrentMap.IsDancing && !session.Character.IsDancing) { session.CurrentMap?.Broadcast("dance 2"); } else if (!session.CurrentMap.IsDancing && session.Character.IsDancing) { session.Character.IsDancing = false; session.CurrentMap?.Broadcast("dance"); } foreach (Group g in Groups) { foreach (ClientSession groupSession in g.Characters) { ClientSession chara = Sessions.FirstOrDefault(s => s.Character != null && s.Character.CharacterId == groupSession.Character.CharacterId && s.CurrentMap.MapId == groupSession.CurrentMap.MapId); if (chara != null) { groupSession.SendPacket(groupSession.Character.GeneratePinit()); } if (groupSession.Character.CharacterId == groupSession.Character.CharacterId) { session.CurrentMap?.Broadcast(groupSession, groupSession.Character.GeneratePidx(), ReceiverType.AllExceptMe); } } } session.Character.IsChangingMap = false; } catch (Exception) { Logger.Log.Warn("Character changed while changing map. Do not abuse Commands."); session.Character.IsChangingMap = false; } } }
private static void Sync(ClientSession session) { for (session.Character.MaxFood = 0; session.Character.MaxFood < 5; session.Character.MaxFood++) { if (session.Character.Hp <= 0 || !session.Character.IsSitting) { _regenerateDisposable?.Dispose(); session.Character.FoodAmount = 0; session.Character.FoodHp = 0; session.Character.FoodMp = 0; return; } int hpLoad = (int)session.Character.HPLoad(); int mpLoad = (int)session.Character.MPLoad(); double buffRc = session.Character.GetBuff(BCardType.CardType.LeonaPassiveSkill, (byte)AdditionalTypes.LeonaPassiveSkill.IncreaseRecoveryItems)[0] / 100D; int hpAmount = session.Character.FoodHp + (int)(session.Character.FoodHp * buffRc); int mpAmount = session.Character.FoodMp + (int)(session.Character.FoodMp * buffRc); if (session.Character.Hp + hpAmount > hpLoad) { hpAmount = hpLoad - session.Character.Hp; } if (session.Character.Mp + mpAmount > mpLoad) { mpAmount = mpLoad - session.Character.Mp; } bool convertRecoveryToDamage = ServerManager.RandomNumber() < session.Character.GetBuff(BCardType.CardType.DarkCloneSummon, (byte)AdditionalTypes.DarkCloneSummon.ConvertRecoveryToDamage)[0]; if (convertRecoveryToDamage) { session.Character.Hp -= hpAmount; if (session.Character.Hp < 1) { session.Character.Hp = 1; } if (hpAmount > 0) { session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateDm(hpAmount)); } } else { session.Character.Hp += hpAmount; if (hpAmount > 0) { session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateRc(hpAmount)); } } session.Character.Mp += mpAmount; foreach (Mate mate in session.Character.Mates.Where(s => s.IsTeamMember && s.IsAlive && s.IsSitting)) { hpLoad = mate.HpLoad(); mpLoad = mate.MpLoad(); hpAmount = session.Character.FoodHp; mpAmount = session.Character.FoodMp; if (mate.Hp + hpAmount > hpLoad) { hpAmount = hpLoad - (int)mate.Hp; } if (mate.Mp + mpAmount > mpLoad) { mpAmount = mpLoad - (int)mate.Mp; } mate.Hp += hpAmount; mate.Mp += mpAmount; if (hpAmount > 0) { session.CurrentMapInstance?.Broadcast(session, mate.GenerateRc(hpAmount)); } } if (session.IsConnected) { session.SendPacket(session.Character.GenerateStat()); if (session.Character.Mates.Any(m => m.IsTeamMember && m.IsAlive && m.IsSitting)) { session.SendPackets(session.Character.GeneratePst()); } Thread.Sleep(1800); } } }
public abstract void Use(ClientSession Session, ref ItemInstance Inv, bool DelayUsed = false, string[] packetsplit = null);
public static void NRun(ClientSession Session, byte type, short runner, short value, short npcid) { if (!Session.HasCurrentMap) { return; } MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == npcid); switch (runner) { case 1: if (Session.Character.Class != (byte)ClassType.Adventurer) { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0)); return; } if (Session.Character.Level < 15 || Session.Character.JobLevel < 20) { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0)); return; } if (type == (byte)Session.Character.Class) { return; } if (Session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear)) { Session.Character.Inventory.AddNewToInventory((short)(4 + type * 14), type: InventoryType.Wear); Session.Character.Inventory.AddNewToInventory((short)(81 + type * 13), type: InventoryType.Wear); switch (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.CurrentMap?.Broadcast(Session.Character.GenerateEq()); Session.SendPacket(Session.Character.GenerateEquipment()); Session.Character.ChangeClass((ClassType)type); } else { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; case 2: Session.SendPacket("wopen 1 0"); break; case 10: Session.SendPacket("wopen 3 0"); break; case 12: Session.SendPacket($"wopen {type} 0"); break; case 14: Session.SendPacket("wopen 27 0"); string recipelist = "m_list 2"; if (npc != null) { List<Recipe> tp = npc.Recipes; foreach (Recipe s in tp) { if (s.Amount > 0) recipelist = recipelist + $" {s.ItemVNum}"; } recipelist += " -100"; Session.SendPacket(recipelist); } break; case 16: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { if (Session.Character.Gold >= 1000 * type) { ServerManager.Instance.LeaveMap(Session.Character.CharacterId); Session.Character.Gold -= 1000 * 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 26: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { if (Session.Character.Gold >= 5000 * type) { ServerManager.Instance.LeaveMap(Session.Character.CharacterId); Session.Character.Gold -= 5000 * 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: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { if (Session.Character.Gold >= 500) { ServerManager.Instance.LeaveMap(Session.Character.CharacterId); 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: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { ServerManager.Instance.LeaveMap(Session.Character.CharacterId); ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } } break; case 301: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { ServerManager.Instance.LeaveMap(Session.Character.CharacterId); ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } } break; case 23: Session.SendPacket(Session.Character.GenerateInbox(type, 14)); Session.SendPacket(Session.Character.GenerateFamilyMember(Session.Character.Group)); break; case 5002: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { Session.SendPacket("it 3"); ServerManager.Instance.LeaveMap(Session.Character.CharacterId); ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } } break; case 5012: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { ServerManager.Instance.LeaveMap(Session.Character.CharacterId); ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY); } } break; default: Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), runner)); break; } }
private void CharacterLifeManager() { try { List <Task> NpcLifeTask = new List <Task>(); for (int i = Sessions.Where(s => s.HasSelectedCharacter).Count() - 1; i >= 0; i--) { ClientSession Session = Sessions.Where(s => s?.Character != null).ElementAt(i); if (Session.Character.LastMailRefresh.AddSeconds(30) < DateTime.Now) { Session.Character.RefreshMail(); } int x = 1; bool change = false; if (Session.Character.Hp == 0 && Session.Character.LastHealth.AddSeconds(2) <= DateTime.Now) { Session.Character.Mp = 0; Session.SendPacket(Session.Character.GenerateStat()); Session.Character.LastHealth = DateTime.Now; } else { WearableInstance amulet = Session.Character.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Amulet, InventoryType.Wear); if (Session.Character.LastEffect.AddSeconds(5) <= DateTime.Now && amulet != null) { if (amulet.ItemVNum == 4503 || amulet.ItemVNum == 4504) { Session.CurrentMap?.Broadcast(Session.Character.GenerateEff(amulet.Item.EffectValue + (Session.Character.Class == (byte)ClassType.Adventurer ? 0 : Session.Character.Class - 1)), Session.Character.MapX, Session.Character.MapY); } else { Session.CurrentMap?.Broadcast(Session.Character.GenerateEff(amulet.Item.EffectValue), Session.Character.MapX, Session.Character.MapY); } Session.Character.LastEffect = DateTime.Now; } if ((Session.Character.LastHealth.AddSeconds(2) <= DateTime.Now) || (Session.Character.IsSitting && Session.Character.LastHealth.AddSeconds(1.5) <= DateTime.Now)) { Session.Character.LastHealth = DateTime.Now; if (Session.HealthStop) { Session.HealthStop = false; return; } if (Session.Character.LastDefence.AddSeconds(2) <= DateTime.Now && Session.Character.LastSkill.AddSeconds(2) <= DateTime.Now && Session.Character.Hp > 0) { if (x == 0) { x = 1; } if (Session.Character.Hp + Session.Character.HealthHPLoad() < Session.Character.HPLoad()) { change = true; Session.Character.Hp += Session.Character.HealthHPLoad(); } else { if (Session.Character.Hp != (int)Session.Character.HPLoad()) { change = true; } Session.Character.Hp = (int)Session.Character.HPLoad(); } if (x == 1) { if (Session.Character.Mp + Session.Character.HealthMPLoad() < Session.Character.MPLoad()) { Session.Character.Mp += Session.Character.HealthMPLoad(); change = true; } else { if (Session.Character.Mp != (int)Session.Character.MPLoad()) { change = true; } Session.Character.Mp = (int)Session.Character.MPLoad(); } x = 0; } if (change) { Session.SendPacket(Session.Character.GenerateStat()); } } } } } } catch (Exception e) { Logger.Error(e); } }
public void Broadcast(ClientSession client, PacketDefinition packet, ReceiverType receiver = ReceiverType.All, string characterName = "", long characterId = -1) { Broadcast(client, PacketFactory.Serialize(packet), receiver, characterName, characterId); }
public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null) { switch (Effect) { default: short slot = inv.Slot; 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; } else 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(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0)); return; } if (EquipmentSlot == EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Specialist) != null) { session.SendPacket(session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0)); return; } if ((ItemType != Domain.ItemType.Weapon && ItemType != Domain.ItemType.Armor && ItemType != Domain.ItemType.Fashion && ItemType != Domain.ItemType.Jewelery && ItemType != Domain.ItemType.Specialist) || LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) || ((ItemType != Domain.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, InventoryType.Wear); if (sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement) { session.SendPacket(session.Character.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; } ItemInstance currentlyEquippedItem = session.Character.Inventory.LoadBySlotAndType((short)EquipmentSlot, InventoryType.Wear); if (EquipmentSlot == EquipmentType.Amulet) { session.SendPacket(session.Character.GenerateEff(39)); inv.BoundCharacterId = session.Character.CharacterId; } if (currentlyEquippedItem == null) { // move from equipment to wear session.Character.Inventory.MoveInInventory(inv.Slot, itemToWearType, InventoryType.Wear); session.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, itemToWearType, slot, 0, 0, 0, 0)); session.SendPacket(session.Character.GenerateStatChar()); session.CurrentMap?.Broadcast(session.Character.GenerateEq()); session.SendPacket(session.Character.GenerateEquipment()); session.CurrentMap?.Broadcast(session.Character.GeneratePairy()); } else { // move from wear to equipment and back session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, InventoryType.Wear, itemToWearType, inv.Slot); session.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, itemToWearType, slot, 0, 0, 0, 0)); session.SendPacket(session.Character.GenerateInventoryAdd(currentlyEquippedItem.ItemVNum, currentlyEquippedItem.Amount, currentlyEquippedItem.Type, currentlyEquippedItem.Slot, currentlyEquippedItem.Rare, currentlyEquippedItem.Design, currentlyEquippedItem.Upgrade, currentlyEquippedItem is SpecialistInstance ? ((SpecialistInstance)currentlyEquippedItem).SpStoneUpgrade : (byte)0)); session.SendPacket(session.Character.GenerateStatChar()); session.CurrentMap?.Broadcast(session.Character.GenerateEq()); session.SendPacket(session.Character.GenerateEquipment()); session.CurrentMap?.Broadcast(session.Character.GeneratePairy()); } if (EquipmentSlot == EquipmentType.Fairy) { WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Fairy, InventoryType.Wear); session.SendPacket(session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXpData(fairy.ElementRate + fairy.Item.ElementRate)), 10)); } break; } }
public virtual void RegisterSession(ClientSession session) { if (!session.HasSelectedCharacter) { return; } if (session != null) { // Create a ChatClient and store it in a collection _sessions[session.Character.CharacterId] = session; if (session.HasCurrentMap) { session.CurrentMap.IsSleeping = false; } } }
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 { } }
protected virtual ClientSession IntializeNewSession(INetworkClient client) { ClientSession session = new ClientSession(client); client.SetClientSession(session); return session; }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { switch (Effect) { // airwaves - eventitems case 0: if (inv.Item.ItemType == ItemType.Shell) { if (inv.ShellEffects.Count != 0 && packetsplit?.Length > 9 && byte.TryParse(packetsplit[9], out byte islot)) { ItemInstance wearable = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(islot, InventoryType.Equipment); if (wearable != null && (wearable.Item.ItemType == ItemType.Weapon || wearable.Item.ItemType == ItemType.Armor) && wearable.Item.LevelMinimum >= inv.Upgrade && wearable.Rare >= inv.Rare && !wearable.Item.IsHeroic) { bool weapon = false; if ((inv.ItemVNum >= 565 && inv.ItemVNum <= 576) || (inv.ItemVNum >= 589 && inv.ItemVNum <= 598)) { weapon = true; } else if ((inv.ItemVNum >= 577 && inv.ItemVNum <= 588) || (inv.ItemVNum >= 656 && inv.ItemVNum <= 664) || inv.ItemVNum == 599) { weapon = false; } else { return; } if ((wearable.Item.ItemType == ItemType.Weapon && weapon) || (wearable.Item.ItemType == ItemType.Armor && !weapon)) { if (wearable.ShellEffects.Count > 0 && ServerManager.RandomNumber() < 50) { session.Character.DeleteItemByItemInstanceId(inv.Id); session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_APPLY_FAIL"), 0)); return; } wearable.ShellEffects.Clear(); DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearable.EquipmentSerialId); wearable.ShellEffects.AddRange(inv.ShellEffects); if (wearable.EquipmentSerialId == Guid.Empty) { wearable.EquipmentSerialId = Guid.NewGuid(); } DAOFactory.ShellEffectDAO.InsertOrUpdateFromList(wearable.ShellEffects, wearable.EquipmentSerialId); session.Character.DeleteItemByItemInstanceId(inv.Id); session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_APPLY_SUCCESS"), 0)); } } } return; } if (ItemType == ItemType.Event) { session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, EffectValue)); if (MappingHelper.GuriItemEffects.ContainsKey(EffectValue)) { session.CurrentMapInstance?.Broadcast(UserInterfaceHelper.GenerateGuri(19, 1, session.Character.CharacterId, MappingHelper.GuriItemEffects[EffectValue]), session.Character.MapX, session.Character.MapY); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; //respawn objects case 1: if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance || ServerManager.Instance.ChannelId == 51) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_USE_THAT"), 10)); return; } int type, secondaryType, inventoryType, slot; if (packetsplit != null && int.TryParse(packetsplit[2], out type) && int.TryParse(packetsplit[3], out secondaryType) && int.TryParse(packetsplit[4], out inventoryType) && int.TryParse(packetsplit[5], out slot)) { int packetType; switch (EffectValue) { case 0: if (Option == 0) { session.SendPacket(UserInterfaceHelper.GenerateDialog($"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1 #u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2 {Language.Instance.GetMessageFromKey("WANT_TO_SAVE_POSITION")}")); } else if (int.TryParse(packetsplit[6], out packetType)) { switch (packetType) { case 1: session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^3")); break; case 2: session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^4")); break; case 3: session.Character.SetReturnPoint(session.Character.MapId, session.Character.MapX, session.Character.MapY); RespawnMapTypeDTO respawn = session.Character.Respawn; if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0) { ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, (short)(respawn.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawn.DefaultY + ServerManager.RandomNumber(-5, 5))); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; case 4: RespawnMapTypeDTO respawnObj = session.Character.Respawn; if (respawnObj.DefaultX != 0 && respawnObj.DefaultY != 0 && respawnObj.DefaultMapId != 0) { ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawnObj.DefaultMapId, (short)(respawnObj.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawnObj.DefaultY + ServerManager.RandomNumber(-5, 5))); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; } } break; case 1: if (int.TryParse(packetsplit[6], out packetType)) { RespawnMapTypeDTO respawn = session.Character.Return; switch (packetType) { case 0: if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0) { session.SendPacket(UserInterfaceHelper.GenerateRp(respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1")); } break; case 1: session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2")); break; case 2: if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0) { ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY); } session.Character.Inventory.RemoveItemFromInventory(inv.Id); break; } } break; case 2: if (Option == 0) { session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1")); } else { ServerManager.Instance.JoinMiniland(session, session); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; } } break; // dyes or waxes case 10: case 11: if (!session.Character.IsVehicled) { if (Effect == 10) { if (EffectValue == 99) { byte nextValue = (byte)ServerManager.RandomNumber(0, 127); session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), nextValue) ? (HairColorType)nextValue : 0; } else { session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)EffectValue) ? (HairColorType)EffectValue : 0; } } else if (Effect == 11) { if (session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1) { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10)); return; } if (session.Character.Gender != (GenderType)Sex) { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANNOT_USE"), 10)); return; } session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0; } else { if (session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1) { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10)); return; } session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0; } session.SendPacket(session.Character.GenerateEq()); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn()); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // dignity restoration case 14: if ((EffectValue == 100 || EffectValue == 200) && session.Character.Dignity < 100 && !session.Character.IsVehicled) { session.Character.Dignity += EffectValue; if (session.Character.Dignity > 100) { session.Character.Dignity = 100; } session.SendPacket(session.Character.GenerateFd()); session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 49 - (byte)session.Character.Faction)); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else if (EffectValue == 2000 && session.Character.Dignity < 100 && !session.Character.IsVehicled) { session.Character.Dignity = 100; session.SendPacket(session.Character.GenerateFd()); session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 49 - (byte)session.Character.Faction)); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; // speakers case 15: if (!session.Character.IsVehicled && Option == 0) { session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 3, session.Character.CharacterId, 1)); } break; // bubbles case 16: if (!session.Character.IsVehicled && Option == 0) { session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 4, session.Character.CharacterId, 1)); } break; // wigs case 30: if (!session.Character.IsVehicled) { ItemInstance wig = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Hat, InventoryType.Wear); if (wig != null) { wig.Design = (byte)ServerManager.RandomNumber(0, 15); session.SendPacket(session.Character.GenerateEq()); session.SendPacket(session.Character.GenerateEquipment()); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn()); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0)); } } break; case 31: if (!session.Character.IsVehicled && session.Character.HairStyle == HairStyleType.Hair7) { session.Character.HairStyle = HairStyleType.Hair8; session.SendPacket(session.Character.GenerateEq()); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn()); session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx()); session.Character.Inventory.RemoveItemFromInventory(inv.Id); // idk how it works yet but seems like all characters with this hairstyle have DarkPurple hair //session.Character.HairColor = HairColorType.DarkPurple; } break; case 300: if (session.Character.Group != null && session.Character.Group.GroupType != GroupType.Group && session.Character.Group.IsLeader(session) && session.CurrentMapInstance.Portals.Any(s => s.Type == (short)PortalType.Raid)) { int delay = 0; foreach (ClientSession sess in session.Character.Group.Characters.GetAllItems()) { Observable.Timer(TimeSpan.FromMilliseconds(delay)).Subscribe(o => { if (sess?.Character != null && session?.CurrentMapInstance != null && session?.Character != null) { ServerManager.Instance.ChangeMapInstance(sess.Character.CharacterId, session.CurrentMapInstance.MapInstanceId, session.Character.PositionX, session.Character.PositionY); } }); delay += 100; } session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue)); break; } }
public bool IsLeader(ClientSession session) { return(Characters.OrderBy(s => s.Character.LastGroupJoin).ElementAt(0) == session); }
public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null) { switch (Effect) { // sp point potions case 150: case 151: session.Character.SpAdditionPoint += EffectValue; if (session.Character.SpAdditionPoint > 1000000) { session.Character.SpAdditionPoint = 1000000; } session.SendPacket(session.Character.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(session.Character.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; /*********************************\ ** Sceaux ** *********************************** ** VNUM : ** - 1127 : Cuby ** - 1128 : Ginseng ** - 1129 : Castra ** - 1130 : Jack ** - 1131 : Slade \**********************************/ case 301: // Delete item //session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); // Create raid Raid raid = new Raid(); raid.JoinRaid(session); session.SendPacket($"raid 2 {session.Character.CharacterId}"); session.SendPacket($"raid 0 {session.Character.CharacterId}"); session.SendPacket("raid 1 1"); session.SendPacket(raid.GenerateRdlst()); session.SendPacket($"say 1 {session.Character.CharacterId} 10 Tu es chef de raid à présent. Invite des membres."); session.SendPacket($"msg 0 Tu es chef de raid à présent. Invite des membres."); ServerManager.Instance.AddRaid(raid); break; // Divorce letter case 6969: // this is imaginary number I = √(-1) break; // Cupid's arrow case 34: // this is imaginary number I = √(-1) break; // wings case 650: SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear); if (session.Character.UseSp && specialistInstance != null) { if (!delay) { 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.CurrentMap?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateStat()); session.SendPacket(session.Character.GenerateStatChar()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0)); } break; // presentation messages case 203: if (!session.Character.IsVehicled) { if (!delay) { session.SendPacket(session.Character.GenerateGuri(10, 2, 1)); } } break; // magic lamps case 651: if (session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear)) { if (!delay) { 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(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; // vehicles case 1000: if (Morph > 0) { if (!delay && !session.Character.IsVehicled) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.CurrentMap?.Broadcast(session.Character.GenerateRest()); } session.SendPacket(session.Character.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2")); } else { if (!session.Character.IsVehicled) { 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.CurrentMap?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY); session.CurrentMap?.Broadcast(session.Character.GenerateCMode()); session.SendPacket(session.Character.GenerateCond()); } else { session.Character.RemoveVehicle(); } } } break; case 69: session.Character.Reput += ReputPrice; session.SendPacket(session.Character.GenerateFd()); session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); break; default: Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType())); Logger.Log.Warn($"ID : {Effect}"); break; } }
public void RequiereBroadcastFromAllMapUsers(ClientSession client, string methodName) { foreach (ClientSession session in sessions.Where(s=> s.Character != null && s.Character.Name != client.Character.Name)) { Type t = session.Character.GetType(); MethodInfo method = t.GetMethod(methodName); string result = (string)method.Invoke(session.Character, null); client.Client.SendPacket(result); } }
//TODO: Convert to PacketDefinition public abstract void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null);
public void BuyValidate(ClientSession Session, KeyValuePair<long, MapShop> shop,short slot, short amount) { PersonalShopItem itemshop = Session.CurrentMap.ShopUserList[shop.Key].Items.FirstOrDefault(i => i.Slot.Equals(slot)); Session.CurrentMap.ShopUserList[shop.Key].Items.FirstOrDefault(i => i.Slot.Equals(slot)).Amount -= amount; PersonalShopItem itemDelete = Session.CurrentMap.ShopUserList[shop.Key].Items.FirstOrDefault(i => i.Slot.Equals(slot)); if (itemDelete.Amount <= 0) Session.CurrentMap.ShopUserList[shop.Key].Items.Remove(itemDelete); ClientSession session = sessions.FirstOrDefault(s => s.Character.CharacterId.Equals(shop.Value.OwnerId)); { if (session != null) { session.Character.Gold += itemshop.Price* amount; session.Client.SendPacket(session.Character.GenerateGold()); session.Client.SendPacket(session.Character.GenerateShopMemo(1, String.Format(Language.Instance.GetMessageFromKey("BUY_ITEM"), session.Character.Name, ServerManager.GetItem(itemshop.ItemVNum).Name, amount))); Session.CurrentMap.ShopUserList[shop.Key].Sell += itemshop.Price * amount; session.Client.SendPacket(String.Format("sell_list {0} {1}.{2}.{3}", shop.Value.Sell, slot, amount, itemshop.Amount)); Inventory inv = session.Character.InventoryList.AmountMinusFromSlotAndType(amount, itemshop.InvSlot, itemshop.InvType); if (inv != null) { session.Client.SendPacket(session.Character.GenerateInventoryAdd(inv.InventoryItem.ItemVNum, inv.InventoryItem.Amount, inv.Type, inv.Slot, inv.InventoryItem.Rare, inv.InventoryItem.Color, inv.InventoryItem.Upgrade)); } else session.Client.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, itemshop.InvType, itemshop.InvSlot, 0, 0, 0)); } } }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { if (!session.HasCurrentMapInstance) { return; } if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < (session.CurrentMapInstance.Map.MapTypes.OrderByDescending(s => s.PotionDelay).FirstOrDefault()?.PotionDelay ?? 750)) { return; } session.Character.LastPotion = DateTime.Now; switch (Effect) { default: if (session.CurrentMapInstance.IsPVP) { return; } int hpLoad = (int)session.Character.HPLoad(); int mpLoad = (int)session.Character.MPLoad(); if ((session.Character.Hp == hpLoad && session.Character.Mp == mpLoad) || session.Character.Hp <= 0) { return; } if (session.Character.MapId == 134 || session.Character.MapId == 153 || session.Character.MapId == 132 || session.Character.MapId == 151 || session.Character.MapId == 133 || session.Character.MapId == 152) { if (inv.ItemVNum == 1244 || inv.ItemVNum == 1243 || inv.ItemVNum == 1242) { return; } } session.Character.Inventory.RemoveItemFromInventory(inv.Id); if (hpLoad - session.Character.Hp < Hp) { session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(hpLoad - session.Character.Hp)); } else if (hpLoad - session.Character.Hp > Hp) { session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(Hp)); } session.Character.Mp += Mp; session.Character.Hp += Hp; if (session.Character.Mp > mpLoad) { session.Character.Mp = mpLoad; } if (session.Character.Hp > hpLoad) { session.Character.Hp = hpLoad; } if (ServerManager.Instance.ChannelId != 51 || session.Character.MapId == 130 || session.Character.MapId == 131) { if (inv.ItemVNum == 1242 || inv.ItemVNum == 5582) { if (session.CurrentMapInstance.IsPVP) { return; } session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(hpLoad - session.Character.Hp)); session.Character.Hp = hpLoad; } else if (inv.ItemVNum == 1243 || inv.ItemVNum == 5583) { if (session.CurrentMapInstance.IsPVP) { return; } session.Character.Mp = mpLoad; } else if (inv.ItemVNum == 1244 || inv.ItemVNum == 5584) { if (session.CurrentMapInstance.IsPVP) { return; } session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(hpLoad - session.Character.Hp)); session.Character.Hp = hpLoad; session.Character.Mp = mpLoad; } } session.SendPacket(session.Character.GenerateStat()); foreach (Mate mate in session.Character.Mates.Where(s => s.IsTeamMember)) { hpLoad = mate.MaxHp; mpLoad = mate.MaxMp; if ((mate.Hp == hpLoad && mate.Mp == mpLoad) || mate.Hp <= 0) { return; } if (hpLoad - mate.Hp < Hp) { session.CurrentMapInstance?.Broadcast(mate.GenerateRc(hpLoad - mate.Hp)); } else if (hpLoad - mate.Hp > Hp) { session.CurrentMapInstance?.Broadcast(mate.GenerateRc(Hp)); } mate.Mp += Mp; mate.Hp += Hp; if (mate.Mp > mpLoad) { mate.Mp = mpLoad; } if (mate.Hp > hpLoad) { mate.Hp = hpLoad; } if (ServerManager.Instance.ChannelId != 51 || session.Character.MapId == 130 || session.Character.MapId == 131) { if (inv.ItemVNum == 1242 || inv.ItemVNum == 5582) { if (session.CurrentMapInstance.IsPVP) { return; } session.CurrentMapInstance?.Broadcast( mate.GenerateRc(hpLoad - mate.Hp)); mate.Hp = hpLoad; } else if (inv.ItemVNum == 1243 || inv.ItemVNum == 5583) { if (session.CurrentMapInstance.IsPVP) { return; } mate.Mp = mpLoad; } else if (inv.ItemVNum == 1244 || inv.ItemVNum == 5584) { if (session.CurrentMapInstance.IsPVP) { return; } session.CurrentMapInstance?.Broadcast( mate.GenerateRc(hpLoad - mate.Hp)); mate.Hp = hpLoad; mate.Mp = mpLoad; } } session.SendPacket(mate.GenerateStatInfo()); } break; } }
/// <summary> /// Inform client(s) about the Packet. /// </summary> /// <param name="session">Session of the sender.</param> /// <param name="packet">The packet content to send.</param> /// <param name="receiver">The receiver(s) of the Packet.</param> public void BroadCast(ClientSession session, string packet, ReceiverType receiver) { QueuePacket(new MapPacket(session, packet, receiver)); }
public UselessPacketHandler(ClientSession session) { _session = session; }
public WorldPacketHandler(ClientSession session) { _session = session; }
public MapPacket(ClientSession session, string content, ReceiverType receiver) { Session = session; Content = content; Receiver = receiver; }
private bool BuyValidate(ClientSession clientSession, KeyValuePair<long, MapShop> shop, short slot, byte amount) { if (!clientSession.HasCurrentMap) { return false; } PersonalShopItem shopitem = clientSession.CurrentMap.UserShops[shop.Key].Items.FirstOrDefault(i => i.ShopSlot.Equals(slot)); if (shopitem == null) { return false; } Guid id = shopitem.ItemInstance.Id; ClientSession shopOwnerSession = ServerManager.Instance.GetSessionByCharacterId(shop.Value.OwnerId); if (shopOwnerSession == null) { return false; } if (amount > shopitem.SellAmount) { amount = shopitem.SellAmount; } shopOwnerSession.Character.Gold += shopitem.Price * amount; shopOwnerSession.SendPacket(shopOwnerSession.Character.GenerateGold()); shopOwnerSession.SendPacket(shopOwnerSession.Character.GenerateShopMemo(1, String.Format(Language.Instance.GetMessageFromKey("BUY_ITEM"), Session.Character.Name, shopitem.ItemInstance.Item.Name, amount))); clientSession.CurrentMap.UserShops[shop.Key].Sell += shopitem.Price * amount; if (shopitem.ItemInstance.Type != InventoryType.Equipment) { // remove sold amount of items shopOwnerSession.Character.Inventory.RemoveItemAmountFromInventory(amount, id); // remove sold amount from sellamount shopitem.SellAmount -= amount; } else { // remove equipment shopOwnerSession.Character.Inventory.Remove(shopitem.ItemInstance.Id); // send empty slot to owners inventory shopOwnerSession.SendPacket(shopOwnerSession.Character.GenerateInventoryAdd(-1, 0, shopitem.ItemInstance.Type, shopitem.ItemInstance.Slot, 0, 0, 0, 0)); // remove the sell amount shopitem.SellAmount = 0; } // remove item from shop if the amount the user wanted to sell has been sold if (shopitem.SellAmount == 0) { clientSession.CurrentMap.UserShops[shop.Key].Items.Remove(shopitem); } // update currently sold item shopOwnerSession.SendPacket($"sell_list {shop.Value.Sell} {slot}.{amount}.{shopitem.SellAmount}"); // end shop if (!clientSession.CurrentMap.UserShops[shop.Key].Items.Any(s => s.SellAmount > 0)) { shopOwnerSession.Character.CloseShop(); } return true; }
public void JoinGroup(ClientSession session) { session.Character.Group = this; session.Character.LastGroupJoin = DateTime.Now; Characters.Add(session); }
public MapItem PutItem(ClientSession Session, short type, short slot, short amount, out Inventory inv) { Random rnd = new Random(); int random = 0; inv = Session.Character.InventoryList.LoadBySlotAndType(slot, type); MapItem DroppedItem = null; if (amount <= inv.InventoryItem.Amount) { DroppedItem = new MapItem((short)(rnd.Next(Session.Character.MapX - 2, Session.Character.MapX + 3)), (short)(rnd.Next(Session.Character.MapY - 2, Session.Character.MapY + 3))) { Amount = amount, Color = inv.InventoryItem.Color, Concentrate = inv.InventoryItem.Concentrate, CriticalLuckRate = inv.InventoryItem.CriticalLuckRate, CriticalRate = inv.InventoryItem.CriticalRate, DamageMaximum = inv.InventoryItem.DamageMaximum, DamageMinimum = inv.InventoryItem.DamageMinimum, DarkElement = inv.InventoryItem.DarkElement, DistanceDefence = inv.InventoryItem.DistanceDefence, DefenceDodge = inv.InventoryItem.DefenceDodge, DistanceDefenceDodge = inv.InventoryItem.DistanceDefenceDodge, ElementRate = inv.InventoryItem.ElementRate, FireElement = inv.InventoryItem.FireElement, HitRate = inv.InventoryItem.HitRate, WaterElement = inv.InventoryItem.WaterElement, SlHit = inv.InventoryItem.SlHit, ItemVNum = inv.InventoryItem.ItemVNum, LightElement = inv.InventoryItem.LightElement, MagicDefence = inv.InventoryItem.MagicDefence, RangeDefence = inv.InventoryItem.RangeDefence, Rare = inv.InventoryItem.Rare, SlDefence = inv.InventoryItem.SlDefence, SlElement = inv.InventoryItem.SlElement, SlHP = inv.InventoryItem.SlHP, Upgrade = inv.InventoryItem.Upgrade }; while (Session.CurrentMap.DroppedList.ContainsKey(random = rnd.Next(1, 999999))) { } DroppedItem.InventoryItemId = random; Session.CurrentMap.DroppedList.Add(random, DroppedItem); inv.InventoryItem.Amount = (short)(inv.InventoryItem.Amount - amount); Session.Character.InventoryList.InsertOrUpdate(ref inv); } return DroppedItem; }
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 RarifyItem(ClientSession session, RarifyMode mode, RarifyProtection protection, bool isCommand = false) { double raren2 = 80; double raren1 = 70; double rare0 = 60; double rare1 = 40; double rare2 = 30; double rare3 = 15; double rare4 = 10; double rare5 = 5; double rare6 = 3; double rare7 = 2; double rare8 = 1; const short goldprice = 500; const double reducedpricefactor = 0.5; const double reducedchancefactor = 1.1; const byte cella = 5; const int cellaVnum = 1014; const int scrollVnum = 1218; double rnd; if (session != null && !session.HasCurrentMapInstance) { return; } if (mode != RarifyMode.Drop || Item.ItemType == ItemType.Shell) { raren2 = 0; raren1 = 0; rare0 = 0; rnd = ServerManager.Instance.RandomNumber(0, 80); } else { rnd = ServerManager.Instance.RandomNumber(0, 1000) / 10D; } if (protection == RarifyProtection.RedAmulet) { raren2 = raren1 * reducedchancefactor; raren1 = raren1 * reducedchancefactor; rare0 = rare0 * reducedchancefactor; rare1 = rare1 * reducedchancefactor; rare2 = rare2 * reducedchancefactor; rare3 = rare3 * reducedchancefactor; rare4 = rare4 * reducedchancefactor; rare5 = rare5 * reducedchancefactor; rare6 = rare6 * reducedchancefactor; rare7 = rare7 * reducedchancefactor; rare8 = rare8 * reducedchancefactor; } if (session != null) { switch (mode) { case RarifyMode.Free: break; case RarifyMode.Reduced: // TODO: Reduced Item Amount if (session.Character.Gold < (long)(goldprice * reducedpricefactor)) { return; } if (session.Character.Inventory.CountItem(cellaVnum) < cella * reducedpricefactor) { return; } session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella * reducedpricefactor)); session.Character.Gold -= (long)(goldprice * reducedpricefactor); session.SendPacket(session.Character.GenerateGold()); break; case RarifyMode.Normal: // TODO: Normal Item Amount if (session.Character.Gold < goldprice) { return; } if (session.Character.Inventory.CountItem(cellaVnum) < cella) { return; } if (protection == RarifyProtection.Scroll && !isCommand && session.Character.Inventory.CountItem(scrollVnum) < 1) { return; } if (protection == RarifyProtection.Scroll && !isCommand) { session.Character.Inventory.RemoveItemAmount(scrollVnum); session.SendPacket("shop_end 2"); } session.Character.Gold -= goldprice; session.Character.Inventory.RemoveItemAmount(cellaVnum, cella); session.SendPacket(session.Character.GenerateGold()); break; case RarifyMode.Drop: break; default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } } if (Item.IsHeroic && protection == RarifyProtection.Scroll) { if (rnd < rare8 && !(protection == RarifyProtection.Scroll && Rare >= 8)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(8); } Rare = 8; SetRarityPoint(); ItemInstance inventory = session?.Character.Inventory.GetItemInstanceById(Id); if (inventory != null) { session.SendPacket(inventory.GenerateInventoryAdd()); } return; } } if (rnd < rare7 && !(protection == RarifyProtection.Scroll && Rare >= 7)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(7); } Rare = 7; SetRarityPoint(); } else if (rnd < rare6 && !(protection == RarifyProtection.Scroll && Rare >= 6)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(6); } Rare = 6; SetRarityPoint(); } else if (rnd < rare5 && !(protection == RarifyProtection.Scroll && Rare >= 5)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(5); } Rare = 5; SetRarityPoint(); } else if (rnd < rare4 && !(protection == RarifyProtection.Scroll && Rare >= 4)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(4); } Rare = 4; SetRarityPoint(); } else if (rnd < rare3 && !(protection == RarifyProtection.Scroll && Rare >= 3)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(3); } Rare = 3; SetRarityPoint(); } else if (rnd < rare2 && !(protection == RarifyProtection.Scroll && Rare >= 2)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(2); } Rare = 2; SetRarityPoint(); } else if (rnd < rare1 && !(protection == RarifyProtection.Scroll && Rare >= 1)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(1); } Rare = 1; SetRarityPoint(); } else if (rnd < rare0 && !(protection == RarifyProtection.Scroll && Rare >= 0)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(0); } Rare = 0; SetRarityPoint(); } else if (rnd < raren1 && !(protection == RarifyProtection.Scroll && Rare >= -1)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(-1); } Rare = -1; SetRarityPoint(); } else if (rnd < raren2 && !(protection == RarifyProtection.Scroll && Rare >= -2)) { if (mode != RarifyMode.Drop) { session?.Character.NotifyRarifyResult(-2); } Rare = -2; SetRarityPoint(); } else { if (mode != RarifyMode.Drop && session != null) { if (protection == RarifyProtection.None) { session.Character.DeleteItemByItemInstanceId(Id); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0)); } else { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11)); session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0)); session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY); } } } if (mode != RarifyMode.Drop && session != null) { ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id); if (inventory != null) { session.SendPacket(inventory.GenerateInventoryAdd()); } } }
public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null) { if (Effect == 0) { if (EffectValue != 0) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.SendPacket(session.Character.GenerateRest()); } session.SendPacket(session.Character.GenerateGuri(12, 1, EffectValue)); } else if (EffectValue == 0) { if (packetsplit != null) { byte TypeEquip = 0; short SlotEquip = -1; if (byte.TryParse(packetsplit[8], out TypeEquip) && short.TryParse(packetsplit[9], out SlotEquip)) { if (session.Character.IsSitting) { session.Character.IsSitting = false; session.SendPacket(session.Character.GenerateRest()); } if (delay) { bool isUsed = false; switch (inv.ItemVNum) { case 1219: WearableInstance equip = session.Character.Inventory.LoadBySlotAndType<WearableInstance>(SlotEquip, (Domain.InventoryType)TypeEquip); if (equip != null && equip.IsFixed) { equip.IsFixed = false; session.SendPacket(session.Character.GenerateEff(3003)); session.SendPacket(session.Character.GenerateGuri(17, 1, SlotEquip)); session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_UNFIXED"), 12)); isUsed = true; } break; case 1365: case 9039: SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType<SpecialistInstance>(SlotEquip, (Domain.InventoryType)TypeEquip); if (specialist != null && specialist.Rare == -2) { specialist.Rare = 0; session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SP_RESURRECTED"), 0)); session.CurrentMap?.Broadcast(session.Character.GenerateGuri(13, 1, 1), session.Character.MapX, session.Character.MapY); session.Character.SpPoint = 10000; if (session.Character.SpPoint > 10000) { session.Character.SpPoint = 10000; } session.SendPacket(session.Character.GenerateSpPoint()); session.SendPacket(session.Character.GenerateInventoryAdd(specialist.ItemVNum, 1, (Domain.InventoryType)TypeEquip, SlotEquip, specialist.Rare, specialist.Design, specialist.Upgrade, 0)); isUsed = true; } break; } switch (inv.ItemVNum) { case 9039: SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType<SpecialistInstance>(SlotEquip, (Domain.InventoryType)TypeEquip); if (specialist != null && specialist.Rare == -2) { specialist.Rare = 0; session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SP_RESURRECTED"), 0)); session.CurrentMap?.Broadcast(session.Character.GenerateGuri(13, 1, 1), session.Character.MapX, session.Character.MapY); session.Character.SpPoint = 10000; session.SendPacket(session.Character.GenerateSpPoint()); session.SendPacket(session.Character.GenerateInventoryAdd(specialist.ItemVNum, 1, (Domain.InventoryType)TypeEquip, SlotEquip, specialist.Rare, specialist.Design, specialist.Upgrade, 0)); isUsed = true; } break; } if (!isUsed) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_NOT_FIXED"), 11)); } else { session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id); } } else { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^0^1^{TypeEquip}^{SlotEquip} {Language.Instance.GetMessageFromKey("QNA_ITEM")}"); } } } } } else { Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString())); } }
public MapItem PutItem(InventoryType type, short slot, byte amount, ref ItemInstance inv, ClientSession session) { Logger.LogUserEventDebug("PUTITEM", session.GenerateIdentity(), $"type: {type} slot: {slot} amount: {amount}"); Guid random2 = Guid.NewGuid(); MapItem droppedItem = null; List <GridPos> possibilities = new List <GridPos>(); for (short x = -2; x < 3; x++) { for (short y = -2; y < 3; y++) { possibilities.Add(new GridPos { X = x, Y = y }); } } short mapX = 0; short mapY = 0; bool niceSpot = false; foreach (GridPos possibility in possibilities.OrderBy(s => _random.Next())) { mapX = (short)(session.Character.PositionX + possibility.X); mapY = (short)(session.Character.PositionY + possibility.Y); if (!Map.IsBlockedZone(mapX, mapY)) { niceSpot = true; break; } } if (niceSpot && amount > 0 && amount <= inv.Amount) { ItemInstance newItemInstance = inv.DeepCopy(); newItemInstance.Id = random2; newItemInstance.Amount = amount; droppedItem = new CharacterMapItem(mapX, mapY, newItemInstance); DroppedList[droppedItem.TransportId] = droppedItem; inv.Amount -= amount; } return(droppedItem); }