private void MaintainProximity(float range) { if (!findNewTarget && !attack && npc.Distance(target().Center) > range) { move = ArchaeaNPC.FindAny(npc, target(), false, 200); SyncNPC(move.X, move.Y); } }
public void WormAI() { if (!PreWormAI()) { return; } if (timer++ > maxTime) { timer = 0; } if (timer % 300 == 0) { SyncNPC(true); } npc.rotation = npc.velocity.ToRotation(); npc.noGravity = chaseThroughAir; if (attack && PreAttack()) { Attacking(); if (npc.Hitbox.Intersects(target().Hitbox) || target().dead || !target().active) { attack = false; } chase = target().Center; if (timer % 30 == 0) { SyncNPC(chase.X, chase.Y); } } else { if (timer % 120 == 0) { chase = ArchaeaNPC.FindAny(npc, 400); SyncNPC(chase.X, chase.Y); } } if (npc.Hitbox.Intersects(target().Hitbox)) { chase = ArchaeaNPC.FindAny(npc, 400); SyncNPC(chase.X, chase.Y); attack = false; } if (StartDigging()) { Digging(); float acceleration = attack ? this.acceleration : 0.1f; float angle = npc.AngleTo(chase); float cos = (float)(acceleration * Math.Cos(angle)); float sine = (float)(acceleration * Math.Sin(angle)); npc.velocity += new Vector2(cos, sine); ArchaeaNPC.VelocityClamp(ref npc.velocity, speedClamp * -1, speedClamp); } if (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(); } }
private bool MPAI() { if (timer++ > elapse) { timer = 0; if (pattern < Attacking) { pattern++; } } if (!init) { init = JustSpawned(); } if (pattern == Attacking) { if (attacks < maxAttacks) { if (timer % elapse == 0 && timer != 0) { attacks++; Attack(); } } else { if (npc.alpha < 255) { npc.alpha += 5; } else { move = ArchaeaNPC.FindAny(npc, Main.player[npc.target], true, 300); if (move != Vector2.Zero) { pattern++; Teleport(); SyncNPC(move.X, move.Y); } } } return(true); } if (npc.alpha > 0) { npc.alpha -= 5; } else { pattern = 0; } return(false); }
public override void AI() { if (!init) { pathing = 1; 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, target(), true, 800); if (newPosition != Vector2.Zero) { npc.netUpdate = true; if (Main.netMode == 0) { npc.position = newPosition; } } else { return; } } init = true; } if (!ArchaeaWorld.Inbounds((int)npc.position.X / 16, (int)npc.position.Y / 16)) { return; } if (npc.alpha > 0) { npc.alpha -= 5; } if (timer++ > 600) { timer = 0; redirectTimer = 0; } if (timer % 300 == 0 && timer != 0) { Attack(); } if (timer % 180 == 0) { if (FacingWall()) { npc.velocity.Y -= 5f; } else { npc.velocity.Y -= 3f; } SyncNPC(); } if (canSee()) { if (OnGround()) { npc.velocity.X -= direction ? 0.25f * -1 : 0.25f; } else { npc.velocity.X -= direction ? 8f * -1 : 8f; } } else { npc.velocity.X += pathing * 1f; if (FacingWall() && redirectTimer++ % 180 == 0) { pathing *= -1; } } if (BottomLeftTile() && !TopLeftTile() && npc.velocity.X < 0f) { npc.position.X -= 2f; npc.position.Y -= 8f; } if (BottomRightTile() && !TopRightTile() && npc.velocity.X > 0f) { npc.position.X += 2f; npc.position.Y -= 8f; } ArchaeaNPC.VelClampX(npc, -3f, 3f); if (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(); } }
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; } }
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 bool PreAI() { if (time++ > frameCount * frameTime) { time = 0; } if (!chosenTexture) { int rand = Main.rand.Next(4); switch (rand) { case 0: break; case 1: Main.npcTexture[npc.type] = mod.GetTexture("Gores/Sky_1_1"); npc.defense = 30; npc.netUpdate = true; break; case 2: Main.npcTexture[npc.type] = mod.GetTexture("Gores/Sky_1_2"); npc.defense = 20; npc.netUpdate = true; break; case 3: Main.npcTexture[npc.type] = mod.GetTexture("Gores/Sky_1_3"); npc.defense = 25; npc.netUpdate = true; break; } chosenTexture = true; } 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, target(), true, 800); if (newPosition != Vector2.Zero) { npc.netUpdate = true; if (Main.netMode == 0) { npc.position = newPosition; } } else { return(false); } } oldX = npc.position.X; upperPoint = npc.position.Y - 50f; idle = npc.position; upper = new Vector2(oldX, upperPoint); init = true; } return(PreSkyAI() && BeginActive()); }
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; } }
internal void SkyAI() { if (timer++ > 900) { SyncNPC(true); timer = 0; } if (timer % 300 == 0 && timer != 0) { fade = true; } findNewTarget = target() == null || !target().active || target().dead; if (!findNewTarget) { MaintainProximity(300f); } if (fade) { if (npc.alpha < 255 && PreFadeOut()) { npc.alpha += 255 / 60; } else if (timer % 90 == 0) { if (!findNewTarget) { npc.position = ArchaeaNPC.FindAny(npc, target(), false, 300); SyncNPC(); } fade = false; } } else { if (npc.alpha > 0) { npc.alpha -= 255 / 60; } } if (!fade && npc.alpha == 0) { if (timer % 150 == 0) { if (!findNewTarget) { if (!attack) { move = ArchaeaNPC.FindAny(npc, target(), false, 300); SyncNPC(move.X, move.Y); } else if (PreAttack()) { move = target().Center; SyncNPC(move.X, move.Y); } } } if (move != Vector2.Zero && (npc.position.X > move.X || npc.position.X < move.X || npc.position.Y > move.Y || npc.position.Y < move.Y)) { float angle = npc.AngleTo(move); float cos = (float)(0.25f * Math.Cos(angle)); float sine = (float)(0.25f * Math.Sin(angle)); npc.velocity += new Vector2(cos, sine); ArchaeaNPC.VelocityClamp(ref npc.velocity, -3f, 3f); if (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(); } } } }