86 lines
3.0 KiB
C#
86 lines
3.0 KiB
C#
using Terraria.DataStructures;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Microsoft.Xna.Framework;
|
|
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Projectiles.Rogue;
|
|
using CalamityMod.CalPlayer;
|
|
|
|
namespace CalamityMod.Items.Weapons.Rogue
|
|
{
|
|
public class SkyStabber : RogueWeapon
|
|
{
|
|
private static int damage = 50;
|
|
private static int knockBack = 2;
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = damage;
|
|
Item.DamageType = RogueDamageClass.Instance;
|
|
Item.noMelee = true;
|
|
Item.noUseGraphic = true;
|
|
Item.width = 16;
|
|
Item.height = 16;
|
|
Item.useTime = 15;
|
|
Item.useAnimation = 15;
|
|
Item.useStyle = ItemUseStyleID.Swing;
|
|
Item.knockBack = knockBack;
|
|
Item.value = CalamityGlobalItem.Rarity3BuyPrice;
|
|
Item.rare = ItemRarityID.Orange;
|
|
Item.UseSound = SoundID.Item1;
|
|
|
|
Item.shootSpeed = 2f;
|
|
Item.shoot = ModContent.ProjectileType<SkyStabberProj>();
|
|
}
|
|
|
|
// Terraria seems to really dislike high crit values in SetDefaults
|
|
public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 4;
|
|
|
|
public override bool CanUseItem(Player player)
|
|
{
|
|
if (player.altFunctionUse == 2)
|
|
{
|
|
Item.shoot = ProjectileID.None;
|
|
return player.ownedProjectileCounts[ModContent.ProjectileType<SkyStabberProj>()] > 0;
|
|
}
|
|
else
|
|
{
|
|
Item.shoot = ModContent.ProjectileType<SkyStabberProj>();
|
|
return player.ownedProjectileCounts[ModContent.ProjectileType<SkyStabberProj>()] < 4;
|
|
}
|
|
}
|
|
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
CalamityPlayer modPlayer = player.Calamity();
|
|
modPlayer.killSpikyBalls = false;
|
|
if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike
|
|
{
|
|
int stealth = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType<SkyStabberProj>(), damage, knockback, player.whoAmI);
|
|
if (stealth.WithinBounds(Main.maxProjectiles))
|
|
Main.projectile[stealth].Calamity().stealthStrike = true;
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public override bool AltFunctionUse(Player player)
|
|
{
|
|
CalamityPlayer modPlayer = player.Calamity();
|
|
modPlayer.killSpikyBalls = true;
|
|
return true;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient<AerialiteBar>(4).
|
|
AddIngredient(ItemID.SunplateBlock, 8).
|
|
AddTile(TileID.SkyMill).
|
|
Register();
|
|
}
|
|
|
|
}
|
|
}
|