public bool Absorb(float range, Action action) { variance += Main.rand.NextFloat(0.5f, 3f); if (time % elapsed * 5 * rotate == 0) { center = ArchaeaNPC.AngleBased(npc.Center, rotation + variance, range); dust[total] = Dust.NewDustDirect(center, 1, 1, DustID.Fire, 0f, 0f, 0, color, scale); dust[total].noGravity = true; total++; } foreach (Dust d in Main.dust) { if (d != null) { if (Vector2.Distance(d.position - npc.position, Vector2.Zero) < range + 32) { d.velocity = ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(d.position, npc.Center), 3f); Target.VelClamp(ref d.velocity, -3f, 3f, out d.velocity); } } } action.Invoke(); if (range < npc.width || total > elapsed * 12) { Reset(); return(true); } return(false); }
public override bool PreAI() { if (!begin) { Initialize(); SpawnParts(); begin = true; } direction = follow.X > npc.Center.X; rotate = WrapAngle(ref rotate); ArchaeaNPC.RotateIncrement(true, ref rotate, 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.velocity = ArchaeaNPC.AngleToSpeed(npc.rotation, leadSpeed / acc); 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(); } } PostMovement(); return(true); }
public static void TileExplode(int i, int j) { int x = i * 16 + 8; int y = j * 16 + 8; float range = 3f * 16; Vector2 center = new Vector2(x, y); Player[] proximity = Main.player.Where(t => t.Distance(center) < range).ToArray(); for (float k = 0; k < Math.PI * 2f; k++) { for (int l = 0; l < range; l++) { Vector2 velocity = ArchaeaNPC.AngleToSpeed(k, 3f); int rand = Main.rand.Next(20); if (rand == 0) { Dust.NewDustDirect(ArchaeaNPC.AngleBased(center, k, range), 1, 1, DustID.Smoke, velocity.X, velocity.Y, 0, default(Color), 2f); } if (rand == 10) { Dust.NewDustDirect(ArchaeaNPC.AngleBased(center, k, l), 4, 4, DustID.Fire, 0f, 0f, 0, default(Color), 2f); } } } foreach (Player player in proximity) { player.Hurt(PlayerDeathReason.ByCustomReason(player.name + " struck dead in a mining accident"), 10, player.position.X / 16 < i ? -1 : 1); if (Main.netMode == 2) { NetMessage.SendData(MessageID.PlayerHurtV2, player.whoAmI, -1, null); } } }
public static void BeingAttacked() { foreach (Player target in Sky_boss.targets) { if (time++ % elapsed * 2 == 0 && time != 0) { if (target != null) { if (npc.Distance(target.Center) < range) { switch (type) { case Melee: target.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 10, 0); break; case Range: target.velocity += ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(target.Center, npc.Center), 0.5f); VelClamp(ref target.velocity, -2f, 2f, out target.velocity); break; case Magic: if (target.statMana > 5) { target.statMana -= 5; target.manaRegenDelay = 30; } break; } } } } } }
public void Update(NPC npc, Player target) { proj.timeLeft = 100; if (npc.Distance(target.Center) < 800) { focus = target.Center; } else { focus = npc.Center; } ArchaeaNPC.RotateIncrement(proj.Center.X > focus.X, ref proj.rotation, ArchaeaNPC.AngleTo(focus, proj.Center), 0.5f, out proj.rotation); proj.velocity += ArchaeaNPC.AngleToSpeed(npc.rotation, 0.4f); VelClamp(ref proj.velocity, -10f, 10f, out proj.velocity); }
private bool FlameBurst() { float angle = ArchaeaNPC.RandAngle(); for (int i = 0; i < flames.Length; i++) { flames[i] = Projectile.NewProjectileDirect(npc.Center, ArchaeaNPC.AngleToSpeed(angle), mod.ProjectileType <Flame>(), 20, 3f, 255, 1f, npc.target); angle += (float)Math.PI / 3f; if (Main.netMode == 2) { NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, flames[i].whoAmI); } } return(true); }
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 override bool BeginAttack() { foreach (Projectile proj in projs) { if (proj != null) { ArchaeaNPC.RotateIncrement(target().Center.X > npc.Center.X, ref proj.rotation, ArchaeaNPC.AngleTo(proj.Center, target().Center), 1f, out proj.rotation); proj.velocity += ArchaeaNPC.AngleToSpeed(proj.rotation, 0.30f); proj.timeLeft = 60; if (proj.Colliding(proj.Hitbox, target().Hitbox)) { proj.active = 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.30f; } else { acc += 0.01f; } Clamp(acc, 0.3f, 1f, out acc); npc.Center += ArchaeaNPC.AngleToSpeed(npc.rotation, speed * acc); } }
public void Update(NPC npc, Player target) { proj.timeLeft = 100; if (npc.Distance(target.Center) < 800) { focus = target.Center; } else { focus = npc.Center; } ArchaeaNPC.RotateIncrement(proj.Center.X > focus.X, ref proj.rotation, ArchaeaNPC.AngleTo(focus, proj.Center), 0.5f, out proj.rotation); proj.velocity += ArchaeaNPC.AngleToSpeed(npc.rotation, 0.4f); VelClamp(ref proj.velocity, -5f, 5f, out proj.velocity); if (proj.velocity.X < 0f && proj.oldVelocity.X >= 0f || proj.velocity.X > 0f && proj.oldVelocity.X <= 0f || proj.velocity.Y < 0f && proj.oldVelocity.Y >= 0f || proj.velocity.Y > 0f && proj.oldVelocity.Y <= 0f) { proj.netUpdate = true; } }
private void ProjectileDirection() { foreach (Projectile proj in projs) { if (proj != null) { ArchaeaNPC.RotateIncrement(target().Center.X > npc.Center.X, ref proj.rotation, ArchaeaNPC.AngleTo(proj.Center, target().Center), 1f, out proj.rotation); proj.velocity += ArchaeaNPC.AngleToSpeed(proj.rotation, 0.10f); proj.timeLeft = 60; if (proj.Colliding(proj.Hitbox, target().Hitbox)) { proj.active = false; } if (proj.velocity.X < 0f && proj.oldVelocity.X >= 0f || proj.velocity.X > 0f && proj.oldVelocity.X <= 0f || proj.velocity.Y < 0f && proj.oldVelocity.Y >= 0f || proj.velocity.Y > 0f && proj.oldVelocity.Y <= 0f) { proj.netUpdate = true; } } } }
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 static void BeingAttacked() { foreach (Player target in Main.player.Where(t => t.Distance(npc.Center) < range)) { if (time++ % elapsed * 2 == 0 && time != 0) { if (target != null) { if (npc.Distance(target.Center) < range) { switch (type) { case Melee: target.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 10, 0); NetMessage.SendData(MessageID.HurtPlayer, -1, -1, null, target.whoAmI); break; case Range: target.velocity += ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(target.Center, npc.Center), 0.5f); VelClamp(ref target.velocity, -2f, 2f, out target.velocity); break; case Magic: if (target.statMana > 5) { target.statMana -= 5; target.manaRegenDelay = 180; NetMessage.SendData(MessageID.PlayerMana, -1, -1, null, target.whoAmI, target.statMana); } break; } } } } } }
public override bool PreFadeOut() { index = 0; for (double r = 0d; r < Math.PI * 2d; r += Math.PI / 3d) { if (index < max) { projs[index] = Projectile.NewProjectileDirect(npc.Center, ArchaeaNPC.AngleToSpeed((float)r, 2f), ProjectileID.Fireball, 20, 4f); projs[index].timeLeft = 900; projs[index].rotation = (float)r; projs[index].tileCollide = false; index++; } } return(true); }