Example #1
0
 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);
 }
Example #2
0
        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;
                        }
                    }
                }
            }
        }
Example #3
0
        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);
        }
Example #4
0
 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;
     }
 }
Example #5
0
 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;
                 }
             }
         }
     }
 }
Example #6
0
        public override void AI()
        {
            npc.spriteDirection = 1;
            if (timer++ > 900)
            {
                npcCounter++;
                timer = 0;
            }
            if (timer % 600 == 0 && timer != 0)
            {
                move = Vector2.Zero;
                do
                {
                    move = ArchaeaNPC.FindEmptyRegion(target(), ArchaeaNPC.defaultBounds(target()));
                } while (move == Vector2.Zero);
                SyncNPC(move.X, move.Y);
                fade = true;
            }
            if (timer % 300 == 0 && timer != 0)
            {
                if (timer != 600)
                {
                    move = target().Center;
                    SyncNPC(true, true);
                }
            }
            if (npcCounter > 1)
            {
                Vector2 newPosition = ArchaeaNPC.FindAny(npc, target(), false, 300);
                int     n           = NPC.NewNPC((int)newPosition.X, (int)newPosition.Y, mod.NPCType <Sky_1>(), 0, 0f, 0f, 0f, 0f, npc.target);
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, n);
                }
                npcCounter = 0;
                SyncNPC();
            }
            if (fade)
            {
                npc.velocity = Vector2.Zero;
                if (npc.alpha < 255)
                {
                    npc.scale -= 1f / 90f;
                    npc.alpha += 255 / 15;
                }
                else
                {
                    npc.position = move;
                    if (FlameBurst())
                    {
                        npc.scale = 1f;
                        fade      = false;
                    }
                }
            }
            else
            {
                if (npc.alpha > 0)
                {
                    npc.alpha -= 255 / 60;
                }
                if (timer < 600)
                {
                    if (timer % 150 == 0)
                    {
                        move = ArchaeaNPC.FindAny(npc, target(), false);
                    }
                    float angle = npc.AngleTo(move);
                    float cos   = (float)(0.2f * Math.Cos(angle));
                    float sine  = (float)(0.2f * Math.Sin(angle));
                    npc.velocity += new Vector2(cos, sine);
                    ArchaeaNPC.VelocityClamp(ref npc.velocity, -4f, 4f);
                }
            }
            if (attack)
            {
                if (counter++ % 90 == 0)
                {
                    angle += (float)Math.PI / 3f;
                    float cos  = (float)(npc.Center.X + npc.width * 3f * Math.Cos(angle));
                    float sine = (float)(npc.Center.Y + npc.height * 3f * Math.Sin(angle));
                    int   t    = Projectile.NewProjectile(new Vector2(cos, sine), Vector2.Zero, mod.ProjectileType <Orb>(), 12, 2f, 255, 0f, target().whoAmI);
                    Main.projectile[t].whoAmI = t;
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, t);
                    }
                    index++;
                }
                if (index == 6)
                {
                    attack = false;
                }
            }
            else
            {
                index = 0;
                angle = ArchaeaNPC.RandAngle();
                SyncNPC(false, false);
            }

            if (fade && npc.position != npc.oldPosition || 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();
            }
        }
Example #7
0
        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;
            }
        }