Files
CalamityModPublic/Items/Weapons/Rogue/Glaive.cs
T

70 lines
2.3 KiB
C#

using CalamityMod.Projectiles.Rogue;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Rogue
{
public class Glaive : RogueWeapon
{
public static int BaseDamage = 45;
public static float Knockback = 3f;
public static float Speed = 10f;
public static float StealthSpeedMult = 1.8f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Glaive");
Tooltip.SetDefault(@"Stacks up to 3
Stealth strikes are super fast and pierce infinitely");
}
public override void SafeSetDefaults()
{
item.damage = BaseDamage;
item.Calamity().rogue = true;
item.noMelee = true;
item.noUseGraphic = true;
item.width = 1;
item.height = 1;
item.useTime = 15;
item.useAnimation = 15;
item.useStyle = ItemUseStyleID.SwingThrow;
item.knockBack = Knockback;
item.value = Item.buyPrice(0, 1, 40, 0);
item.rare = ItemRarityID.Orange;
item.UseSound = SoundID.Item1;
item.maxStack = 3;
item.shootSpeed = Speed;
item.shoot = ModContent.ProjectileType<GlaiveProj>();
}
// Terraria seems to really dislike high crit values in SetDefaults
public override void GetWeaponCrit(Player player, ref int crit) => crit += 4;
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
float ai1 = 0f;
if (player.Calamity().StealthStrikeAvailable())
{
speedX *= StealthSpeedMult;
speedY *= StealthSpeedMult;
ai1 = 1f;
}
int p = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, ai1);
if (player.Calamity().StealthStrikeAvailable() && p.WithinBounds(Main.maxProjectiles))
Main.projectile[p].Calamity().stealthStrike = true;
return false;
}
public override bool CanUseItem(Player player)
{
return player.ownedProjectileCounts[item.shoot] < item.stack;
}
}
}