public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { if (rangeOut) { if (npc.alpha < 250) { npc.alpha += 25; } else { move = ArchaeaNPC.FindEmptyRegion(target(), targetRange); if (move != Vector2.Zero) { type = 0; index = 0; if (pattern != Pattern.Attack) { count++; } npc.position = move; rangeOut = false; } } } return(npc.alpha < 250); }
public override bool ActiveMovement() { if (timer % 300 == 0) { ai++; } switch (ai) { case 0: if (canSee() && OnGround()) { npc.velocity.X -= direction ? 0.25f * -1 : 0.25f; } if (timer > 90) { ArchaeaNPC.VelClampX(npc, -3f, 3f); } break; case 1: ai = 0; return(true); } return(false); }
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(); } }
public override void Attack() { int a = Projectile.NewProjectile(npc.Center, ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(npc, npcTarget) + compensate, 4f), ProjectileID.Fireball, 10, 1f); Main.projectile[a].timeLeft = 300; Main.projectile[a].hostile = true; Main.projectile[a].friendly = false; Main.projectile[a].tileCollide = false; }
public override void Teleport() { var dusts = ArchaeaNPC.DustSpread(npc.Center, dustType, 10, 3f); foreach (Dust d in dusts) { d.noGravity = true; } }
public static Dust[] DustSpread(Vector2 v, int dustType = 6, int total = 10, float scale = 1f) { Dust[] dusts = new Dust[total]; for (int k = 0; k < total; k++) { Vector2 speed = ArchaeaNPC.AngleToSpeed(ArchaeaNPC.RandAngle(), 8f); dusts[k] = Dust.NewDustDirect(v + speed, 1, 1, dustType, speed.X, speed.Y, 0, default(Color), 2f); } return(dusts); }
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 static Dust[] DustSpread(Vector2 v, int width = 1, int height = 1, int dustType = 6, int total = 10, float scale = 1f, Color color = default(Color), bool noGravity = false, float spreadSpeed = 8f) { Dust[] dusts = new Dust[total]; for (int k = 0; k < total; k++) { Vector2 speed = ArchaeaNPC.AngleToSpeed(ArchaeaNPC.RandAngle(), spreadSpeed); dusts[k] = Dust.NewDustDirect(v + speed, width, height, dustType, speed.X, speed.Y, 0, color, scale); dusts[k].noGravity = noGravity; } return(dusts); }
public override bool PreDefaultMove() { move = ArchaeaNPC.FindEmptyRegion(target(), targetRange); if (move != Vector2.Zero) { return(true); } else { return(false); } }
public override bool JustSpawned() { elapse = 120; dustType = 6; var dusts = ArchaeaNPC.DustSpread(npc.Center, dustType, 10, 3f); foreach (Dust d in dusts) { d.noGravity = true; } return(true); }
public Player target() { Player player = ArchaeaNPC.FindClosest(npc); if (player != null) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
public Player target() { Player player = ArchaeaNPC.FindClosest(npc, true); if (player != null && npc.Distance(player.position) < range) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
public virtual Player nearbyPlayer() { Player player = ArchaeaNPC.FindClosest(npc, false); if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } else { return(npcTarget); } }
public Player target() { Player player = ArchaeaNPC.FindClosest(npc, false, 1000); if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } else { return(Main.player[Main.myPlayer]); } }
public override bool PreFadeOut() { Vector2 v = ArchaeaNPC.FindEmptyRegion(target(), targetRange); if (v != Vector2.Zero) { move = v; return(true); } else { return(false); } }
internal Player target() { Player player = ArchaeaNPC.FindClosest(npc, maxRange, 2048); if (player != null) { maxRange = false; return(player); } else { return(Main.player[npc.target]); } }
public override void AI() { if (timer > interval) { timer = 0; } foreach (Projectile a in bombs) { if (a != null && a.active) { if (a.Hitbox.Intersects(target().Hitbox)) { a.timeLeft = 1; } } } if (pattern != Pattern.Attack) { if (npc.alpha > 0) { npc.alpha--; } } npc.direction = direction ? 1 : -1; if (target().Distance(npc.position) < range && canSee()) { if (npc.velocity.Y == 0f && (timer % 150 == 0 || ArchaeaNPC.OnHurt(npc.life, oldLife, out oldLife))) { velX = npc.velocity.X; npc.velocity.Y -= randY; } } if (!OnGround()) { npc.velocity.X = velX; } if (!canSee() || !target().active || target().dead) { if (FacingWall()) { isBlind = !isBlind; } if (OnGround()) { npc.velocity.X -= isBlind ? -0.2f : 0.2f; } ArchaeaNPC.VelClampX(npc, -2f, 2f); } }
public Player target() { Player player = ArchaeaNPC.FindClosest(npc, firstTarget); firstTarget = false; if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
public bool canSee() { Vector2 line; for (float k = 0; k < npc.Distance(target().position); k += 0.5f) { line = npc.Center + ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(npc, target()), k); int i = (int)line.X / 16; int j = (int)line.Y / 16; Tile tile = Main.tile[i, j]; if (tile.active() && Main.tileSolid[tile.type]) { return(false); } } return(true); }
protected bool DefaultAI() { reData = true; switch (ai) { case 0: ai = 0; if (PreDefaultMove()) { type = 0; index = 0; goto case 1; } return(false); case 1: ai = 1; move = ArchaeaNPC.FindEmptyRegion(target(), targetRange); if (npc.alpha < 225) { npc.alpha += 25; } else { if (move != Vector2.Zero) { npc.position = move; } goto case 2; } return(true); case 2: ai = 2; if (npc.alpha > 0) { npc.alpha -= 25; } else { goto case 0; } return(true); } return(false); }
protected bool DefaultAI() { reData = true; switch (ai) { case 0: ai = 0; move = Vector2.Zero; if (target() != null && target().Distance(npc.position) < range * 3f) { move = ArchaeaNPC.FastMove(target()); } if (move != Vector2.Zero) { goto case 1; } return(false); case 1: ai = 1; if (npc.alpha < 250) { npc.alpha += 25; } else { npc.position = move; goto case 2; } return(true); case 2: ai = 2; if (npc.alpha > 0) { npc.alpha -= 25; } else { goto case 0; } return(true); } return(false); }
public static void DiggerPartsAI(NPC npc, NPC part, float speed, ref float acc) { Vector2 connect = ArchaeaNPC.AngleBased(new Vector2(part.position.X, part.position.Y + part.height / 2), part.rotation, part.width); npc.rotation = ArchaeaNPC.AngleTo(npc.Center, part.Center); if (Vector2.Distance(part.Center, npc.Center) > npc.width * 1.2f) { if (!npc.Hitbox.Contains(connect.ToPoint())) { acc = 0.60f; } else { acc += 0.01f; } Clamp(acc, 0.6f, 1f, out acc); npc.Center += ArchaeaNPC.AngleToSpeed(npc.rotation, speed * acc); } }
protected bool Initialize() { if (!begin) { body = new int[8]; body[0] = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, bodyType, 0, npc.whoAmI); for (int k = 1; k < body.Length - 1; k++) { body[k] = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, bodyType, 0, body[k - 1], npc.whoAmI); } body[7] = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, tailType, 0, body[6], npc.whoAmI); npc.ai[0] = Main.npc[body[7]].whoAmI; for (int l = 0; l < body.Length; l++) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, body[l]); } follow = FindAny(bounds); rotateTo = ArchaeaNPC.AngleTo(npc.Center, npc.Center + follow); begin = true; } return(begin); }
public override bool PreAI() { Initialize(); direction = follow.X > npc.Center.X; ArchaeaNPC.RotateIncrement(direction, ref npc.rotation, rotateTo, turnSpeed, out npc.rotation); if (PreMovement() && Vector2.Distance(follow, npc.Center) > npc.width * 1.2f) { if (acc > 0.90f) { if (!npc.Hitbox.Contains(follow.ToPoint())) { acc -= 0.01f; } else { acc += 0.025f; } } npc.Center = npc.Center + ArchaeaNPC.AngleToSpeed(npc.rotation, leadSpeed / acc); } PostMovement(); return(true); }
public override bool PreAI() { target = ArchaeaNPC.FindClosest(npc, false); if (target != null && (!target.active || target.dead)) { targeted = false; } if (target == null) { return(false); } if (Main.mouseRight && npc.Hitbox.Contains(Main.MouseWorld.ToPoint()) && ArchaeaNPC.WithinRange(target.position, new Rectangle(npc.Hitbox.X - 300, npc.Hitbox.Y - 200, 600, 400))) { targeted = true; } npc.immortal = !targeted; npc.target = target.whoAmI; if (!targeted) { return(false); } return(true); }
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(); } }
private void Attack() { projIndex = 0; for (int k = -3; k <= 3; k += 2) { proj[projIndex] = Projectile.NewProjectileDirect(npc.Center, ArchaeaNPC.AngleToSpeed(ArchaeaNPC.RandAngle(), 4f), ProjectileID.ShadowFlame, 15, 5f); proj[projIndex].tileCollide = false; proj[projIndex].timeLeft = 180; proj[projIndex].hostile = true; proj[projIndex].friendly = false; if (Main.netMode == 2) { NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj[projIndex].whoAmI); } projIndex++; } }
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 void Attack() { int proj = Projectile.NewProjectile(npc.Center + new Vector2(npc.width * 0.35f * npc.direction, -4f), ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(npc, npcTarget) + compensate, 4f), ProjectileID.Fireball, 10, 1f); Main.projectile[proj].timeLeft = 300; Main.projectile[proj].friendly = false; Main.projectile[proj].tileCollide = false; scale = 0.2f; }