private void ExecuteHandler(ClientSession session) => session.SendPacket(UserInterfaceHelper.GenerateFrank(Type));
internal static void GenerateTalentArena() { long groupid = 0; int seconds = 0; IDisposable obs = Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(start2 => { lock (ServerManager.Instance.ArenaMembers) { ServerManager.Instance.ArenaMembers.ToList().Where(s => s.ArenaType == EventType.TALENTARENA).ToList().ForEach(s => { s.Time -= 1; List <long> groupids = new List <long>(); ServerManager.Instance.ArenaMembers.ToList().Where(o => o.GroupId != null).ToList().ForEach(o => { if (ServerManager.Instance.ArenaMembers.ToList().Count(g => g.GroupId == o.GroupId) != 3) { return; } if (o.GroupId != null) { groupids.Add(o.GroupId.Value); } }); if (s.Time > 0) { if (s.GroupId == null) { List <ArenaMember> members = ServerManager.Instance.ArenaMembers.ToList() .Where(e => e.Session != s.Session && e.ArenaType == EventType.TALENTARENA && e.Session.Character.Level <= s.Session.Character.Level + 5 && e.Session.Character.Level >= s.Session.Character.Level - 5).ToList(); members.RemoveAll(o => o.GroupId != null && groupids.Contains(o.GroupId.Value)); ArenaMember member = members.FirstOrDefault(); if (member == null) { return; } else { if (member.GroupId == null) { groupid++; member.GroupId = groupid; } s.GroupId = member.GroupId; ServerManager.Instance.ArenaMembers.ToList().Where(e => e.ArenaType == EventType.TALENTARENA && e.GroupId == member.GroupId).ToList().ForEach(o => { o.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 2, -1, 6)); o.Session.SendPacket(o.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ARENA_TEAM_FOUND"), 10)); Observable.Timer(TimeSpan.FromSeconds(1)).Subscribe(time => { s.Time = 300; if (ServerManager.Instance.ArenaMembers.ToList().Count(g => g.GroupId == s.GroupId) < 3) { o.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(0, 2, s.Time, 8)); o.Session.SendPacket(o.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SEARCH_ARENA_TEAM"), 10)); } else { o.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(0, 2, s.Time, 1)); o.Session.SendPacket(o.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SEARCH_RIVAL_ARENA_TEAM"), 10)); } }); }); } } else { if (ServerManager.Instance.ArenaMembers.ToList().Count(g => g.GroupId == s.GroupId) != 3) { return; } ArenaMember member = ServerManager.Instance.ArenaMembers.ToList().FirstOrDefault(o => o.GroupId != null && o.GroupId != s.GroupId && groupids.Contains(o.GroupId.Value) && o.Session.Character.Level <= s.Session.Character.Level + 5 && o.Session.Character.Level >= s.Session.Character.Level - 5); if (member == null) { return; } MapInstance map = ServerManager.GenerateMapInstance(2015, MapInstanceType.TalentArenaMapInstance, new InstanceBag()); map.IsPVP = true; ConcurrentBag <ArenaTeamMember> arenaTeam = new ConcurrentBag <ArenaTeamMember>(); ServerManager.Instance.ArenaTeams.Add(arenaTeam); ArenaMember[] arenamembers = ServerManager.Instance.ArenaMembers.ToList().Where(o => o.GroupId == member.GroupId || o.GroupId == s.GroupId).OrderBy(o => o.GroupId) .ToArray(); for (int i = 0; i < 6; i++) { ItemInstance item = Inventory.InstantiateItemInstance((short)(4433 + (i > 2 ? 5 - i : i)), member.Session.Character.CharacterId); item.Design = (short)(4433 + (i > 2 ? 5 - i : i)); map.MapDesignObjects.Add(new MapDesignObject { ItemInstance = item, ItemInstanceId = item.Id, CharacterId = member.Session.Character.CharacterId, MapX = (short)(i > 2 ? 120 : 19), MapY = (short)(i > 2 ? 35 + i % 3 * 4 : 36 + i % 3 * 4) }); } map.InstanceBag.Clock.TotalSecondsAmount = 60; map.InstanceBag.Clock.SecondsRemaining = 600; map.InstanceBag.Clock.StartClock(); IDisposable obs4 = null; IDisposable obs2 = null; IDisposable obs3 = null; IDisposable obs6 = null; bool WinLoseMsgSent = false; Observable.Timer(TimeSpan.FromSeconds(5)).Subscribe(time2 => { obs3 = Observable.Interval(TimeSpan.FromSeconds(5)).Subscribe(effect => { arenamembers.Where(c => !c.Session.Character.Invisible).ToList().ForEach(o => map.Broadcast(o.Session.Character.GenerateEff(o.GroupId == s.GroupId ? 3012 : 3013))); }); }); IDisposable obs5 = Observable.Interval(TimeSpan.FromMilliseconds(500)).Subscribe(start3 => { map.Broadcast(arenamembers.FirstOrDefault(o => o.Session != null)?.Session.Character.GenerateTaPs()); List <ArenaTeamMember> erenia = arenaTeam.Replace(team => team.ArenaTeamType == ArenaTeamType.ERENIA).ToList(); List <ArenaTeamMember> zenas = arenaTeam.Replace(team => team.ArenaTeamType == ArenaTeamType.ZENAS).ToList(); BuffTeam(erenia); BuffTeam(zenas); }); arenamembers.ToList().ForEach(o => { o.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(0, 2, s.Time, 2)); o.Session.SendPacket(o.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RIVAL_ARENA_TEAM_FOUND"), 10)); Observable.Timer(TimeSpan.FromSeconds(1)).Subscribe(time => { o.Session.SendPacket("ta_close"); Observable.Timer(TimeSpan.FromSeconds(5)).Subscribe(time2 => { if (o.Session.Character.IsVehicled) { o.Session.Character.RemoveVehicle(); } Group grp = o.Session.Character.Group; if (grp != null) { grp.LeaveGroup(o.Session); } o.Session.Character.Mates.Where(m => m.IsTeamMember).ToList().ForEach(m => m.BackToMiniland()); o.Session.Character.GeneralLogs.Add(new GeneralLogDTO { AccountId = o.Session.Account.AccountId, CharacterId = o.Session.Character.CharacterId, IpAddress = o.Session.IpAddress, LogData = "Entry", LogType = "TalentArena", Timestamp = DateTime.Now }); List <BuffType> bufftodisable = new List <BuffType> { BuffType.Bad, BuffType.Good, BuffType.Neutral }; o.Session.Character.DisableBuffs(bufftodisable); int i = Array.IndexOf(arenamembers, o) + 1; o.Session.Character.Hp = (int)o.Session.Character.HPLoad(); o.Session.Character.Mp = (int)o.Session.Character.MPLoad(); ServerManager.Instance.ChangeMapInstance(o.Session.Character.CharacterId, map.MapInstanceId, o.GroupId == member.GroupId ? 125 : 14, (o.GroupId == member.GroupId ? 37 : 38) + i % 3 * 2); o.Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SELECT_ORDER_ARENA_TIME"), 0)); o.Session.SendPacket(o.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SELECT_ORDER_ARENA_TIME"), 10)); o.Session.SendPacket(o.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SELECT_ORDER_ARENA"), 10)); o.Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SELECT_ORDER_ARENA"), 0)); o.Session.SendPacket(o.Session.Character.GenerateTaM(0)); o.Session.SendPacket("ta_sv 0"); o.Session.SendPacket(UserInterfaceHelper.Instance.GenerateTaSt(TalentArenaOptionType.Watch)); o.Session.SendPacket(o.Session.Character.GenerateTaM(3)); o.Session.SendPacket(o.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(o.GroupId == s.GroupId ? "ZENAS" : "ERENIA"), 10)); arenaTeam.Add(new ArenaTeamMember(o.Session, o.GroupId == s.GroupId ? ArenaTeamType.ZENAS : ArenaTeamType.ERENIA, null)); o.Session.SendPacket(o.Session.Character.GenerateTaP(0, false)); obs2 = Observable.Interval(TimeSpan.FromMilliseconds(100)).Subscribe(start3 => { bool resettap = false; map.MapDesignObjects.ToList().ForEach(e => { if (e.ItemInstance.Design >= 4433 && e.ItemInstance.Design <= 4435) { Character chara = map.GetCharactersInRange(e.MapX, e.MapY, 0).FirstOrDefault(); if (chara != null) { resettap = true; ArenaTeamMember teammember = arenaTeam.FirstOrDefault(at => at.Session == chara.Session); if (teammember != null && !arenaTeam.Any(at => at.Order == (e.ItemInstance.ItemVNum - 4433) && at.ArenaTeamType == (e.MapX == 120 ? ArenaTeamType.ERENIA : ArenaTeamType.ZENAS))) { if (teammember.Order != null) { MapDesignObject obj = map.MapDesignObjects.FirstOrDefault(mapobj => mapobj.ItemInstance.ItemVNum == e.ItemInstance.ItemVNum && e.MapX == (teammember.ArenaTeamType == ArenaTeamType.ERENIA ? 120 : 19)); if (obj != null) { obj.ItemInstance.Design = obj.ItemInstance.ItemVNum; } } teammember.Order = (byte)(e.ItemInstance.ItemVNum - 4433); } } } else if (e.ItemInstance.Design == 4436) { if (!map.GetCharactersInRange(e.MapX, e.MapY, 0).Any()) { resettap = true; ArenaTeamMember teammember = arenaTeam.FirstOrDefault(at => at.Order == (e.ItemInstance.ItemVNum - 4433) && at.ArenaTeamType == (e.MapX == 120 ? ArenaTeamType.ERENIA : ArenaTeamType.ZENAS)); if (teammember != null) { teammember.Order = null; } } } if (!arenaTeam.Any(at => at.Order == (e.ItemInstance.ItemVNum - 4433) && at.ArenaTeamType == (e.MapX == 120 ? ArenaTeamType.ERENIA : ArenaTeamType.ZENAS))) { if (e.ItemInstance.Design != 4436) { return; } e.ItemInstance.Design = e.ItemInstance.ItemVNum; map.Broadcast(e.GenerateEffect(false)); } else if (e.ItemInstance.Design != 4436) { e.ItemInstance.Design = 4436; map.Broadcast(e.GenerateEffect(false)); } }); if (resettap) { arenaTeam.ToList().ForEach(arenauser => { arenauser.Session.SendPacket(arenauser.Session.Character.GenerateTaP(2, false)); }); } }); }); }); }); Observable.Timer(TimeSpan.FromSeconds(map.InstanceBag.Clock.TotalSecondsAmount)).Subscribe(start => { obs2.Dispose(); arenaTeam.ToList().ForEach(arenauser => { if (arenauser.Order == null) { for (byte x = 0; x < 3; x++) { if (!arenaTeam.Any(at => at.ArenaTeamType == arenauser.ArenaTeamType && at.Order == x)) { arenauser.Order = x; } } } arenauser.Session.SendPacket($"ta_pn {arenauser.Order + 1}"); }); map.MapDesignObjects.ToList().ForEach(md => map.Broadcast(md.GenerateEffect(true))); map.MapDesignObjects.Clear(); arenaTeam.ToList().ForEach(arenauser => arenauser.Session.SendPacket(arenauser.Session.Character.GenerateTaP(2, true))); bool newround1 = true; bool newround2 = true; int count1 = 0; int count2 = 0; IDisposable obs7 = obs4; ArenaTeamMember beforetm = null; ArenaTeamMember beforetm2 = null; obs4 = Observable.Interval(TimeSpan.FromMilliseconds(500)).Subscribe(start3 => { int ereniacount = arenaTeam.Count(at => at.Dead && at.ArenaTeamType == ArenaTeamType.ERENIA); int zenascount = arenaTeam.Count(at => at.Dead && at.ArenaTeamType == ArenaTeamType.ZENAS); if (ServerManager.Instance.ArenaTeams.ToList().Find(a => a.Any(b => arenaTeam.Contains(b))) is ConcurrentBag <ArenaTeamMember> updatedTeam) { arenaTeam = updatedTeam; } else { arenaTeam.Clear(); obs2.Dispose(); obs3.Dispose(); obs5.Dispose(); obs7?.Dispose(); map.Dispose(); ServerManager.Instance.ArenaMembers.RemoveAll(o => o.GroupId == member.GroupId || o.GroupId == s.GroupId); obs4.Dispose(); return; } if (count1 != ereniacount || count2 != zenascount) { if (count1 != ereniacount) { newround1 = true; } if (count2 != zenascount) { newround2 = true; } count1 = ereniacount; count2 = zenascount; } ArenaTeamMember tm = arenaTeam.OrderBy(tm3 => tm3.Order).FirstOrDefault(tm3 => tm3.ArenaTeamType == ArenaTeamType.ERENIA && !tm3.Dead); ArenaTeamMember tm2 = arenaTeam.OrderBy(tm3 => tm3.Order).FirstOrDefault(tm3 => tm3.ArenaTeamType == ArenaTeamType.ZENAS && !tm3.Dead); if (tm == beforetm && tm2 == beforetm2) { return; } else { if (tm != null) { beforetm = tm; } if (tm2 != null) { beforetm2 = tm2; } } if (!newround1 && !newround2 && tm != null && tm2 != null) { return; } int timeToWait = 0; try { timeToWait = tm?.Order == arenaTeam.OrderBy(tm3 => tm3.Order).FirstOrDefault(tm3 => tm3.ArenaTeamType == ArenaTeamType.ERENIA).Order&& tm2?.Order == arenaTeam.OrderBy(tm3 => tm3.Order).FirstOrDefault(tm3 => tm3.ArenaTeamType == ArenaTeamType.ZENAS).Order ? 0 : 3; } catch (Exception ex) { Logger.Error($"Talent Arena error: {ex}"); return; } map.InstanceBag.Clock.TotalSecondsAmount = 300 + timeToWait; map.InstanceBag.Clock.SecondsRemaining = 3000 + timeToWait * 10; arenaTeam.ToList().ForEach(friends => { friends.Session.SendPacket(friends.Session.Character.GenerateTaM(2)); friends.Session.SendPacket(friends.Session.Character.GenerateTaM(3)); }); map.Sessions.Except(arenaTeam.Select(ss => ss.Session)).ToList().ForEach(o => { o.SendPacket(tm2?.Session.Character.GenerateTaM(2)); o.SendPacket(tm2?.Session.Character.GenerateTaM(3)); }); obs6?.Dispose(); obs6 = Observable.Timer(TimeSpan.FromSeconds(map.InstanceBag.Clock.TotalSecondsAmount)).Subscribe(start4 => { if (tm2 != null && tm != null) { tm.Dead = true; tm2.Dead = true; tm.Session.Character.PositionX = 120; tm.Session.Character.PositionY = 39; tm2.Session.Character.PositionX = 19; tm2.Session.Character.PositionY = 40; map.Broadcast(tm2.Session, tm.Session.Character.GenerateTp()); map.Broadcast(tm2.Session, tm2.Session.Character.GenerateTp()); tm.Session.SendPacket(UserInterfaceHelper.Instance.GenerateTaSt(TalentArenaOptionType.Watch)); tm2.Session.SendPacket(UserInterfaceHelper.Instance.GenerateTaSt(TalentArenaOptionType.Watch)); List <BuffType> bufftodisable = new List <BuffType> { BuffType.Bad }; tm.Session.Character.DisableBuffs(bufftodisable); tm.Session.Character.Hp = (int)tm.Session.Character.HPLoad(); tm.Session.Character.Mp = (int)tm.Session.Character.MPLoad(); tm.Session.SendPacket(tm.Session.Character.GenerateStat()); tm2.Session.Character.DisableBuffs(bufftodisable); tm2.Session.Character.Hp = (int)tm2.Session.Character.HPLoad(); tm2.Session.Character.Mp = (int)tm2.Session.Character.MPLoad(); tm2.Session.SendPacket(tm2.Session.Character.GenerateStat()); arenaTeam.Replace(friends => friends.ArenaTeamType == tm.ArenaTeamType).ToList().ForEach(friends => { friends.Session.SendPacket(friends.Session.Character.GenerateTaFc(0)); }); } newround1 = true; newround2 = true; arenaTeam.ToList().ForEach(arenauser => { arenauser.Session.SendPacket(arenauser.Session.Character.GenerateTaP(2, true)); }); }); if (tm != null && tm2 != null) { map.IsPVP = false; arenaTeam.ToList().ForEach(friends => { friends.Session.SendPacket(friends.ArenaTeamType == ArenaTeamType.ERENIA ? tm.Session.Character.GenerateTaFc(0) : tm2.Session.Character.GenerateTaFc(0)); }); map.Sessions.Except(arenaTeam.Select(ss => ss.Session)).ToList().ForEach(ss => { ss.SendPacket(tm.Session.Character.GenerateTaFc(0)); ss.SendPacket(tm2.Session.Character.GenerateTaFc(1)); }); if (newround1) { Observable.Timer(TimeSpan.FromSeconds(timeToWait)).Subscribe(start5 => { map.Broadcast(tm.Session.Character.GenerateTaFc(1)); tm.Session.Character.PositionX = 87; tm.Session.Character.PositionY = 39; map.Broadcast(tm.Session, tm.Session.Character.GenerateTp()); }); } if (newround2) { Observable.Timer(TimeSpan.FromSeconds(timeToWait)).Subscribe(start5 => { tm2.Session.Character.PositionX = 56; tm2.Session.Character.PositionY = 40; map.Broadcast(tm2.Session, tm2.Session.Character.GenerateTp()); }); } Observable.Timer(TimeSpan.FromSeconds(timeToWait)).Subscribe(start5 => { arenaTeam.Replace(at => at.LastSummoned != null).ToList().ForEach(at => { at.LastSummoned = null; at.Session.Character.PositionX = at.ArenaTeamType == ArenaTeamType.ERENIA ? (short)120 : (short)19; at.Session.Character.PositionY = at.ArenaTeamType == ArenaTeamType.ERENIA ? (short)39 : (short)40; at.Session.CurrentMapInstance.Broadcast(at.Session.Character.GenerateTp()); at.Session.SendPacket(UserInterfaceHelper.Instance.GenerateTaSt(TalentArenaOptionType.Watch)); List <BuffType> bufftodisable = new List <BuffType> { BuffType.Bad }; at.Session.Character.DisableBuffs(bufftodisable); at.Session.Character.Hp = (int)at.Session.Character.HPLoad(); at.Session.Character.Mp = (int)at.Session.Character.MPLoad(); }); tm.Session.SendPacket(UserInterfaceHelper.Instance.GenerateTaSt(TalentArenaOptionType.Call)); tm2.Session.SendPacket(UserInterfaceHelper.Instance.GenerateTaSt(TalentArenaOptionType.Call)); map.Broadcast("ta_s"); Observable.Timer(TimeSpan.FromSeconds(5)).Subscribe(start4 => { map.IsPVP = true; }); }); } else { switch (tm) { case null when tm2 == null: if (!WinLoseMsgSent) { map.Broadcast(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQUALITY"), 0)); arenaTeam.ToList().ForEach(arenauser => { arenauser.Session.SendPacket(arenauser.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("EQUALITY"), 10)); arenauser.Session.SendPacket(arenauser.Session.Character.GenerateTaF(3)); }); map.Sessions.Except(arenamembers.Select(x => x.Session)).ToList().ForEach( x => { ArenaTeamMember arenauser = arenaTeam.FirstOrDefault(se => se.Session != null); if (arenauser == null) { return; } x.SendPacket(arenauser.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("EQUALITY"), 10)); x.SendPacket(arenauser.Session.Character.GenerateTaF(0)); } ); WinLoseMsgSent = true; } break; case null: if (!WinLoseMsgSent) { map.Broadcast(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("VICTORIOUS_ZENAS"), 0)); arenaTeam.ToList().ForEach(arenauser => { Observable.Timer(TimeSpan.FromSeconds(2)).Subscribe(WinZenas => { SendRewards(arenauser, arenauser.ArenaTeamType == ArenaTeamType.ZENAS); arenauser.Session.SendPacket(arenauser.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("VICTORIOUS_ZENAS"), 10)); arenauser.Session.SendPacket(arenauser.Session.Character.GenerateTaF(1)); }); }); WinLoseMsgSent = true; } break; default: if (!WinLoseMsgSent) { map.Broadcast(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("VICTORIOUS_ERENIA"), 0)); arenaTeam.ToList().ForEach(arenauser => { SendRewards(arenauser, arenauser.ArenaTeamType == ArenaTeamType.ERENIA); arenauser.Session.SendPacket(arenauser.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("VICTORIOUS_ERENIA"), 10)); arenauser.Session.SendPacket(arenauser.Session.Character.GenerateTaF(2)); }); WinLoseMsgSent = true; } break; } map.IsPVP = false; obs3.Dispose(); obs2.Dispose(); obs7?.Dispose(); obs5.Dispose(); Observable.Timer(TimeSpan.FromSeconds(5)).Subscribe(start4 => //Observable.Timer(TimeSpan.FromSeconds(30)).Subscribe(start4 => { arenaTeam.ToList().ForEach(o => { if (o.Session?.CurrentMapInstance?.MapInstanceType == MapInstanceType.TalentArenaMapInstance) { o.Session.Character.GetSkills().ForEach(c => c.LastUse = DateTime.Now.AddDays(-1)); o.Session.SendPacket(o.Session.Character.GenerateSki()); o.Session.SendPackets(o.Session.Character.GenerateQuicklist()); List <BuffType> bufftodisable = new List <BuffType> { BuffType.Bad }; o.Session.Character.DisableBuffs(bufftodisable); o.Session.Character.RemoveBuff(491); ServerManager.Instance.TeleportOnRandomPlaceInMap(o.Session, ServerManager.Instance.ArenaInstance.MapInstanceId); } }); map.Sessions.ToList().ForEach(sess => { if (sess.CurrentMapInstance?.MapInstanceType == MapInstanceType.TalentArenaMapInstance) { List <BuffType> bufftodisable = new List <BuffType> { BuffType.Bad }; sess.Character.DisableBuffs(bufftodisable); sess.Character.RemoveBuff(491); ServerManager.Instance.TeleportOnRandomPlaceInMap(sess, ServerManager.Instance.ArenaInstance.MapInstanceId); } }); map.Dispose(); }); } newround1 = false; newround2 = false; }); }); ServerManager.Instance.ArenaMembers.ToList().Where(o => o.GroupId == member.GroupId || o.GroupId == s.GroupId).ToList() .ForEach(se => { se.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(2, 2, 0, 0)); }); ServerManager.Instance.ArenaMembers.RemoveAll(o => o.GroupId == member.GroupId || o.GroupId == s.GroupId); } } else { if (s.GroupId == null) { if (s.Time != -1) { s.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 2, s.Time, 7)); s.Session.SendPacket(s.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NO_TEAM_ARENA"), 10)); } s.Time = 300; s.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 2, s.Time, 5)); s.Session.SendPacket(s.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SEARCH_ARENA_TEAM"), 10)); } else if (ServerManager.Instance.ArenaMembers.ToList().Count(g => g.GroupId == s.GroupId) < 3) { s.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 2, -1, 4)); Observable.Timer(TimeSpan.FromSeconds(1)).Subscribe(time => { s.Time = 300; s.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 2, s.Time, 8)); s.Session.SendPacket(s.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RETRY_SEARCH_ARENA_TEAM"), 10)); }); } else { s.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(0, 2, -1, 3)); Observable.Timer(TimeSpan.FromSeconds(1)).Subscribe(time => { s.Time = 300; s.Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(0, 2, s.Time, 1)); s.Session.SendPacket(s.Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SEARCH_RIVAL_ARENA_TEAM"), 10)); }); } } }); seconds++; } }); CommunicationServiceClient.Instance.SendMessageToCharacter(new SCSCharacterMessage { SourceWorldId = ServerManager.Instance.WorldId, Message = UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("TALENT_ARENA_OPENED"), ServerManager.Instance.ChannelId), 0), Type = MessageType.Broadcast }); //Observable.Timer(TimeSpan.FromHours(7)).Subscribe(start2 => //{ // ServerManager.Instance.StartedEvents.Remove(EventType.TALENTARENA); // obs.Dispose(); //}); }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { switch (Effect) { default: Mate mate = null; if (Option != 0) { mate = session.Character.Mates.Find(s => s.MateType == MateType.Partner && s.PetId == Option - 1); } short slot = inv.Slot; InventoryType equipment = InventoryType.Wear; switch (Option) { case 1: equipment = InventoryType.FirstPartnerInventory; break; case 2: equipment = InventoryType.SecondPartnerInventory; break; case 3: equipment = InventoryType.ThirdPartnerInventory; break; } InventoryType itemToWearType = inv.Type; if (inv == null) { return; } if (ItemValidTime > 0 && !inv.IsBound) { inv.ItemDeleteTime = DateTime.Now.AddSeconds(ItemValidTime); } //if (!inv.IsBound) //{ // if (!delay && (EquipmentSlot == EquipmentType.Fairy && (MaxElementRate == 70 || MaxElementRate == 80) || EquipmentSlot == EquipmentType.CostumeHat || EquipmentSlot == EquipmentType.CostumeSuit || EquipmentSlot == EquipmentType.WeaponSkin)) // { // session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)itemToWearType}^{slot}^1 {Language.Instance.GetMessageFromKey("ASK_BIND")}"); // return; // } // if (delay) // { // inv.BoundCharacterId = session.Character.CharacterId; // } //} double timeSpanSinceLastSpUsage = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp; if (EquipmentSlot == EquipmentType.Sp && inv.Rare == -2) { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0)); return; } if (Option == 0) { if (EquipmentSlot == EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Specialist) != null) { session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0)); return; } if ((ItemType != ItemType.Weapon && ItemType != ItemType.Armor && ItemType != ItemType.Fashion && ItemType != ItemType.Jewelery && ItemType != ItemType.Specialist) || LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) || (ItemType != ItemType.Jewelery && EquipmentSlot != EquipmentType.Boots && EquipmentSlot != EquipmentType.Gloves && ((Class >> (byte)session.Character.Class) & 1) != 1)) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10)); return; } if (session.Character.UseSp) { if (session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, equipment) is ItemInstance sp && sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement) { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0)); return; } } if (session.Character.UseSp && EquipmentSlot == EquipmentType.Sp) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10)); return; } if (session.Character.JobLevel < LevelJobMinimum) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10)); return; } } else if (mate != null) { if (mate.Level < LevelMinimum) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10)); return; } switch (EquipmentSlot) { case EquipmentType.Armor: if (ItemSubType == 4) { mate.ArmorInstance = inv; break; } else { goto default; } case EquipmentType.MainWeapon: if (ItemSubType == 12) { mate.WeaponInstance = inv; break; } else { goto default; } case EquipmentType.Gloves: mate.GlovesInstance = inv; break; case EquipmentType.Boots: mate.BootsInstance = inv; break; case EquipmentType.Sp: if (ItemSubType == 4) { mate.SpInstance = inv; break; } else { goto default; } default: session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10)); return; } } if (inv.Type == InventoryType.FirstPartnerInventory) { return; } if ((ItemType != ItemType.Weapon && ItemType != ItemType.Armor && ItemType != ItemType.Fashion && ItemType != ItemType.Jewelery && ItemType != ItemType.Specialist) || LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) || (ItemType != ItemType.Jewelery && EquipmentSlot != EquipmentType.Boots && EquipmentSlot != EquipmentType.Gloves && EquipmentSlot != EquipmentType.Wings && ((Class >> (byte)session.Character.Class) & 1) != 1)) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10)); return; } ItemInstance currentlyEquippedItem = session.Character.Inventory.LoadBySlotAndType((short)EquipmentSlot, equipment); if (currentlyEquippedItem == null) { // move from equipment to wear session.Character.Inventory.MoveInInventory(inv.Slot, itemToWearType, equipment); session.SendPacket(UserInterfaceHelper.Instance.GenerateInventoryRemove(itemToWearType, slot)); } else { Logger.LogUserEvent("EQUIPMENT_TAKEOFF", session.GenerateIdentity(), $"IIId: {currentlyEquippedItem.Id} ItemVnum: {currentlyEquippedItem.ItemVNum} Upgrade: {currentlyEquippedItem.Upgrade} Rare: {currentlyEquippedItem.Rare}"); // move from wear to equipment and back session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, equipment, itemToWearType, inv.Slot); session.SendPacket(currentlyEquippedItem.GenerateInventoryAdd()); session.Character.EquipmentBCards.RemoveAll(o => o.ItemVNum == currentlyEquippedItem.ItemVNum); } Logger.LogUserEvent("EQUIPMENT_WEAR", session.GenerateIdentity(), $"IIId: {inv.Id} ItemVnum: {inv.ItemVNum} Upgrade: {inv.Upgrade} Rare: {inv.Rare} itemtype: {inv.Type} InventorySlot: {inv.Slot}"); session.Character.EquipmentBCards.AddRange(inv.Item.BCards); switch (inv.Item.ItemType) { case ItemType.Armor: session.Character.ShellEffectArmor.Clear(); foreach (ShellEffectDTO dto in inv.ShellEffects) { session.Character.ShellEffectArmor.Add(dto); } break; case ItemType.Weapon: switch (inv.Item.EquipmentSlot) { case EquipmentType.MainWeapon: session.Character.ShellEffectMain.Clear(); foreach (ShellEffectDTO dto in inv.ShellEffects) { session.Character.ShellEffectMain.Add(dto); } break; case EquipmentType.SecondaryWeapon: session.Character.ShellEffectSecondary.Clear(); foreach (ShellEffectDTO dto in inv.ShellEffects) { session.Character.ShellEffectSecondary.Add(dto); } break; } break; } if (Option == 0) { session.SendPacket(session.Character.GenerateStatChar()); session.CurrentMapInstance?.Broadcast(session.Character.GenerateEq()); session.SendPacket(session.Character.GenerateEquipment()); session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy()); if (EquipmentSlot == EquipmentType.Fairy) { Logger.Log.Info("test"); ItemInstance fairy = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Fairy, equipment); session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXPData(fairy.ElementRate + fairy.Item.ElementRate)), 10)); } if (EquipmentSlot == EquipmentType.Amulet) { session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 39)); inv.BoundCharacterId = session.Character.CharacterId; } } else if (mate != null) { session.SendPacket(mate.GenerateScPacket()); } break; } }
public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null) { switch (Effect) { // Shell 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 (inv.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; //Bank case 10066: if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance) { return; } session.Character.OpenBank(); session.Character.Inventory.RemoveItemFromInventory(inv.Id); return; case 10541: 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; } if (inv.Item.VNum == 2188 /* LoD Teleport Scroll */) { session.Character.Inventory.RemoveItemAmount(inv.Item.VNum); ServerManager.Instance.ChangeMap(session.Character.CharacterId, 98, (short)ServerManager.RandomNumber(12, 18), (short)ServerManager.RandomNumber(18, 24)); 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 (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, 50 - (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, 50 - (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)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } 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; //Fresh dye 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; //Speedbooster case 9011: if (!session.Character.Buff.ContainsKey(336)) { session.Character.Inventory.RemoveItemFromInventory(inv.Id); session.Character.AddStaticBuff(new StaticBuffDTO { CardId = 336 }); } else { session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0)); } break; //Teleport Vip shop case 9016: if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE_EC_KEY")}"); } else { ServerManager.Instance.ChangeMap(session.Character.CharacterId, 4200, 7, 13); session.SendPacket( session.Character.GenerateSay( Language.Instance.GetMessageFromKey("WELCOME_VIP_SHOP_MAP"), 0)); } break; //Haar Fix case 9021: session.Character.HairStyle = HairStyleType.Hair7; session.Character.Inventory.RemoveItemFromInventory(inv.Id); ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY, true); break; //Haar Fix case 9022: session.Character.HairStyle = HairStyleType.Hair6; session.Character.Inventory.RemoveItemFromInventory(inv.Id); ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY, true); break; //Pes Item ID: 2457 case 9030: session.SendPacket("wopen 41"); break; //Luinia case 9041: if (Option == 0) { session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE_LUINIA")}"); } else { session.CurrentMapInstance?.Broadcast( StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 647), session.Character.PositionX, session.Character.PositionY); Buff buff = new Buff(35, 10); session.Character.AddBuff(buff, true); session.SendPacket(session.Character.GenerateSay("Luinia la restauración fue utilizada.", 12)); session.Character.Inventory.RemoveItemFromInventory(inv.Id); } break; default: Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType())); break; } }
private void ExecuteHandler(ClientSession session) { SpinWait.SpinUntil(() => !ServerManager.Instance.InBazaarRefreshMode); BazaarItemDTO bz = DAOFactory.BazaarItemDAO.LoadById(BazaarId); if (bz != null) { ItemInstance itemInstance = new ItemInstance(DAOFactory.ItemInstanceDAO.LoadById(bz.ItemInstanceId)); if (bz.SellerId != session.Character.CharacterId) { return; } int solddamount = bz.Amount - itemInstance.Amount; long taxes = bz.MedalUsed ? 0 : (long)(bz.Price * 0.10 * solddamount); long price = (bz.Price * solddamount) - taxes; if (session.Character.Inventory.CanAddItem(itemInstance.ItemVNum)) { if (session.Character.Gold + price <= ServerManager.Instance.Configuration.MaxGold) { session.Character.Gold += price; session.SendPacket(session.Character.GenerateGold()); session.SendPacket(session.Character.GenerateSay( string.Format(Language.Instance.GetMessageFromKey("REMOVE_FROM_BAZAAR"), price), 10)); // Edit this soo we dont generate new guid every single time we take something out. if (itemInstance.Amount != 0) { ItemInstance newBz = itemInstance.DeepCopy(); newBz.Id = Guid.NewGuid(); newBz.Type = newBz.Item.Type; session.Character.Inventory.AddToInventory(newBz); } session.SendPacket( $"rc_scalc 1 {bz.Price} {bz.Amount - itemInstance.Amount} {bz.Amount} {taxes} {price + taxes}"); GameLogger.Instance.LogBazaarRemove(ServerManager.Instance.ChannelId, session.Character.Name, session.Character.CharacterId, bz, itemInstance, price, taxes); if (DAOFactory.BazaarItemDAO.LoadById(bz.BazaarItemId) != null) { DAOFactory.BazaarItemDAO.Delete(bz.BazaarItemId); } DAOFactory.ItemInstanceDAO.Delete(itemInstance.Id); ServerManager.Instance.BazaarRefresh(bz.BazaarItemId); } else { session.SendPacket( UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("MAX_GOLD"), 0)); session.SendPacket($"rc_scalc 1 {bz.Price} 0 {bz.Amount} 0 0"); } } else { session.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"))); session.SendPacket($"rc_scalc 1 {bz.Price} 0 {bz.Amount} 0 0"); } } else { session.SendPacket("rc_scalc 1 0 0 0 0 0"); } }
private void spreadBroadcastpacket(BroadcastPacket sentPacket) { if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet)) { switch (sentPacket.Receiver) { case ReceiverType.All: // send packet to everyone if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture)) { foreach (ClientSession session in Sessions.Where(s => s.Character == null || !s.Character.IsChangingMapInstance)) { if (session.HasSelectedCharacter) { if (sentPacket.Sender != null) { if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId)) { session.SendPacket(sentPacket.Packet); } } else { session.SendPacket(sentPacket.Packet); } } } } else { Parallel.ForEach(Sessions, session => { if (session?.HasSelectedCharacter == true) { if (sentPacket.Sender != null) { if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId) || sentPacket.Packet.StartsWith("revive", StringComparison.CurrentCulture)) { session.SendPacket(sentPacket.Packet); } } else { session.SendPacket(sentPacket.Packet); } } }); } break; case ReceiverType.AllExceptMe: // send to everyone except the sender if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture)) { foreach (ClientSession session in Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance))) { if (session.HasSelectedCharacter) { if (sentPacket.Sender != null) { //if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId)) { session.SendPacket(sentPacket.Packet); } } else { session.SendPacket(sentPacket.Packet); } } } } else { Parallel.ForEach(Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId), session => { if (session?.HasSelectedCharacter == true) { if (sentPacket.Sender != null) { if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId)) { session.SendPacket(sentPacket.Packet); } } else { session.SendPacket(sentPacket.Packet); } } }); } break; case ReceiverType.AllExceptGroup: if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture)) { foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance))) { if (session.HasSelectedCharacter) { if (sentPacket.Sender != null) { if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId)) { session.SendPacket(sentPacket.Packet); } } else { session.SendPacket(sentPacket.Packet); } } } } else { foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId && (s.Character?.Group == null || (s.Character?.Group?.GroupId != sentPacket.Sender?.Character?.Group?.GroupId)))) { if (session.HasSelectedCharacter && !sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId)) { session.SendPacket(sentPacket.Packet); } } } break; case ReceiverType.AllExceptMeAct4: // send to everyone except the sender(Act4) Parallel.ForEach(Sessions.Where(s => s.SessionId != sentPacket.Sender?.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance)), session => { if (session?.HasSelectedCharacter == true) { if (sentPacket.Sender != null) { if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId)) { if (session.Character.Faction == sentPacket.Sender.Character.Faction) { session.SendPacket(sentPacket.Packet); } else if (session.Account.Authority >= AuthorityType.TrialModerator /*|| session.Account.Authority == AuthorityType.Moderator*/) { string[] vals = sentPacket.Packet.Split(' '); if (vals[0] == "say" && vals[3] == "13") { vals[5] = $"[{sentPacket.Sender.Character.Faction}] {vals[5]}"; sentPacket.Packet = string.Join(" ", vals); } session.SendPacket(sentPacket.Packet); } } } else { session.SendPacket(sentPacket.Packet); } } }); break; case ReceiverType.AllInRange: // send to everyone which is in a range of 50x50 if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0) { Parallel.ForEach(Sessions.Where(s => s?.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate) == true && (s.Character == null || !s.Character.IsChangingMapInstance)), session => { if (session?.HasSelectedCharacter == true) { if (sentPacket.Sender != null) { if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId)) { session.SendPacket(sentPacket.Packet); } } else { session.SendPacket(sentPacket.Packet); } } }); } break; case ReceiverType.OnlySomeone: if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName)) { ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName); if (targetSession?.HasSelectedCharacter == true) { if (sentPacket.Sender != null) { if (!sentPacket.Sender.Character.IsBlockedByCharacter(targetSession.Character.CharacterId)) { targetSession.SendPacket(sentPacket.Packet); } else { sentPacket.Sender.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED"))); } } else { targetSession.SendPacket(sentPacket.Packet); } } } break; case ReceiverType.AllNoEmoBlocked: Parallel.ForEach(Sessions.Where(s => s?.Character.EmoticonsBlocked == false), session => { if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false) { session.SendPacket(sentPacket.Packet); } }); break; case ReceiverType.AllNoHeroBlocked: Parallel.ForEach(Sessions.Where(s => s?.Character.HeroChatBlocked == false), session => { if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false) { session.SendPacket(sentPacket.Packet); } }); break; case ReceiverType.Group: foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId)) { session.SendPacket(sentPacket.Packet); } break; case ReceiverType.Unknown: break; } } }
private void runRound(int number) { if (number == 6) { endEvent(); } int amount = 120 + (60 * number); int i = amount; while (i != 0) { spawnCircle(number); Thread.Sleep(60000 / amount); i--; } Thread.Sleep(5000); string round = ""; switch (number) { case 1: round = "first"; _map.Broadcast(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("TOURNAMENT_ROUND"), round), 0)); break; case 2: round = "second"; _map.Broadcast(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("TOURNAMENT_ROUND"), round), 0)); break; case 3: round = "three"; _map.Broadcast(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("TOURNAMENT_ROUND"), round), 0)); break; case 4: round = "fourth"; _map.Broadcast(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("TOURNAMENT_ROUND"), round), 0)); break; case 5: round = "ultimate"; _map.Broadcast(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("TOURNAMENT_ROUND"), round), 0)); break; } Thread.Sleep(5000); // Your dropped reward _map.DropItems(generateDrop(_map.Map, 1046, 20, 200 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 1030, 10, 3 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2282, 10, 3 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2514, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2515, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2516, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2517, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2518, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2519, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2520, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); _map.DropItems(generateDrop(_map.Map, 2521, 5, 1 * ((number + 1) > 10 ? 10 : (number + 1))).ToList()); foreach (ClientSession session in _map.Sessions) { // Your reward that every player should get } Thread.Sleep(30000); }
public void Run() { byte[] levelCaps = { 40, 50, 60, 70, 80, 85, 90, 95, 100, 120, 150, 180, 255 }; while (!_shouldStop) { IEnumerable <IGrouping <byte, ClientSession> > groups = from sess in RegisteredParticipants.GetAllItems() group sess by Array.Find(levelCaps, s => s > sess.Character.Level) into grouping select grouping; foreach (IGrouping <byte, ClientSession> group in groups) { foreach (List <ClientSession> grp in group.ToList().Split(3).Where(s => s.Count == 3)) { Group g = new Group { GroupType = GroupType.TalentArena, TalentArenaBattle = new TalentArenaBattle { GroupLevel = group.Key } }; foreach (ClientSession sess in grp) { RegisteredParticipants.Remove(sess); g.JoinGroup(sess); sess.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 3, -1, 6)); Observable.Timer(TimeSpan.FromSeconds(1)).Subscribe(observer => sess?.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 3, 300, 1))); } RegisteredGroups[g.GroupId] = g; } } Thread.Sleep(5000); } }
private void openRaid(Family fam) { List <EventContainer> onDeathEvents = new List <EventContainer> { new EventContainer(fam.Act4RaidBossMap, EventActionType.THROWITEMS, new Tuple <int, short, byte, int, int>(_bossVNum, 1046, 10, 20000, 20001)), new EventContainer(fam.Act4RaidBossMap, EventActionType.THROWITEMS, new Tuple <int, short, byte, int, int>(_bossVNum, 1244, 10, 5, 6)) }; if (_raidType.Equals(MapInstanceType.Act4Berios)) { onDeathEvents.Add(new EventContainer(fam.Act4RaidBossMap, EventActionType.THROWITEMS, new Tuple <int, short, byte, int, int>(_bossVNum, 2395, 3, 1, 2))); onDeathEvents.Add(new EventContainer(fam.Act4RaidBossMap, EventActionType.THROWITEMS, new Tuple <int, short, byte, int, int>(_bossVNum, 2396, 5, 1, 2))); onDeathEvents.Add(new EventContainer(fam.Act4RaidBossMap, EventActionType.THROWITEMS, new Tuple <int, short, byte, int, int>(_bossVNum, 2397, 10, 1, 2))); } onDeathEvents.Add(new EventContainer(fam.Act4RaidBossMap, EventActionType.SCRIPTEND, (byte)1)); MonsterToSummon bossMob = new MonsterToSummon(_bossVNum, new MapCell { X = _bossX, Y = _bossY }, -1, _bossMove) { DeathEvents = onDeathEvents }; EventHelper.Instance.RunEvent(new EventContainer(fam.Act4RaidBossMap, EventActionType.SPAWNMONSTER, bossMob)); EventHelper.Instance.RunEvent(new EventContainer(fam.Act4Raid, EventActionType.SENDPACKET, UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ACT4RAID_OPEN"), 0))); //Observable.Timer(TimeSpan.FromSeconds(90)).Subscribe(o => //{ //TODO: Summon Monsters //}); }
public void Run() { while (!_shouldStop) { IEnumerable <IGrouping <byte, Group> > groups = from grp in RegisteredGroups.GetAllItems() where grp.TalentArenaBattle != null group grp by grp.TalentArenaBattle.GroupLevel into grouping select grouping; foreach (IGrouping <byte, Group> group in groups) { Group prevGroup = null; foreach (Group g in group) { if (prevGroup == null) { prevGroup = g; } else { RegisteredGroups.Remove(g); RegisteredGroups.Remove(prevGroup); MapInstance mapInstance = ServerManager.GenerateMapInstance(2015, MapInstanceType.NormalInstance, new InstanceBag()); mapInstance.IsPVP = true; g.TalentArenaBattle.MapInstance = mapInstance; prevGroup.TalentArenaBattle.MapInstance = mapInstance; g.TalentArenaBattle.Side = 0; prevGroup.TalentArenaBattle.Side = 1; g.TalentArenaBattle.Calls = 5; prevGroup.TalentArenaBattle.Calls = 5; IEnumerable <ClientSession> gs = g.Characters.GetAllItems().Concat(prevGroup.Characters.GetAllItems()); foreach (ClientSession sess in gs) { sess.SendPacket(UserInterfaceHelper.GenerateBSInfo(1, 3, -1, 2)); } Thread.Sleep(1000); foreach (ClientSession sess in gs) { sess.SendPacket(UserInterfaceHelper.GenerateBSInfo(2, 3, 0, 0)); sess.SendPacket(UserInterfaceHelper.GenerateTeamArenaClose()); } Thread.Sleep(5000); foreach (ClientSession sess in gs) { sess.SendPacket(UserInterfaceHelper.GenerateTeamArenaMenu(0, 0, 0, 0, 0)); short x = 125; if (sess.Character.Group.TalentArenaBattle.Side == 0) { x = 15; } ServerManager.Instance.ChangeMapInstance(sess.Character.CharacterId, mapInstance.MapInstanceId, x, 39); sess.SendPacketAfter(UserInterfaceHelper.GenerateTeamArenaMenu(3, 0, 0, 60, 0), 5000); } PlayingGroups[g.GroupId] = new List <Group> { g, prevGroup }; BattleThread battleThread = new BattleThread(); Observable.Timer(TimeSpan.FromSeconds(0)).Subscribe(observer => battleThread.Run(PlayingGroups[g.GroupId])); prevGroup = null; } } } Thread.Sleep(5000); } }
private void ExecuteHandler(ClientSession session) { if (!session.HasCurrentMapInstance) { return; } double currentRunningSeconds = (DateTime.UtcNow - Process.GetCurrentProcess().StartTime.AddHours(-2).AddSeconds(-50)).TotalSeconds; double timeSpanSinceLastPortal = currentRunningSeconds - session.Character.LastPortal; if (!(timeSpanSinceLastPortal >= 4) || !session.HasCurrentMapInstance) { session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10)); return; } if (session.CurrentMapInstance.Portals.Concat(session.Character.GetExtraPortal()) .FirstOrDefault(s => session.Character.PositionY >= s.SourceY - 1 && session.Character.PositionY <= s.SourceY + 1 && session.Character.PositionX >= s.SourceX - 1 && session.Character.PositionX <= s.SourceX + 1) is Portal portal) { switch (portal.Type) { case (sbyte)PortalType.MapPortal: case (sbyte)PortalType.TsNormal: case (sbyte)PortalType.Open: case (sbyte)PortalType.Miniland: case (sbyte)PortalType.TsEnd: case (sbyte)PortalType.Exit: case (sbyte)PortalType.Effect: case (sbyte)PortalType.ShopTeleport: break; case (sbyte)PortalType.Raid: if (session.Character.Group?.Raid != null) { if (session.Character.Group.IsLeader(session)) { session.SendPacket( $"qna #mkraid^0^275 {Language.Instance.GetMessageFromKey("RAID_START_QUESTION")}"); } else { session.SendPacket( session.Character.GenerateSay( Language.Instance.GetMessageFromKey("NOT_TEAM_LEADER"), 10)); } } else { session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NEED_TEAM"), 10)); } return; case (sbyte)PortalType.BlueRaid: case (sbyte)PortalType.DarkRaid: if ((int)session.Character.Faction == portal.Type - 9 && session.Character.Family?.Act4Raid != null && session.Character.Level > 59 && session.Character.Reputation > 60000) { session.Character.SetReputation(session.Character.Level * -50); session.Character.LastPortal = currentRunningSeconds; switch (session.Character.Family.Act4Raid.MapInstanceType) { case MapInstanceType.Act4Morcos: ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.Family.Act4Raid.MapInstanceId, 43, 179); break; case MapInstanceType.Act4Hatus: ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.Family.Act4Raid.MapInstanceId, 15, 9); break; case MapInstanceType.Act4Calvina: ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.Family.Act4Raid.MapInstanceId, 24, 6); break; case MapInstanceType.Act4Berios: ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.Family.Act4Raid.MapInstanceId, 20, 20); break; } } else { session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PORTAL_BLOCKED"), 10)); } return; default: session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PORTAL_BLOCKED"), 10)); return; } if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.TimeSpaceInstance && !session.Character.Timespace.InstanceBag.Lock) { if (session.Character.CharacterId == session.Character.Timespace.InstanceBag.CreatorId) { session.SendPacket(UserInterfaceHelper.GenerateDialog( $"#rstart^1 rstart {Language.Instance.GetMessageFromKey("FIRST_ROOM_START")}")); } return; } portal.OnTraversalEvents.ForEach(e => EventHelper.Instance.RunEvent(e)); if (portal.DestinationMapInstanceId == default) { return; } if (ServerManager.Instance.ChannelId == 51) { if ((session.Character.Faction == FactionType.Angel && portal.DestinationMapId == 131) || (session.Character.Faction == FactionType.Demon && portal.DestinationMapId == 130)) { session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PORTAL_BLOCKED"), 10)); return; } if ((portal.DestinationMapId == 130 || portal.DestinationMapId == 131) && timeSpanSinceLastPortal < 60) { session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10)); return; } } session.SendPacket(session.CurrentMapInstance.GenerateRsfn()); session.Character.LastPortal = currentRunningSeconds; if (ServerManager.GetMapInstance(portal.SourceMapInstanceId).MapInstanceType != MapInstanceType.BaseMapInstance && ServerManager.GetMapInstance(portal.DestinationMapInstanceId).MapInstanceType == MapInstanceType.BaseMapInstance) { ServerManager.Instance.ChangeMap(session.Character.CharacterId, session.Character.MapId, session.Character.MapX, session.Character.MapY); } else if (portal.DestinationMapInstanceId == session.Character.Miniland.MapInstanceId) { ServerManager.Instance.JoinMiniland(session, session); } else if (portal.DestinationMapId == 20000) { ClientSession sess = ServerManager.Instance.Sessions.FirstOrDefault(s => s.Character.Miniland.MapInstanceId == portal.DestinationMapInstanceId); if (sess != null) { ServerManager.Instance.JoinMiniland(session, sess); } } else { if (ServerManager.Instance.ChannelId == 51) { short destinationX = portal.DestinationX; short destinationY = portal.DestinationY; if (portal.DestinationMapInstanceId == CaligorRaid.CaligorMapInstance?.MapInstanceId ) /* Caligor Raid Map */ { switch (session.Character.Faction) { case FactionType.Angel: destinationX = 50; destinationY = 172; break; case FactionType.Demon: destinationX = 130; destinationY = 172; break; } } else if (portal.DestinationMapId == 153) /* Unknown Land */ { switch (session.Character.Faction) { case FactionType.Angel: destinationX = 50; destinationY = 172; break; case FactionType.Demon: destinationX = 130; destinationY = 172; break; } } ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, portal.DestinationMapInstanceId, destinationX, destinationY); } else { ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, portal.DestinationMapInstanceId, portal.DestinationX, portal.DestinationY); } } } }
private void ExecuteHandler(ClientSession session) { if (session.Character.ExchangeInfo?.ExchangeList.Count > 0 || session.Character.IsShopping) { return; } if (Amount.HasValue && Slot.HasValue) { InventoryType inventoryType = (InventoryType)Data; byte amount = Amount.Value, slot = Slot.Value; if (inventoryType == InventoryType.Bazaar) { return; } ItemInstance inv = session.Character.Inventory.LoadBySlotAndType(slot, inventoryType); if (inv == null || amount > inv.Amount) { return; } if (session.Character.MinilandObjects.Any(s => s.ItemInstanceId == inv.Id)) { return; } if (!inv.Item.IsSoldable) { session.SendPacket(UserInterfaceHelper.GenerateShopMemo(2, string.Format(Language.Instance.GetMessageFromKey("ITEM_NOT_SOLDABLE")))); return; } long price = inv.Item.ItemType == ItemType.Sell ? inv.Item.Price : inv.Item.Price / 20; if (session.Character.Gold + (price * amount) > ServerManager.Instance.Configuration.MaxGold) { string message = UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("MAX_GOLD"), 0); session.SendPacket(message); return; } session.Character.Gold += price * amount; session.SendPacket(UserInterfaceHelper.GenerateShopMemo(1, string.Format(Language.Instance.GetMessageFromKey("SELL_ITEM_VALID"), inv.Item.Name, amount))); session.Character.Inventory.RemoveItemFromInventory(inv.Id, amount); session.SendPacket(session.Character.GenerateGold()); } else { short vNum = Data; CharacterSkill skill = session.Character.Skills[vNum]; if (skill == null || vNum == 200 + (20 * (byte)session.Character.Class) || vNum == 201 + (20 * (byte)session.Character.Class)) { return; } session.Character.Gold -= skill.Skill.Price; session.SendPacket(session.Character.GenerateGold()); foreach (CharacterSkill loadedSkill in session.Character.Skills.GetAllItems()) { if (skill.Skill.SkillVNum == loadedSkill.Skill.UpgradeSkill) { session.Character.Skills.Remove(loadedSkill.SkillVNum); } } session.Character.Skills.Remove(skill.SkillVNum); session.SendPacket(session.Character.GenerateSki()); session.SendPackets(session.Character.GenerateQuicklist()); session.SendPacket(session.Character.GenerateLev()); } }
private void ExecuteHandler(ClientSession session) { if (_isParsed) { Logger.LogUserEvent("GMCOMMAND", session.GenerateIdentity(), $"[AddSkill]SkillVNum: {SkillVnum}"); Skill skillinfo = ServerManager.GetSkill(SkillVnum); if (skillinfo == null) { session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SKILL_DOES_NOT_EXIST"), 11)); return; } if (skillinfo.SkillVNum < 200) { foreach (CharacterSkill skill in session.Character.Skills.GetAllItems()) { if (skillinfo.CastId == skill.Skill.CastId && skill.Skill.SkillVNum < 200) { session.Character.Skills.Remove(skill.SkillVNum); } } } else { if (session.Character.Skills.ContainsKey(SkillVnum)) { session.SendPacket( session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SKILL_ALREADY_EXIST"), 11)); return; } if (skillinfo.UpgradeSkill != 0) { CharacterSkill oldupgrade = session.Character.Skills.FirstOrDefault(s => s.Skill.UpgradeSkill == skillinfo.UpgradeSkill && s.Skill.UpgradeType == skillinfo.UpgradeType && s.Skill.UpgradeSkill != 0); if (oldupgrade != null) { session.Character.Skills.Remove(oldupgrade.SkillVNum); } } } session.Character.Skills[SkillVnum] = new CharacterSkill { SkillVNum = SkillVnum, CharacterId = session.Character.CharacterId }; session.SendPacket(session.Character.GenerateSki()); session.SendPackets(session.Character.GenerateQuicklist()); session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SKILL_LEARNED"), 0)); session.Character.LoadPassiveSkills(); session.SendPacket(session.Character.GenerateLev()); } else { session.SendPacket(session.Character.GenerateSay(ReturnHelp(), 10)); } }
private void ExecuteHandler(ClientSession session) { if (session.CurrentMapInstance?.MapInstanceType == MapInstanceType.BaseMapInstance) { if (!session.Character.IsFriendlistFull()) { long characterId = CharacterId; if (!session.Character.IsFriendOfCharacter(characterId)) { if (!session.Character.IsBlockedByCharacter(characterId)) { if (!session.Character.IsBlockingCharacter(characterId)) { ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterId(characterId); if (otherSession != null) { if (otherSession.Character.FriendRequestBlocked) { session.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_REJECTED"))); return; } if (otherSession.Character.FriendRequestCharacters.GetAllItems() .Contains(session.Character.CharacterId)) { switch (Type) { case 1: session.Character.AddRelation(characterId, CharacterRelationType.Friend); session.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_ADDED"))); otherSession.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_ADDED"))); break; case 2: otherSession.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_REJECTED"))); break; default: if (session.Character.IsFriendlistFull()) { session.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_FULL"))); otherSession.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_FULL"))); } break; } } else { otherSession.SendPacket(UserInterfaceHelper.GenerateDialog( $"#fins^1^{session.Character.CharacterId} #fins^2^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("FRIEND_ADD"), session.Character.Name)}")); session.Character.FriendRequestCharacters.Add(characterId); if (otherSession.Character.IsAfk) { session.SendPacket(UserInterfaceHelper.GenerateInfo( string.Format(Language.Instance.GetMessageFromKey("PLAYER_IS_AFK"), otherSession.Character.Name))); } } } } else { session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKING"))); } } else { session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED"))); } } else { session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("ALREADY_FRIEND"))); } } else { session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_FULL"))); } } else { session.SendPacket( UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("IMPOSSIBLE_TO_USE"))); } }