示例#1
0
 public override void NPCLoot(NPC npc)
 {
     if (npc.lifeMax > 5 && npc.value > 0f)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleItem"));
     }
     if (((npc.type == NPCID.Pumpking && Main.pumpkinMoon) || (npc.type == NPCID.IceQueen && Main.snowMoon)) && NPC.waveCount > 10)
     {
         int chance = NPC.waveCount - 10;
         if (Main.expertMode)
         {
             chance++;
         }
         if (Main.rand.Next(5) < chance)
         {
             int stack = 1;
             if (NPC.waveCount >= 15)
             {
                 stack = Main.rand.Next(4, 7);
                 if (Main.expertMode)
                 {
                     stack++;
                 }
             }
             else if (Main.rand.Next(2) == 0)
             {
                 stack++;
             }
             string type = npc.type == NPCID.Pumpking ? "ScytheBlade" : "Icicle";
             Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType(type), stack);
         }
     }
     if (npc.type == NPCID.DukeFishron && !Main.expertMode)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Bubble"), Main.rand.Next(5, 8));
     }
     if (npc.type == NPCID.Bunny && npc.AnyInteractions())
     {
         Vector2 pos = npc.Center;
         int i = (int)pos.X / 16;
         int j = (int)pos.Y / 16;
         Tile tile = Main.tile[i, j];
         if (tile.active() && tile.type == mod.TileType("ElementalPurge") && !NPC.AnyNPCs(mod.NPCType("PuritySpirit")))
         {
             i -= Main.tile[i, j].frameX % 18;
             j -= Main.tile[i, j].frameY % 18;
             i = (i * 16) + 16;
             j = (j * 16) - 8 + 60;
             bool flag = false;
             for (int k = 0; k < 255; k++)
             {
                 Player player = Main.player[k];
                 if (player.active && player.position.X > i - NPC.sWidth / 2 && player.position.X + player.width < i + NPC.sWidth / 2 && player.position.Y > j - NPC.sHeight / 2 && player.position.Y < j + NPC.sHeight / 2)
                 {
                     flag = true;
                     break;
                 }
             }
             if (flag)
             {
                 NPC.NewNPC(i, j, mod.NPCType("PuritySpirit"));
             }
         }
     }
 }
 public override void NPCLoot(NPC npc)
 {
     if (npc.lifeMax > 5 && npc.value > 0f)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleItem"));
         if (Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer<ExamplePlayer>(mod).ZoneExample)
         {
             Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BossItem"));
         }
     }
     if (((npc.type == NPCID.Pumpking && Main.pumpkinMoon) || (npc.type == NPCID.IceQueen && Main.snowMoon)) && NPC.waveNumber > 10)
     {
         int chance = NPC.waveNumber - 10;
         if (Main.expertMode)
         {
             chance++;
         }
         if (Main.rand.Next(5) < chance)
         {
             int stack = 1;
             if (NPC.waveNumber >= 15)
             {
                 stack = Main.rand.Next(4, 7);
                 if (Main.expertMode)
                 {
                     stack++;
                 }
             }
             else if (Main.rand.Next(2) == 0)
             {
                 stack++;
             }
             string type = npc.type == NPCID.Pumpking ? "ScytheBlade" : "Icicle";
             Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType(type), stack);
         }
     }
     if (npc.type == NPCID.DukeFishron && !Main.expertMode)
     {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Bubble"), Main.rand.Next(5, 8));
     }
     if (npc.type == NPCID.Bunny && npc.AnyInteractions())
     {
         int left = (int)(npc.position.X / 16f);
         int top = (int)(npc.position.Y / 16f);
         int right = (int)((npc.position.X + npc.width) / 16f);
         int bottom = (int)((npc.position.Y + npc.height) / 16f);
         bool flag = false;
         for (int i = left; i <= right; i++)
         {
             for (int j = top; j <= bottom; j++)
             {
                 Tile tile = Main.tile[i, j];
                 if (tile.active() && tile.type == mod.TileType("ElementalPurge") && !NPC.AnyNPCs(mod.NPCType("PuritySpirit")))
                 {
                     i -= Main.tile[i, j].frameX / 18;
                     j -= Main.tile[i, j].frameY / 18;
                     i = (i * 16) + 16;
                     j = (j * 16) + 24 + 60;
                     for (int k = 0; k < 255; k++)
                     {
                         Player player = Main.player[k];
                         if (player.active && player.position.X > i - NPC.sWidth / 2 && player.position.X + player.width < i + NPC.sWidth / 2 && player.position.Y > j - NPC.sHeight / 2 && player.position.Y < j + NPC.sHeight / 2)
                         {
                             flag = true;
                             break;
                         }
                     }
                     if (flag)
                     {
                         NPC.NewNPC(i, j, mod.NPCType("PuritySpirit"));
                         break;
                     }
                 }
             }
             if (flag)
             {
                 break;
             }
         }
     }
 }