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

84 lines
3.4 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.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.DraedonsArsenal
{
public class Phaseslayer : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal";
public const int Damage = 980;
// When below this percentage of charge, the sword is small instead of big.
public const float SizeChargeThreshold = 0.25f;
// The small sword barely affects damage on its own because damage is already dropping significantly at low charge.
public const float SmallDamageMultiplier = 0.9f;
// This is the amount of charge consumed every frame the holdout projectile is summoned, i.e. the weapon is in use.
public const float HoldoutChargeUse = 0.005f;
// This is the amount of charge consumed every time a sword beam is fired.
public const float SwordBeamChargeUse = 0.1f;
public override void SetDefaults()
{
CalamityGlobalItem modItem = Item.Calamity();
Item.damage = Damage;
Item.DamageType = DamageClass.MeleeNoSpeed;
Item.width = 26;
Item.height = 26;
Item.useTime = 24;
Item.useAnimation = 24;
Item.useStyle = ItemUseStyleID.Shoot;
Item.useTurn = false;
Item.knockBack = 7f;
Item.noUseGraphic = true;
Item.value = CalamityGlobalItem.Rarity14BuyPrice;
Item.rare = ModContent.RarityType<DarkBlue>();
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.shoot = ModContent.ProjectileType<PhaseslayerProjectile>();
Item.channel = true;
modItem.UsesCharge = true;
modItem.MaxCharge = 250f;
modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile.
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && Item.Calamity().Charge > 0;
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Projectile blade = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI);
blade.rotation = blade.AngleTo(Main.MouseWorld);
blade.netUpdate = true;
return false;
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5);
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<MysteriousCircuitry>(15).
AddIngredient<DubiousPlating>(25).
AddIngredient<CosmiliteBar>(8).
AddIngredient<AscendantSpiritEssence>(2).
AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(5, out Func<bool> condition), condition).
AddTile<CosmicAnvil>().
Register();
}
}
}