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 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); }
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 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); }
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); } }
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); }
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 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; }
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; } }
public override void Attack() { projIndex = 0; for (int k = -3; k <= 3; k += 2) { bombs[projIndex] = Projectile.NewProjectileDirect(npc.Center, ArchaeaNPC.AngleToSpeed(ArchaeaNPC.RandAngle(), 4f), ProjectileID.BouncyGrenade, 15, 5f); bombs[projIndex].timeLeft = 180; bombs[projIndex].hostile = true; bombs[projIndex].friendly = false; projIndex++; } }