public void AddShop(Item newItem) { int num = 0; while (true) { if (num < 19) { if (item[num] == null || item[num].type == 0) { break; } num++; continue; } return; } item[num] = (Item)newItem.Clone(); item[num].buyOnce = true; if (item[num].value > 0) { item[num].value = item[num].value / 5; if (item[num].value < 1) { item[num].value = 1; } } }
public void AddShop(Item newItem) { int i = 0; while (i < 39) { if (this.item[i] == null || this.item[i].type == 0) { this.item[i] = newItem.Clone(); this.item[i].buyOnce = true; if (this.item[i].value <= 0) { break; } this.item[i].value = this.item[i].value / 5; if (this.item[i].value < 1) { this.item[i].value = 1; return; } break; } else { i++; } } }
private static Item[] GetItemsPrefixes(Item item) { var items = new List<Item>(); for (int i = 0; i < Lang.prefix.Length; i++) { var prefixedItem = item.Clone(); prefixedItem.SetDefaults(item.type); prefixedItem.Prefix(i); var prefixAlreadyAdded = (from existingItem in items where existingItem.prefix == prefixedItem.prefix select existingItem).Count() > 0; if (prefixedItem.prefix > 0 && !prefixAlreadyAdded) items.Add(prefixedItem); } return items.OrderBy(it => -it.rare).ThenBy(it=> Lang.prefix[it.prefix]).ToArray(); }
public void AddShop(Item newItem) { for (int i = 0; i < 0x13; i++) { if ((this.item[i] == null) || (this.item[i].type == 0)) { this.item[i] = (Item)newItem.Clone(); this.item[i].buyOnce = true; if (this.item[i].value > 0) { this.item[i].value /= 5; if (this.item[i].value < 1) { this.item[i].value = 1; return; } } break; } } }
public static Item armorSwap(Item newItem) { for (int i = 0; i < Main.player[Main.myPlayer].armor.Length; i++) { if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[i])) { Main.accSlotCount = i; } } if (newItem.headSlot == -1 && newItem.bodySlot == -1 && newItem.legSlot == -1 && !newItem.accessory) { return newItem; } Item result = newItem; if (newItem.headSlot != -1) { result = (Item) Main.player[Main.myPlayer].armor[0].Clone(); Main.player[Main.myPlayer].armor[0] = (Item) newItem.Clone(); } else { if (newItem.bodySlot != -1) { result = (Item) Main.player[Main.myPlayer].armor[1].Clone(); Main.player[Main.myPlayer].armor[1] = (Item) newItem.Clone(); } else { if (newItem.legSlot != -1) { result = (Item) Main.player[Main.myPlayer].armor[2].Clone(); Main.player[Main.myPlayer].armor[2] = (Item) newItem.Clone(); } else { if (newItem.accessory) { for (int j = 3; j < 8; j++) { if (Main.player[Main.myPlayer].armor[j].type == 0) { Main.accSlotCount = j - 3; break; } } for (int k = 0; k < Main.player[Main.myPlayer].armor.Length; k++) { if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[k])) { Main.accSlotCount = k - 3; } } if (Main.accSlotCount >= 5) { Main.accSlotCount = 0; } if (Main.accSlotCount < 0) { Main.accSlotCount = 4; } result = (Item) Main.player[Main.myPlayer].armor[3 + Main.accSlotCount].Clone(); Main.player[Main.myPlayer].armor[3 + Main.accSlotCount] = (Item) newItem.Clone(); Main.accSlotCount++; if (Main.accSlotCount >= 5) { Main.accSlotCount = 0; } } } } } Main.PlaySound(7, -1, -1, 1); Recipe.FindRecipes(); return result; }
public static Item armorSwap(Item newItem) { for (int i = 0; i < player[myPlayer].armor.Length; i++) { if (newItem.IsTheSameAs(player[myPlayer].armor[i])) { accSlotCount = i; } } if (((newItem.headSlot == -1) && (newItem.bodySlot == -1)) && ((newItem.legSlot == -1) && !newItem.accessory)) { return newItem; } Item item = newItem; if (newItem.headSlot != -1) { item = (Item)player[myPlayer].armor[0].Clone(); player[myPlayer].armor[0] = (Item)newItem.Clone(); } else if (newItem.bodySlot != -1) { item = (Item)player[myPlayer].armor[1].Clone(); player[myPlayer].armor[1] = (Item)newItem.Clone(); } else if (newItem.legSlot != -1) { item = (Item)player[myPlayer].armor[2].Clone(); player[myPlayer].armor[2] = (Item)newItem.Clone(); } else if (newItem.accessory) { for (int j = 3; j < 8; j++) { if (player[myPlayer].armor[j].type == 0) { accSlotCount = j - 3; break; } } for (int k = 0; k < player[myPlayer].armor.Length; k++) { if (newItem.IsTheSameAs(player[myPlayer].armor[k])) { accSlotCount = k - 3; } } if (accSlotCount >= 5) { accSlotCount = 0; } if (accSlotCount < 0) { accSlotCount = 4; } item = (Item)player[myPlayer].armor[3 + accSlotCount].Clone(); player[myPlayer].armor[3 + accSlotCount] = (Item)newItem.Clone(); accSlotCount++; if (accSlotCount >= 5) { accSlotCount = 0; } } PlaySound(7, -1, -1, 1); Recipe.FindRecipes(); return item; }
public static Item dyeSwap(Item newItem) { if (newItem.dye <= 0) { return newItem; } for (int i = 0; i < 3; i++) { if (Main.player[Main.myPlayer].dye[i].type == 0) { Main.dyeSlotCount = i; break; } } if (Main.dyeSlotCount >= 3) { Main.dyeSlotCount = 0; } if (Main.dyeSlotCount < 0) { Main.dyeSlotCount = 2; } Item result = (Item)Main.player[Main.myPlayer].dye[Main.dyeSlotCount].Clone(); Main.player[Main.myPlayer].dye[Main.dyeSlotCount] = (Item)newItem.Clone(); Main.dyeSlotCount++; if (Main.dyeSlotCount >= 3) { Main.accSlotCount = 0; } Main.PlaySound(7, -1, -1, 1); Recipe.FindRecipes(); return result; }
public void AddShop(Item newItem) { int num = 0; while (num < 39) { if (this.item[num] == null || this.item[num].type == 0) { this.item[num] = newItem.Clone(); this.item[num].favorited = false; this.item[num].buyOnce = true; if (this.item[num].@value <= 0) { break; } this.item[num].@value = this.item[num].@value / 5; if (this.item[num].@value >= 1) { break; } this.item[num].@value = 1; return; } else { num++; } } }
public static Item PutItemInNearbyChest(Item item, Vector2 position) { if (Main.netMode == 1) { return item; } for (int i = 0; i < 1000; i++) { bool flag = false; bool flag1 = false; if (Main.chest[i] != null && !Chest.IsPlayerInChest(i) && !Chest.isLocked(Main.chest[i].x, Main.chest[i].y)) { Vector2 vector2 = new Vector2((float)(Main.chest[i].x * 16 + 16), (float)(Main.chest[i].y * 16 + 16)); if ((vector2 - position).Length() < 200f) { for (int j = 0; j < (int)Main.chest[i].item.Length; j++) { if (Main.chest[i].item[j].type <= 0 || Main.chest[i].item[j].stack <= 0) { flag1 = true; } else if (item.IsTheSameAs(Main.chest[i].item[j])) { flag = true; int num = Main.chest[i].item[j].maxStack - Main.chest[i].item[j].stack; if (num > 0) { if (num > item.stack) { num = item.stack; } Item item1 = item; item1.stack = item1.stack - num; Item item2 = Main.chest[i].item[j]; item2.stack = item2.stack + num; if (item.stack <= 0) { item.SetDefaults(0, false); return item; } } } } if (flag && flag1 && item.stack > 0) { for (int k = 0; k < (int)Main.chest[i].item.Length; k++) { if (Main.chest[i].item[k].type == 0 || Main.chest[i].item[k].stack == 0) { Main.chest[i].item[k] = item.Clone(); item.SetDefaults(0, false); return item; } } } } } } return item; }
public void AddShop(Item newItem) { for (int index = 0; index < 39; ++index) { if (item[index] == null || item[index].itemId == 0) { item[index] = newItem.Clone(); item[index].favorited = false; item[index].buyOnce = true; if (item[index].value <= 0) break; item[index].value = item[index].value / 5; if (item[index].value >= 1) break; item[index].value = 1; break; } } }
/// <summary> /// Gets items by name /// </summary> /// <param name="name">name</param> /// <returns>List of Items</returns> public static List<Item> GetItemByName(string name) { var found = new List<Item>(); Item item = new Item(); string nameLower = name.ToLower(); for (int i = -24; i < Main.maxItemTypes; i++) { item.netDefaults(i); if (item.name.ToLower() == nameLower) return new List<Item> { item }; if (item.name.ToLower().StartsWith(nameLower)) found.Add((Item)item.Clone()); } return found; }
private static Item EquipSwap(Item item, Item[] inv, int slot, out bool success) { success = false; Player player = Main.player[Main.myPlayer]; item.favorited = false; Item obj = inv[slot].Clone(); inv[slot] = item.Clone(); Main.PlaySound(7, -1, -1, 1); Recipe.FindRecipes(); success = true; return obj; }
private static Item ArmorSwap(Item item, out bool success) { success = false; if (item.headSlot == -1 && item.bodySlot == -1 && (item.legSlot == -1 && !item.accessory)) return item; Player player = Main.player[Main.myPlayer]; int index1 = !item.vanity || item.accessory ? 0 : 10; item.favorited = false; Item obj = item; if (item.headSlot != -1) { obj = player.armor[index1].Clone(); player.armor[index1] = item.Clone(); } else if (item.bodySlot != -1) { obj = player.armor[index1 + 1].Clone(); player.armor[index1 + 1] = item.Clone(); } else if (item.legSlot != -1) { obj = player.armor[index1 + 2].Clone(); player.armor[index1 + 2] = item.Clone(); } else if (item.accessory) { int num = 5 + Main.player[Main.myPlayer].extraAccessorySlots; for (int index2 = 3; index2 < 3 + num; ++index2) { if (player.armor[index2].itemId == 0) { ItemSlot.accSlotCount = index2 - 3; break; } } for (int index2 = 0; index2 < player.armor.Length; ++index2) { if (item.IsTheSameAs(player.armor[index2])) ItemSlot.accSlotCount = index2 - 3; if (index2 < 10 && (int)item.wingSlot > 0 && (int)player.armor[index2].wingSlot > 0) ItemSlot.accSlotCount = index2 - 3; } if (ItemSlot.accSlotCount >= num) ItemSlot.accSlotCount = 0; if (ItemSlot.accSlotCount < 0) ItemSlot.accSlotCount = num - 1; int index3 = 3 + ItemSlot.accSlotCount; for (int index2 = 0; index2 < player.armor.Length; ++index2) { if (item.IsTheSameAs(player.armor[index2])) index3 = index2; } obj = player.armor[index3].Clone(); player.armor[index3] = item.Clone(); ++ItemSlot.accSlotCount; if (ItemSlot.accSlotCount >= num) ItemSlot.accSlotCount = 0; } Main.PlaySound(7, -1, -1, 1); Recipe.FindRecipes(); success = true; return obj; }
private static Item DyeSwap(Item item, out bool success) { success = false; if ((int)item.dye <= 0) return item; Player player = Main.player[Main.myPlayer]; for (int index = 0; index < 10; ++index) { if (player.dye[index].itemId == 0) { ItemSlot.dyeSlotCount = index; break; } } if (ItemSlot.dyeSlotCount >= 10) ItemSlot.dyeSlotCount = 0; if (ItemSlot.dyeSlotCount < 0) ItemSlot.dyeSlotCount = 9; Item obj = player.dye[ItemSlot.dyeSlotCount].Clone(); player.dye[ItemSlot.dyeSlotCount] = item.Clone(); ++ItemSlot.dyeSlotCount; if (ItemSlot.dyeSlotCount >= 10) ItemSlot.accSlotCount = 0; Main.PlaySound(7, -1, -1, 1); Recipe.FindRecipes(); success = true; return obj; }
public static bool TryPlacingInChest(Item I, bool justCheck) { bool flag1 = false; Player player = Main.player[Main.myPlayer]; Item[] objArray = player.bank.item; if (player.chest > -1) { objArray = Main.chest[player.chest].item; flag1 = Main.netMode == 1; } else if (player.chest == -2) objArray = player.bank.item; else if (player.chest == -3) objArray = player.bank2.item; bool flag2 = false; if (I.maxStack > 1) { for (int index = 0; index < 40; ++index) { if (objArray[index].stack < objArray[index].maxStack && I.IsTheSameAs(objArray[index])) { int num = I.stack; if (I.stack + objArray[index].stack > objArray[index].maxStack) num = objArray[index].maxStack - objArray[index].stack; if (justCheck) { flag2 = flag2 || num > 0; break; } I.stack -= num; objArray[index].stack += num; Main.PlaySound(7, -1, -1, 1); if (I.stack <= 0) { I.SetDefaults(0, false); if (flag1) { NetMessage.SendData(32, -1, -1, "", player.chest, (float)index, 0.0f, 0.0f, 0, 0, 0); break; } break; } if (objArray[index].itemId == 0) { objArray[index] = I.Clone(); I.SetDefaults(0, false); } if (flag1) NetMessage.SendData(32, -1, -1, "", player.chest, (float)index, 0.0f, 0.0f, 0, 0, 0); } } } if (I.stack > 0) { for (int index = 0; index < 40; ++index) { if (objArray[index].stack == 0) { if (justCheck) { flag2 = true; break; } Main.PlaySound(7, -1, -1, 1); objArray[index] = I.Clone(); I.SetDefaults(0, false); if (flag1) { NetMessage.SendData(32, -1, -1, "", player.chest, (float)index, 0.0f, 0.0f, 0, 0, 0); break; } break; } } } return flag2; }
public static Item PutItemInNearbyChest(Item item, Vector2 position) { if (Main.netMode == 1) return item; for (int i = 0; i < 1000; ++i) { bool flag1 = false; bool flag2 = false; if (Main.chest[i] != null && !IsPlayerInChest(i) && !isLocked(Main.chest[i].x, Main.chest[i].y) && (new Vector2((Main.chest[i].x * 16 + 16), (Main.chest[i].y * 16 + 16)) - position).Length() < 200.0) { for (int index = 0; index < Main.chest[i].item.Length; ++index) { if (Main.chest[i].item[index].itemId > 0 && Main.chest[i].item[index].stack > 0) { if (item.IsTheSameAs(Main.chest[i].item[index])) { flag1 = true; int num = Main.chest[i].item[index].maxStack - Main.chest[i].item[index].stack; if (num > 0) { if (num > item.stack) num = item.stack; item.stack -= num; Main.chest[i].item[index].stack += num; if (item.stack <= 0) { item.SetDefaults(0, false); return item; } } } } else flag2 = true; } if (flag1 && flag2 && item.stack > 0) { for (int index = 0; index < Main.chest[i].item.Length; ++index) { if (Main.chest[i].item[index].itemId == 0 || Main.chest[i].item[index].stack == 0) { Main.chest[i].item[index] = item.Clone(); item.SetDefaults(0, false); return item; } } } } } return item; }