public override void AI() { Player P = Main.player[npc.target]; Cratrosity origin = npc.modNPC as Cratrosity; pmlphasetimer--; npc.dontTakeDamage = false; if (pmlphasetimer > 0) { //phase 1 if (pmlphase == 1) { OrderOfTheCrates(P); origin.compressvargoal = 4f; origin.themode = 1; npc.rotation = Idglib.LookAt(npc.Center, P.Center); npc.dontTakeDamage = true; npc.velocity = (npc.velocity * 0.97f); if (pmlphasetimer < 1000) { Vector2 it = new Vector2(P.Center.X - npc.Center.X, P.Center.Y - npc.Center.Y); it.Normalize(); if (pmlphasetimer % 120 == 0) { npc.velocity = (it * (30f - pmlphasetimer * 0.02f)); } if (pmlphasetimer % 120 < 60 && pmlphasetimer % 20 == 0) { Idglib.Shattershots(npc.Center, npc.Center + it * 50, new Vector2(0, 0), ProjectileID.NanoBullet, 40, (float)6, 80, 3, true, 0, false, 600); Idglib.PlaySound(13, npc.Center, 0); } } } //phase 2 if (pmlphase == 2) { npc.dontTakeDamage = true; OrderOfTheCrates(P); npc.velocity = (npc.velocity * 0.77f); Vector2 it = new Vector2(P.Center.X - npc.Center.X, P.Center.Y - npc.Center.Y); it.Normalize(); npc.velocity += it * 0.3f; npc.Opacity += (0.1f - npc.Opacity) / 30f; } //phase 3 if (pmlphase == 3) { npc.ai[0] = 0; if (pmlphasetimer > 1000) { int spawnedint = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CratrosityNight")); spawnedint = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CratrosityLight")); pmlphasetimer = 105; Idglib.Chat("Give in to Temptation!", 144, 79, 16); } if (NPC.CountNPCS(mod.NPCType("Cratrosity")) > 0) { pmlphasetimer = 100; } npc.dontTakeDamage = true; base.OrderOfTheCrates(P); npc.velocity = (npc.velocity * 0.77f); Vector2 it = new Vector2(P.Center.X - npc.Center.X, P.Center.Y - npc.Center.Y); it.Normalize(); npc.velocity += it * 0.3f; npc.Opacity += (0.1f - npc.Opacity) / 30f; } //phase 4 if (pmlphase > 3) { npc.velocity /= 1.5f; if (pmlphasetimer > 1000) { pmlphasetimer = 100; } } } else { npc.rotation = npc.rotation * 0.85f; npc.Opacity += (1f - npc.Opacity) / 30f; base.AI(); } if (phase < 1) { int val; val = (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.WoodenCrate.ToString()))) + (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.IronCrate.ToString()))) + (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.GoldenCrate.ToString()))) + (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.DungeonFishingCrate.ToString()))) + (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.JungleFishingCrate.ToString()))) + (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + evilcratetype.ToString()))) + (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.HallowedFishingCrate.ToString()))) + (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.FloatingIslandFishingCrate.ToString()))); val += NPC.CountNPCS(mod.NPCType("CratrosityCrateOfWitheredWeapon")) + NPC.CountNPCS(mod.NPCType("CratrosityCrateOfWitheredArmor")) + NPC.CountNPCS(mod.NPCType("CratrosityCrateOfPoisoned")) + NPC.CountNPCS(mod.NPCType("CratrosityCrateOfSlowing")); if (val > 0) { npc.dontTakeDamage = true; } } }