How do I make a custom projectile that goes straight?

ThatGuyGabe

Terrarian
I made a melee sword and I want to add a custom projectile to it but do not know how. Does anyone what code can do this if so let me know.
 
And plz don't send me to example mod I want the projectile to be this sprite
1660429366057.png
I've even messaged discord servers have not gotten any response that helps me.
 
this is the code for the sword
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
using EstherMod.Content.Projectiles;


namespace EstherMod.Content.Items.Weapons
{
public class Esther : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Esther"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.

}

public override void SetDefaults()
{
Item.damage = 55;
Item.DamageType = DamageClass.Melee;
Item.width = 70;
Item.height = 70;
Item.useTime = 21;
Item.useAnimation = 21;
Item.useStyle = 1;
Item.knockBack = 4.5f;
Item.value = 10000;
Item.rare = 2;
Item.UseSound = SoundID.Item72;
Item.autoReuse = true;
Item.shoot = Mod.Find<ModProjectile>("EstherProjectile").Type;
Item.shootSpeed = 7f;



}





public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.BloodButcherer, 1);
recipe.AddIngredient(ItemID.Muramasa, 1);
recipe.AddIngredient(ItemID.BladeofGrass, 1);
recipe.AddIngredient(ItemID.FieryGreatsword, 1);
recipe.AddTile(TileID.Anvils);
recipe.Register();
}
}
}
 
And this is the code for the projectile
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;

namespace EstherMod.Content.Projectiles
{
public class EstherProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Zephyr Blade");
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 3;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}

public override void SetDefaults()
{
Projectile.aiStyle = 1;
Projectile.width = 14;
Projectile.height = 24;
AIType = 0;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.tileCollide = true;
Projectile.extraUpdates = 1;
}
public override void Kill(int timeLeft)
{
Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
SoundEngine.PlaySound(SoundID.Item10, Projectile.position);
int num570 = Main.rand.Next(4, 10);
int num3;
for (int num571 = 0; num571 < num570; num571 = num3 + 1)
{
int num572 = Dust.NewDust(Projectile.Center, 0, 0, 16, 0f, 0f, 100, default(Color), 1f);
Dust dust = Main.dust[num572];
dust.velocity *= 1.6f;
Dust dust56 = Main.dust[num572];
dust56.velocity.Y = dust56.velocity.Y - 1f;
dust = Main.dust[num572];
dust.velocity += -Projectile.velocity * (Main.rand.NextFloat() * 2f - 1f) * 0.5f;
Main.dust[num572].scale = 2f;
Main.dust[num572].fadeIn = 0.5f;
Main.dust[num572].noGravity = true;
num3 = num571;
}
}
public override bool PreDraw(ref Color lightColor)
{
Vector2 drawOrigin = new Vector2(TextureAssets.Projectile[Projectile.type].Value.Width * 0.5f, Projectile.height * 0.5f);
for (int k = 0; k < Projectile.oldPos.Length; k++)
{
Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, Projectile.gfxOffY);
Color color = Projectile.GetAlpha(lightColor) * ((float)(Projectile.oldPos.Length - k) / (float)Projectile.oldPos.Length);

}
return true;
}
}
}
 
I figured out how to get the projectile straight and the sprite of that projectile to go straight I just put Projectile.rotation = Projectile.velocity.ToRotation(); in ai
 
Back
Top Bottom