Script Request: Does anyone have an example script for a modded sword that shoots a custom projectile that i can use?

RicksBy

Terrarian
My script keeps showing up with errors because im still very new to coding if any one has a script for a modded sword that shoots a custom projectile that i can borrow it'd be much apprectiated
 
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespaceYOURMODHERE.Items
{
    public class ITEMNAME : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("NAME");
            Tooltip.SetDefault("DESCRIPTION");
        }

        public override void SetDefaults()
        {
            item.damage = 210;
            item.melee = true;
            item.width = 60;
            item.height = 60;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 1;
            item.knockBack = 10;
            item.value = 1000000;
            item.rare = 11;
            item.UseSound = SoundID.Item105;
            item.autoReuse = true;
            item.shoot = 132;
            item.shootSpeed = 6f;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(INGREDIENT, AMOUNT);
            recipe.AddTile(CRAFTINGSTATION);
            recipe.SetResult(this);
            recipe.AddRecipe();
               }
                public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
               {
// you can add debuffs here or delete this entire section!
                        target.AddBuff(BuffID.Bleeding, 5 * 60);
                        target.AddBuff(BuffID.ShadowFlame, 15 * 60);
               }
        
        }

}
 
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespaceYOURMODHERE.Items
{
    public class ITEMNAME : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("NAME");
            Tooltip.SetDefault("DESCRIPTION");
        }

        public override void SetDefaults()
        {
            item.damage = 210;
            item.melee = true;
            item.width = 60;
            item.height = 60;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 1;
            item.knockBack = 10;
            item.value = 1000000;
            item.rare = 11;
            item.UseSound = SoundID.Item105;
            item.autoReuse = true;
            item.shoot = 132;
            item.shootSpeed = 6f;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(INGREDIENT, AMOUNT);
            recipe.AddTile(CRAFTINGSTATION);
            recipe.SetResult(this);
            recipe.AddRecipe();
               }
                public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
               {
// you can add debuffs here or delete this entire section!
                        target.AddBuff(BuffID.Bleeding, 5 * 60);
                        target.AddBuff(BuffID.ShadowFlame, 15 * 60);
               }
       
        }

}
that code shoots a normal vanilla projectile, so here

using Terraria.ID;
using Terraria.ModLoader;

namespaceYOURMODHERE.Items
{
public class ITEMNAME : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("NAME");
Tooltip.SetDefault("DESCRIPTION");
}

public override void SetDefaults()
{
item.damage = 210;
item.melee = true;
item.width = 60;
item.height = 60;
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 10;
item.value = 1000000;
item.rare = 11;
item.UseSound = SoundID.Item105;
item.autoReuse = true;
item.shoot = mod.ProjectileType("MODPROJECTILENAME");
item.shootSpeed = 6f;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(INGREDIENT, AMOUNT);
recipe.AddTile(CRAFTINGSTATION);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
// you can add debuffs here or delete this entire section!
target.AddBuff(BuffID.Bleeding, 5 * 60);
target.AddBuff(BuffID.ShadowFlame, 15 * 60);
}

}
 
Back
Top Bottom