• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

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

Storm Diver

Skeletron Prime
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.
 

AxerTheAxe

Terrarian
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:

Storm Diver

Skeletron Prime
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...
 
Top Bottom