Terraria Wiki

  • Discussions are now available on the Terraria Wiki.
  • Miss the old Hydra Skin? Try out our Hydralize gadget! Visit the preferences page while logged in and turn on the gadget.

READ MORE

Terraria Wiki

Worm math[]

The spawn chances from grass come from the code. This is it (I think), in case anyone else wants to have a look. I commented (//) below. It's possible I'm misinterpreting it so if anyone else sees something different feel free to chime in.

   public static void KillTile(int i, int j, bool fail = false, bool effectOnly = false, bool noItem = false)
   ... // lots of other stuff comes first, then ...
   if ((double)j < Main.worldSurface){  // above surface
   	if (tile.type == 3 || tile.type == 60){ // short plants/grass
   		num39 = 400; // used below in rand() to generate chances of worm, this means 1/400 chance
   		num40 = 100; // used below in rand() to generate chances of grasshopper, this means 1/100 chance
   	}
   	if (tile.type == 73 || tile.type == 74){  // tall plants/grass
   		num39 = 200; // worm 1/200 chance
   		num40 = 50;  // grasshopper 1/50 chance
   	}
   } else {        // below surface
   	if (tile.type == 3 || tile.type == 60){ //short grass/plants
   		num39 = 600; // worm 1/600 chance (no grasshopper chance below surface)
   	}
   	if (tile.type == 73 || tile.type == 74){ //tall grass/plants
   		num39 = 300; // worm 1/300 chance (no grasshopper chance below surface)
   	}
   }
   if (tile.type == 185) { // dirt piles, all cases are 1/6 worm chance
   	if (tile.frameY == 0 && tile.frameX < 214){
   		num39 = 6;
   	}
   	if (tile.frameY == 18 && (tile.frameX < 214 || tile.frameX >= 1368)){
   		num39 = 6;
   	}
   }
   else if (tile.type == 186){
   	if (tile.frameX >= 378 && tile.frameX <= 700){
   		num39 = 6;
   	}
   }
   else if (tile.type == 187){
   	if (tile.frameX >= 756 && tile.frameX <= 916){
   		num39 = 6;
   	}
   	if (tile.frameX <= 322){
   		num39 = 6;
   	}
   }
   
          // if less than 5 worms (NPC type 357) roll the dice for worm spawn using number from above
   if (NPC.CountNPCS(357) < 5 && num39 > 0 && Main.rand.Next(num39) == 0){ 
   	int num41 = NPC.NewNPC(i * 16 + 10, j * 16, 357, 0);
   	Main.npc[num41].TargetClosest(true);
   	Main.npc[num41].velocity.Y = (float)Main.rand.Next(-50, -21) * 0.1f;
   	Main.npc[num41].velocity.X = (float)Main.rand.Next(0, 26) * 0.1f * (float)(-(float)Main.npc[num41].direction);
   	Main.npc[num41].direction *= -1;
   	Main.npc[num41].netUpdate = true;
   }
   
          // if less than 5 grasshoppers (NPC type 377) roll the dice for grasshopper spawn using number from above
   if (NPC.CountNPCS(377) < 5 && num40 > 0 && Main.rand.Next(num40) == 0){ 
   	int num42 = NPC.NewNPC(i * 16 + 10, j * 16, 377, 0);
   	Main.npc[num42].TargetClosest(true);
   	Main.npc[num42].velocity.Y = (float)Main.rand.Next(-50, -21) * 0.1f;
   	Main.npc[num42].velocity.X = (float)Main.rand.Next(0, 26) * 0.1f * (float)(-(float)Main.npc[num42].direction);
   	Main.npc[num42].direction *= -1;
   	Main.npc[num42].netUpdate = true;
   }

worm discussion[]

I have noticed that when I use certain items near a campfire, a worm spawns (I'm on the PS Vita/console version with all updates installed). I first noticed it when I accidentally dropped two heart lanterns into a campfire and two worms spawned. It also consistently works when I use the Magic Mirror next to a campfire. It does not work for many other items though.

Anyone know the logic governing this?