Spawn a new projectile when a projectile hits an NPC (tModLoader 1.4)

TimeParadox_

Terrarian
Hello,

I am trying to make a projectile that will split into more projectiles when it hits an NPC. I seem to have everything right, except I cannot figure out the spawnSource parameter for projectile.NewProjectile.

C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System;

namespace PewPew.Projectiles
{
    internal class RailgunRound : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Railgun Round");
        }

        public override void SetDefaults()
        {
            Projectile.damage = 100;
            Projectile.width = 16;
            Projectile.height = 8;
            Projectile.aiStyle = 1;
            Projectile.friendly = true;
            Projectile.hostile = false;
            Projectile.DamageType = DamageClass.Ranged;
            Projectile.penetrate = 10;
            Projectile.timeLeft = 600;
            Projectile.alpha = 255;
            Projectile.light = 1f;
            Projectile.ignoreWater = false;
            Projectile.tileCollide = true;
            AIType = ProjectileID.Bullet;            
        }

        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            Projectile.penetrate--;
            if (Projectile.penetrate <= 0)
            {
                Projectile.Kill();
                int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GoldFlame);
                Main.dust[dust].noGravity = true;
            }
            return true;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            Projectile.NewProjectile(spawnSource ?, Projectile.position, Projectile.velocity, ProjectileID.Grenade, new Vector2(0, 20), 0f);
        }

        public override void AI()
        {
            float valueChangeX = Math.Abs(Projectile.velocity.X) / (int)Projectile.velocity.X;
            Projectile.velocity.X += valueChangeX;
            
        }

    }
}
 
Basically, what do I put for the spawnsource parameter in Projectile.NewProjectile?
 
Projectile.GetSource_FromThis(), should work
 
Back
Top Bottom