114 lines
4.4 KiB
C#
114 lines
4.4 KiB
C#
using Terraria.DataStructures;
|
|
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Projectiles.Ranged;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Ranged
|
|
{
|
|
public class PlanetaryAnnihilation : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Ranged";
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 66;
|
|
Item.DamageType = DamageClass.Ranged;
|
|
Item.width = 58;
|
|
Item.height = 102;
|
|
Item.useTime = 22;
|
|
Item.useAnimation = 22;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 5.5f;
|
|
Item.value = CalamityGlobalItem.Rarity11BuyPrice;
|
|
Item.rare = ItemRarityID.Purple;
|
|
Item.UseSound = SoundID.Item75;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ModContent.ProjectileType<PlanetaryAnnihilationProj>();
|
|
Item.shootSpeed = 12f;
|
|
Item.useAmmo = AmmoID.Arrow;
|
|
}
|
|
|
|
public override Vector2? HoldoutOffset()
|
|
{
|
|
return new Vector2(-5, 0);
|
|
}
|
|
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
float num72 = Item.shootSpeed;
|
|
Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
float num78 = Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
float num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
if (player.gravDir == -1f)
|
|
{
|
|
num79 = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - vector2.Y;
|
|
}
|
|
float num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79);
|
|
if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f))
|
|
{
|
|
num78 = player.direction;
|
|
num79 = 0f;
|
|
num80 = num72;
|
|
}
|
|
else
|
|
{
|
|
num80 = num72 / num80;
|
|
}
|
|
|
|
vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f);
|
|
vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201);
|
|
vector2.Y -= 100f;
|
|
num78 = Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
if (num79 < 0f)
|
|
{
|
|
num79 *= -1f;
|
|
}
|
|
if (num79 < 20f)
|
|
{
|
|
num79 = 20f;
|
|
}
|
|
num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79);
|
|
num80 = num72 / num80;
|
|
num78 *= num80;
|
|
num79 *= num80;
|
|
if (CalamityUtils.CheckWoodenAmmo(type, player))
|
|
{
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
float speedX4 = num78 + Main.rand.Next(-120, 121) * 0.02f;
|
|
float speedY5 = num79 + Main.rand.Next(-120, 121) * 0.02f;
|
|
Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType<PlanetaryAnnihilationProj>(), damage, knockback, player.whoAmI, 0f, i);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
float speedX4 = num78 + Main.rand.Next(-120, 121) * 0.02f;
|
|
float speedY5 = num79 + Main.rand.Next(-120, 121) * 0.02f;
|
|
int num121 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI);
|
|
Main.projectile[num121].noDropItem = true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient<CosmicBolter>().
|
|
AddIngredient(ItemID.DaedalusStormbow).
|
|
AddIngredient(ItemID.LunarBar, 5).
|
|
AddIngredient<LifeAlloy>(5).
|
|
AddIngredient<GalacticaSingularity>(5).
|
|
AddTile(TileID.LunarCraftingStation).
|
|
Register();
|
|
}
|
|
}
|
|
}
|