public void ResolveMType() { MType = -1; var list = new int[0]; if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_1) { list = MerchantLists.store1List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_2) { list = MerchantLists.store2List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_3) { list = MerchantLists.store3List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_4) { list = MerchantLists.store4List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_5) { list = MerchantLists.store5List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_6) { list = MerchantLists.store6List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_7) { list = MerchantLists.store7List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_8) { list = MerchantLists.store8List; } //else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_9) // list = MerchantLists.store9List; //else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_10) // list = MerchantLists.store10List; //else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_11) // list = MerchantLists.store11List; else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_12) { list = MerchantLists.AccessoryDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_13) { list = MerchantLists.ClothingClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_14) { list = MerchantLists.AccessoryClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_15) { list = MerchantLists.ClothingDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_16) { list = MerchantLists.store5List; } //else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_17) // list = MerchantLists.store7List; else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_18) { list = MerchantLists.store6List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_19) { list = MerchantLists.store2List; } //else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_20) // list = MerchantLists.store20List; else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_21) { list = MerchantLists.AccessoryClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_22) { list = MerchantLists.AccessoryDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_23) { list = MerchantLists.ClothingClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_24) { list = MerchantLists.ClothingDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_25) { list = MerchantLists.store25List; } if (AddedTypes == null) { AddedTypes = new List <KeyValuePair <string, int> >(); } list.Shuffle(); foreach (var t1 in list.Where(t1 => !AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, t1)))) { AddedTypes.Add(new KeyValuePair <string, int>(Owner.Name, t1)); MType = t1; MTime = Random.Next(6, 15); MRemaining = Random.Next(6, 11); newMerchant = true; Owner.Timers.Add(new WorldTimer(30000, (w, t) => { newMerchant = false; UpdateCount++; })); var s = Random.Next(0, 100); if (s < 2) { Discount = 0; } else if (s < 5) { Discount = 0; } else if (s < 10) { Discount = 0; } else if (s < 15) { Discount = 0; } else { Discount = 0; } Tuple <int, CurrencyType> price; if (prices.TryGetValue(MType, out price)) { if (Discount != 0) { Price = (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))) < 1 ? price.Item1 : (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))); } else { Price = price.Item1; } Currency = price.Item2; } break; } UpdateCount++; }
public void ResolveMType() { MType = -1; int[] list = new int[0]; if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_1) { list = MerchantLists.KeyList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_2) { list = MerchantLists.WeaponList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_3) { list = MerchantLists.AbilityList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_4) { list = MerchantLists.ArmorList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_5) { list = MerchantLists.RingList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_6) { list = MerchantLists.BoosterList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_7) { list = MerchantLists.MaterialList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_12) { list = MerchantLists.AccessoryDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_13) { list = MerchantLists.ClothingClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_14) { list = MerchantLists.AccessoryClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_15) { list = MerchantLists.ClothingDyeList; } if (AddedTypes == null) { AddedTypes = new List <KeyValuePair <string, int> >(); } //list.Shuffle(); for (int i = 0; i < list.Length; i++) { if (!AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, list[i]))) { AddedTypes.Add(new KeyValuePair <string, int>(Owner.Name, list[i])); MType = list[i]; MTime = Random.Next(6, 15); MRemaining = Random.Next(10, 20); newMerchant = true; Owner.Timers.Add(new WorldTimer(30000, (w, t) => { newMerchant = false; UpdateCount++; })); Tuple <int, CurrencyType> price; if (prices.TryGetValue(MType, out price)) { Price = price.Item1; Currency = price.Item2; } break; } } UpdateCount++; }
public override void Tick(RealmTime time) { try { if (Size == 0 && MType != -1) { Size = MERCHANT_SIZE; UpdateCount++; } if (!closing) { tickcount++; if (tickcount % (Manager?.TPS * 60) == 0) //once per minute after spawning { MTime--; UpdateCount++; } } if (MRemaining == 0 && MType != -1) { if (AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, MType))) { AddedTypes.Remove(new KeyValuePair <string, int>(Owner.Name, MType)); } Recreate(this); UpdateCount++; } if (MTime == -1 && Owner != null) { if (AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, MType))) { AddedTypes.Remove(new KeyValuePair <string, int>(Owner.Name, MType)); } Recreate(this); UpdateCount++; } if (MTime == 1 && !closing) { closing = true; Owner?.Timers.Add(new WorldTimer(30 * 1000, (w1, t1) => { MTime--; UpdateCount++; w1.Timers.Add(new WorldTimer(30 * 1000, (w2, t2) => { MTime--; UpdateCount++; })); })); } if (MType == -1) { Owner?.LeaveWorld(this); } base.Tick(time); } catch (Exception ex) { log.Error(ex); } }
public override void Tick(RealmTime time) { try { if (Size == 0 && MType != -1) { Size = merchantSize; UpdateCount++; } if (!closing) { tickcount++; if (Manager != null) { if (tickcount % (Manager.TPS * 60) == 0) //once per minute after spawning { MTime--; UpdateCount++; } } } if (MRemaining == 0 && MType != -1) { if (AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, MType))) { AddedTypes.Remove(new KeyValuePair <string, int>(Owner.Name, MType)); } Recreate(this); UpdateCount++; } if (MTime == -1 && Owner != null) { if (AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, MType))) { AddedTypes.Remove(new KeyValuePair <string, int>(Owner.Name, MType)); } Recreate(this); UpdateCount++; } if (MTime == 1 && !closing) { closing = true; if (Owner != null) { Owner.Timers.Add(new WorldTimer(30 * 1000, (w1, t1) => { MTime--; UpdateCount++; w1.Timers.Add(new WorldTimer(30 * 1000, (w2, t2) => { MTime--; UpdateCount++; })); })); } } if (!MerchantLists.NoDiscountList.Contains(MType)) { int s = MRemaining; if (s <= 2) { Discount = 50; } else if (s <= 5) { Discount = 25; } else if (s <= 10) { Discount = 15; } else if (s <= 15) { Discount = 10; } else { Discount = 0; } Tuple <int, CurrencyType> price; if (prices.TryGetValue(MType, out price)) { Price = (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))) < 1 ? price.Item1 : (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))); } } if (MType == -1 && Owner != null) { Owner.LeaveWorld(this); } base.Tick(time); } catch (Exception ex) { log.Error(ex); } }
public void ResolveMType() { MType = -1; var list = new int[0]; if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_1) { list = region1list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_2) { list = region2list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_3) { list = region3list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_4) { list = region4list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_5) { list = region5list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_6) { list = region6list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_7) { list = region7list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_8) { list = region8list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_9) { list = region9list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_10) { list = region10list; } ; if (AddedTypes == null) { AddedTypes = new List <KeyValuePair <string, int> >(); } list.Shuffle(); foreach (var t1 in list.Where(t1 => !AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, t1)))) { AddedTypes.Add(new KeyValuePair <string, int>(Owner.Name, t1)); MType = t1; MTime = Random.Next(6, 15); MRemaining = int.MaxValue - 1; newMerchant = true; Owner.Timers.Add(new WorldTimer(30000, (w, t) => { newMerchant = false; UpdateCount++; })); if (prices.TryGetValue(MType, out Tuple <int, CurrencyType> price)) { Price = price.Item1; Currency = price.Item2; } break; } UpdateCount++; }
public void ResolveMType() { MType = -1; var list = new int[0]; if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_1) { list = MerchantLists.StoreList1; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_2) { list = MerchantLists.StoreList2; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_3) { list = MerchantLists.StoreList3; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_4) { list = MerchantLists.StoreList4; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_5) { list = MerchantLists.StoreList5; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_6) { list = MerchantLists.StoreList6; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_7) { list = MerchantLists.StoreList7; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_8) { list = MerchantLists.StoreList8; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_9) { list = MerchantLists.StoreList9; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_10) { list = MerchantLists.StoreList10; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_11) { list = MerchantLists.StoreList11; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_12) { list = MerchantLists.AccessoryDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_13) { list = MerchantLists.ClothingClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_14) { list = MerchantLists.AccessoryClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_15) { list = MerchantLists.ClothingDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_16) { list = MerchantLists.StoreList5; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_17) { list = MerchantLists.StoreList7; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_18) { list = MerchantLists.StoreList6; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_19) { list = MerchantLists.StoreList2; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_20) { list = MerchantLists.StoreList20; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_21) { list = MerchantLists.AccessoryClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_22) { list = MerchantLists.AccessoryDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_23) { list = MerchantLists.ClothingClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_24) { list = MerchantLists.ClothingDyeList; } if (AddedTypes == null) { AddedTypes = new List <KeyValuePair <string, int> >(); } list.Shuffle(); foreach (var t1 in list.Where(t1 => !AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, t1)))) { AddedTypes.Add(new KeyValuePair <string, int>(Owner.Name, t1)); MType = t1; MTime = Random.Next(6, 15); MRemaining = Random.Next(6, 11); newMerchant = true; Owner.Timers.Add(new WorldTimer(30000, (w, t) => { newMerchant = false; UpdateCount++; })); Discount = Random.Next(0, 100) < 10 ? 15 : Random.Next(0, 100) == 1 ? 25 : 0; Tuple <int, int, CurrencyType, CurrencyType> price; if (prices.TryGetValue(MType, out price)) { if (Discount != 0) { if (Program.TestingMerchants) { Price = 1; Currency = (CurrencyType)1; } else if (Program.Settings.GetValue <bool>("SimplifiedMerchant", "false")) { Price = (int)(price.Item2 - (price.Item2 * ((double)Discount / 100))) < 1 ? price.Item2 : (int)(price.Item2 - (price.Item2 * ((double)Discount / 100))); Currency = price.Item4; } else { Price = (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))) < 1 ? price.Item1 : (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))); Currency = price.Item3; } } else { if (Program.TestingMerchants) { Price = 1; Currency = (CurrencyType)1; } else if (Program.Settings.GetValue <bool>("SimplifiedMerchant", "false")) { Price = price.Item2; Currency = price.Item4; } else { Price = price.Item1; Currency = price.Item3; } } } break; } UpdateCount++; }
public void ResolveMType() { MType = -1; var list = new int[0]; if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_1) { list = region1list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_2) { list = region2list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_3) { list = region3list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_4) { list = region4list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_5) { list = region5list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_6) { list = region6list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_7) { list = region7list; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_8) { list = region8list; } /*else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_12) * list = accessorylist; * else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_13) * list = largeclothlist; * else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_14) * list = smallclothlist; * else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_15) * list = clothinglist; * else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_16) * list = accessorylist; * else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_17) * list = largeclothlist; * else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_18) * list = smallclothlist; * else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_19) * list = clothinglist*/ ; if (AddedTypes == null) { AddedTypes = new List <KeyValuePair <string, int> >(); } list.Shuffle(); foreach (var t1 in list.Where(t1 => !AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, t1)))) { AddedTypes.Add(new KeyValuePair <string, int>(Owner.Name, t1)); MType = t1; MTime = Random.Next(6, 15); MRemaining = Random.Next(6, 11); newMerchant = true; Owner.Timers.Add(new WorldTimer(30000, (w, t) => { newMerchant = false; UpdateCount++; })); var s = Random.Next(0, 100); if (s < 2 * Settings.EVENT_RATE) { Discount = 50; } else if (s < 5 * Settings.EVENT_RATE) { Discount = 25; } else if (s < 10 * Settings.EVENT_RATE) { Discount = 15; } else if (s < 15 * Settings.EVENT_RATE) { Discount = 10; } else { Discount = 0; } if (prices.TryGetValue(MType, out Tuple <int, CurrencyType> price)) { if (Discount != 0) { Price = (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))) < 1 ? price.Item1 : (int)(price.Item1 - (price.Item1 * ((double)Discount / 100))); } else { Price = price.Item1; } Currency = price.Item2; } break; } UpdateCount++; }
public void ResolveMType() { MType = -1; var list = new int[0]; if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_1) { list = MerchantLists.store1List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_2) { list = MerchantLists.store2List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_3) { list = MerchantLists.store3List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_4) { list = MerchantLists.store4List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_5) { list = MerchantLists.store5List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_6) { list = MerchantLists.store6List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_7) { list = MerchantLists.store7List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_8) { list = MerchantLists.store8List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_9) { list = MerchantLists.store9List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_10) { list = MerchantLists.store10List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_11) { list = MerchantLists.store11List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_12) { list = MerchantLists.AccessoryDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_13) { list = MerchantLists.ClothingClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_14) { list = MerchantLists.AccessoryClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_15) { list = MerchantLists.ClothingDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_16) { list = MerchantLists.store5List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_17) { list = MerchantLists.store7List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_18) { list = MerchantLists.store6List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_19) { list = MerchantLists.store2List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_20) { list = MerchantLists.store20List; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_21) { list = MerchantLists.AccessoryClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_22) { list = MerchantLists.AccessoryDyeList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_23) { list = MerchantLists.ClothingClothList; } else if (Owner.Map[(int)X, (int)Y].Region == TileRegion.Store_24) { list = MerchantLists.ClothingDyeList; } if (AddedTypes == null) { AddedTypes = new List <KeyValuePair <string, int> >(); } list.Shuffle(); foreach (var t1 in list.Where(t1 => !AddedTypes.Contains(new KeyValuePair <string, int>(Owner.Name, t1)))) { AddedTypes.Add(new KeyValuePair <string, int>(Owner.Name, t1)); MType = t1; MRemaining = Random.Next(99999, 99999); Owner.Timers.Add(new WorldTimer(15000, (w, t) => { UpdateCount++; })); Tuple <int, CurrencyType> price; if (prices.TryGetValue(MType, out price)) { Price = price.Item1; Currency = price.Item2; } break; } UpdateCount++; }