tModLoader Trying to make a custom High Velocity Bullet variant

Ahndrek Li'Cyri

Skeletron Prime
Hey there!
I'm working on some weapons and i wanted to make a High Velocity bullet but that applied the 'On Fire!' de-buff and was more orange.
But something seems to be off. While i can set the 'On Fire!' de-buff, the color doesn't seem to change and the bullet looks odd.

Here's what i mean by the bullet looks weird:
Screenshot_7.png
Here's what my code for the custom projectile is:
C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TechAndScalesMod.Projectiles
{
    class LavaHighVelocity : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Lava High Velocity");
            ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;
            ProjectileID.Sets.TrailingMode[projectile.type] = 0;
        }

        public override void SetDefaults()
        {
            projectile.width = 136;
            projectile.height = 2;
            projectile.aiStyle = 1; // The AI this projectile has.
            projectile.friendly = true;
            projectile.hostile = false;
            projectile.ranged = true; // Is this shot out of a ranged weapon?
            projectile.penetrate = 1; // If this projectile has penetration. Set to 0 to disable.
            projectile.timeLeft = 600; // Life of the projectile. 60 = 1 sec.
            projectile.alpha = 255; // The alpha of the bullet.
            projectile.light = 1f; // How bright the light this projectile emits. Set to 0 for none.
            projectile.tileCollide = true; // Can this projectile hit tiles?
            projectile.extraUpdates = 8; // How often the projectile checks for a movement update. Higher makes the projectile faster. Musket ball = 1, High Vel = 8.
            aiType = ProjectileID.Bullet; // Makes the project act like a normal Bullet.
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            if (!target.HasBuff(BuffID.OnFire))
            {
                target.AddBuff(BuffID.OnFire, 60 * 3);
            }
        }

        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            lightColor = new Color(1, 1, 0);
            Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].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);
                spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
            }
            return true;
        }

        public override void Kill(int timeLeft)
        {
            Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height);
            Main.PlaySound(SoundID.Item10, projectile.position);
        }
    }
}
And here is the sprite and file itself:
Screenshot_8.png
Any help would be very much appreciated! Thank you.
 
Well, I'm not using a bullet. The gun I'm using is suppose to turn a normal musket ball into this type of bullet.
Here's the gun code though:
C#:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace TechAndScalesMod.Items.Weapons.Ranged.Guns
{
    public class MoltenAccelerator : ModItem
    {
        public override void SetStaticDefaults()
        {
            Tooltip.SetDefault("Turns shot bullets into High Velocity bullets.\nBullets will inflict 'On Fire!' for 3 Seconds. (WIP)");
        }

        public override void SetDefaults()
        {
            item.damage = 30; // Inital damage with no modifications.
            item.crit = 3; // Added to the base critical chance (4%)
            item.ranged = true; // Is this a ranged weapon?
            item.width = 50;
            item.height = 30;
            item.useTime = 40;
            item.useAnimation = 40; // UseAnimation and useTime SHOULD match to prevent multiple attacks in one animation unless desired.
            item.useStyle = 5; // 5 = Gun/Wand
            item.noMelee = true; // Prevents animation from doing damage.
            item.knockBack = 7;
            item.value = Item.sellPrice(0, 2, 50, 0); // The sell price. In (Platnium, Gold, Silver, Copper)
            item.rare = 3;
            item.UseSound = SoundID.Item11;
            item.autoReuse = true; // Does the item automatically get used if the use button is hold?
            item.shoot = 10; // Fired Projectile of the weapon.
            item.shootSpeed = 30f; // Velocity?
            item.useAmmo = AmmoID.Bullet; // Use bullet type ammo.
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.HellstoneBar, 10);
            recipe.AddIngredient(ItemType<DiamondAccelerator>());
            recipe.AddTile(TileID.Anvils);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            // Turns regular ammo into Lava High Velocity ones
            if (type == ProjectileID.Bullet)
            {
                type = ProjectileType<Projectiles.LavaHighVelocity>(); //<--- LavaHighVelocity type is broken, need to fix
                //type = ProjectileID.BulletHighVelocity;
            }
            // Should make the bullets come right out of the muzzle
            Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY)) * 25;
            if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0))
            {
                position += muzzleOffset;
            }
            return true; // Have to return true here or it won't work!
        }

        public override Vector2? HoldoutOffset()
        {
            return Vector2.Zero; // Change where the weapon is held (X,Y).
        }
    }
}
 
The idea was the gun would turn the bullets into the type i am trying to make.
And it could very well just be the sprite that is the issue, but I'm not 100% sure on that since i can't access the vanilla code for projectiles.
 
Can you send your whole mod file if possible?
Because i need to test something
And i'll reply to you as soon as possible after testing
 
Apologies for the late response.
While i very much appreciate the help, i think I'll simply just rework the weapon into something else for now.
Thank you for the help though.
 
Back
Top Bottom