Appears to originally have been done this way due to some interaction with reforging, but doing it like this breaks continuous updating stats; perhaps check on reforge stuff just in case?
71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Projectiles.Ranged;
|
|
using CalamityMod.Rarities;
|
|
using CalamityMod.Tiles.Furniture.CraftingStations;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.Localization;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Ranged
|
|
{
|
|
public class SDFMG : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Ranged";
|
|
|
|
public static int AmmoSavedPercent = 66;
|
|
public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent);
|
|
|
|
private int ShotCounter = 0;
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 74;
|
|
Item.height = 34;
|
|
Item.damage = 118;
|
|
Item.DamageType = DamageClass.Ranged;
|
|
Item.crit = 15;
|
|
Item.useTime = Item.useAnimation = 3;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 2.75f;
|
|
Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice;
|
|
Item.UseSound = SoundID.Item11;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ProjectileID.PurificationPowder;
|
|
Item.shootSpeed = 16f;
|
|
Item.useAmmo = AmmoID.Bullet;
|
|
Item.rare = ModContent.RarityType<CosmicPurple>();
|
|
}
|
|
|
|
public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
|
|
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
float SpeedX = velocity.X + Main.rand.NextFloat(-0.25f, 0.25f);
|
|
float SpeedY = velocity.Y + Main.rand.NextFloat(-0.25f, 0.25f);
|
|
ShotCounter++;
|
|
if (ShotCounter >= 7)
|
|
{
|
|
ShotCounter = 0;
|
|
Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType<FishronRPG>(), damage, knockback, player.whoAmI);
|
|
}
|
|
Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI);
|
|
return false;
|
|
}
|
|
|
|
public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent;
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient(ItemID.SDMG).
|
|
AddIngredient<CosmiliteBar>(8).
|
|
AddIngredient<EndothermicEnergy>(20).
|
|
AddTile<CosmicAnvil>().
|
|
Register();
|
|
}
|
|
}
|
|
}
|