How to make a projectile that is not starfury

DiscoLlama

Terrarian
hi, i'm trying to make a sword that will shoot projectiles from the sky but the example only shows you how to use starfury's projectile and i have created a sprite for it so how do i make the projectile it shoots, the sprite i made?

this is the code:


public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2 target = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY);
float ceilingLimit = target.Y;
if (ceilingLimit > player.Center.Y - 200f)
{
ceilingLimit = player.Center.Y - 200f;
}
for (int i = 0; i < 3; i++)
{
position = player.Center + new Vector2((-(float)Main.rand.Next(0, 401) * player.direction), -600f);
position.Y -= (100 * i);
Vector2 heading = target - position;
if (heading.Y < 0f)
{
heading.Y *= -1f;
}
if (heading.Y < 20f)
{
heading.Y = 20f;
}
heading.Normalize();
heading *= new Vector2(speedX, speedY).Length();
speedX = heading.X;
speedY = heading.Y + Main.rand.Next(-40, 41) * 0.02f;
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage * 2, knockBack, player.whoAmI, 0f, ceilingLimit);
}
return false;
}
 
I used this code and it worked fine without shooting starfury

If u have coded the projectile then go to the defaults of the sword and put item.shoot = mod.ProjectileType(" name of projectile ");

I hope it helps:D
 
Last edited:
Back
Top Bottom