Custom gun has 0 ammo even though I have ammo

profanedsauced

Terrarian
412.PNG
411 - 0AMMO.PNG

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace CustomMod.Items
{
    public class SpaceShark : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("S.S.M.G"); // 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("It came from the vast void of space.");
        }

        public override void SetDefaults()
        {
            item.damage = 175;  //gun damage
            item.ranged = true;   //its a gun so set this to true
            item.width = 38;     //gun image width
            item.height = 18;   //gun image  height
            item.useTime = 15;  //how fast
            item.useAnimation = 16;
            item.useStyle = 5;    //
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 2;
            item.UseSound = SoundID.Item38;
            item.autoReuse = true;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 11f;
            item.useAmmo = ProjectileID.Bullet;
            item.ammo = AmmoID.Bullet;
        }

        public override void AddRecipes()  //How to craft this gun
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Megashark, 1);   //you need 1 DirtBlock
            recipe.AddIngredient(ItemID.SDMG, 1);   //you need 1 DirtBlock
            recipe.AddTile(TileID.WorkBenches);   //at work bench
            recipe.SetResult(this);
            recipe.AddRecipe();

        }
    }
 
Change item.useAmmo = ProjectileID.Bullet; to item.useAmmo = AmmoID.Bullet;
Remove item.ammo = AmmoID.Bullet;

I think you're telling the game your gun is a bullet.
 
Back
Top Bottom