public WvsGameClient(WvsGame game, Socket socket) : base(socket) { Server = game; MigratedIn = false; Account = null; NpcScript = null; }
public WvsGameSocket( IChannel channel, uint seqSend, uint seqRecv, WvsGame wvsGame ) : base(channel, seqSend, seqRecv) => WvsGame = wvsGame;
public CFieldEntry(WvsGame parent, int nFieldID) { Parent = parent; TemplateID = nFieldID; m_aItems = new Dictionary <int, CFieldItem>(); }
public WvsGameClient(WvsGame game, CClientSocket socket) : base(socket) { ParentServer = game; SentCharData = false; Character = null; NpcScript = null; }
} = ""; // make sure it's initialized public CField(WvsGame parentInstance, int nMapId, int nInstanceId) { ParentInstance = parentInstance; MapId = nMapId; nInstanceID = nInstanceId; dwUniqueId = (nMapId << 4) | nInstanceId; Portals = new CPortalMap(); Footholds = new CFootholdMap(); Users = new CUserPool(this); Mobs = new CMobPool(this); Npcs = new CNpcPool(this); Drops = new CDropPool(this); Reactors = new CReactorPool(this); AffectedAreas = new CAffectedAreaPool(this); Kites = new CMessageBoxPool(this); TownPortals = new CTownPortalPool(this); MiniRooms = new CMiniRoomPool(this); Summons = new CSummonedPool(this); OpenGates1 = new COpenGatePool(this, true); OpenGates2 = new COpenGatePool(this, false); CurrentWeather = new BlowWeather(this); }
public CField_AreaBoss(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { _timeSinceCreation = DateTime.Now; //#if DEBUG // bPauseSpawn = true; //#endif }
private static void Register(Packet inPacket) { ServerRegsitrationResponse response = (ServerRegsitrationResponse)inPacket.ReadByte(); switch (response) { case ServerRegsitrationResponse.Valid: { WvsGame.WorldID = inPacket.ReadByte(); WvsGame.WorldName = inPacket.ReadString(); WvsGame.TickerMessage = inPacket.ReadString(); WvsGame.ChannelID = inPacket.ReadByte(); WvsGame.RemoteEndPoint = new IPEndPoint(IPAddress.Loopback, inPacket.ReadUShort()); WvsGame.Listen(); WvsGame.AllowMultiLeveling = inPacket.ReadBool(); Log.Inform("Characters will {0}be able to continuously level-up.", WvsGame.AllowMultiLeveling ? "" : "not "); WvsGame.ExperienceRate = inPacket.ReadInt(); WvsGame.QuestExperienceRate = inPacket.ReadInt(); WvsGame.PartyQuestExperienceRate = inPacket.ReadInt(); WvsGame.MesoRate = inPacket.ReadInt(); WvsGame.DropRate = inPacket.ReadInt(); Log.Inform("Rates: \n ExpRate: {0}x \n QuestExpRate: {1}x \n PartyQuestExpRate: {2}x \n MesoRate: {3}x \n DropRate: {4}x", WvsGame.ExperienceRate, WvsGame.QuestExperienceRate, WvsGame.PartyQuestExperienceRate, WvsGame.MesoRate, WvsGame.DropRate); Log.SkipLine(); Log.Success("Registered Channel: {0}-{2} on World: {0}-{1}.", WvsGame.WorldName, WvsGame.WorldID, (WvsGame.ChannelID + 1)); Log.SkipLine(); } break; case ServerRegsitrationResponse.InvalidType: break; case ServerRegsitrationResponse.InvalidCode: break; case ServerRegsitrationResponse.Full: break; default: { Log.SkipLine(); Log.Error("Unable to register as Channel Server: {0}", ServerRegistrationResponseResolver.Explain(response)); Log.SkipLine(); WvsGame.Stop(); } break; } WvsGame.CenterConnectionDone.Set(); }
private async Task OnMigrateIn(IPacket packet) { var characterID = packet.Decode <int>(); using (var db = WvsGame.DataContextFactory.Create()) { var character = db.Characters .Include(c => c.Data) .ThenInclude(a => a.Account) .Include(c => c.Data) .ThenInclude(c => c.Trunk) .ThenInclude(c => c.Items) .Include(c => c.Inventories) .ThenInclude(c => c.Items) .Include(c => c.WishList) .Single(c => c.ID == characterID); character.CoupleRecords = db.CoupleRecord .Where(c => c.CharacterID == character.ID) .ToList(); character.FriendRecords = db.FriendRecord .Where(c => c.CharacterID == character.ID) .ToList(); character.Memos = db.Memos .Where(m => m.CharacterID == character.ID) .ToList(); if (!await WvsGame.TryMigrateFrom(character, WvsGame.Info)) { await Disconnect(); } var field = WvsGame.FieldManager.Get(character.FieldID); var fieldUser = new FieldUser(this, character); FieldUser = fieldUser; await field.Enter(fieldUser); var memos = character.Memos; if (memos.Count > 0) { using (var p = new Packet(SendPacketOperations.MemoResult)) { p.Encode <byte>((byte)MemoResult.Load); p.Encode <byte>((byte)memos.Count); memos.ForEach(m => { p.Encode <int>(m.ID); p.Encode <string>(m.Sender); p.Encode <string>(m.Content); p.Encode <DateTime>(m.DateSent); p.Encode <byte>((byte)m.Flag); }); await SendPacket(p); } } } }
public CField_Zakum(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { SpawnPoint = new TagPoint(-11, -215); DropRect = new TagRect(-185, -240, 185, -200); IsChaosZakum = MapId == CHAOSZAKUM_MAP_ID; _exitmap = IsChaosZakum ? 211042301 : 211042300; // door to (chaos) zakum }
public CField_Dojang(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { _normal = (MapId / 10000) - 92500 == 2; _stage = (MapId - BASE_MAP_ID) / 100; var stageIncrement = (int)Math.Floor(_stage / 6f); _bossMob = BASE_BOSS_ID + _stage - stageIncrement; _summonItem = BASE_BOSS_ITEM_SPAWNER_ID + _stage; }
public CField_DungeonRaid_GolemTemple(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { MapSuccession = new Dictionary <int, int> // <FieldFrom, FieldTo> { { 100040100, 100040200 }, // first to second map { 100040200, 100040300 }, // second to third map { 100040300, 100040400 }, // third to fourth map { 100040400, 100040500 }, // fourth to fifth map { 100040500, WarpOutField } // fifth to warpout map }; DungeonFieldIndex = nMapId % 1000 / 100; }
//----------------------------------------------------------------------------- public WvsCenter(IConfiguration config) { Config = config; var channels = config.GetValue <int>("channels"); WvsLogin = new WvsLogin(this); WvsShop = new WvsShop(this); WvsGames = new WvsGame[channels]; for (int i = 0; i < WvsGames.Length; i++) { var channel = (byte)i; WvsGames[i] = new WvsGame(this, channel); } }
public CField_WaitingRoom(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { switch (MapId) { case BattlefieldData.RanchWaitingRoom: // TODO figure out how to add support for more group sizes MaxPlayers = 5; //#if DEBUG // 2; //#else // 5; //#endif nWarpMap = BattlefieldData.BattleMap; nTimeoutMap = BattlefieldData.RanchEntranceMap; WaitTimeSeconds = 120; // two minutes WeatherMessage = $"When the room reaches {MaxPlayers} players, talk to me and get warped in!"; break; } }
public static void Main() { try { WvsGame.CenterConnection = new CenterServer(new IPEndPoint( Settings.GetIPAddress("Center/IP"), Settings.GetInt("Center/Port")), Settings.GetString("Center/SecurityCode")); WvsGame.CenterConnection.Loop(); } catch (Exception e) { Log.Error("Server connection failed: \n{0}", e.Message); WvsGame.Stop(); } finally { WvsGame.CenterConnectionDone.Set(); } }
public CFieldMan(WvsGame parent) { Parent = parent; m_aFields = new Dictionary <int, CFieldEntry>(); }
// TODO: Items validation. private void CreateCharacter(Packet inPacket) { int accountID = inPacket.ReadInt(); string name = inPacket.ReadString(); JobType jobType = (JobType)inPacket.ReadInt(); int face = inPacket.ReadInt(); int hair = inPacket.ReadInt(); int hairColor = inPacket.ReadInt(); byte skin = (byte)inPacket.ReadInt(); int topID = inPacket.ReadInt(); int bottomID = inPacket.ReadInt(); int shoesID = inPacket.ReadInt(); int weaponID = inPacket.ReadInt(); Gender gender = (Gender)inPacket.ReadByte(); bool error = false; if (ValidCharacterName(name)) { switch (gender) // TODO: these need error catching with item info. { case Gender.Male: if (!DataProvider.CreationData.MaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.MaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.MaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.MaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.MaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.MaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.MaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.MaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; case Gender.Female: if (!DataProvider.CreationData.FemaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.FemaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.FemaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.FemaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.FemaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.FemaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.FemaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.FemaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; default: error = false; break; } } if (error) { Log.SkipLine(); Log.Error("Failed to load character items on character creation!"); Log.SkipLine(); WvsGame.Stop(); } Character character = new Character { AccountID = accountID, WorldID = WvsGame.WorldID, Name = name, Gender = gender, Skin = skin, Face = face, Hair = hair + hairColor, Level = 1, Job = jobType == JobType.Cygnus ? Job.Noblesse : jobType == JobType.Explorer ? Job.Beginner : Job.Aran, Strength = 12, Dexterity = 5, Intelligence = 4, Luck = 4, MaxHealth = 50, MaxMana = 5, Health = 50, Mana = 5, AbilityPoints = 0, SkillPoints = 0, Experience = 0, Fame = 0, Map = DataProvider.Maps[jobType == JobType.Cygnus ? 130030000 : jobType == JobType.Explorer ? 10000 : 914000000], SpawnPoint = 0, Meso = 0 }; character.Items.Add(new Item(topID, equipped: true)); character.Items.Add(new Item(bottomID, equipped: true)); character.Items.Add(new Item(shoesID, equipped: true)); character.Items.Add(new Item(weaponID, equipped: true)); character.Items.Add(new Item(jobType == JobType.Cygnus ? 4161047 : jobType == JobType.Explorer ? 4161001 : 4161048), forceGetSlot: true); character.Keymap.Add(new Shortcut(KeymapKey.One, KeymapAction.AllChat)); character.Keymap.Add(new Shortcut(KeymapKey.Two, KeymapAction.PartyChat)); character.Keymap.Add(new Shortcut(KeymapKey.Three, KeymapAction.BuddyChat)); character.Keymap.Add(new Shortcut(KeymapKey.Four, KeymapAction.GuildChat)); character.Keymap.Add(new Shortcut(KeymapKey.Five, KeymapAction.AllianceChat)); character.Keymap.Add(new Shortcut(KeymapKey.Six, KeymapAction.SpouseChat)); character.Keymap.Add(new Shortcut(KeymapKey.Q, KeymapAction.QuestMenu)); character.Keymap.Add(new Shortcut(KeymapKey.W, KeymapAction.WorldMap)); character.Keymap.Add(new Shortcut(KeymapKey.E, KeymapAction.EquipmentMenu)); character.Keymap.Add(new Shortcut(KeymapKey.R, KeymapAction.BuddyList)); character.Keymap.Add(new Shortcut(KeymapKey.I, KeymapAction.ItemMenu)); character.Keymap.Add(new Shortcut(KeymapKey.O, KeymapAction.PartySearch)); character.Keymap.Add(new Shortcut(KeymapKey.P, KeymapAction.PartyList)); character.Keymap.Add(new Shortcut(KeymapKey.BracketLeft, KeymapAction.Shortcut)); character.Keymap.Add(new Shortcut(KeymapKey.BracketRight, KeymapAction.QuickSlot)); character.Keymap.Add(new Shortcut(KeymapKey.LeftCtrl, KeymapAction.Attack)); character.Keymap.Add(new Shortcut(KeymapKey.S, KeymapAction.AbilityMenu)); character.Keymap.Add(new Shortcut(KeymapKey.F, KeymapAction.FamilyList)); character.Keymap.Add(new Shortcut(KeymapKey.G, KeymapAction.GuildList)); character.Keymap.Add(new Shortcut(KeymapKey.H, KeymapAction.WhisperChat)); character.Keymap.Add(new Shortcut(KeymapKey.K, KeymapAction.SkillMenu)); character.Keymap.Add(new Shortcut(KeymapKey.L, KeymapAction.QuestHelper)); character.Keymap.Add(new Shortcut(KeymapKey.Semicolon, KeymapAction.Medal)); character.Keymap.Add(new Shortcut(KeymapKey.Quote, KeymapAction.ExpandChat)); character.Keymap.Add(new Shortcut(KeymapKey.Backtick, KeymapAction.CashShop)); character.Keymap.Add(new Shortcut(KeymapKey.Backslash, KeymapAction.SetKey)); character.Keymap.Add(new Shortcut(KeymapKey.Z, KeymapAction.PickUp)); character.Keymap.Add(new Shortcut(KeymapKey.X, KeymapAction.Sit)); character.Keymap.Add(new Shortcut(KeymapKey.C, KeymapAction.Messenger)); character.Keymap.Add(new Shortcut(KeymapKey.B, KeymapAction.MonsterBook)); character.Keymap.Add(new Shortcut(KeymapKey.M, KeymapAction.MiniMap)); character.Keymap.Add(new Shortcut(KeymapKey.LeftAlt, KeymapAction.Jump)); character.Keymap.Add(new Shortcut(KeymapKey.Space, KeymapAction.NpcChat)); character.Keymap.Add(new Shortcut(KeymapKey.F1, KeymapAction.Cockeyed)); character.Keymap.Add(new Shortcut(KeymapKey.F2, KeymapAction.Happy)); character.Keymap.Add(new Shortcut(KeymapKey.F3, KeymapAction.Sarcastic)); character.Keymap.Add(new Shortcut(KeymapKey.F4, KeymapAction.Crying)); character.Keymap.Add(new Shortcut(KeymapKey.F5, KeymapAction.Outraged)); character.Keymap.Add(new Shortcut(KeymapKey.F6, KeymapAction.Shocked)); character.Keymap.Add(new Shortcut(KeymapKey.F7, KeymapAction.Annoyed)); character.Save(); using (Packet outPacket = new Packet(InteroperabilityOperationCode.CharacterCreationResponse)) { outPacket.WriteInt(accountID); outPacket.WriteBytes(character.ToByteArray()); this.Send(outPacket); } }
protected override void StopServer() { WvsGame.Stop(); }
// CField_SnowBall::CField_SnowBall // CField_SnowBall::OnStart(CField_SnowBall *this, CUser *pUser, CInPacket *iPacket) public CField_Snowball(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { }
protected CField_DungeonRaid(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { MobKills = new Dictionary <int, int>(); }
public CenterServerSocket(IContainer container, IChannel channel, uint seqSend, uint seqRecv) : base(channel, seqSend, seqRecv) { _container = container; _wvsGame = container.GetInstance <WvsGame>(); }
public CEventManager(WvsGame parent) { tLastEventStart = DateTime.Now.AddMinutes(-nEventIntervalMinutes + 5); Parent = parent; MasterManager.Log.Info("CommunityEventManager loaded."); }
public static void SetEventManager(WvsGame parent) => EventManager = new CEventManager(parent);
public CField_Battlefield(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { }
// TODO: Items validation. private void CreateCharacter(Packet inPacket) { int accountID = inPacket.ReadInt(); string name = inPacket.ReadString(); CharacterConstants.JobType jobType = (CharacterConstants.JobType)inPacket.ReadInt(); int face = inPacket.ReadInt(); int hair = inPacket.ReadInt(); int hairColor = inPacket.ReadInt(); byte skin = (byte)inPacket.ReadInt(); int topID = inPacket.ReadInt(); int bottomID = inPacket.ReadInt(); int shoesID = inPacket.ReadInt(); int weaponID = inPacket.ReadInt(); CharacterConstants.Gender gender = (CharacterConstants.Gender)inPacket.ReadByte(); bool error = false; if (ValidCharacterName(name)) { switch (gender) // TODO: these need error catching with item info. { case CharacterConstants.Gender.Male: if (!DataProvider.CreationData.MaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.MaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.MaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.MaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.MaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.MaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.MaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.MaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; case CharacterConstants.Gender.Female: if (!DataProvider.CreationData.FemaleSkins.Any(x => x.Item1 == jobType && x.Item2 == skin) || !DataProvider.CreationData.FemaleFaces.Any(x => x.Item1 == jobType && x.Item2 == face) || !DataProvider.CreationData.FemaleHairs.Any(x => x.Item1 == jobType && x.Item2 == hair) || !DataProvider.CreationData.FemaleHairColors.Any(x => x.Item1 == jobType && x.Item2 == hairColor) || !DataProvider.CreationData.FemaleTops.Any(x => x.Item1 == jobType && x.Item2 == topID) || !DataProvider.CreationData.FemaleBottoms.Any(x => x.Item1 == jobType && x.Item2 == bottomID) || !DataProvider.CreationData.FemaleShoes.Any(x => x.Item1 == jobType && x.Item2 == shoesID) || !DataProvider.CreationData.FemaleWeapons.Any(x => x.Item1 == jobType && x.Item2 == weaponID)) { error = true; } break; case CharacterConstants.Gender.Both: break; case CharacterConstants.Gender.Unset: break; default: break; } } if (error) { Log.SkipLine(); Log.Error("Failed to load character items on character creation!"); Log.SkipLine(); WvsGame.Stop(); } Character character = new Character { AccountID = accountID, WorldID = WvsGame.WorldID, Name = name, Appearance = { Gender = gender, Skin = skin, Face = face, Hair = hair + hairColor }, Stats = { Level = 1, Experience = 0, MaxHealth = 50, MaxMana = 5, Health = 50, Mana = 5, AbilityPoints = 0, SkillPoints = 0, Strength = 12, Dexterity = 5, Intelligence = 4, Luck = 4, Fame = 0, Meso = 0 }, Jobs = { Job = jobType == CharacterConstants.JobType.Cygnus ? CharacterConstants.Job.Noblesse : jobType == CharacterConstants.JobType.Explorer ? CharacterConstants.Job.Beginner : CharacterConstants.Job.Aran }, Map = DataProvider.Maps[ jobType == CharacterConstants.JobType.Cygnus ? 130030000 : jobType == CharacterConstants.JobType.Explorer ? 10000 : 914000000], SpawnPoint = 0, }; character.Items.AddItemToInventory(new Item(topID, equipped: true)); character.Items.AddItemToInventory(new Item(bottomID, equipped: true)); character.Items.AddItemToInventory(new Item(shoesID, equipped: true)); character.Items.AddItemToInventory(new Item(weaponID, equipped: true)); switch (jobType) { case CharacterConstants.JobType.Cygnus: character.Items.AddItemToInventory(new Item(4161047)); // Noblesse Guide break; case CharacterConstants.JobType.Explorer: character.Items.AddItemToInventory(new Item(4161001)); // Beginner's Guide break; case CharacterConstants.JobType.Aran: // Legend character.Items.AddItemToInventory(new Item(4161048)); // Legend's Guide break; default: throw new ArgumentOutOfRangeException(); } character.Keymap.InitiateDefaultKeymap(); character.Save(); using (Packet outPacket = new Packet(InteroperabilityOperationCode.CharacterCreationResponse)) { outPacket.WriteInt(accountID); outPacket.WriteBytes(character.ToByteArray()); Send(outPacket); } }
protected override void Terminate() { WvsGame.Stop(); }
public CField_PersonalTimeLimit(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { }
public CField_RussianRoulette(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { }
public CField_PinkBean(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { }
protected CField_CommunityEvent(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { tFieldTimerExpiration = DateTime.Now.AddMinutes(5); MasterManager.CharacterPool.Broadcast(CPacket.SystemMessage($"[Community Event] {sEventName} is about to start! Enter @event to join.")); }
public CField_Hontail(WvsGame parentInstance, int nMapId, int nInstanceId) : base(parentInstance, nMapId, nInstanceId) { }