99 lines
4.0 KiB
C#
99 lines
4.0 KiB
C#
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Items.Placeables;
|
|
using CalamityMod.Projectiles.Magic;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Magic
|
|
{
|
|
public class UndinesRetribution : ModItem
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Undine's Retribution");
|
|
Tooltip.SetDefault("Casts a swarm of homing spears");
|
|
Item.staff[item.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
item.damage = 30;
|
|
item.magic = true;
|
|
item.mana = 15;
|
|
item.width = 64;
|
|
item.height = 64;
|
|
item.useTime = 18;
|
|
item.useAnimation = 18;
|
|
item.useStyle = 5;
|
|
item.noMelee = true;
|
|
item.knockBack = 3.5f;
|
|
item.value = Item.buyPrice(0, 60, 0, 0);
|
|
item.rare = 7;
|
|
item.UseSound = SoundID.Item66;
|
|
item.autoReuse = true;
|
|
item.shootSpeed = 12f;
|
|
item.shoot = ModContent.ProjectileType<UndinesRetributionSpear>();
|
|
}
|
|
|
|
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 num72 = item.shootSpeed;
|
|
Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
if (player.gravDir == -1f)
|
|
{
|
|
num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y;
|
|
}
|
|
float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
|
|
if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f))
|
|
{
|
|
num78 = (float)player.direction;
|
|
}
|
|
else
|
|
{
|
|
num80 = num72 / num80;
|
|
}
|
|
for (int num108 = 0; num108 < 3; num108++)
|
|
{
|
|
vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //-
|
|
vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200
|
|
vector2.Y += (float)(100 * num108); //-=
|
|
num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; //+ -
|
|
num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; //+ -
|
|
if (num79 < 0f)
|
|
{
|
|
num79 *= -1f;
|
|
}
|
|
if (num79 < 20f)
|
|
{
|
|
num79 = 20f;
|
|
}
|
|
num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
|
|
num80 = num72 / num80;
|
|
num78 *= num80;
|
|
num79 *= num80;
|
|
float speedX6 = num78 + (float)Main.rand.Next(-60, 61) * 0.02f;
|
|
float speedY7 = num79 + (float)Main.rand.Next(-60, 61) * 0.02f;
|
|
float ai1 = Main.rand.NextFloat() + 0.5f;
|
|
int bullet2 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX6, -speedY7, type, damage, knockBack, player.whoAmI, 0.0f, ai1);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
ModRecipe recipe = new ModRecipe(mod);
|
|
recipe.AddIngredient(ModContent.ItemType<DepthCells>(), 30);
|
|
recipe.AddIngredient(ModContent.ItemType<Lumenite>(), 10);
|
|
recipe.AddIngredient(ModContent.ItemType<Tenebris>(), 10);
|
|
recipe.AddTile(TileID.MythrilAnvil);
|
|
recipe.SetResult(this);
|
|
recipe.AddRecipe();
|
|
}
|
|
}
|
|
}
|