tModLoader How to make an item drop from enemies in the ice biome?

AxerTheAxe

Skeletron Prime
Hi, I have looked on the forums and have not been able to find any forum that solves my problem. Thanks!
 
C#:
public class ModGlobalNPC : GlobalNPC
        {
            public override void NPCLoot(NPC npc)
            {
                    if (Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneOverworldHeight && Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneSnow)
                    {
                          Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ITEMNAMEHERE"), Main.rand.Next(1, 4));
                    }                  
            }
        }
This here will make any enemy in the surface snow biome drop the item.
The "Main.rand.Next(1, 4)" is how many will drop, if you only want 1 to drop at a time you do not need this.
 
C#:
public class ModGlobalNPC : GlobalNPC
        {
            public override void NPCLoot(NPC npc)
            {
                    if (Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneOverworldHeight && Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].ZoneSnow)
                    {
                          Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ITEMNAMEHERE"), Main.rand.Next(1, 4));
                    }                
            }
        }
This here will make any enemy in the surface snow biome drop the item.
The "Main.rand.Next(1, 4)" is how many will drop, if you only want 1 to drop at a time you do not need this.


Thanks! Also how do I change the drop chance? Thanks
 
Last edited:
C#:
 if (Main.rand.Next(2) == 0)
 {
    
 }
Surround the drop line with this, and the number is the drop chance, so here it's a 1 in 2 (50%), putting it as 4 is a 1 in 4 drop (25%) ect...
 
Back
Top Bottom