protected Character(RealmManager manager, ushort objType, wRandom rand) : base(manager, objType) { Random = rand; _hp = new SV <int>(this, StatsType.HP, 0); _maximumHP = new SV <int>(this, StatsType.MaximumHP, 0); if (ObjectDesc != null) { if (ObjectDesc.SizeStep != 0) { var step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; SetDefaultSize(ObjectDesc.MinSize + step); } else { SetDefaultSize(ObjectDesc.MinSize); } SetConditions(); HP = ObjectDesc.MaxHP; MaximumHP = HP; } }
protected Character(short objType, wRandom rand) : base(objType) { this.Random = rand; if (ObjectDesc != null) { //Name = ObjectDesc.DisplayId ?? ""; if (ObjectDesc.SizeStep != 0) { var step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else Size = ObjectDesc.MinSize; HP = ObjectDesc.MaxHP; Stars = ObjectDesc.Stars; isNPC = ObjectDesc.Class == "NPC"; } else { Stars = 0; isNPC = false; } }
public void CheckGroundOnMove() { WmapTile tile = Owner.Map[(int)X, (int)Y]; TileDesc tileDesc = Manager.GameData.Tiles[tile.TileId]; if (tile.Region == TileRegion.Encounter_1 || tile.Region == TileRegion.Encounter_2 || tile.Region == TileRegion.Encounter_3 || tile.Region == TileRegion.Encounter_4) { string[] pokemons = new string[] { }; switch(tile.Region) { case TileRegion.Encounter_1: pokemons = new string[] { "Caterpie", "Weedle", "Kakuna", "Metapod" }; break; case TileRegion.Encounter_2: pokemons = new string[] { "Pidgey", "Rattata" }; break; case TileRegion.Encounter_3: pokemons = new string[] { "Bulbasaur", "Squirtle", "Charmander" }; break; case TileRegion.Encounter_4: pokemons = new string[] { "Venusaur", "Blastoise", "Charizard" }; break; } wRandom pokerand = new wRandom(); if (pokerand.Next(0, 10) == 0) { Client.SendPacket(new EncounterStartPacket() { Pokemon = pokemons[pokerand.Next(0, pokemons.Length)] }); } } }
public string GetMusic(wRandom rand) { if (Music != null && Music.Length > 0) { return(Music[rand.Next(0, Music.Length)]); } return("None"); }
public string GetMusic() { if (Music.Length == 0) { return("null"); } var rand = new wRandom(); return(Music[rand.Next(0, Music.Length)]); }
public string GetMusic(wRandom rand = null) { if (Music.Length == 0) { return("null"); } if (rand == null) { rand = new wRandom(); } return(Music[rand.Next(0, Music.Length)]); }
protected Character(RealmManager manager, ushort objType, wRandom rand) : base(manager, objType) { this.Random = rand; if (ObjectDesc != null) { if (ObjectDesc.SizeStep != 0) { var step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else Size = ObjectDesc.MinSize; HP = ObjectDesc.MaxHP; } }
public Character(RealmManager manager, ushort objType, wRandom rand) : base(manager, objType) { Random = rand; if (ObjectDesc == null) return; Name = ObjectDesc.DisplayId ?? ""; if (ObjectDesc.SizeStep != 0) { int step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else Size = ObjectDesc.MinSize; HP = (int)ObjectDesc.MaxHP; }
protected Character(short objType, wRandom rand) : base(objType) { Random = rand; if (ObjectDesc == null) return; //Name = ObjectDesc.DisplayId ?? ""; if (ObjectDesc.SizeStep != 0) { var step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize)/ObjectDesc.SizeStep + 1)* ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else Size = ObjectDesc.MinSize; HP = ObjectDesc.MaxHp; }
public void Dispose() { if (disposed) { return; } handler?.Dispose(); handler = null; ReceiveKey = null; SendKey = null; Manager = null; skt = null; Character = null; Account = null; Player?.Dispose(); Player = null; Random = null; disposed = true; }
protected Character(RealmManager manager, ushort objType, wRandom rand) : base(manager, objType) { this.Random = rand; if (ObjectDesc != null) { if (ObjectDesc.SizeStep != 0) { var step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else { Size = ObjectDesc.MinSize; } HP = ObjectDesc.MaxHP; } }
protected Character(short objType, wRandom rand) : base(objType) { this.Random = rand; if (ObjectDesc != null) { //Name = ObjectDesc.DisplayId ?? ""; if (ObjectDesc.SizeStep != 0) { var step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else { Size = ObjectDesc.MinSize; } HP = ObjectDesc.MaxHP; } }
public Character(RealmManager manager, ushort objType, wRandom rand) : base(manager, objType) { Random = rand; if (ObjectDesc == null) { return; } Name = ObjectDesc.DisplayId ?? ""; if (ObjectDesc.SizeStep != 0) { int step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else { Size = ObjectDesc.MinSize; } HP = (int)ObjectDesc.MaxHP; }
protected Character(short objType, wRandom rand) : base(objType) { Random = rand; if (ObjectDesc == null) { return; } //Name = ObjectDesc.DisplayId ?? ""; if (ObjectDesc.SizeStep != 0) { int step = Random.Next(0, (ObjectDesc.MaxSize - ObjectDesc.MinSize) / ObjectDesc.SizeStep + 1) * ObjectDesc.SizeStep; Size = ObjectDesc.MinSize + step; } else { Size = ObjectDesc.MinSize; } HP = ObjectDesc.MaxHp; }
public void CheckGroundOnMove() { WmapTile tile = Owner.Map[(int)X, (int)Y]; TileDesc tileDesc = Manager.GameData.Tiles[tile.TileId]; if (tile.Region == TileRegion.Encounter_1 || tile.Region == TileRegion.Encounter_2 || tile.Region == TileRegion.Encounter_3 || tile.Region == TileRegion.Encounter_4) { string[] pokemons = new string[] { }; switch (tile.Region) { case TileRegion.Encounter_1: pokemons = new string[] { "Caterpie", "Weedle", "Kakuna", "Metapod" }; break; case TileRegion.Encounter_2: pokemons = new string[] { "Pidgey", "Rattata" }; break; case TileRegion.Encounter_3: pokemons = new string[] { "Bulbasaur", "Squirtle", "Charmander" }; break; case TileRegion.Encounter_4: pokemons = new string[] { "Venusaur", "Blastoise", "Charizard" }; break; } wRandom pokerand = new wRandom(); if (pokerand.Next(0, 10) == 0) { Client.SendPacket(new EncounterStartPacket() { Pokemon = pokemons[pokerand.Next(0, pokemons.Length)] }); } } }
public Inflation() { // TODO: Actually implement real inflation based on the real averidge wealth. min = new wRandom().Next(10000, 20000); max = new wRandom().Next(80000, 100000); }
private void ProcessHelloPacket(HelloPacket pkt) { if (isGuest) { Disconnect(); } db = new Database(); if ((account = db.Verify(pkt.GUID, pkt.Password)) == null) { logger.Info("Account not verified."); account = Database.CreateGuestAccount(pkt.GUID); if (account == null) { logger.Info("Account is null!"); SendPacket(new svrPackets.FailurePacket() { Message = "Invalid account." }); Disconnect(); return; } } logger.Info("Client trying to connect!"); ConnectedBuild = pkt.BuildVersion; if (!RealmManager.TryConnect(this)) { if (CheckAccountInUse(account.AccountId) != false) { logger.Info("Account in use: " + account.AccountId + " " + account.Name); account = null; SendPacket(new svrPackets.FailurePacket() { Message = "Account in use! Retrying..." }); Disconnect(); return; } account = null; SendPacket(new svrPackets.FailurePacket() { Message = "Failed to connect." }); Disconnect(); logger.Info("Failed to connect."); return; } else { logger.Warn("Client loading world"); World world = RealmManager.GetWorld(pkt.GameId); if (world == null) { SendPacket(new svrPackets.FailurePacket() { Message = "Invalid world." }); Disconnect(); logger.Error("Invalid world"); } logger.Error("Client joined world " + world.Id.ToString()); if (world.Id == -6) //Test World { (world as realm.worlds.Test).LoadJson(pkt.MapInfo); } else if (world.IsLimbo) { world = world.GetInstance(this); } var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue; Random = new wRandom(seed); targetWorld = world.Id; SendPacket(new MapInfoPacket() { Width = world.Map.Width, Height = world.Map.Height, Name = world.Name, Seed = seed, Background = world.Background, AllowTeleport = world.AllowTeleport, ShowDisplays = world.ShowDisplays, ClientXML = world.ClientXML, ExtraXML = world.ExtraXML }); stage = ProtocalStage.Handshaked; } }
public string GetMusic(wRandom rand) { if (Music != null && Music.Length > 0) return Music[rand.Next(0, Music.Length)]; else return "None"; }
public string GetMusic(wRandom rand = null) { if (Music.Length == 0) return "null"; if (rand == null) rand = new wRandom(); return Music[rand.Next(0, Music.Length)]; }
private void ProcessHelloPacket(HelloPacket pkt) { if (isGuest) Disconnect(); db = new Database(); if ((account = db.Verify(pkt.GUID, pkt.Password)) == null) { logger.Info("Account not verified."); account = Database.CreateGuestAccount(pkt.GUID); if (account == null) { logger.Info("Account is null!"); SendPacket(new svrPackets.FailurePacket() { Message = "Invalid account." }); Disconnect(); return; } } logger.Info("Client trying to connect!"); ConnectedBuild = pkt.BuildVersion; if (!RealmManager.TryConnect(this)) { if (CheckAccountInUse(account.AccountId) != false) { logger.Info("Account in use: " + account.AccountId + " " + account.Name); account = null; SendPacket(new svrPackets.FailurePacket() { Message = "Account in use! Retrying..." }); Disconnect(); return; } account = null; SendPacket(new svrPackets.FailurePacket() { Message = "Failed to connect." }); Disconnect(); logger.Info("Failed to connect."); return; } else { logger.Warn("Client loading world"); World world = RealmManager.GetWorld(pkt.GameId); if (world == null) { SendPacket(new svrPackets.FailurePacket() { Message = "Invalid world." }); Disconnect(); logger.Error("Invalid world"); } logger.Error("Client joined world " + world.Id.ToString()); if (world.Id == -6) //Test World (world as realm.worlds.Test).LoadJson(pkt.MapInfo); else if (world.IsLimbo) world = world.GetInstance(this); var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue; Random = new wRandom(seed); targetWorld = world.Id; SendPacket(new MapInfoPacket() { Width = world.Map.Width, Height = world.Map.Height, Name = world.Name, Seed = seed, Background = world.Background, AllowTeleport = world.AllowTeleport, ShowDisplays = world.ShowDisplays, ClientXML = world.ClientXML, ExtraXML = world.ExtraXML }); stage = ProtocalStage.Handshaked; } }
void ProcessHelloPacket(HelloPacket pkt) { /*if (!skt.RemoteEndPoint.ToString().StartsWith("127.0.0.1")) { SendPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "*Error*", Text = "You should not be here!" }); Disconnect(); return; }*/ db = new Database(); if ((account = db.Verify(pkt.GUID, pkt.Password)) == null) { account = Database.Register(pkt.GUID, pkt.Password, true); if (account == null) { SendFailure("Invalid account."); Disconnect(); return; } } if (!Manager.TryConnect(this)) { account = null; SendFailure("Failed to connect."); Disconnect(); } else { World world = Manager.GetWorld(pkt.GameId); if (world == null) { SendFailure("Invalid world."); Disconnect(); } else { if (world.Id == -6) //Test World (world as realm.worlds.Test).LoadJson(pkt.MapInfo); else if (world.IsLimbo) world = world.GetInstance(this); var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue; Random = new wRandom(seed); targetWorld = world.Id; SendPacket(new MapInfoPacket() { Width = world.Map.Width, Height = world.Map.Height, Name = world.Name, Seed = seed, Background = world.Background, AllowTeleport = world.AllowTeleport, ShowDisplays = world.ShowDisplays, ClientXML = world.ClientXML, ExtraXML = world.ExtraXML }); stage = ProtocalStage.Handshaked; } } }