public override bool PreAI(NPC npc) { NPC mouth = FargoSoulsUtil.NPCExists(npc.realLife, NPCID.WallofFlesh); if (FargoSoulsWorld.SwarmActive || RepeatingAI || mouth == null) { return(true); } if (PreventAttacks > 0) { PreventAttacks--; } float maxTime = 540f; if (mouth.GetEModeNPCMod <WallofFlesh>().InDesperationPhase) { if (npc.ai[1] < maxTime - 180) //dont lower this if it's already telegraphing laser { maxTime = 240f; } if (!FargoSoulsWorld.MasochistModeReal) { npc.localAI[1] = -1f; //no more regular lasers npc.localAI[2] = 0f; } } if (++npc.ai[1] >= maxTime) { npc.ai[1] = 0f; if (npc.ai[2] == 0f) { npc.ai[2] = 1f; } else { npc.ai[2] *= -1f; } if (npc.ai[2] > 0) //FIRE LASER { Vector2 speed = Vector2.UnitX.RotatedBy(npc.ai[3]); if (Main.netMode != NetmodeID.MultiplayerClient && PreventAttacks <= 0) { Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <PhantasmalDeathrayWOF>(), npc.damage / 4, 0f, Main.myPlayer, 0, npc.whoAmI); } } else //ring dust to denote i am vulnerable now { if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.type); } } npc.netUpdate = true; NetSync(npc); } if (npc.ai[2] >= 0f) { npc.alpha = 175; npc.dontTakeDamage = true; if (npc.ai[1] <= 90) //still firing laser rn { RepeatingAI = true; npc.AI(); RepeatingAI = false; npc.localAI[1] = -1f; npc.localAI[2] = 0f; npc.rotation = npc.ai[3]; return(false); } else { npc.ai[2] = 1; } } else { npc.alpha = 0; npc.dontTakeDamage = false; if (npc.ai[1] == maxTime - 3 * 5 && Main.netMode != NetmodeID.MultiplayerClient) { if (Main.netMode != NetmodeID.MultiplayerClient && PreventAttacks <= 0) { float ai0 = (npc.realLife != -1 && Main.npc[npc.realLife].velocity.X > 0) ? 1f : 0f; Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <WOFBlast>(), 0, 0f, Main.myPlayer, ai0, npc.whoAmI); } } if (npc.ai[1] > maxTime - 180f) { if (Main.rand.Next(4) < 3) //dust telegraphs switch { int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 88, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 114, default(Color), 3.5f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Main.dust[dust].velocity.Y -= 0.5f; if (Main.rand.NextBool(4)) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } float stopTime = maxTime - 90f; if (npc.ai[1] == stopTime) //shoot warning dust in phase 2 { int t = npc.HasPlayerTarget ? npc.target : npc.FindClosestPlayer(); if (t != -1) { if (npc.Distance(Main.player[t].Center) < 3000) { Main.PlaySound(SoundID.Roar, (int)Main.player[t].position.X, (int)Main.player[t].position.Y, 0); } npc.ai[2] = -2f; npc.ai[3] = (npc.Center - Main.player[t].Center).ToRotation(); if (npc.realLife != -1 && Main.npc[npc.realLife].velocity.X > 0) { npc.ai[3] += (float)Math.PI; } Vector2 speed = Vector2.UnitX.RotatedBy(npc.ai[3]); if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <PhantasmalDeathrayWOFS>(), 0, 0f, Main.myPlayer, 0, npc.whoAmI); } } npc.netUpdate = true; NetSync(npc); } else if (npc.ai[1] > stopTime) { HasTelegraphedNormalLasers = false; RepeatingAI = true; npc.AI(); RepeatingAI = false; npc.localAI[1] = -1f; npc.localAI[2] = 0f; npc.rotation = npc.ai[3]; return(false); } } } //dont fire during mouth's special attacks (this is at bottom to override others) if (((mouth.GetEModeNPCMod <WallofFlesh>().InPhase2&& mouth.GetEModeNPCMod <WallofFlesh>().WorldEvilAttackCycleTimer < 240) || mouth.GetEModeNPCMod <WallofFlesh>().InDesperationPhase) && !FargoSoulsWorld.MasochistModeReal) { npc.localAI[1] = -90f; npc.localAI[2] = 0f; HasTelegraphedNormalLasers = false; } if (npc.localAI[2] > 1) //has shot at least one laser { HasTelegraphedNormalLasers = false; } else if (npc.localAI[1] >= 0f && !HasTelegraphedNormalLasers && npc.HasValidTarget) //telegraph for imminent laser { HasTelegraphedNormalLasers = true; if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, npc.whoAmI, -22); } } //if (NPC.FindFirstNPC(npc.type) == npc.whoAmI) FargoSoulsUtil.PrintAI(npc); return(true); }