private bool SinglePlayerAI() { if (timer++ > elapse) { timer = 0; } ArchaeaNPC.SlowDown(ref npc.velocity); switch (pattern) { case PatternID.JustSpawned: npc.target = ArchaeaNPC.FindClosest(npc, true).whoAmI; if (JustSpawned()) { goto case PatternID.FadeIn; } break; case PatternID.FadeIn: pattern = PatternID.FadeIn; if (npc.alpha > 0) { npc.alpha -= 5; break; } else { goto case PatternID.Idle; } case PatternID.FadeOut: pattern = PatternID.FadeOut; if (npc.alpha < 255) { npc.immortal = true; npc.alpha += 5; break; } goto case PatternID.Teleport; case PatternID.Teleport: pattern = PatternID.Teleport; move = ArchaeaNPC.FindAny(npc, npcTarget); if (move != Vector2.Zero) { SyncNPC(move.X, move.Y); Teleport(); hasAttacked = false; goto case PatternID.FadeIn; } break; case PatternID.Idle: pattern = PatternID.Idle; npc.immortal = false; if (timer % elapse == 0 && Main.rand.Next(3) == 0) { if (!hasAttacked) { hasAttacked = true; goto case PatternID.Attack; } else { goto case PatternID.FadeOut; } } return(false); case PatternID.Attack: pattern = PatternID.Attack; if (PreAttack()) { if (attacks > 0) { Attack(); } attacks++; } if (attacks > maxAttacks) { pattern = PatternID.Idle; attacks = 0; } return(true); } if (oldPattern != pattern) { SyncNPC(npc.position.X, npc.position.Y); } oldPattern = pattern; return(false); }
public override void AI() { int attackTime = 180 + 90 * maxAttacks; if (timer++ > 60 + attackTime) { timer = 0; } ArchaeaNPC.SlowDown(ref npc.velocity, 0.1f); if (!init) { npc.target = ArchaeaNPC.FindClosest(npc, true).whoAmI; SyncNPC(npc.position.X, npc.position.Y); dustType = 6; var dusts = ArchaeaNPC.DustSpread(npc.Center, 1, 1, dustType, 10); foreach (Dust d in dusts) { d.noGravity = true; } init = true; } if (!fade) { if (npc.alpha > 0) { npc.alpha -= 255 / 60; } } else { if (npc.alpha < 255) { npc.alpha += 255 / 50; } else { timer = attackTime + 50; move = ArchaeaNPC.FindAny(npc, npcTarget, true); if (move != Vector2.Zero) { SyncNPC(move.X, move.Y); var dusts = ArchaeaNPC.DustSpread(npc.Center - new Vector2(npc.width / 4, npc.height / 4), npc.width / 2, npc.height / 2, dustType, 10, 2.4f); foreach (Dust d in dusts) { d.noGravity = true; } fade = false; timer = 0; } } } if (timer > 180 && timer <= attackTime) { OrbGrow(); if (timer >= 180 + 60 && timer % 90 == 0) { Attack(); } } if (timer >= attackTime) { fade = true; } else { fade = false; } }
public override void AI() { time++; if (!init) { int i = (int)npc.position.X / 16; int j = (int)npc.position.Y / 16; if (ArchaeaWorld.Inbounds(i, j) && Main.tile[i, j].wall != ArchaeaWorld.skyBrickWall) { newPosition = ArchaeaNPC.FindAny(npc, ArchaeaNPC.FindClosest(npc, true), true, 800); if (newPosition != Vector2.Zero) { npc.netUpdate = true; init = true; } } } if (newPosition != Vector2.Zero && ai == Idle) { npc.position = newPosition; } if (time > 150) { if (npc.alpha > 12) { npc.alpha -= 12; } else { npc.alpha = 0; } } if (npc.target == 255) { if (npc.life < npc.lifeMax) { npc.TargetClosest(); } return; } if (time > 300) { time = 0; ai = Attack; } if (time == 240) { tracking = npcTarget.Center; } if (ai == Attack) { npc.velocity += ArchaeaNPC.AngleToSpeed(npc.AngleTo(tracking), rushSpeed); ai = Activated; npc.netUpdate = true; } else { ArchaeaNPC.SlowDown(ref npc.velocity, 0.2f); if (time % 45 == 0 && time != 0) { npc.velocity = Vector2.Zero; } } if (npc.velocity.X >= npc.oldVelocity.X || npc.velocity.X < npc.oldVelocity.X || npc.velocity.Y >= npc.oldVelocity.Y || npc.velocity.Y < npc.oldVelocity.Y) { npc.netUpdate = true; } if (npc.Center.X <= npcTarget.Center.X) { float angle = (float)Math.Round(Math.PI * 0.2f, 1); if (npc.rotation > angle) { npc.rotation -= rotateSpeed; } else { npc.rotation += rotateSpeed; } } else { float angle = (float)Math.Round((Math.PI * 0.2f) * -1, 1); if (npc.rotation > angle) { npc.rotation -= rotateSpeed; } else { npc.rotation += rotateSpeed; } } if (ai == Idle && npc.Distance(npcTarget.Center) < 64f) { ArchaeaNPC.DustSpread(npc.position, npc.width, npc.height, DustID.Stone, 5, 1.2f); npc.TargetClosest(); ai = Activated; npc.netUpdate = true; } }