public virtual void Init(World owner) { Owner = owner; WorldInstance = owner; if (ObjectType == 0x0754) { var en = new StaticObject(Manager, 0x1942, null, true, false, true); en.Move(X, Y); owner.EnterWorld(en); } }
public override void LeaveWorld(Entity entity) { base.LeaveWorld(entity); if (entity.ObjectType != 0x0744) { return; } var x = new StaticObject(_client.Manager, 0x0743, null, true, false, false); x.Move(entity.X, entity.Y); EnterWorld(x); }
public override void LeaveWorld(Entity entity) { base.LeaveWorld(entity); if (entity.ObjectType != 0x0744) { return; } var x = new StaticObject(_client.Manager, 0x0743, null, true, false, false); x.Move(entity.X, entity.Y); EnterWorld(x); if (_client.Account.Gifts.Length <= 0) { _client.SendPacket(new GlobalNotification { Text = "giftChestEmpty" }); } }
void InitVault() { var vaultChestPosition = new List <IntPoint>(); var giftChestPosition = new List <IntPoint>(); var spawn = new IntPoint(0, 0); var w = Map.Width; var h = Map.Height; for (var y = 0; y < h; y++) { for (var x = 0; x < w; x++) { var tile = Map[x, y]; switch (tile.Region) { case TileRegion.Spawn: spawn = new IntPoint(x, y); break; case TileRegion.Vault: vaultChestPosition.Add(new IntPoint(x, y)); break; case TileRegion.Gifting_Chest: giftChestPosition.Add(new IntPoint(x, y)); break; } } } vaultChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); giftChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); for (var i = 0; i < _client.Account.VaultCount && vaultChestPosition.Count > 0; i++) { var vaultChest = new DbVaultSingle(_client.Account, i); var con = new Container(_client.Manager, 0x0504, null, false, vaultChest); con.BagOwners = new int[] { _client.Account.AccountId }; con.Inventory.SetItems(vaultChest.Items); con.Inventory.InventoryChanged += (sender, e) => SaveChest(((Inventory)sender).Parent); con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); vaults.AddFirst(con); } foreach (var i in vaultChestPosition) { var x = new ClosedVaultChest(_client.Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } var gifts = _client.Account.Gifts.ToList(); while (gifts.Count > 0 && giftChestPosition.Count > 0) { var c = Math.Min(8, gifts.Count); var items = gifts.GetRange(0, c); gifts.RemoveRange(0, c); if (c < 8) { items.AddRange(Enumerable.Repeat(ushort.MaxValue, 8 - c)); } var con = new GiftChest(_client.Manager, 0x0744, null, false); con.BagOwners = new int[] { _client.Account.AccountId }; con.Inventory.SetItems(items); con.Move(giftChestPosition[0].X + 0.5f, giftChestPosition[0].Y + 0.5f); EnterWorld(con); giftChestPosition.RemoveAt(0); } foreach (var i in giftChestPosition) { var x = new StaticObject(_client.Manager, 0x0743, null, true, false, false); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } // devon roach if (_client.Account.Name.Equals("Devon")) { var e = new Enemy(Manager, 0x12C); e.Move(38, 68); EnterWorld(e); } }
private void Init(Client psr) { AccountId = psr.Account.AccountId; PlayerOwnerName = psr.Account.Name; List <IntPoint> vaultChestPosition = new List <IntPoint>(); List <IntPoint> giftChestPosition = new List <IntPoint>(); IntPoint spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { WmapTile tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) { spawn = new IntPoint(x, y); } else if (tile.Region == TileRegion.Vault) { vaultChestPosition.Add(new IntPoint(x, y)); } else if (tile.Region == TileRegion.Gifting_Chest) { giftChestPosition.Add(new IntPoint(x, y)); } } } vaultChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); List <VaultChest> chests = psr.Account.Vault.Chests; if (psr.Account.Gifts != null) { List <GiftChest> giftChests = new List <GiftChest>(); GiftChest c = new GiftChest(); c.Items = new List <Item>(8); bool wasLastElse = false; int[] gifts = psr.Account.Gifts.ToArray(); gifts.Shuffle(); using (Database db = new Database()) { for (int i = 0; i < gifts.Count(); i++) { Item newGift = db.getSerialInfo(gifts[i], Manager.GameData); if (c.Items.Count < 8) { c.Items.Add(newGift); wasLastElse = false; } else { giftChests.Add(c); c = new GiftChest(); c.Items = new List <Item>(8); c.Items.Add(newGift); wasLastElse = true; } } } if (!wasLastElse) { giftChests.Add(c); } foreach (GiftChest chest in giftChests) { if (giftChestPosition.Count == 0) { break; } while (chest.Items.Count < 8) { chest.Items.Add(null); } OneWayContainer con = new OneWayContainer(Manager, 0x0744, null, false); List <Item> inv = chest.Items; for (int j = 0; j < 8; j++) { con.Inventory[j] = inv[j]; } con.Move(giftChestPosition[0].X + 0.5f, giftChestPosition[0].Y + 0.5f); EnterWorld(con); giftChestPosition.RemoveAt(0); } } foreach (VaultChest t in chests) { if (vaultChestPosition.Count == 0) { break; } Container con = new Container(Manager, 0x0504, null, false); Item[] inv; using (Database db = new Database()) { inv = db.getSerialInfo(t.Items, Manager.GameData); }; for (int j = 0; j < 8; j++) { con.Inventory[j] = inv[j]; } con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); _vaultChests[new Tuple <Container, VaultChest>(con, t)] = con.UpdateCount; } foreach (IntPoint i in giftChestPosition) { StaticObject x = new StaticObject(Manager, 0x0743, null, true, false, false); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } foreach (IntPoint i in vaultChestPosition) { SellableObject x = new SellableObject(Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
private void GenerateGravestone() { var maxed = (from i in Manager.GameData.ObjectTypeToElement[ObjectType].Elements("LevelIncrease") let xElement = Manager.GameData.ObjectTypeToElement[ObjectType].Element(i.Value) where xElement != null let limit = int.Parse(xElement.Attribute("max").Value) let idx = StatsManager.StatsNameToIndex(i.Value) where Stats[idx] >= limit select limit).Count(); ushort objType; int? time; switch (maxed) { case 8: objType = 0x0735; time = null; break; case 7: objType = 0x0734; time = null; break; case 6: objType = 0x072b; time = null; break; case 5: objType = 0x072a; time = null; break; case 4: objType = 0x0729; time = null; break; case 3: objType = 0x0728; time = null; break; case 2: objType = 0x0727; time = null; break; case 1: objType = 0x0726; time = null; break; default: if (Level <= 1) { objType = 0x0723; time = 30 * 1000; } else if (Level < 20) { objType = 0x0724; time = 60 * 1000; } else { objType = 0x0725; time = 5 * 60 * 1000; } break; } var obj = new StaticObject(Manager, objType, time, true, time != null, false); obj.Move(X, Y); obj.Name = Name; Owner.EnterWorld(obj); }
private void GenerateGravestone() { var maxed = 0; foreach (var i in XmlDatas.TypeToElement[ObjectType].Elements("LevelIncrease")) { var limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(i.Value).Attribute("max").Value); var idx = StatsManager.StatsNameToIndex(i.Value); if (Stats[idx] >= limit) maxed++; } short objType; int? time; switch (maxed) { case 8: objType = 0x0735; time = null; /* if (player.objType = 782) //Wizard { objType = 0x0723; time = null; } else if (player.objType = 784) //Priest { objType = 0x0723; time = null; } else if (player.objType = 768) //Rogue { objType = 0x0723; time = null; } else if (player.objType = 801) //Necromancer { objType = 0x0723; time = null; } else if (player.objType = 798) //Knight { objType = 0x0723; time = null; } else if (player.objType = 800) //Assassin { objType = 0x0723; time = null; } else if (player.objType = 802) //Huntress { objType = 0x0723; time = null; } else if (player.objType = 804) //Trickster { objType = 0x0723; time = null; } else if (player.objType = 775) //Warrior { objType = 0x0723; time = null; } * else if (player.objType = 782) { objType = 0x0723; time = null; } else if (player.objType = 782) { objType = 0x0723; time = null; } else if (player.objType = 782) { objType = 0x0723; time = null; } else if (player.objType = 782) { objType = 0x0723; time = null; } else if (player.objType = 782) { objType = 0x0723; time = null; } */ break; case 7: objType = 0x0734; time = null; break; case 6: objType = 0x072b; time = null; break; case 5: objType = 0x072a; time = null; break; case 4: objType = 0x0729; time = null; break; case 3: objType = 0x0728; time = null; break; case 2: objType = 0x0727; time = null; break; case 1: objType = 0x0726; time = null; break; default: if (Level <= 1) { objType = 0x0723; time = 30*1000; } else if (Level < 20) { objType = 0x0724; time = 60*1000; } else { objType = 0x0725; time = 5*60*1000; } break; } var obj = new StaticObject(objType, time, true, time != null, false); obj.Move(X, Y); obj.Name = Name; Owner.EnterWorld(obj); }
private void GenerateGravestone() { var maxed = (from i in XmlData.TypeToElement[ObjectType].Elements("LevelIncrease") let limit = int.Parse(XmlData.TypeToElement[ObjectType].Element(i.Value).Attribute("max").Value) let idx = StatsManager.StatsNameToIndex(i.Value) where Stats[idx] >= limit select limit).Count(); short objType; int? time; switch (maxed) { case 8: objType = 0x0735; time = null; break; case 7: objType = 0x0734; time = null; break; case 6: objType = 0x072b; time = null; break; case 5: objType = 0x072a; time = null; break; case 4: objType = 0x0729; time = null; break; case 3: objType = 0x0728; time = null; break; case 2: objType = 0x0727; time = null; break; case 1: objType = 0x0726; time = null; break; default: if (Level <= 1) { objType = 0x0723; time = 30 * 1000; } else if (Level < 20) { objType = 0x0724; time = 60 * 1000; } else { objType = 0x0725; time = 5 * 60 * 1000; } break; } var obj = new StaticObject(objType, time, true, time != null, false); obj.Move(X, Y); obj.Name = Name; Owner.EnterWorld(obj); }
private void GenerateGravestone() { var maxed = 0; foreach (var i in XmlDatas.TypeToElement[ObjectType].Elements("LevelIncrease")) { var limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(i.Value).Attribute("max").Value); var idx = StatsManager.StatsNameToIndex(i.Value); if (Stats[idx] >= limit) { maxed++; } } short objType; int? time; switch (maxed) { case 8: objType = 0x0735; time = null; /* * if (player.objType = 782) //Wizard * { * objType = 0x0723; time = null; * } * else if (player.objType = 784) //Priest * { * objType = 0x0723; time = null; * } * else if (player.objType = 768) //Rogue * { * objType = 0x0723; time = null; * } * else if (player.objType = 801) //Necromancer * { * objType = 0x0723; time = null; * } * else if (player.objType = 798) //Knight * { * objType = 0x0723; time = null; * } * else if (player.objType = 800) //Assassin * { * objType = 0x0723; time = null; * } * else if (player.objType = 802) //Huntress * { * objType = 0x0723; time = null; * } * else if (player.objType = 804) //Trickster * { * objType = 0x0723; time = null; * } * else if (player.objType = 775) //Warrior * { * objType = 0x0723; time = null; * } * * else if (player.objType = 782) * { * objType = 0x0723; time = null; * } * else if (player.objType = 782) * { * objType = 0x0723; time = null; * } * else if (player.objType = 782) * { * objType = 0x0723; time = null; * } * else if (player.objType = 782) * { * objType = 0x0723; time = null; * } * else if (player.objType = 782) * { * objType = 0x0723; time = null; * } */ break; case 7: objType = 0x0734; time = null; break; case 6: objType = 0x072b; time = null; break; case 5: objType = 0x072a; time = null; break; case 4: objType = 0x0729; time = null; break; case 3: objType = 0x0728; time = null; break; case 2: objType = 0x0727; time = null; break; case 1: objType = 0x0726; time = null; break; default: if (Level <= 1) { objType = 0x0723; time = 30 * 1000; } else if (Level < 20) { objType = 0x0724; time = 60 * 1000; } else { objType = 0x0725; time = 5 * 60 * 1000; } break; } var obj = new StaticObject(objType, time, true, time != null, false); obj.Move(X, Y); obj.Name = Name; Owner.EnterWorld(obj); }
private void Init(Client psr) { AccountId = psr.Account.AccountId; PlayerOwnerName = psr.Account.Name; List <IntPoint> vaultChestPosition = new List <IntPoint>(); List <IntPoint> giftChestPosition = new List <IntPoint>(); IntPoint spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { WmapTile tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) { spawn = new IntPoint(x, y); } else if (tile.Region == TileRegion.Vault) { vaultChestPosition.Add(new IntPoint(x, y)); } else if (tile.Region == TileRegion.Gifting_Chest) { giftChestPosition.Add(new IntPoint(x, y)); } } } vaultChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); List <VaultChest> chests = psr.Account.Vault.Chests; foreach (VaultChest t in chests) { if (vaultChestPosition.Count == 0) { break; } Container con = new Container(Manager, 0x0504, null, false); Item[] inv = t.Items.Select( _ => _ == -1 ? null : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null)) .ToArray(); for (int j = 0; j < 8; j++) { con.Inventory[j] = inv[j]; } con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); _vaultChests[new Tuple <Container, VaultChest>(con, t)] = con.UpdateCount; } foreach (IntPoint i in giftChestPosition) { StaticObject x = new StaticObject(Manager, 0x0743, null, true, false, false); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } foreach (IntPoint i in vaultChestPosition) { SellableObject x = new SellableObject(Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
private void InitVault() { var vaultChestPosition = new List <IntPoint>(); List <IntPoint> giftChestPosition = new List <IntPoint>(); var spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { WmapTile tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) { spawn = new IntPoint(x, y); } else if (tile.Region == TileRegion.Vault) { vaultChestPosition.Add(new IntPoint(x, y)); } else if (tile.Region == TileRegion.Gifting_Chest) { giftChestPosition.Add(new IntPoint(x, y)); } } } vaultChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); List <VaultChest> chests = client.Account.Vault.Chests; if (client.Account.Gifts != null) { List <GiftChest> giftChests = new List <GiftChest>(); GiftChest c = new GiftChest(); c.Items = new List <Item>(8); bool wasLastElse = false; int[] gifts = client.Account.Gifts.ToArray(); gifts.Shuffle(); for (int i = 0; i < gifts.Count(); i++) { if (Manager.GameData.Items.ContainsKey((ushort)gifts[i])) { if (c.Items.Count < 8) { c.Items.Add(Manager.GameData.Items[(ushort)gifts[i]]); wasLastElse = false; } else { giftChests.Add(c); c = new GiftChest(); c.Items = new List <Item>(8); c.Items.Add(Manager.GameData.Items[(ushort)gifts[i]]); wasLastElse = true; } } } if (!wasLastElse) { giftChests.Add(c); } foreach (GiftChest chest in giftChests) { if (giftChestPosition.Count == 0) { break; } while (chest.Items.Count < 8) { chest.Items.Add(null); } OneWayContainer con = new OneWayContainer(Manager, 0x0744, null, false); List <Item> inv = chest.Items; for (int j = 0; j < 8; j++) { con.Inventory[j] = inv[j]; } con.Move(giftChestPosition[0].X + 0.5f, giftChestPosition[0].Y + 0.5f); EnterWorld(con); giftChestPosition.RemoveAt(0); } } for (int i = 0; i < chests.Count; i++) { var con = new Container(client.Manager, 0x0504, null, false); Item[] inv = chests[i].Items.Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_]).ToArray(); ItemData[] dats = chests[i].Datas; for (int j = 0; j < 8; j++) { con.Inventory[j] = inv[j]; con.Inventory.Data[j] = dats[j]; } con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); vaultChests[new Tuple <Container, VaultChest>(con, chests[i])] = con.UpdateCount; } foreach (IntPoint i in giftChestPosition) { StaticObject x = new StaticObject(Manager, 0x0743, null, true, false, false); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } foreach (IntPoint i in vaultChestPosition) { var x = new SellableObject(client.Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }