Files
CalamityModPublic/Items/Weapons/Ranged/SDFMG.cs
T

74 lines
2.7 KiB
C#

using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
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.ModLoader;
namespace CalamityMod.Items.Weapons.Ranged
{
public class SDFMG : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Ranged";
public override void SetDefaults()
{
Item.damage = 100;
Item.DamageType = DamageClass.Ranged;
Item.width = 74;
Item.height = 34;
Item.useTime = 2;
Item.useAnimation = 2;
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<DarkBlue>();
Item.Calamity().canFirePointBlankShots = true;
}
// Terraria seems to really dislike high crit values in SetDefaults
public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 15;
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.Next(-5, 6) * 0.05f;
float SpeedY = velocity.Y + Main.rand.Next(-5, 6) * 0.05f;
if (Main.rand.NextBool(5))
{
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)
{
if (Main.rand.Next(0, 100) < 50)
return false;
return true;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient(ItemID.SDMG).
AddIngredient<FetidEmesis>().
AddIngredient<CosmiliteBar>(8).
AddIngredient<EndothermicEnergy>(20).
AddTile<CosmicAnvil>().
Register();
}
}
}