• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

I think I got the code correct for the custom item to be dropped, but isn't correct, Help?

ShinkaPlant

Terrarian
I'm using TmodLoader 11.5

An error ocurred while building ShinkasUltimateMod
Compiling ShinkasUltimateMod.XNAdll failed with 2 errors and C:\Users\micha\Documents\My Games\ Terraria\ModLoader\Mod Sources\ShinkasUltimateMod\Items\PieceOfRedBloon.cs(18.25) : error CS0103: The name 'Item' does not exist in the current context warnings.

NPC (RedBloon.cs)

C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ShinkasUltimateMod.NPCs
{
    
    public class RedBloon : ModNPC
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Red Bloon");
            Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Zombie];
        }

        public override void SetDefaults()
        {
            npc.width = 14;
            npc.height = 24;
            npc.damage = 10;
            npc.defense = 10;
            npc.lifeMax = 100;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath2;
            npc.value = 10f;
            npc.knockBackResist = 0.25f;
            npc.aiStyle = 44;
            aiType = NPCID.Zombie;
            animationType = NPCID.Zombie;
            banner = Item.NPCtoBanner(NPCID.Zombie);
            bannerItem = Item.BannerToItem(banner);
        }

        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            return SpawnCondition.OverworldDaySlime.Chance * 10f;
        }

        public override void HitEffect(int hitDirection, double damage)
        {
            for (int i = 0; i < 10; i++)
            {
                int dustType = mod.DustType("TMMCDust");
                int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
                Dust dust = Main.dust[dustIndex];
                dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
                dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
                dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
            }
        }

        public override void NPCLoot()
        {
            Item.NewItem(npc.position, mod.ItemType("TMMCMountItem"));
            if(Main.rand.Next(2) == 0)
            {
                Item.NewItem(npc.position, ItemID.PieceOfRedBloon, 3);
            }
        }
    }
}
Item (PieceOfRedBloon.cs)

C#:
using Terraria.ID;
using Terraria.ModLoader;

namespace ShinkasUltimateMod.Items
{
    public class PieceOfRedBloon : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Piece of Red Bloon");
            Tooltip.SetDefault("Just a shredded piece of Red Bloon.");
        }

        public override void SetDefaults()
        {
            item.width = 20;
            item.height = 21;
            item.maxStack = 999;
            item.value = Item.buyPrice(0, 0, 5, 0);
            item.rare = 1;
            item.useStyle = 1;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useTurn = false;
            item.autoReuse = false;
        }
    }
}
 

Attachments

Top Bottom