123 lines
4.8 KiB
C#
123 lines
4.8 KiB
C#
using CalamityMod.Projectiles.Magic;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Magic
|
|
{
|
|
public class WyvernsCall : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Magic";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Item.staff[Item.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 45;
|
|
Item.DamageType = DamageClass.Magic;
|
|
Item.mana = 10;
|
|
Item.width = 52;
|
|
Item.height = 74;
|
|
Item.useTime = 23;
|
|
Item.useAnimation = 23;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 4.75f;
|
|
Item.value = CalamityGlobalItem.Rarity5BuyPrice;
|
|
Item.rare = ItemRarityID.Pink;
|
|
Item.UseSound = SoundID.Item102;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ModContent.ProjectileType<WyvernFeatherPurple>();
|
|
Item.shootSpeed = 18f;
|
|
}
|
|
|
|
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 = (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;
|
|
num79 = 0f;
|
|
num80 = num72;
|
|
}
|
|
else
|
|
{
|
|
num80 = num72 / num80;
|
|
}
|
|
|
|
int num107 = 3;
|
|
for (int num108 = 0; num108 < num107; num108++)
|
|
{
|
|
float damageMult = 1f;
|
|
float kbMult = 1f;
|
|
if (Main.rand.NextBool(10))
|
|
{
|
|
type = ModContent.ProjectileType<WyvernProjectile>();
|
|
}
|
|
else if (Main.rand.NextBool(3))
|
|
{
|
|
type = ModContent.ProjectileType<WyvernFeatherGreen>();
|
|
}
|
|
else if (Main.rand.NextBool(2))
|
|
{
|
|
type = ModContent.ProjectileType<WyvernFeatherPink>();
|
|
}
|
|
if (type == ModContent.ProjectileType<WyvernProjectile>())
|
|
{
|
|
damageMult = 20f;
|
|
kbMult = 1.5f;
|
|
}
|
|
if (type == ModContent.ProjectileType<WyvernFeatherPink>())
|
|
{
|
|
damageMult = 1.2f;
|
|
kbMult = 2f;
|
|
}
|
|
vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(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(-200, 201);
|
|
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 speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f;
|
|
float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f;
|
|
int feather = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient<SkyGlaze>().
|
|
AddRecipeGroup("AnyMythrilBar", 5).
|
|
AddIngredient(ItemID.SoulofFlight, 15).
|
|
AddTile(TileID.MythrilAnvil).
|
|
Register();
|
|
}
|
|
}
|
|
}
|