First Sliver
Terrarian
I just started modding Terraria a little while ago, and I'm having trouble making my custom bow shoot a custom custom projectile. I know how to make it shoot a custom projectile, but It doesn't work if it uses ammo. I've tried looking at tutorials, but I get errors with overriding Shoot().
Here's the code for the bow:
And here's the code for the projectile:
I've tried overriding Shoot() like this:
but it says "type or namespace 'Vector2' could not be found."
I've also tried overriding it like this:
and it says "type or namespace 'EntitySource_ItemUse_WithAmmo' could not be found."
What is it that I'm doing wrong?
Edit:
After searching around more, I realized what the issue was. I forgot this line of code in the code for the bow:
Here's the code for the bow:
C#:
using Terraria;
using Terraria.ModLoader;
using Terraria.GameContent.Creative;
using Terraria.ID;
using ESP.Projectiles.Weapons;
namespace ESP.Items.Weapons.Bows
{
internal class SlimeBow : ModItem
{
public int baseDamage = 11;
public override void SetStaticDefaults()
{
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
DisplayName.SetDefault("Slime Bow"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("The remains of a once powerful bow...");
}
public override void SetDefaults()
{
Item.width = 16;
Item.height = 32;
Item.useTime = 35;
Item.useAnimation = 35;
Item.useStyle = 5;
Item.UseSound = SoundID.Item5;
Item.autoReuse = true;
Item.DamageType = DamageClass.Ranged;
Item.damage = baseDamage;
Item.knockBack = 2;
Item.rare = ItemRarityID.Blue;
Item.value = 50;
Item.noUseGraphic = false;
Item.noMelee = true;
Item.shootSpeed = 6f;
Item.useAmmo = AmmoID.Arrow;
Item.shoot = ModContent.ProjectileType<SlimyArrow>();
}
public override void ModifyWeaponDamage(Player player, ref StatModifier damage)
{
Item.damage = baseDamage;
Item.damage+= player.GetModPlayer<GlobalPlayer>().slimyDamageFlat;
damage += player.GetModPlayer<GlobalPlayer>().slimyDamagePercent;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.Gel, 20);
recipe.AddIngredient(ModContent.ItemType<FracturedSlimeBow>());
recipe.AddTile(TileID.Solidifier);
recipe.Register();
}
}
}
And here's the code for the projectile:
C#:
using Terraria;
using Terraria.ModLoader;
using Terraria.GameContent.Creative;
using Terraria.ID;
using ESP.Projectiles.Weapons;
namespace ESP.Projectiles.Weapons
{
internal class SlimyArrow : ModProjectile
{
public int baseDamage = 4;
public override void SetStaticDefaults()
{
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
DisplayName.SetDefault("Slimy Arrow");
}
public override void SetDefaults()
{
Projectile.DamageType = DamageClass.Ranged;
Projectile.width = 14;
Projectile.height = 32;
Projectile.aiStyle = 0;
Projectile.friendly = true;
Projectile.hostile = false;
Projectile.penetrate = 2;
Projectile.timeLeft = 600;
Projectile.light = 0f;
Projectile.ignoreWater = false;
Projectile.tileCollide = true;
}
}
}
I've tried overriding Shoot() like this:
C#:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
}
but it says "type or namespace 'Vector2' could not be found."
I've also tried overriding it like this:
C#:
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
}
and it says "type or namespace 'EntitySource_ItemUse_WithAmmo' could not be found."
What is it that I'm doing wrong?
Edit:
After searching around more, I realized what the issue was. I forgot this line of code in the code for the bow:
C#:
using Microsoft.Xna.Framework;
Last edited: