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 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 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; }
private static bool AccCheck(Item newItem, int slot) { if (Main.player[Main.myPlayer].armor[slot].IsTheSameAs(newItem)) { return false; } for (int i = 0; i < Main.player[Main.myPlayer].armor.Length; i++) { if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[i])) { return true; } } return false; }
public bool ItemSpace(Item newItem) { if (newItem.uniqueStack && this.HasItem(newItem.itemId)) return false; if (newItem.itemId == 58 || newItem.itemId == 184 || (newItem.itemId == 1734 || newItem.itemId == 1735) || (newItem.itemId == 1867 || newItem.itemId == 1868 || ItemID.Sets.NebulaPickup[newItem.itemId])) return true; int num = 50; if (newItem.itemId == 71 || newItem.itemId == 72 || (newItem.itemId == 73 || newItem.itemId == 74)) num = 54; for (int index = 0; index < num; ++index) { if (this.inventory[index].itemId == 0) return true; } for (int index = 0; index < num; ++index) { if (this.inventory[index].itemId > 0 && this.inventory[index].stack < this.inventory[index].maxStack && newItem.IsTheSameAs(this.inventory[index])) return true; } if (newItem.ammo > 0 && !newItem.notAmmo) { if (newItem.itemId != 75 && newItem.itemId != 169 && (newItem.itemId != 23 && newItem.itemId != 408) && (newItem.itemId != 370 && newItem.itemId != 1246)) { for (int index = 54; index < 58; ++index) { if (this.inventory[index].itemId == 0) return true; } } for (int index = 54; index < 58; ++index) { if (this.inventory[index].itemId > 0 && this.inventory[index].stack < this.inventory[index].maxStack && newItem.IsTheSameAs(this.inventory[index])) return true; } } return false; }
private static bool AccCheck(Item newItem, int slot) { if (Main.player[Main.myPlayer].armor[slot].IsTheSameAs(newItem)) { return false; } if (Main.player[Main.myPlayer].armor[slot].wingSlot > 0 && newItem.wingSlot > 0) { return false; } for (int i = 0; i < Main.player[Main.myPlayer].armor.Length; i++) { if (slot < 8 && i < 8) { if (newItem.wingSlot > 0 && Main.player[Main.myPlayer].armor[i].wingSlot > 0) { return true; } } else { if (slot >= 8 && i >= 8 && newItem.wingSlot > 0 && Main.player[Main.myPlayer].armor[i].wingSlot > 0) { return true; } } if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[i])) { return true; } } return false; }
public bool ItemSpace(Item newItem) { if (newItem.type == 58 || newItem.type == 184) { return true; } else { int num = 40; if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74) num = 44; for (int index = 0; index < num; ++index) { if (this.inventory[index].type == 0) return true; } for (int index = 0; index < num; ++index) { if (this.inventory[index].type > 0 && this.inventory[index].stack < this.inventory[index].maxStack && newItem.IsTheSameAs(this.inventory[index])) return true; } return false; } }
public bool ItemSpace(Item newItem) { if (newItem.type == 58) { return true; } if (newItem.type == 184) { return true; } int num = 40; if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74) { num = 44; } for (int i = 0; i < num; i++) { if (this.inventory[i].type == 0) { return true; } } for (int j = 0; j < num; j++) { if (this.inventory[j].type > 0 && this.inventory[j].stack < this.inventory[j].maxStack && newItem.IsTheSameAs(this.inventory[j])) { return true; } } if (newItem.ammo > 0) { if (newItem.type != 75 && newItem.type != 169 && newItem.type != 23 && newItem.type != 408 && newItem.type != 370) { for (int k = 44; k < 48; k++) { if (this.inventory[k].type == 0) { return true; } } } for (int l = 44; l < 48; l++) { if (this.inventory[l].type > 0 && this.inventory[l].stack < this.inventory[l].maxStack && newItem.IsTheSameAs(this.inventory[l])) { return true; } } } return false; }
public Item GetItem(int plr, Item newItem) { Item result; if (newItem.noGrabDelay <= 0) { int num = 0; if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74) { num = -4; } for (int i = num; i < 40; i++) { int num2 = i; if (num2 < 0) { num2 = 44 + i; } if (this.inventory[num2].type > 0 && this.inventory[num2].stack < this.inventory[num2].maxStack && newItem.IsTheSameAs(this.inventory[num2])) { if (newItem.stack + this.inventory[num2].stack <= this.inventory[num2].maxStack) { Item item = this.inventory[num2]; item.stack += newItem.stack; this.DoCoins(num2); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } result = new Item(); return result; } newItem.stack -= this.inventory[num2].maxStack - this.inventory[num2].stack; this.inventory[num2].stack = this.inventory[num2].maxStack; this.DoCoins(num2); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } } } for (int i = num; i < 40; i++) { int num2 = i; if (num2 < 0) { num2 = 44 + i; } if (this.inventory[num2].type == 0) { this.inventory[num2] = newItem; this.DoCoins(num2); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } result = new Item(); return result; } } } result = newItem; return result; }
public bool ItemSpace(Item newItem) { bool result; if (newItem.type == 58) { result = true; } else { if (newItem.type == 184) { result = true; } else { int num = 40; if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74) { num = 44; } for (int i = 0; i < num; i++) { if (this.inventory[i].type == 0) { result = true; return result; } } for (int i = 0; i < num; i++) { if (this.inventory[i].type > 0 && this.inventory[i].stack < this.inventory[i].maxStack && newItem.IsTheSameAs(this.inventory[i])) { result = true; return result; } } result = false; } } return result; }
public Item FillAmmo(int plr, Item newItem, bool noText = false) { for (int i = 54; i < 58; i++) { if (this.inventory[i].type > 0 && this.inventory[i].stack < this.inventory[i].maxStack && newItem.IsTheSameAs(this.inventory[i])) { Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1); if (newItem.stack + this.inventory[i].stack <= this.inventory[i].maxStack) { this.inventory[i].stack += newItem.stack; if (!noText) { ItemText.NewText(newItem, newItem.stack, false, false); } this.DoCoins(i); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } return new Item(); } newItem.stack -= this.inventory[i].maxStack - this.inventory[i].stack; if (!noText) { ItemText.NewText(newItem, this.inventory[i].maxStack - this.inventory[i].stack, false, false); } this.inventory[i].stack = this.inventory[i].maxStack; this.DoCoins(i); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } } } if (newItem.bait <= 0 && newItem.type != 169 && newItem.type != 75 && newItem.type != 23 && newItem.type != 408 && newItem.type != 370 && newItem.type != 1246 && newItem.type != 154 && !newItem.notAmmo) { for (int j = 54; j < 58; j++) { if (this.inventory[j].type == 0) { this.inventory[j] = newItem; if (!noText) { ItemText.NewText(newItem, newItem.stack, false, false); } this.DoCoins(j); Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } return new Item(); } } } return newItem; }
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 bool AccCheck(Item item, int slot) { Player player = Main.player[Main.myPlayer]; if (slot != -1 && (player.armor[slot].IsTheSameAs(item) || (int)player.armor[slot].wingSlot > 0 && (int)item.wingSlot > 0)) return false; for (int index = 0; index < player.armor.Length; ++index) { if (slot < 10 && index < 10 && ((int)item.wingSlot > 0 && (int)player.armor[index].wingSlot > 0 || slot >= 10 && index >= 10 && ((int)item.wingSlot > 0 && (int)player.armor[index].wingSlot > 0)) || item.IsTheSameAs(player.armor[index])) return true; } return false; }
public bool ItemSpace(Item newItem) { if (newItem.uniqueStack && this.HasItem(newItem.type)) { return false; } if (newItem.type == 58 || newItem.type == 184 || newItem.type == 1734 || newItem.type == 1735 || newItem.type == 1867 || newItem.type == 1868) { return true; } int num = 50; if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74) { num = 54; } for (int i = 0; i < num; i++) { if (this.inventory[i].type == 0) { return true; } } for (int j = 0; j < num; j++) { if (this.inventory[j].type > 0 && this.inventory[j].stack < this.inventory[j].maxStack && newItem.IsTheSameAs(this.inventory[j])) { return true; } } if (newItem.ammo > 0 && !newItem.notAmmo) { if (newItem.type != 75 && newItem.type != 169 && newItem.type != 23 && newItem.type != 408 && newItem.type != 370 && newItem.type != 1246) { for (int k = 54; k < 58; k++) { if (this.inventory[k].type == 0) { return true; } } } for (int l = 54; l < 58; l++) { if (this.inventory[l].type > 0 && this.inventory[l].stack < this.inventory[l].maxStack && newItem.IsTheSameAs(this.inventory[l])) { return true; } } } return false; }
public bool ItemSpace(Item newItem) { if (newItem.uniqueStack && this.HasItem(newItem.type)) { return false; } if (newItem.type == ItemID.Heart || newItem.type == ItemID.Star || newItem.type == ItemID.CandyApple || newItem.type == ItemID.SoulCake || newItem.type == ItemID.CandyCane || newItem.type == ItemID.SugarPlum) { return true; } if (ItemID.Sets.NebulaPickup[newItem.type]) { return true; } int num = 50; if (newItem.type == ItemID.CopperCoin || newItem.type == ItemID.SilverCoin || newItem.type == ItemID.GoldCoin || newItem.type == ItemID.PlatinumCoin) { num = 54; } for (int i = 0; i < num; i++) { if (this.inventory[i].type == 0) { return true; } } for (int j = 0; j < num; j++) { if (this.inventory[j].type > 0 && this.inventory[j].stack < this.inventory[j].maxStack && newItem.IsTheSameAs(this.inventory[j])) { return true; } } if (newItem.ammo > 0 && !newItem.notAmmo) { if (newItem.type != ItemID.FallenStar && newItem.type != ItemID.SandBlock && newItem.type != ItemID.Gel && newItem.type != ItemID.PearlsandBlock && newItem.type != ItemID.EbonsandBlock && newItem.type != ItemID.CrimsandBlock) { for (int k = 54; k < 58; k++) { if (this.inventory[k].type == 0) { return true; } } } for (int l = 54; l < 58; l++) { if (this.inventory[l].type > 0 && this.inventory[l].stack < this.inventory[l].maxStack && newItem.IsTheSameAs(this.inventory[l])) { return true; } } } return false; }
public Item FillAmmo(int plr, Item newItem) { for (int i = 44; i < 48; i++) { if (this.inventory[i].type > 0 && this.inventory[i].stack < this.inventory[i].maxStack && newItem.IsTheSameAs(this.inventory[i])) { Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1); if (newItem.stack + this.inventory[i].stack <= this.inventory[i].maxStack) { this.inventory[i].stack += newItem.stack; ItemText.NewText(newItem, newItem.stack); this.DoCoins(i); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } return new Item(); } newItem.stack -= this.inventory[i].maxStack - this.inventory[i].stack; ItemText.NewText(newItem, this.inventory[i].maxStack - this.inventory[i].stack); this.inventory[i].stack = this.inventory[i].maxStack; this.DoCoins(i); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } } } if (newItem.type != 169 && newItem.type != 75 && newItem.type != 23 && newItem.type != 408 && newItem.type != 370) { for (int j = 44; j < 48; j++) { if (this.inventory[j].type == 0) { this.inventory[j] = newItem; ItemText.NewText(newItem, newItem.stack); this.DoCoins(j); Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1); if (plr == Main.myPlayer) { Recipe.FindRecipes(); } return new Item(); } } } return newItem; }
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 bool ItemSpace(Item newItem) { if (newItem.type == 0x3a) { return true; } if (newItem.type == 0xb8) { return true; } int num = 40; if (((newItem.type == 0x47) || (newItem.type == 0x48)) || ((newItem.type == 0x49) || (newItem.type == 0x4a))) { num = 0x2c; } for (int i = 0; i < num; i++) { if (this.inventory[i].type == 0) { return true; } } for (int j = 0; j < num; j++) { if (((this.inventory[j].type > 0) && (this.inventory[j].stack < this.inventory[j].maxStack)) && newItem.IsTheSameAs(this.inventory[j])) { return true; } } return false; }
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; }