tModLoader Modifying vanilla projectiles?

MrMangoGoose

Terrarian
I'm completely new to modding, started working on something a couple days ago.
But I'm wondering if there's any way of modifying the behavior/color/dust/etc. of vanilla projectiles?
 
You mean you want to completely change the AI of an existing projectile? I'd recommend cloning it and making your own, and modifying it as you want.
Yeah, exactly! I mean just modifying it in general, changing its colors to fit another weapon design or making it homing or changing the particles/dust emitted, but yeah!
How do you go about copying it though? Would I have to locate where the original code is and copy it from there? I'll try to do that, but I'll keep an eye on this post.
Thanks for the help though! :)
 
You can change anything globally by overriding methods in the GlobalProjectile class. Just create a class and inherit from GlobalProjectile as shown in the example. But of course it's better to use cloning so as not to cause any problems with other mods or with the game itself
C#:
public class GlobProj : GlobalProjectile
    {
        public override Color? GetAlpha(Projectile projectile, Color lightColor)
        {
            if (projectile.aiStyle == ProjAIStyleID.FallingStar) // if the AI projectile is a shooting star
                return Color.Black; // change its color to black
            return base.GetAlpha(projectile, lightColor); // otherwise return the default color
        }
    }
To add/remove dust or change the behavior of a projectile, override the AI() method and check for a specific projectile
1659901229370.png
 
Back
Top Bottom