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); }
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 void Teleport() { var dusts = ArchaeaNPC.DustSpread(npc.Center, 1, 1, dustType, 10, 3f); foreach (Dust d in dusts) { d.noGravity = true; } }
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 width = 1, int height = 1, 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, width, height, dustType, speed.X, speed.Y, 0, default(Color), 2f); } 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, 1, 1, dustType, 10, 3f); foreach (Dust d in dusts) { d.noGravity = true; } return(true); }
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, findClosest); if (player != null && npc.Distance(player.position) < range) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
public Player target() { Player player = ArchaeaNPC.FindClosest(npc); if (player != null) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
public override bool PreFadeOut() { Vector2 v = ArchaeaNPC.FindEmptyRegion(target(), targetRange); if (v != Vector2.Zero) { move = v; return(true); } else { return(false); } }
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 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 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 bool PreAI() { if (timer++ > interval) { timer = 0; } if (npc.velocity.Y == 0f && !npc.wet && Collision.SolidCollision(npc.position, npc.width, npc.height + 8)) { npc.velocity = Vector2.Zero; } target = ArchaeaNPC.FindClosest(npc, true); if (target == null) { DefaultActions(); return(false); } inRange = ArchaeaNPC.WithinRange(target.position, ArchaeaNPC.defaultBounds(npc)); switch (pattern) { case Pattern.JustSpawned: if (JustSpawned()) { goto case Pattern.Idle; } return(false); case Pattern.Idle: pattern = Pattern.Idle; if (inRange) { goto case Pattern.Active; } DefaultActions(150, flip); return(true); case Pattern.Active: if (inRange) { if (Hurt()) { goto case Pattern.Attack; } } else if (timer % interval / 4 == 0) { counter++; } if (counter > maxAggro) { counter = 0; goto case Pattern.Idle; } Active(); return(true); case Pattern.Attack: Attack(); return(true); default: return(false); } }
protected void AttackPattern() { if (preAttack) { move = Vector2.Zero; attacks = 0; attack = -1; preAttack = false; reData = true; } 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; } }
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++; } }
protected void AttackPattern() { if (preAttack) { move = Vector2.Zero; attacks = 0; attack = -1; time = 0; preAttack = false; reData = true; } if (attack != FadeOut) { npc.velocity = Vector2.Zero; } switch (attack) { case -1: goto case Teleport; case Attack: if (BeginAttack() && time++ % attackRate == 0 && time != 0) { attacks++; if (attacks > totalAttacks) { pattern = Pattern.Active; reData = true; preAttack = true; break; } goto case Teleport; } break; case Teleport: attack = Teleport; if (PreFadeOut()) { goto case FadeOut; } break; case FadeOut: attack = FadeOut; move = ArchaeaNPC.FindEmptyRegion(target(), targetRange); if (npc.alpha < 200) { npc.alpha += 5; } else if (BeginTeleport()) { if (npc.Distance(target().position) < 800f) { if (move != Vector2.Zero) { npc.position = move; } } goto case FadeIn; } break; case FadeIn: attack = FadeIn; if (npc.alpha > 0) { npc.alpha -= 5; } else { goto case Attack; } break; } }
protected void Active() { if (reData) { oldX = npc.position.X; upperPoint = npc.position.Y - 50f; idle = npc.position; upper = new Vector2(oldX, upperPoint); type = -1; points = new Vector2[5]; reData = false; } switch (type) { case -1: BeginInRange(); if (BeginActive()) { type = 0; index = 0; goto case 0; } break; case 0: Vector2 ground = ArchaeaNPC.FindEmptyRegion(target(), targetRange); if (index < points.Length) { if (ground != Vector2.Zero) { points[index] = ground; index++; } } else { index = 0; goto case 1; } break; case 1: type = 1; if (index++ > moveRate) { rand = Main.rand.Next(points.Length); index = 0; moveCount++; count++; } newMove = points[rand]; ArchaeaNPC.PositionToVel(npc, newMove, 0.6f, 0.4f, true, -5f, 5f); if (npc.Distance(target().position) > range * 2f || moveCount > 2) { moveCount = 0; type = 0; goto case 0; } break; } }
public override bool PreAI() { if (timer++ > elapse) { timer = 0; } switch (pattern) { case Pattern.JustSpawned: if (JustSpawned()) { goto case Pattern.FadeIn; } break; case Pattern.FadeIn: pattern = Pattern.FadeIn; if (npc.alpha > 0) { npc.alpha -= 5; break; } else { goto case Pattern.Idle; } case Pattern.FadeOut: pattern = Pattern.FadeOut; if (npc.alpha < 255) { npc.alpha += 5; break; } goto case Pattern.Teleport; case Pattern.Teleport: pattern = Pattern.Teleport; move = ArchaeaNPC.FastMove(npc); if (move != Vector2.Zero) { npc.position = move; Teleport(); hasAttacked = false; goto case Pattern.FadeIn; } break; case Pattern.Idle: pattern = Pattern.Idle; if (timer % elapse == 0 && Main.rand.Next(3) == 0) { if (!hasAttacked) { hasAttacked = true; goto case Pattern.Attack; } else { goto case Pattern.FadeOut; } } return(false); case Pattern.Attack: pattern = Pattern.Attack; if (PreAttack()) { Attack(); attacks++; } if (attacks > maxAttacks) { pattern = Pattern.Idle; attacks = 0; } return(true); } return(false); }