Files
CalamityModPublic/Items/Weapons/DraedonsArsenal/PulseRifle.cs
T

84 lines
2.9 KiB
C#

using CalamityMod.CustomRecipes;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.DraedonsArsenal;
using CalamityMod.Rarities;
using CalamityMod.Tiles.Furniture.CraftingStations;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.DraedonsArsenal
{
public class PulseRifle : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal";
public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/PulseRifleFire");
private int BaseDamage = 1420;
public override void SetDefaults()
{
CalamityGlobalItem modItem = Item.Calamity();
Item.width = 62;
Item.height = 22;
Item.DamageType = DamageClass.Ranged;
Item.damage = BaseDamage;
Item.knockBack = 0f;
Item.useTime = 35;
Item.useAnimation = 35;
Item.autoReuse = true;
Item.useStyle = ItemUseStyleID.Shoot;
Item.UseSound = FireSound;
Item.noMelee = true;
Item.value = CalamityGlobalItem.Rarity14BuyPrice;
Item.rare = ModContent.RarityType<DarkBlue>();
Item.shoot = ModContent.ProjectileType<PulseRifleShot>();
Item.shootSpeed = 5f;
modItem.UsesCharge = true;
modItem.MaxCharge = 250f;
modItem.ChargePerUse = 0.24f;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
if (velocity.Length() > 5f)
{
velocity.Normalize();
velocity *= 5f;
}
float SpeedX = velocity.X + (float)Main.rand.Next(-1, 2) * 0.05f;
float SpeedY = velocity.Y + (float)Main.rand.Next(-1, 2) * 0.05f;
Projectile.NewProjectile(source, position, new Vector2(SpeedX, SpeedY), ModContent.ProjectileType<PulseRifleShot>(), damage, knockback, player.whoAmI, 0f, 0f);
return false;
}
public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
public override void ModifyTooltips(List<TooltipLine> tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5);
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<MysteriousCircuitry>(20).
AddIngredient<DubiousPlating>(20).
AddIngredient<CosmiliteBar>(8).
AddIngredient<AscendantSpiritEssence>(2).
AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(5, out Func<bool> condition), condition).
AddTile<CosmicAnvil>().
Register();
}
}
}