public override void PostMovement() { if (npc.Distance(target().position) > range / 2) { ai = ChasePlayer; } if (projs == null || projCenter == null || attack == null) { return; } attack.Update(npc, target()); for (int j = 0; j < projs[1].Length; j++) { for (int i = 0; i < max; i++) { projs[i][j].Stationary(j, npc.width); if (time % interval == 0 && time != 0) { Vector2 v = ArchaeaNPC.FindEmptyRegion(target(), ArchaeaNPC.defaultBounds(target())); if (v != Vector2.Zero) { projs[i][j].position = v; } } } } }
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 StartDigging() { attack = new Attack(Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ProjectileID.Fireball, 20, 4f)); attack.proj.tileCollide = false; attack.proj.ignoreWater = true; projCenter = new Vector2[max]; projs = new Attack[max][]; for (int i = 0; i < projs.GetLength(0); i++) { projs[i] = new Attack[6]; index = 0; for (double r = 0d; r < Math.PI * 2d; r += Math.PI / 3d) { if (index < 6) { projs[i][index] = new Attack(Projectile.NewProjectileDirect(ArchaeaNPC.AngleBased(npc.Center, (float)r, npc.width * 4f), Vector2.Zero, ProjectileID.Fireball, 20, 4f), (float)r); projs[i][index].proj.timeLeft = 600; projs[i][index].proj.rotation = (float)r; projs[i][index].proj.tileCollide = false; projs[i][index].proj.ignoreWater = true; Vector2 v = Vector2.Zero; do { v = ArchaeaNPC.FindEmptyRegion(target(), ArchaeaNPC.defaultBounds(target())); projs[i][index].position = v; } while (v == Vector2.Zero); index++; } } } start = false; index = 0; return(true); }
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { if (rangeOut) { if (npc.alpha < 250) { npc.alpha += 25; } else { move = ArchaeaNPC.FindAny(npc, target(), false); if (move != Vector2.Zero) { type = 0; index = 0; if (pattern != Pattern.Attack) { count++; } npc.position = move; rangeOut = false; } } } return(npc.alpha < 250); }
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 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 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; } } } } } }
protected void SpawnParts() { if (Main.netMode != 1) { body = new int[totalParts]; 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[totalParts - 1] = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, tailType, 0, body[totalParts - 2], npc.whoAmI); npc.ai[0] = Main.npc[body[totalParts - 1]].whoAmI; if (Main.netMode == 2) { for (int l = 0; l < body.Length; l++) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, body[l]); } } NextDirection(FindAny(bounds)); rotateTo = ArchaeaNPC.AngleTo(npc.Center, npc.Center + follow); rotate = npc.rotation; npc.netUpdate = true; } }
public override void Kill(bool effect) { if (effect && active) { ArchaeaNPC.DustSpread(Center, 2, 2, ModLoader.GetMod("ArchaeaMod").DustType <Merged.Dusts.magno_dust>(), 8, 1.2f, Color.White, false, 2f); } active = false; }
public override bool JustSpawned() { proximity = false; if (timer % elapsed / 24 == 0 && timer != 0) { flip = !flip; } if (ai < SpawnParts) { npc.velocity.Y = flip ? 0.5f : -0.5f; } else { npc.velocity.Y = 0f; } switch (ai) { case Begin: move = ArchaeaNPC.FindEmptyRegion(target(), ArchaeaNPC.defaultBounds(target())); if (move != Vector2.Zero) { npc.position = move; npc.alpha = 250; goto case FadeIn; } break; case FadeIn: ai = FadeIn; if (npc.alpha > 0) { npc.alpha -= 5; } else { goto case 0; } break; case SpawnParts: ai = SpawnParts; if (timer % elapsed / 4 == 0 && timer != 0) { f += (float)Math.PI * 2f / 4f; Vector2 around = ArchaeaNPC.AngleBased(npc.Center, f, npc.width * 8f); NPC.ReleaseNPC((int)around.X, (int)around.Y, ModNPCID.MonolithOrb, 0, 255); } if (f == (float)Math.PI * 2f) { goto case End; } break; case End: return(true); } return(false); }
private Player target() { Player player = ArchaeaNPC.FindClosest(npc, true); if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } return(Main.player[npc.target]); }
public Player target() { Player player = ArchaeaNPC.FindClosest(npc, findClosest); if (player != null && npc.Distance(player.position) < range) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
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 Player target() { Player player = ArchaeaNPC.FindClosest(npc, firstTarget, 400); firstTarget = false; if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
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); }
public override void Attacking() { if (timer % maxTime == 0 && timer != 0) { if (projs != null) { for (int j = 0; j < projs.GetLength(0); j++) { foreach (Attack sets in projs[j]) { sets.proj.active = false; } } } attack = new Attack(Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ProjectileID.Fireball, 20, 4f)); attack.proj.tileCollide = false; attack.proj.ignoreWater = true; max = Math.Max(8 / npc.life, 3); projCenter = new Vector2[max]; projs = new Attack[max][]; for (int i = 0; i < projs.GetLength(0); i++) { projs[i] = new Attack[6]; index = 0; for (double r = 0d; r < Math.PI * 2d; r += Math.PI / 3d) { if (index < 6) { projs[i][index] = new Attack(Projectile.NewProjectileDirect(ArchaeaNPC.AngleBased(npc.Center, (float)r, npc.width * 4f), Vector2.Zero, ProjectileID.Fireball, 20, 4f), (float)r); projs[i][index].proj.timeLeft = maxTime; projs[i][index].proj.rotation = (float)r; projs[i][index].proj.tileCollide = false; projs[i][index].proj.ignoreWater = true; Vector2 v = Vector2.Zero; do { v = ArchaeaNPC.FindEmptyRegion(target(), ArchaeaNPC.defaultBounds(target())); projs[i][index].position = v; } while (v == Vector2.Zero); index++; } } } start = false; index = 0; } }
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 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.FindAny(npc, target(), false); 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.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; } }
public override void Update() { netUpdate = true; Player player = Main.player[owner]; rotation = ArchaeaNPC.AngleTo(player.Center, Center); orbit += radian * Math.Min(player.statLifeMax / Math.Max(player.statLife, 1) + 2f, 6f); if (orbit > Math.PI * 2f) { orbit = 0f; } float cos = player.Center.X + (float)(radius * Math.Cos(start + orbit)); float sine = player.Center.Y + (float)(radius * Math.Sin(start + orbit)); Center = new Vector2(cos, sine); if (!player.active || Items.ArchaeaItem.NotEquipped(player, ModLoader.GetMod("ArchaeaMod").GetItem <Items.m_shield>().item)) { Kill(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 override void Digging() { if (projs == null || projCenter == null || attack == null) { return; } attack.Update(npc, target()); for (int j = 0; j < projs[1].Length; j++) { for (int i = 0; i < max; i++) { projs[i][j].Stationary(j, npc.width); if (timer % maxTime / 2 == 0 && timer != 0) { Vector2 v = ArchaeaNPC.FindEmptyRegion(target(), ArchaeaNPC.defaultBounds(target())); if (v != Vector2.Zero) { projs[i][j].position = v; } } } } }
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; } } } } } }
protected void NextDirection(Vector2 chase) { follow = chase + npc.position; SyncNPC(follow.X, follow.Y); rotateTo = ArchaeaNPC.AngleTo(npc.Center, follow); }
public void Stationary(int j, int radius) { rotation += 0.017f; proj.timeLeft = 100; proj.Center = ArchaeaNPC.AngleBased(position, (float)Math.PI / 3f * j, radius * 4f * (float)Math.Cos(rotation)); }
protected void AttackPattern() { if (preAttack) { move = Vector2.Zero; attacks = 0; attack = -1; preAttack = false; reData = true; } if (attack != FadeOut) { npc.velocity = Vector2.Zero; } AttackMovement(); switch (attack) { case -1: goto case Teleport; case Attack_: if (index++ % attackRate == 0 && index != 0) { Attack(); attacks++; if (attacks > totalAttacks) { pattern = Pattern.Active; preAttack = true; break; } goto case Teleport; } break; case Teleport: attack = Teleport; if (BeginTeleport()) { Vector2 v = ArchaeaNPC.FastMove(target()); if (v != Vector2.Zero) { move = v; goto case FadeOut; } } break; case FadeOut: attack = FadeOut; if (npc.alpha < 200) { npc.alpha += 5; } else { if (npc.Distance(target().position) < 800f) { npc.position = move; } goto case FadeIn; } break; case FadeIn: attack = FadeIn; if (npc.alpha > 0) { npc.alpha -= 5; } else { goto case Attack_; } break; } }