public override void AI() { if (projectile.alpha > 0) { projectile.alpha -= 255 / 60; } else { projectile.alpha = 0; } float maxSpeed = Math.Max(((boss.lifeMax + 1 - boss.life) / boss.lifeMax) * 5f, 2f); float angle; if (timer++ > 90) { if (target.active && !target.dead) { angle = projectile.AngleTo(target.Center); } else { angle = projectile.AngleFrom(target.Center); } projectile.velocity += ArchaeaNPC.AngleToSpeed(angle, 0.5f); ArchaeaNPC.VelocityClamp(ref projectile.velocity, maxSpeed * -1, maxSpeed); } projectile.rotation = projectile.velocity.ToRotation(); if (Main.netMode == 2 && (projectile.velocity.X < 0f && projectile.oldVelocity.X >= 0f || projectile.velocity.X > 0f && projectile.oldVelocity.X <= 0f || projectile.velocity.Y < 0f && projectile.oldVelocity.Y >= 0f || projectile.velocity.Y > 0f && projectile.oldVelocity.Y <= 0f)) { projectile.netUpdate = true; } if (projectile.scale == 1f) { for (int k = 0; k < 4; k++) { int t = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 0, default(Color), 2f); Main.dust[t].noGravity = true; } } }
public override void AI() { npc.spriteDirection = 1; if (timer++ > 900) { npcCounter++; timer = 0; } if (timer % 600 == 0 && timer != 0) { move = Vector2.Zero; do { move = ArchaeaNPC.FindEmptyRegion(target(), ArchaeaNPC.defaultBounds(target())); } while (move == Vector2.Zero); SyncNPC(move.X, move.Y); fade = true; } if (timer % 300 == 0 && timer != 0) { if (timer != 600) { move = target().Center; SyncNPC(true, true); } } if (npcCounter > 1) { Vector2 newPosition = ArchaeaNPC.FindAny(npc, target(), false, 300); int n = NPC.NewNPC((int)newPosition.X, (int)newPosition.Y, mod.NPCType <Sky_1>(), 0, 0f, 0f, 0f, 0f, npc.target); if (Main.netMode == 2) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, n); } npcCounter = 0; SyncNPC(); } if (fade) { npc.velocity = Vector2.Zero; if (npc.alpha < 255) { npc.scale -= 1f / 90f; npc.alpha += 255 / 15; } else { npc.position = move; if (FlameBurst()) { npc.scale = 1f; fade = false; } } } else { if (npc.alpha > 0) { npc.alpha -= 255 / 60; } if (timer < 600) { if (timer % 150 == 0) { move = ArchaeaNPC.FindAny(npc, target(), false); } float angle = npc.AngleTo(move); float cos = (float)(0.2f * Math.Cos(angle)); float sine = (float)(0.2f * Math.Sin(angle)); npc.velocity += new Vector2(cos, sine); ArchaeaNPC.VelocityClamp(ref npc.velocity, -4f, 4f); } } if (attack) { if (counter++ % 90 == 0) { angle += (float)Math.PI / 3f; float cos = (float)(npc.Center.X + npc.width * 3f * Math.Cos(angle)); float sine = (float)(npc.Center.Y + npc.height * 3f * Math.Sin(angle)); int t = Projectile.NewProjectile(new Vector2(cos, sine), Vector2.Zero, mod.ProjectileType <Orb>(), 12, 2f, 255, 0f, target().whoAmI); Main.projectile[t].whoAmI = t; if (Main.netMode == 2) { NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, t); } index++; } if (index == 6) { attack = false; } } else { index = 0; angle = ArchaeaNPC.RandAngle(); SyncNPC(false, false); } if (fade && npc.position != npc.oldPosition || npc.velocity.X < 0f && npc.oldVelocity.X >= 0f || npc.velocity.X > 0f && npc.oldVelocity.X <= 0f || npc.velocity.Y < 0f && npc.oldVelocity.Y >= 0f || npc.velocity.Y > 0f && npc.oldVelocity.Y <= 0f) { SyncNPC(); } }