Help with enemy Drops!!

Noah167

Terrarian
So I made a custom item that I want a slime to drop but I cannot for the life of me get it to drop!! What am I doing wrong?
 

Attachments

  • Capture.PNG
    Capture.PNG
    16 KB · Views: 40
you can try this, There's also just a decent chance you can't do it on green slime since I believe it is just a variant so has a negative npc ID which may break it, so I think if you do blue slime instead it should work for both slimes, perhaps there is a better way but I do not know one.
C#:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.GameContent.ItemDropRules;


public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
        {
                if (npc.type == NPCID.GreenSlime)
                {
                    npcLoot.Add(ItemDropRule.Common(Mod.Find<ModItem>("NAMEOFITEM").Type, 1)); // if you want to have a drop chance make it .Type, 2)); this one is 1 out of 2 chance you can change it to what you want
                }
         }
 
I did that, but as soon as I changed the drop to the blue slime, this error showed.
 

Attachments

  • Screenshot (6).png
    Screenshot (6).png
    953.1 KB · Views: 26
I did that, but as soon as I changed the drop to the blue slime, this error showed.
That's strange, did you delete your namespace by chance? Because with the code I sent with it being blue slime worked for me yesterday
 
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.GameContent.ItemDropRules;
namespace beyondtheshadows.Items.Materials
{
public class BossBagLoot : GlobalNPC
{
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
{
if (npc.type == NPCID.BlueSlime)
{
npcLoot.Add(ItemDropRule.Common(ModItem>("Rusted Plate").Type, 1));
}
}
}
}
 
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
namespace beyondtheshadows.Items.Materials
{
public class BossBagLoot : GlobalNPC
{
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
{
if (npc.type == NPCID.BlueSlime)
{
npcLoot.Add(ItemDropRule.Common(Mod.Find<Items.MachineMaterials.PlatePiece>("Rusted Plate").Type, 1));
}
}
}
}
The problem is that you should have it formatted like this npcLoot.Add(ItemDropRule.Common(Mod.Find<ModItem>("RustedPlate").Type, 1)); You just set what ever is inside of the parenthesis and quotes to the file name and will find it without needing items.material.etc
 
btw this is my code for my item

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace beyondtheshadows.Items.MachineMaterials
{
public class PlatePiece : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("RustedPlate");
Tooltip.SetDefault("I wonder what this does?");
}
public override void SetDefaults()
{
Item.width = 20;
Item.height = 20;
Item.maxStack = 999;
Item.rare = ItemRarityID.Orange;
}
}
}
 
btw this is my code for my item

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace beyondtheshadows.Items.MachineMaterials
{
public class PlatePiece : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("RustedPlate");
Tooltip.SetDefault("I wonder what this does?");
}
public override void SetDefaults()
{
Item.width = 20;
Item.height = 20;
Item.maxStack = 999;
Item.rare = ItemRarityID.Orange;
}
}
}
You don't make it the display name you make it the file name "PlatePiece"
 
Any chance you know how to make it dropfrom a boss bag?
I'm not sure if this still works but you can try
C#:
public override void OpenVanillaBag(string context, Player player, int arg)
        {
            if (context == "bossBag" && arg == ItemID.EaterOfWorldsBossBag)
            {
                player.QuickSpawnItem(ItemType<PUTITEMNAMEHERE>(), Main.rand.Next(1, 1));
            }
        }
 
Hi, this should help, add this to your BossBagLoot class
Code:
using beyondtheshadows.Items.Materials

and change your code like this (type is an other thing, netID is the NPCID that you can match with)

Code:
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
        {
            if(npc.netID == NPCID.GreenSlime || npc.netID == NPCID.BlueSlime)
            {
                npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<PlatePiece>(), 2, 2, 5));
            }
        }
 
Back
Top Bottom