84 lines
3.4 KiB
C#
84 lines
3.4 KiB
C#
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Projectiles.Magic;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Magic
|
|
{
|
|
public class InfernalRift : ModItem
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Infernal Rift");
|
|
Tooltip.SetDefault("Summons infernal blades that spawn additional blades on enemy hits");
|
|
Item.staff[Item.type] = true;
|
|
SacrificeTotal = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 40;
|
|
Item.DamageType = DamageClass.Magic;
|
|
Item.mana = 15;
|
|
Item.width = 16;
|
|
Item.height = 16;
|
|
Item.useAnimation = 30;
|
|
Item.useTime = 2;
|
|
Item.reuseDelay = Item.useAnimation + 6;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 7f;
|
|
Item.value = CalamityGlobalItem.Rarity6BuyPrice;
|
|
Item.rare = ItemRarityID.Yellow;
|
|
Item.UseSound = SoundID.Item9;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ModContent.ProjectileType<InfernalBlade>();
|
|
Item.shootSpeed = 16f;
|
|
}
|
|
|
|
// Terraria seems to really dislike high crit values in SetDefaults
|
|
public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 25;
|
|
|
|
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
float num72 = Item.shootSpeed;
|
|
float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
float f = Main.rand.NextFloat() * 6.28318548f;
|
|
float value12 = 20f;
|
|
float value13 = 60f;
|
|
Vector2 vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat());
|
|
for (int num202 = 0; num202 < 50; num202++)
|
|
{
|
|
vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat());
|
|
if (Collision.CanHit(vector2, 0, 0, vector13 + (vector13 - vector2).SafeNormalize(Vector2.UnitX) * 8f, 0, 0))
|
|
{
|
|
break;
|
|
}
|
|
f = Main.rand.NextFloat() * 6.28318548f;
|
|
}
|
|
Vector2 mouseWorld = Main.MouseWorld;
|
|
Vector2 vector14 = mouseWorld - vector13;
|
|
Vector2 vector15 = new Vector2(num78, num79).SafeNormalize(Vector2.UnitY) * num72;
|
|
vector14 = vector14.SafeNormalize(vector15) * num72;
|
|
vector14 = Vector2.Lerp(vector14, vector15, 0.25f);
|
|
Projectile.NewProjectile(source, vector13, vector14, type, damage, knockback, player.whoAmI, 0f, 0f);
|
|
return false;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient(ItemID.SkyFracture).
|
|
AddIngredient<ScoriaBar>(10).
|
|
AddTile(TileID.MythrilAnvil).
|
|
Register();
|
|
}
|
|
}
|
|
}
|