66 lines
2.7 KiB
C#
66 lines
2.7 KiB
C#
using Terraria.DataStructures;
|
|
using CalamityMod.Projectiles.Summon;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Summon
|
|
{
|
|
[LegacyName("MagicalConch")]
|
|
public class EnchantedConch : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Summon";
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 20;
|
|
Item.mana = 10;
|
|
Item.width = 34;
|
|
Item.height = 24;
|
|
Item.useTime = Item.useAnimation = 35;
|
|
Item.useStyle = ItemUseStyleID.Swing;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 2f;
|
|
Item.value = CalamityGlobalItem.Rarity2BuyPrice;
|
|
Item.rare = ItemRarityID.Green;
|
|
Item.UseSound = SoundID.Item44;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ModContent.ProjectileType<HermitCrabMinion>();
|
|
Item.shootSpeed = 10f;
|
|
Item.DamageType = DamageClass.Summon;
|
|
}
|
|
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
int i = Main.myPlayer;
|
|
float projSpeed = Item.shootSpeed;
|
|
player.itemTime = Item.useTime;
|
|
Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X;
|
|
float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y;
|
|
if (player.gravDir == -1f)
|
|
{
|
|
mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y;
|
|
}
|
|
float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist));
|
|
if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f))
|
|
{
|
|
mouseXDist = (float)player.direction;
|
|
}
|
|
else
|
|
{
|
|
mouseDistance = projSpeed / mouseDistance;
|
|
}
|
|
mouseXDist = 0f;
|
|
mouseYDist = 0f;
|
|
realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X;
|
|
realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y;
|
|
int p = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, mouseXDist, mouseYDist, ModContent.ProjectileType<HermitCrabMinion>(), damage, knockback, i, 0f, 0f);
|
|
if (Main.projectile.IndexInRange(p))
|
|
Main.projectile[p].originalDamage = Item.damage;
|
|
return false;
|
|
}
|
|
}
|
|
}
|