67 lines
2.8 KiB
C#
67 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
|
|
{
|
|
[LegacyName("Starfall")]
|
|
public class StarShower : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Magic";
|
|
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 starSpeed = Item.shootSpeed;
|
|
Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X;
|
|
float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y;
|
|
if (player.gravDir == -1f)
|
|
{
|
|
mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y;
|
|
}
|
|
if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f))
|
|
{
|
|
mouseXDist = (float)player.direction;
|
|
mouseYDist = 0f;
|
|
}
|
|
float randXOffset = mouseXDist;
|
|
float randYOffset = mouseYDist;
|
|
randXOffset += (float)Main.rand.Next(-1, 2) * 0.5f;
|
|
randYOffset += (float)Main.rand.Next(-1, 2) * 0.5f;
|
|
realPlayerPos += new Vector2(randXOffset, randYOffset);
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
float speedX4 = 2f + (float)Main.rand.Next(-8, 5);
|
|
float speedY5 = 15f + (float)Main.rand.Next(1, 6);
|
|
int star = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|