76 lines
2.9 KiB
C#
76 lines
2.9 KiB
C#
using CalamityMod.Projectiles.Melee.Spears;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Melee
|
|
{
|
|
public class BansheeHook : ModItem
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Banshee Hook");
|
|
Tooltip.SetDefault("Swings a banshee hook that fires blades and explodes on hit");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
item.width = 120;
|
|
item.damage = 238;
|
|
item.noMelee = true;
|
|
item.noUseGraphic = true;
|
|
item.channel = true;
|
|
item.melee = true;
|
|
item.useAnimation = 21;
|
|
item.useStyle = ItemUseStyleID.HoldingOut;
|
|
item.useTime = 21;
|
|
item.knockBack = 8.5f;
|
|
item.UseSound = SoundID.DD2_GhastlyGlaivePierce;
|
|
item.autoReuse = true;
|
|
item.height = 108;
|
|
item.shoot = ModContent.ProjectileType<BansheeHookProj>();
|
|
item.shootSpeed = 42f;
|
|
|
|
item.value = CalamityGlobalItem.Rarity13BuyPrice;
|
|
item.Calamity().customRarity = CalamityRarity.PureGreen;
|
|
}
|
|
|
|
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
|
|
{
|
|
item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Melee/BansheeHookGlow"));
|
|
}
|
|
|
|
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0;
|
|
|
|
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 num82 = (float)Main.mouseX + Main.screenPosition.X - position.X;
|
|
float num83 = (float)Main.mouseY + Main.screenPosition.Y - position.Y;
|
|
if (player.gravDir == -1f)
|
|
{
|
|
num83 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - position.Y;
|
|
}
|
|
float num84 = (float)Math.Sqrt((double)(num82 * num82 + num83 * num83));
|
|
if ((float.IsNaN(num82) && float.IsNaN(num83)) || (num82 == 0f && num83 == 0f))
|
|
{
|
|
num82 = (float)player.direction;
|
|
num83 = 0f;
|
|
num84 = item.shootSpeed;
|
|
}
|
|
else
|
|
{
|
|
num84 = item.shootSpeed / num84;
|
|
}
|
|
num82 *= num84;
|
|
num83 *= num84;
|
|
float ai4 = Main.rand.NextFloat() * item.shootSpeed * 0.75f * (float)player.direction;
|
|
Vector2 velocity = new Vector2(num82, num83);
|
|
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, ai4, 0.0f);
|
|
return false;
|
|
}
|
|
}
|
|
}
|