72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
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 Starfall : ModItem
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Starfall");
|
|
Tooltip.SetDefault("Casts a spread of astral stars at the mouse cursor");
|
|
SacrificeTotal = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 57;
|
|
Item.DamageType = DamageClass.Magic;
|
|
Item.mana = 15;
|
|
Item.rare = ItemRarityID.Cyan;
|
|
Item.width = 38;
|
|
Item.height = 40;
|
|
Item.useTime = 14;
|
|
Item.useAnimation = 14;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 3.25f;
|
|
Item.value = CalamityGlobalItem.Rarity9BuyPrice;
|
|
Item.UseSound = SoundID.Item105;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ModContent.ProjectileType<AstralStarMagic>();
|
|
Item.shootSpeed = 12f;
|
|
}
|
|
|
|
// 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)
|
|
{
|
|
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;
|
|
}
|
|
if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f))
|
|
{
|
|
num78 = (float)player.direction;
|
|
num79 = 0f;
|
|
}
|
|
float num208 = num78;
|
|
float num209 = num79;
|
|
num208 += (float)Main.rand.Next(-1, 2) * 0.5f;
|
|
num209 += (float)Main.rand.Next(-1, 2) * 0.5f;
|
|
vector2 += new Vector2(num208, num209);
|
|
for (int num108 = 0; num108 < 5; num108++)
|
|
{
|
|
float speedX4 = 2f + (float)Main.rand.Next(-8, 5);
|
|
float speedY5 = 15f + (float)Main.rand.Next(1, 6);
|
|
int star = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|