public void LoadMonster(string file) { if (File.Exists(file + ".xml")) { Logger.Information(ServerMessages.GetMessage(Messages.MonsterMng_Loading), file + ".xml"); var xml = ResourceLoader.XmlLoader <XmlMonsterInfo>(file + ".xml"); _monsterInfo = xml.Monsters.ToDictionary(x => x.Monster); } else if (File.Exists(file + ".txt")) { Logger.Information(ServerMessages.GetMessage(Messages.MonsterMng_Loading), file + ".txt"); var loader = new LoadWZTXT <XmlMonsterInfo>(); var xml = loader.Load(file + ".txt"); foreach (var monst in xml.Monsters) { if (monst.Spell >= (Spell)100 && monst.Spell < (Spell)200) { monst.Spell -= 100; monst.AttackRange += 2; } _monsterInfo.Add(monst.Monster, monst); } //xml.Monsters = _monsterInfo.Select(x => x.Value).ToArray(); ResourceLoader.XmlSaver(file + ".xml", xml); } var bags = ResourceCache.Instance.GetItemBags(); foreach (var mob in _monsterInfo.Values) { mob.Bag = bags.FirstOrDefault(x => x.Monster == mob.Monster); } Logger.Information(ServerMessages.GetMessage(Messages.MonsterMng_Types), _monsterInfo.Count); }
public Item GetItem(ushort mobLevel, Maps map) { foreach (var ev in _events) { var ret = ev.Value.GetItem(mobLevel, map); if (ret == null) { continue; } Logger.Information(ServerMessages.GetMessage(Messages.GE_GetItem), ev.Key, map, ret); return(ret); } foreach (var ev in Program.EventManager.GetEvents()) { var ret = ev.GetItem(mobLevel, map); if (ret == null) { continue; } Logger.Information(ServerMessages.GetMessage(Messages.GE_GetItem), ev.GetType(), map, ret); return(ret); } return(null); }
public GlobalEvents AddEvent(string name, GlobalEvent ev) { Logger.Information(ServerMessages.GetMessage(Messages.GE_AddEvent), name, ev.Active, ev.Rate); _events.Add(name, ev); ev.Name = name; return(this); }
public override void Update() { switch (CurrentState) { case EventState.Closed: break; case EventState.Open: if (((int)TimeLeft.TotalSeconds) % 60 == 0 && TimeLeft.TotalSeconds >= 60) { Program.NoEventMapAnoucement(ServerMessages.GetMessage(Messages.BC_Open, (int)Math.Ceiling(TimeLeft.TotalMinutes))).Wait(); Program.NoEventMapSendAsync(new SEventNotificationS16Kor { Active = 1, EventID = EventIcon.BloodCastle }); } break; case EventState.Playing: break; } foreach (var bridge in _bridges) { bridge.Update(); } base.Update(); }
public override void Update() { switch (CurrentState) { case EventState.Closed: break; case EventState.Open: if (((int)TimeLeft.TotalSeconds) % 60 == 0 && TimeLeft.TotalSeconds >= 60) { Program.NoEventMapAnoucement(ServerMessages.GetMessage(Messages.BC_Open, (int)Math.Ceiling(TimeLeft.TotalMinutes))).Wait(); } break; case EventState.Playing: break; } foreach (var bridge in _bridges) { bridge.Update(); } base.Update(); }
public static void DelGroup(int group) { _logger.Information(ServerMessages.GetMessage(Messages.IA_DeleteGroup, group) /*"Removing group {0}"*/); foreach (var mob in _instance._IAGroups[group]) { MonstersMng.Instance.DeleteMonster(mob.monster); } }
public override void Update() { switch (CurrentState) { case EventState.Closed: if (TimeLeft.TotalMinutes <= 16 && ((int)TimeLeft.TotalMinutes) % 5 == 0 && _nextMessage < DateTimeOffset.Now) { _nextMessage = DateTimeOffset.Now.AddMinutes(4); Program.NoEventMapAnoucement(ServerMessages.GetMessage(Messages.DS_Closed, (int)TimeLeft.TotalMinutes)) .Wait(); } if ((int)TimeLeft.TotalSeconds == 30) { Program.server.Clients .Where(x => x.Player.Status == LoginStatus.Playing) .SendAsync(new SDevilSquareSet(DevilSquareState.Close)) .Wait(); } break; case EventState.Open: if ((int)TimeLeft.TotalSeconds == 30) { Program.server.Clients .Where(x => x.Player.Status == LoginStatus.Playing) .SendAsync(new SDevilSquareSet(DevilSquareState.Open)) .Wait(); } break; case EventState.Playing: if (DateTimeOffset.Now >= _nextSpawn) { _nextSpawn = DateTimeOffset.Now.Add(_playingTime / 7); _nextSpawnNumber++; foreach (var ds in _devilSquares) { ds.SpawList(_nextSpawnNumber); } } if ((int)TimeLeft.TotalSeconds == 30) { Resources.ResourceCache.Instance.GetMaps() .Where(x => x.Key == Maps.DevilSquare || x.Key == Maps.DevilSquare2) .SelectMany(y => y.Value.Players) .Select(z => z.Player.Session) .SendAsync(new SDevilSquareSet(DevilSquareState.Playing)) .Wait(); } break; } foreach (var ds in _devilSquares) { ds.Update(); } base.Update(); }
private void StartSiege() { var seconds = (int)Time.TotalSeconds; var notify = (seconds % 180) == 0; seconds = (int)TimeLeft.TotalSeconds; if (notify) { TimeLeftSend(); } if (seconds % 1800 == 0) { _ = Program.GlobalAnoucement(ServerMessages.GetMessage(Messages.CS_Notify)); } if (seconds < 180 && (seconds % 60) == 0) { TimeLeftSend(); } if ((seconds % 3) == 0) { MinimapUpdate(); } if (main.Switch1 != null) { var sw = main.Switch1.Window as Monster; if (sw.Position.Substract(main.Switch1.Character.Position).LengthSquared() > 3) { main.Switch1 = null; NotifyCrownState(1); } } if (main.Switch2 != null) { var sw = main.Switch2.Window as Monster; if (sw.Position.Substract(main.Switch2.Character.Position).LengthSquared() > 3) { main.Switch2 = null; NotifyCrownState(1); } } NotifySwitchInfo(sw1, main.Switch1); NotifySwitchInfo(sw2, main.Switch2); if (main.Switch1 != null && main.Switch2 != null) { if (main.Switch1.Character.Guild.Union[0] == main.Switch2.Character.Guild.Union[0]) { NotifyCrownState(0); } else { NotifyCrownState(1); } } }
public virtual void Update() { if (!_nextState.Equals(CurrentState) && _nextStateIn < DateTimeOffset.Now) { var protectedState = _nextState; _logger.Information(ServerMessages.GetMessage(Messages.Server_EventStateChange), CurrentState, _nextState); OnTransition(_nextState); CurrentState = protectedState; } }
public static int InitGroup(int group, EventHandler die = null) { _logger.Information(ServerMessages.GetMessage(Messages.IA_CreateGroup, group) /*"Loading group {0}"*/); Monster Leader = null; foreach (var mob in _instance._IAGroups[group]) { Point point = new Point(); var mapInfo = ResourceCache.Instance.GetMaps()[mob.MapNumber]; switch (mob.CreateType) { case 0: point = new Point(mob.StartX, mob.StartY); break; case 1: for (var y = mob.StartY - 5; y <= (mob.StartY + 5) && point.X == 0; y++) { for (var x = mob.StartX - 5; x <= (mob.StartX + 5) && point.X == 0; x++) { if (mapInfo.GetAttributes(x, y).Length == 0) { point = new Point(mob.StartX, mob.StartY); } } } break; default: continue; } if (point.X == 0) { continue; } mob.monster = new Monster(mob.Class, ObjectType.Monster, mob.MapNumber, point, mob.StartDir == -1 ? (byte)Program.RandomProvider(7) : (byte)mob.StartDir) { Index = MonstersMng.Instance.GetNewIndex() }; //mob.monster.Active = false; mob.monster.Die += die; if (mob.Rank == 0) { Leader = mob.monster; } else if (Leader != null) { mob.monster.Leader = Leader; } MonstersMng.Instance.Monsters.Add(mob.monster); } return(_instance._IAGroups[group].Count); }
private void DieMonster(object sender, EventArgs e) { var mob = sender as Monster; mob.Active = false; if (mob.Info.Monster == 361) { _manager.SendAll(new SNotice(NoticeType.Gold, ServerMessages.GetMessage(Messages.Kanturu_Successfull, mob.Killer.Character.Name))); _manager.FailState = false; Trigger(KanturuBattleOfNightmareState.End); } }
private void Notify() { var seconds = (int)Time.TotalSeconds; var notify = (seconds % 1800) == 0; if (!notify) { return; } _ = Program.GlobalAnoucement(ServerMessages.GetMessage(MU.Resources.Messages.CS_Notify)); }
private void ReadySiege() { var seconds = (int)Time.TotalSeconds; var notify = (seconds % 1800) == 0; seconds = (int)TimeLeft.TotalSeconds; var lastNotify = seconds <= 300 && (seconds % 60) == 0; if (notify) { _ = Program.GlobalAnoucement(ServerMessages.GetMessage(Messages.CS_Notify)); } if (lastNotify) { _ = Program.GlobalAnoucement(ServerMessages.GetMessage(Messages.CS_LastNotify, seconds / 60)); } }
public override void OnTransition(EventState NextState) { switch (NextState) { case EventState.Closed: Trigger(EventState.Open, _closedTime); break; case EventState.Open: Trigger(EventState.Playing, _openTime); break; case EventState.Playing: Program.NoEventMapAnoucement(ServerMessages.GetMessage(Messages.BC_Closed)).Wait(); Trigger(EventState.Closed, _playingTime); break; } }
public override void OnTransition(KanturuStandByState NextState) { switch (NextState) { case KanturuStandByState.Start: Trigger(KanturuStandByState.Notify, TimeSpan.FromSeconds(60)); //1140 break; case KanturuStandByState.Notify: Trigger(KanturuStandByState.End, TimeSpan.FromSeconds(60)); /*"[Refinery Tower] Can enter in 1 minute"*/ Program.MapAnoucement(Maps.Kantru2, ServerMessages.GetMessage(Messages.Kanturu_CoreGateOpens, (int)TimeLeft.TotalMinutes)).Wait(); break; case KanturuStandByState.End: _manager.Trigger(EventState.Playing); Trigger(KanturuStandByState.None); break; } }
public override void OnTransition(EventState NextState) { switch (NextState) { case EventState.Closed: Trigger(EventState.Open, _closedTime); break; case EventState.Open: Trigger(EventState.Playing, _openTime); break; case EventState.Playing: Program.NoEventMapAnoucement(ServerMessages.GetMessage(Messages.BC_Closed)).Wait(); Trigger(EventState.Closed, _playingTime); break; } Program.NoEventMapSendAsync(new SEventNotificationS16Kor { Active = (byte)(NextState == EventState.Open ? 1 : 0), EventID = EventIcon.BloodCastle }); }
private static async void WorkerCS() { do { try { Program.client = new CSClient(Instance._csIp, Instance._handlers, Instance._factories, Program.ServerCode, Program.server, Instance._show, Instance._token, Program.Name); while (!Program.client.Closed) { await Task.Delay(1000); } Log.Error("Connection with CS lost"); } catch (Exception) { Log.Error(ServerMessages.GetMessage(Messages.Server_CSServer_Error)); } await Task.Delay(30000); } while (true); }
public void LoadSetBase(string file) { XmlMonsterSetBase xml = null; if (File.Exists(file + ".xml")) { Logger.Information(ServerMessages.GetMessage(Messages.MonsterMng_Loading2), file + ".xml"); xml = ResourceLoader.XmlLoader <XmlMonsterSetBase>(file + ".xml"); } else if (File.Exists(file + ".txt")) { Logger.Information(ServerMessages.GetMessage(Messages.MonsterMng_Loading2), file + ".txt"); var loader = new LoadWZTXT <XmlMonsterSetBase>(); xml = loader.Load(file + ".txt"); ResourceLoader.XmlSaver(file + ".xml", xml); } foreach (var npc in xml.NPCs) { Monsters.Add(new Monster(npc.Type, ObjectType.NPC, npc.Map, new Point(npc.PosX, npc.PosY), (byte)npc.Dir) { Index = GetNewIndex() }); } foreach (var npc in xml.Normal) { Monsters.Add(new Monster(npc.Type, ObjectType.Monster, npc.Map, new Point(npc.PosX, npc.PosY), (byte)npc.Dir) { Index = GetNewIndex() }); } foreach (var npc in xml.BloodCastles) { Monsters.Add(new Monster(npc.Type, ObjectType.Monster, npc.Map, new Point(npc.PosX, npc.PosY), (byte)npc.Dir) { Index = GetNewIndex() }); } foreach (var npc in xml.Golden) { for (var i = 0; i < npc.Quant; i++) { var dir = (byte)_rand.Next(7); var mPos = GetSpawn(npc.Map, npc.PosX, npc.PosX2, npc.PosY, npc.PosY2); var mob = new Monster(npc.Type, ObjectType.Monster, npc.Map, mPos, dir) { Index = GetNewIndex() }; Monsters.Add(mob); Program.GoldenInvasionManager.AddMonster(mob); } } foreach (var npc in xml.Spots) { for (var i = 0; i < npc.Quant; i++) { try { var dir = (byte)_rand.Next(7); var mPos = GetSpawn(npc.Map, npc.PosX, npc.PosX2, npc.PosY, npc.PosY2); var mob = new Monster(npc.Type, ObjectType.Monster, npc.Map, mPos, dir, npc.Element) { Index = GetNewIndex() }; Monsters.Add(mob); }catch (InvalidOperationException) { } } } Logger.Information(ServerMessages.GetMessage(Messages.MonsterMng_Loaded), Monsters.Count); }
static void Main(string[] args) { Predicate <GSSession> MustNotBeLoggedIn = session => session.Player.Status == LoginStatus.NotLogged; Predicate <GSSession> MustBeLoggedIn = session => session.Player.Status == LoginStatus.Logged; Predicate <GSSession> MustBePlaying = session => session.Player.Status == LoginStatus.Playing; Predicate <GSSession> MustBeLoggedOrPlaying = session => session.Player.Status == LoginStatus.Logged || session.Player.Status == LoginStatus.Playing; string output = "{Timestamp: HH:mm:ss} [{Level} {SourceContext}][{AID}:{AUser}] {Message}{NewLine}{Exception}"; Log.Logger = new LoggerConfiguration() .Destructure.ByTransforming <IPEndPoint>(endPoint => endPoint.ToString()) .Destructure.ByTransforming <EndPoint>(endPoint => endPoint.ToString()) .WriteTo.RollingFile("GameServer_{Date}.txt", outputTemplate: output) .WriteTo.Console(outputTemplate: output) .MinimumLevel.Debug() .CreateLogger(); ServerMessages = new ServerMessages(); ServerMessages.LoadMessages("./Data/Lang/ServerMessages(es).xml"); if (!File.Exists("./Server.xml")) { Log.Logger.Error(ServerMessages.GetMessage(Messages.Server_Cfg)); ResourceLoader.XmlSaver("./Server.xml", new ServerInfoDto { AutoRegistre = true, Code = 0, ConnectServerIP = "127.0.0.1", DataBase = "MuOnline", DBIp = "127.0.0.1", BDUser = "******", DBPassword = "", DropRate = 60, Experience = 10, IP = "127.0.0.1", Name = "GameServer", Port = 55901, Serial = "Serial", Show = 1, Version = "10203", Zen = 10, }); Task.Delay(10000); return; } var xml = ResourceLoader.XmlLoader <ServerInfoDto>("./Server.xml"); ServerMessages.LoadMessages($"./Data/Lang/ServerMessages({xml.Lang}).xml"); Console.Title = ServerMessages.GetMessage(Messages.Server_Title, xml.Code, xml.Name, xml.Version, xml.Serial, xml.DataBase); ConnectionString = $"Server={xml.DBIp};port=3306;Database={xml.DataBase};user={xml.BDUser};password={xml.DBPassword};Convert Zero Datetime=True;"; SimpleModulus.LoadDecryptionKey("./Data/Dec1.dat"); SimpleModulus.LoadEncryptionKey("./Data/Enc2.dat"); byte[] key = { 0x44, 0x9D, 0x0F, 0xD0, 0x37, 0x22, 0x8F, 0xCB, 0xED, 0x0D, 0x37, 0x04, 0xDE, 0x78, 0x00, 0xE4, 0x33, 0x86, 0x20, 0xC2, 0x79, 0x35, 0x92, 0x26, 0xD4, 0x37, 0x37, 0x30, 0x98, 0xEF, 0xA4, 0xDE }; PacketEncrypt.Initialize(key); var ip = new IPEndPoint(IPAddress.Parse(xml.IP), xml.Port); var csIP = new IPEndPoint(IPAddress.Parse(xml.ConnectServerIP), 44405); AutoRegistre = xml.AutoRegistre; ServerCode = (ushort)xml.Code; Experience = xml.Experience; Zen = xml.Zen; DropRate = xml.DropRate; Season12 = xml.Rijndael; var mh = new MessageHandler[] { new FilteredMessageHandler <GSSession>() .AddHandler(new AuthServices()) .AddHandler(new GlobalServices()) .AddHandler(new GameServices()) .AddHandler(new CashShopServices()) .AddHandler(new EventServices()) .AddHandler(new QuestSystemServices()) .AddHandler(new GuildServices()) .AddHandler(new AntiHackServices()) .RegisterRule <CIDAndPass>(MustNotBeLoggedIn) .RegisterRule <CCharacterList>(MustBeLoggedIn) .RegisterRule <CCharacterMapJoin>(MustBeLoggedIn) .RegisterRule <CCharacterMapJoin2>(MustBeLoggedIn) .RegisterRule <CCloseWindow>(MustBePlaying) .RegisterRule <CDataLoadOK>(MustBePlaying) .RegisterRule <CAction>(MustBePlaying) }; var mf = new MessageFactory[] { new AuthMessageFactory(), new GlobalMessageFactory(), new GameMessageFactory(), new CashShopMessageFactory(), new EventMessageFactory(), new QuestSystemMessageFactory(), new GuildMessageFactory(), new AntiHackMessageFactory(), }; server = new WZGameServer(ip, mh, mf, xml.Rijndael); server.ClientVersion = xml.Version; server.ClientSerial = xml.Serial; var cmh = new MessageHandler[] { new FilteredMessageHandler <CSClient>() .AddHandler(new CSServices()) }; var cmf = new MessageFactory[] { new CSMessageFactory() }; try { ResourceCache.Initialize(".\\Data"); MonstersMng.Initialize(); MonstersMng.Instance.LoadMonster("./Data/Monsters/Monster.txt"); EventInitialize(); MonstersMng.Instance.LoadSetBase("./Data/Monsters/MonsterSetBase.txt"); GuildManager.Initialize(); PartyManager.Initialzie(400); DuelSystem.Initialize(); SubSystem.Initialize(); Marlon.Initialize(); }catch (MySql.Data.MySqlClient.MySqlException ex) { Log.Error(ex, ServerMessages.GetMessage(Messages.Server_MySQL_Error)); //Migrate(null, new EventArgs()); //Log.Information("Server needs restart to reload all changes"); Task.Delay(10000); } catch (Exception ex) { Log.Error(ex, ServerMessages.GetMessage(Messages.Server_Error)); } try { client = new CSClient(csIP, cmh, cmf, (ushort)xml.Code, server, (byte)xml.Show); }catch (Exception) { Log.Error(ServerMessages.GetMessage(Messages.Server_CSServer_Error)); } Log.Information(ServerMessages.GetMessage(Messages.Server_Disconnecting_Accounts)); try { using (var db = new GameContext()) { var accs = from acc in db.Accounts where acc.IsConnected && acc.ServerCode == xml.Code select acc; foreach (var acc in accs) { acc.IsConnected = false; } db.Accounts.UpdateRange(accs); db.SaveChanges(); } }catch (Exception) { Log.Error("MySQL unavailable."); Task.Delay(15000); return; } Log.Information(ServerMessages.GetMessage(Messages.Server_Ready)); Handler.AddCommand(new Command <GSSession>("exit", Close)) .AddCommand(new Command <GSSession>("quit", Close)) .AddCommand(new Command <GSSession>("stop", Close)) .AddCommand(new Command <GSSession>("reload") .AddCommand(new Command <GSSession>("shops", (object a, CommandEventArgs b) => ResourceCache.Instance.ReloadShops())) .AddCommand(new Command <GSSession>("gates", (object a, CommandEventArgs b) => ResourceCache.Instance.ReloadGates()))) .AddCommand(new Command <GSSession>("create") .AddCommand(new Command <GSSession>("movereq", DumpMoveReq))) .AddCommand(new Command <GSSession>("db") .AddCommand(new Command <GSSession>("migrate", Migrate)) .AddCommand(new Command <GSSession>("create", Create)) .AddCommand(new Command <GSSession>("delete", Delete))) .AddCommand(new Command <GSSession>("!", (object a, CommandEventArgs b) => GlobalAnoucement(b.Argument)).SetPartial()) .AddCommand(new Command <GSSession>("/").SetPartial() .AddCommand(new Command <GSSession>("add").SetPartial() .AddCommand(new Command <GSSession>("str", Character.AddStr)) .AddCommand(new Command <GSSession>("agi", Character.AddAgi)) .AddCommand(new Command <GSSession>("vit", Character.AddVit)) .AddCommand(new Command <GSSession>("ene", Character.AddEne)) .AddCommand(new Command <GSSession>("cmd", Character.AddCmd))) .AddCommand(new Command <GSSession>("set") .AddCommand(new Command <GSSession>("hp", (object a, CommandEventArgs b) => ((GSSession)a).Player.Character.Health = float.Parse(b.Argument))) .AddCommand(new Command <GSSession>("zen", (object a, CommandEventArgs b) => ((GSSession)a).Player.Character.Money = uint.Parse(b.Argument))) .AddCommand(new Command <GSSession>("exp", (object a, CommandEventArgs b) => ((GSSession)a).Player.Character.Experience = uint.Parse(b.Argument)))) .AddCommand(new Command <GSSession>("levelup", LevelUp)) /*.AddCommand(new Command<GSSession>("post"))*/) //.AddCommand(new Command<GSSession>("~").SetPartial()) /*.AddCommand(new Command<GSSession>("]").SetPartial())*/; while (true) { var input = Console.ReadLine(); if (input == null) { break; } Handler.ProcessCommands(null, input); } }
public override void OnTransition(KanturuBattleOfNightmareState NextState) { _manager.SendAll(new SKanturuStateChange { State = _manager._state, btDetailState = (byte)NextState }); switch (NextState) { case KanturuBattleOfNightmareState.None: break; case KanturuBattleOfNightmareState.Idle: _manager.WarpAllTo(134); Trigger(KanturuBattleOfNightmareState.Notify, TimeSpan.FromSeconds(5)); break; case KanturuBattleOfNightmareState.Notify: Trigger(KanturuBattleOfNightmareState.Start, TimeSpan.FromSeconds(10)); _manager.SendAll(new SNotice(NoticeType.Gold, ServerMessages.GetMessage(Messages.Kanturu_NightmareNotify))); break; case KanturuBattleOfNightmareState.Start: { _manager.LoadScene(2); MonsterIA.InitGroup(23, DieMonster); var mob = MonstersMng.Instance.Monsters.FirstOrDefault(x => x.Info.Monster == 361); _nightmare = new PatternManager(mob, Program.XMLConfiguration.Files.NightmarePatterns); _nightmare.UseSkill += _nightmare_UseSkill; _manager.FailState = true; Trigger(KanturuBattleOfNightmareState.End, TimeSpan.FromSeconds(1200)); _manager.SendAll(new SKanturuBattleTime { BattleTime = (int)TimeLeft.TotalSeconds }); } break; case KanturuBattleOfNightmareState.End: _nightmare = null; MonsterIA.DelGroup(23); _logger.Information("Battle result:{0}", _manager.FailState?"Fail":"Win"); _manager.SendAll(new SKanturuBattleResult { Result = (byte)(_manager.FailState ? 0 : 1) }); Trigger(KanturuBattleOfNightmareState.EndCycle, TimeSpan.FromSeconds(5)); break; case KanturuBattleOfNightmareState.EndCycle: if (_manager.FailState) { _manager.Clear(); } else { _manager._towerOfRefinement.Initialize(); _manager.Trigger(EventState.Closed); } Trigger(KanturuBattleOfNightmareState.None); break; } }
public override void OnTransition(KanturuBattleOfMayaState NextState) { _manager.SendAll(new SKanturuStateChange { State = _manager._state, btDetailState = (byte)NextState }); if (NextState == KanturuBattleOfMayaState.EndCycle1 || NextState == KanturuBattleOfMayaState.EndCycle2 || NextState == KanturuBattleOfMayaState.EndCycle3) { var str = ServerMessages.GetMessage(Messages.Kanturu_NextBattle); Program.MapAnoucement(Maps.Kantru1, str).Wait(); Program.MapAnoucement(Maps.Kantru2, str).Wait(); Program.MapAnoucement(Maps.Kantru3, str).Wait(); } switch (NextState) { // Battle Stage 1 case KanturuBattleOfMayaState.StandBy1: Trigger(KanturuBattleOfMayaState.Notify1, TimeSpan.FromSeconds(120)); break; case KanturuBattleOfMayaState.Notify1: if (!_manager.CanRun()) { _manager.FailState = true; Trigger(KanturuBattleOfMayaState.End); return; } Trigger(KanturuBattleOfMayaState.Start1, TimeSpan.FromSeconds(15)); break; case KanturuBattleOfMayaState.Start1: _manager.LoadScene(0); Trigger(KanturuBattleOfMayaState.End1, TimeSpan.FromSeconds(900)); _manager.SendAll(new SKanturuBattleTime { BattleTime = (int)TimeLeft.TotalMilliseconds }); break; case KanturuBattleOfMayaState.Maya1: { _LeftHand = false; _RightHand = false; _manager.LoadScene(3); MonsterIA.InitGroup(20, DieMonster); var h1 = MonstersMng.Instance.Monsters.FirstOrDefault(x => x.Info.Monster == 363 || x.Info.Monster == 362); _hand1 = new PatternManager(h1, Program.XMLConfiguration.Files.MayaLeftHandPatterns); _hand1.UseSkill += _hand_UseSkill; } break; case KanturuBattleOfMayaState.End1: _hand1.UseSkill -= _hand_UseSkill; _hand1 = null; MonsterIA.DelGroup(20); if (_manager.MonsterCount() > 1 || !_LeftHand) { _manager.FailState = true; Trigger(KanturuBattleOfMayaState.End); return; } Trigger(KanturuBattleOfMayaState.EndCycle1, TimeSpan.FromSeconds(5)); break; case KanturuBattleOfMayaState.EndCycle1: { Trigger(KanturuBattleOfMayaState.StandBy2, TimeSpan.FromSeconds(3)); } break; // Battle Stage 2 case KanturuBattleOfMayaState.StandBy2: Trigger(KanturuBattleOfMayaState.Start2, TimeSpan.FromSeconds(60)); break; case KanturuBattleOfMayaState.Start2: _manager.LoadScene(0); Trigger(KanturuBattleOfMayaState.End2, TimeSpan.FromSeconds(900)); _manager.SendAll(new SKanturuBattleTime { BattleTime = (int)TimeLeft.TotalMilliseconds }); break; case KanturuBattleOfMayaState.Maya2: { _LeftHand = false; _RightHand = false; MonsterIA.InitGroup(21, DieMonster); _manager.LoadScene(4); var h1 = MonstersMng.Instance.Monsters.FirstOrDefault(x => x.Info.Monster == 363 || x.Info.Monster == 362); _hand2 = new PatternManager(h1, Program.XMLConfiguration.Files.MayaRightHandPatterns); _hand2.UseSkill += _hand_UseSkill; } break; case KanturuBattleOfMayaState.End2: _hand2.UseSkill -= _hand_UseSkill; _hand2 = null; MonsterIA.DelGroup(21); if (_manager.MonsterCount() > 1 || !_RightHand) { _manager.FailState = true; Trigger(KanturuBattleOfMayaState.End); return; } Trigger(KanturuBattleOfMayaState.EndCycle2, TimeSpan.FromSeconds(5)); break; case KanturuBattleOfMayaState.EndCycle2: Trigger(KanturuBattleOfMayaState.StandBy3, TimeSpan.FromSeconds(3)); break; // Battle Stage 3 case KanturuBattleOfMayaState.StandBy3: Trigger(KanturuBattleOfMayaState.Start3, TimeSpan.FromSeconds(60)); break; case KanturuBattleOfMayaState.Start3: _manager.LoadScene(1); Trigger(KanturuBattleOfMayaState.End3, TimeSpan.FromSeconds(900)); _manager.SendAll(new SKanturuBattleTime { BattleTime = (int)TimeLeft.TotalMilliseconds }); break; case KanturuBattleOfMayaState.Maya3: { _LeftHand = false; _RightHand = false; MonsterIA.InitGroup(22, DieMonster); _manager.LoadScene(5); var h1 = MonstersMng.Instance.Monsters.FirstOrDefault(x => x.Info.Monster == 362); var h2 = MonstersMng.Instance.Monsters.FirstOrDefault(x => x.Info.Monster == 363); _hand1 = new PatternManager(h1, Program.XMLConfiguration.Files.MayaLeftHandPatterns); _hand2 = new PatternManager(h2, Program.XMLConfiguration.Files.MayaRightHandPatterns); _hand1.UseSkill += _hand_UseSkill; _hand2.UseSkill += _hand_UseSkill; } break; case KanturuBattleOfMayaState.End3: _hand1.UseSkill -= _hand_UseSkill; _hand2.UseSkill -= _hand_UseSkill; _hand1 = null; _hand2 = null; MonsterIA.DelGroup(22); if (_manager.MonsterCount() > 1 || !_LeftHand || !_RightHand) { _manager.FailState = true; Trigger(KanturuBattleOfMayaState.End); return; } Trigger(KanturuBattleOfMayaState.EndCycle3, TimeSpan.FromSeconds(5)); break; case KanturuBattleOfMayaState.EndCycle3: Trigger(KanturuBattleOfMayaState.End, TimeSpan.FromSeconds(3)); break; case KanturuBattleOfMayaState.End: Trigger(KanturuBattleOfMayaState.EndCycle, TimeSpan.FromSeconds(3)); if (_manager.FailState) { _manager.SendAll(new SNotice(NoticeType.Gold, ServerMessages.GetMessage(Messages.Kanturu_Fail))); } break; case KanturuBattleOfMayaState.EndCycle: if (!_manager.FailState) { _manager._battleOfNightmare.Initialize(); } else { _manager.Trigger(EventState.Open); } Trigger(KanturuBattleOfMayaState.None); break; } }
public async Task CRelationShipJoinBreakOff(GSSession session, CRelationShipJoinBreakOff message) { var siege = Program.EventManager.GetEvent <CastleSiege>(); if (siege.State >= SiegeStates.Notify && siege.State <= SiegeStates.StartSiege) { //MsgOutput(aIndex, Lang.GetText(0, 197)); await session.SendAsync(new SNotice(NoticeType.Blue, ServerMessages.GetMessage(Messages.Guild_RelationShipCantChange))); return; } Character src, dst; src = session.Player.Character; if (message.TargetUserIndex == 0) { dst = GuildManager.Instance.Guilds.FirstOrDefault(x => x.Value.Name == message.Guild).Value.Master?.Player?.Character ?? null; } else { dst = Program.server.Clients.FirstOrDefault(x => x.ID == message.TargetUserIndex)?.Player?.Character ?? null; } if (dst == null) { await session.SendAsync(new SGuildResult(GuildResult.PlayerOffline)); return; } if (src.Guild == null || dst.Guild == null) { await session.SendAsync(new SGuildResult(GuildResult.HaveGuild)); return; } if (src.Guild.Master.Player != src.Player || dst.Guild.Master.Player != dst.Player) { await session.SendAsync(new SGuildResult(GuildResult.NotGuildMaster)); return; } if (src.Player.Window != null || dst.Player.Window != null) { await session.SendAsync(new SGuildResult(GuildResult.InTransaction)); return; } var errmsg = new SRelationShipJoinBreakOff { RequestType = message.RequestType, Result = 0, RelationShipType = message.RelationShipType, wzTargetUserIndex = message.wzTargetUserIndex, }; switch (message.RequestType) { case GuildUnionRequestType.Join: switch (message.RelationShipType) { case GuildRelationShipType.Union: break; case GuildRelationShipType.Rivals: break; } break; case GuildUnionRequestType.BreakOff: switch (message.RelationShipType) { case GuildRelationShipType.Union: break; case GuildRelationShipType.Rivals: break; } break; } message.wzTargetUserIndex = ((ushort)session.ID).ShufleEnding(); await dst.Player.Session.SendAsync(message); }