private void Player_PickAmmo(On.Terraria.Player.orig_PickAmmo orig, Player player, Item sItem, ref int shoot, ref float speed, ref bool canShoot, ref int Damage, ref float KnockBack, bool dontConsume) { Item item = new Item(); bool flag = false; for (int i = 54; i < 58; i++) { if (player.inventory[i].ammo == sItem.useAmmo && player.inventory[i].stack > 0) { item = player.inventory[i]; canShoot = true; flag = true; break; } } if (!flag) { Item[] bank3 = player.bank3.item; for (int a = 0; a < bank3.Length; a++) { if (bank3[a].ammo == sItem.useAmmo && bank3[a].stack > 0) { item = bank3[a]; canShoot = true; flag = true; break; } } } if (!flag) { Item[] bank4 = player.bank2.item; for (int b = 0; b < bank4.Length; b++) { if (bank4[b].ammo == sItem.useAmmo && bank4[b].stack > 0) { item = bank4[b]; canShoot = true; flag = true; break; } } } if (!flag) { Item[] bank5 = player.bank.item; for (int c = 0; c < bank5.Length; c++) { if (bank5[c].ammo == sItem.useAmmo && bank5[c].stack > 0) { item = bank5[c]; canShoot = true; flag = true; break; } } } if (!flag) { for (int j = 0; j < 54; j++) { if (player.inventory[j].ammo == sItem.useAmmo && player.inventory[j].stack > 0) { item = player.inventory[j]; canShoot = true; break; } } } if (!canShoot) { return; } if (sItem.type == 1946) { shoot = 338 + item.type - 771; if (shoot > 341) { shoot = 341; } } else if (sItem.useAmmo == AmmoID.Rocket) { shoot += item.shoot; } else if (sItem.useAmmo == 780) { shoot += item.shoot; } else if (item.shoot > 0) { shoot = item.shoot; } if (sItem.type == 3019 && shoot == 1) { shoot = 485; } if (sItem.type == 3052) { shoot = 495; } if (sItem.type == 3245 && shoot == 21) { shoot = 532; } if (shoot == 42) { if (item.type == 370) { shoot = 65; Damage += 5; } else if (item.type == 408) { shoot = 68; Damage += 5; } else if (item.type == 1246) { shoot = 354; Damage += 5; } } if (player.inventory[player.selectedItem].type == 2888 && shoot == 1) { shoot = 469; } if (player.magicQuiver && (sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake)) { KnockBack = (float)((int)((double)KnockBack * 1.1)); speed *= 1.1f; } speed += item.shootSpeed; if (item.ranged) { if (item.damage > 0) { if (sItem.damage > 0) { Damage += (int)((float)(item.damage * Damage) / (float)sItem.damage); } else { Damage += item.damage; } } } else { Damage += item.damage; } if (sItem.useAmmo == AmmoID.Arrow && player.archery && speed < 20f) { speed *= 1.2f; if (speed > 20f) { speed = 20f; } } KnockBack += item.knockBack; ItemLoader.PickAmmo(sItem, item, player, ref shoot, ref speed, ref Damage, ref KnockBack); bool flag2 = dontConsume; if (sItem.type == 3245) { if (Main.rand.Next(3) == 0) { flag2 = true; } else if (player.thrownCost33 && Main.rand.Next(100) < 33) { flag2 = true; } else if (player.thrownCost50 && Main.rand.Next(100) < 50) { flag2 = true; } } if (sItem.type == 3475 && Main.rand.Next(3) != 0) { flag2 = true; } if (sItem.type == 3540 && Main.rand.Next(3) != 0) { flag2 = true; } if (player.magicQuiver && sItem.useAmmo == AmmoID.Arrow && Main.rand.Next(5) == 0) { flag2 = true; } if (player.ammoBox && Main.rand.Next(5) == 0) { flag2 = true; } if (player.ammoPotion && Main.rand.Next(5) == 0) { flag2 = true; } if (sItem.type == 1782 && Main.rand.Next(3) == 0) { flag2 = true; } if (sItem.type == 98 && Main.rand.Next(3) == 0) { flag2 = true; } if (sItem.type == 2270 && Main.rand.Next(2) == 0) { flag2 = true; } if (sItem.type == 533 && Main.rand.Next(2) == 0) { flag2 = true; } if (sItem.type == 1929 && Main.rand.Next(2) == 0) { flag2 = true; } if (sItem.type == 1553 && Main.rand.Next(2) == 0) { flag2 = true; } if (sItem.type == 434 && player.itemAnimation < PlayerHooks.TotalMeleeTime((float)sItem.useAnimation, player, sItem) - 2) { flag2 = true; } if (player.ammoCost80 && Main.rand.Next(5) == 0) { flag2 = true; } if (player.ammoCost75 && Main.rand.Next(4) == 0) { flag2 = true; } if (shoot == 85 && player.itemAnimation < player.itemAnimationMax - 6) { flag2 = true; } if ((shoot == 145 || shoot == 146 || shoot == 147 || shoot == 148 || shoot == 149) && player.itemAnimation < player.itemAnimationMax - 5) { flag2 = true; } if (!(flag2 | (!PlayerHooks.ConsumeAmmo(player, sItem, item) | !ItemLoader.ConsumeAmmo(sItem, item, player))) && item.consumable) { PlayerHooks.OnConsumeAmmo(player, sItem, item); ItemLoader.OnConsumeAmmo(sItem, item, player); item.stack--; if (item.stack <= 0) { item.active = false; item.TurnToAir(); } } }