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 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 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); }
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.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); } }
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); }
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 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); }