// Summary:
        //       Get the array of Active NPCs
        public NPC[] getActiveNPCs()
        {
            NPC[] npcs = null;

            int npcCount = 0;
            for (int i = 0; i < Main.npc.Length-1; i++)
            {
                if (Main.npc[i].active)
                {
                    npcCount++;
                }
            }

            if (npcCount > 0)
            {
                npcs = new NPC[npcCount];
                npcCount = 0;
                for (int i = 0; i < Main.npc.Length-1; i++)
                {
                    if (Main.npc[i].active)
                    {
                        npcs[npcCount] = Main.npc[i];
                        npcCount++;
                    }
                }
            }

            return npcs;
        }
예제 #2
0
 // 12
 private void AISkeletronHand(NPC npc, bool flag)
 {
     npc.spriteDirection = -(int)npc.ai[0];
     if (!Main.npcs[(int)npc.ai[1]].Active || Main.npcs[(int)npc.ai[1]].aiStyle != 11)
     {
         npc.ai[2] += 10f;
         if (npc.ai[2] > 50f)
         {
             npc.life = -1;
             npc.HitEffect(0, 10.0);
             npc.Active = false;
         }
     }
     if (npc.ai[2] == 0f || npc.ai[2] == 3f)
     {
         if (Main.npcs[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10)
         {
             npc.timeLeft = 10;
         }
         if (Main.npcs[(int)npc.ai[1]].ai[1] != 0f)
         {
             if (npc.Position.Y > Main.npcs[(int)npc.ai[1]].Position.Y - 100f)
             {
                 if (npc.Velocity.Y > 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y - 0.07f;
                 if (npc.Velocity.Y > 6f)
                 {
                     npc.Velocity.Y = 6f;
                 }
             }
             else
             {
                 if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y - 100f)
                 {
                     if (npc.Velocity.Y < 0f)
                     {
                         npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                     }
                     npc.Velocity.Y = npc.Velocity.Y + 0.07f;
                     if (npc.Velocity.Y < -6f)
                     {
                         npc.Velocity.Y = -6f;
                     }
                 }
             }
             if (npc.Position.X + (float)(npc.Width / 2) > Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 120f * npc.ai[0])
             {
                 if (npc.Velocity.X > 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X * 0.96f;
                 }
                 npc.Velocity.X = npc.Velocity.X - 0.1f;
                 if (npc.Velocity.X > 8f)
                 {
                     npc.Velocity.X = 8f;
                 }
             }
             if (npc.Position.X + (float)(npc.Width / 2) < Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 120f * npc.ai[0])
             {
                 if (npc.Velocity.X < 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X * 0.96f;
                 }
                 npc.Velocity.X = npc.Velocity.X + 0.1f;
                 if (npc.Velocity.X < -8f)
                 {
                     npc.Velocity.X = -8f;
                 }
             }
         }
         else
         {
             npc.ai[3] += 1f;
             if (npc.ai[3] >= 300f)
             {
                 npc.ai[2] += 1f;
                 npc.ai[3] = 0f;
                 npc.netUpdate = true;
             }
             if (npc.Position.Y > Main.npcs[(int)npc.ai[1]].Position.Y + 230f)
             {
                 if (npc.Velocity.Y > 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y - 0.04f;
                 if (npc.Velocity.Y > 3f)
                 {
                     npc.Velocity.Y = 3f;
                 }
             }
             else
             {
                 if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y + 230f)
                 {
                     if (npc.Velocity.Y < 0f)
                     {
                         npc.Velocity.Y = npc.Velocity.Y * 0.96f;
                     }
                     npc.Velocity.Y = npc.Velocity.Y + 0.04f;
                     if (npc.Velocity.Y < -3f)
                     {
                         npc.Velocity.Y = -3f;
                     }
                 }
             }
             if (npc.Position.X + (float)(npc.Width / 2) > Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0])
             {
                 if (npc.Velocity.X > 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X * 0.96f;
                 }
                 npc.Velocity.X = npc.Velocity.X - 0.07f;
                 if (npc.Velocity.X > 8f)
                 {
                     npc.Velocity.X = 8f;
                 }
             }
             if (npc.Position.X + (float)(npc.Width / 2) < Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0])
             {
                 if (npc.Velocity.X < 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X * 0.96f;
                 }
                 npc.Velocity.X = npc.Velocity.X + 0.07f;
                 if (npc.Velocity.X < -8f)
                 {
                     npc.Velocity.X = -8f;
                 }
             }
         }
         Vector2 vector15 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
         float num125 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector15.X;
         float num126 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector15.Y;
         Math.Sqrt((double)(num125 * num125 + num126 * num126));
         npc.rotation = (float)Math.Atan2((double)num126, (double)num125) + 1.57f;
         return;
     }
     if (npc.ai[2] == 1f)
     {
         Vector2 vector16 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
         float num127 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector16.X;
         float num128 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector16.Y;
         float num129 = (float)Math.Sqrt((double)(num127 * num127 + num128 * num128));
         npc.rotation = (float)Math.Atan2((double)num128, (double)num127) + 1.57f;
         npc.Velocity.X = npc.Velocity.X * 0.95f;
         npc.Velocity.Y = npc.Velocity.Y - 0.1f;
         if (npc.Velocity.Y < -8f)
         {
             npc.Velocity.Y = -8f;
         }
         if (npc.Position.Y < Main.npcs[(int)npc.ai[1]].Position.Y - 200f)
         {
             npc.TargetClosest(true);
             npc.ai[2] = 2f;
             vector16 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
             num127 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector16.X;
             num128 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector16.Y;
             num129 = (float)Math.Sqrt((double)(num127 * num127 + num128 * num128));
             num129 = 18f / num129;
             npc.Velocity.X = num127 * num129;
             npc.Velocity.Y = num128 * num129;
             npc.netUpdate = true;
             return;
         }
     }
     else
     {
         if (npc.ai[2] == 2f)
         {
             if (npc.Position.Y > Main.players[npc.target].Position.Y || npc.Velocity.Y < 0f)
             {
                 npc.ai[2] = 3f;
                 return;
             }
         }
         else
         {
             if (npc.ai[2] == 4f)
             {
                 Vector2 vector17 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                 float num130 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 200f * npc.ai[0] - vector17.X;
                 float num131 = Main.npcs[(int)npc.ai[1]].Position.Y + 230f - vector17.Y;
                 float num132 = (float)Math.Sqrt((double)(num130 * num130 + num131 * num131));
                 npc.rotation = (float)Math.Atan2((double)num131, (double)num130) + 1.57f;
                 npc.Velocity.Y = npc.Velocity.Y * 0.95f;
                 npc.Velocity.X = npc.Velocity.X + 0.1f * -npc.ai[0];
                 if (npc.Velocity.X < -8f)
                 {
                     npc.Velocity.X = -8f;
                 }
                 if (npc.Velocity.X > 8f)
                 {
                     npc.Velocity.X = 8f;
                 }
                 if (npc.Position.X + (float)(npc.Width / 2) < Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - 500f || npc.Position.X + (float)(npc.Width / 2) > Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) + 500f)
                 {
                     npc.TargetClosest(true);
                     npc.ai[2] = 5f;
                     vector17 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                     num130 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector17.X;
                     num131 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector17.Y;
                     num132 = (float)Math.Sqrt((double)(num130 * num130 + num131 * num131));
                     num132 = 17f / num132;
                     npc.Velocity.X = num130 * num132;
                     npc.Velocity.Y = num131 * num132;
                     npc.netUpdate = true;
                     return;
                 }
             }
             else
             {
                 if (npc.ai[2] == 5f && ((npc.Velocity.X > 0f && npc.Position.X + (float)(npc.Width / 2) > Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2)) || (npc.Velocity.X < 0f && npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2))))
                 {
                     npc.ai[2] = 0f;
                     return;
                 }
             }
         }
     }
 }
예제 #3
0
        // 16
        private void AIFish(NPC npc, bool flag)
        {
            if (npc.direction == 0)
            {
                npc.TargetClosest(true);
            }
            if (npc.wet)
            {
                if (npc.collideX)
                {
                    npc.Velocity.X = npc.Velocity.X * -1f;
                    npc.direction *= -1;
                }
                if (npc.collideY)
                {
                    if (npc.Velocity.Y > 0f)
                    {
                        npc.Velocity.Y = Math.Abs(npc.Velocity.Y) * -1f;
                        npc.directionY = -1;
                        npc.ai[0] = -1f;
                    }
                    else
                    {
                        if (npc.Velocity.Y < 0f)
                        {
                            npc.Velocity.Y = Math.Abs(npc.Velocity.Y);
                            npc.directionY = 1;
                            npc.ai[0] = 1f;
                        }
                    }
                }
                bool flag16 = false;
                if (!npc.friendly)
                {
                    npc.TargetClosest(false);
                    if (Main.players[npc.target].wet && !Main.players[npc.target].dead)
                    {
                        flag16 = true;
                    }
                }
                if (flag16)
                {
                    npc.TargetClosest(true);
                    if (npc.Type == 65)
                    {
                        npc.Velocity.X = npc.Velocity.X + (float)npc.direction * 0.15f;
                        npc.Velocity.Y = npc.Velocity.Y + (float)npc.directionY * 0.15f;
                        if (npc.Velocity.X > 5f)
                        {
                            npc.Velocity.X = 5f;
                        }
                        if (npc.Velocity.X < -5f)
                        {
                            npc.Velocity.X = -5f;
                        }
                        if (npc.Velocity.Y > 3f)
                        {
                            npc.Velocity.Y = 3f;
                        }
                        if (npc.Velocity.Y < -3f)
                        {
                            npc.Velocity.Y = -3f;
                        }
                    }
                    else
                    {
                        npc.Velocity.X = npc.Velocity.X + (float)npc.direction * 0.1f;
                        npc.Velocity.Y = npc.Velocity.Y + (float)npc.directionY * 0.1f;
                        if (npc.Velocity.X > 3f)
                        {
                            npc.Velocity.X = 3f;
                        }
                        if (npc.Velocity.X < -3f)
                        {
                            npc.Velocity.X = -3f;
                        }
                        if (npc.Velocity.Y > 2f)
                        {
                            npc.Velocity.Y = 2f;
                        }
                        if (npc.Velocity.Y < -2f)
                        {
                            npc.Velocity.Y = -2f;
                        }
                    }
                }
                else
                {
                    npc.Velocity.X = npc.Velocity.X + (float)npc.direction * 0.1f;
                    if (npc.Velocity.X < -1f || npc.Velocity.X > 1f)
                    {
                        npc.Velocity.X = npc.Velocity.X * 0.95f;
                    }
                    if (npc.ai[0] == -1f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y - 0.01f;
                        if ((double)npc.Velocity.Y < -0.3)
                        {
                            npc.ai[0] = 1f;
                        }
                    }
                    else
                    {
                        npc.Velocity.Y = npc.Velocity.Y + 0.01f;
                        if ((double)npc.Velocity.Y > 0.3)
                        {
                            npc.ai[0] = -1f;
                        }
                    }
                    int num163 = (int)(npc.Position.X + (float)(npc.Width / 2)) / 16;
                    int num164 = (int)(npc.Position.Y + (float)(npc.Height / 2)) / 16;

                    if (Main.tile.At(num163, num164 - 1).Exists && Main.tile.At(num163, num164 - 1).Liquid > 128)
                    {
                        if (Main.tile.At(num163, num164 + 1).Active)
                        {
                            npc.ai[0] = -1f;
                        }
                        else
                        {
                            if (Main.tile.At(num163, num164 + 2).Active)
                            {
                                npc.ai[0] = -1f;
                            }
                        }
                    }
                    if ((double)npc.Velocity.Y > 0.4 || (double)npc.Velocity.Y < -0.4)
                    {
                        npc.Velocity.Y = npc.Velocity.Y * 0.95f;
                    }
                }
            }
            else
            {
                if (npc.Velocity.Y == 0f)
                {
                    if (npc.Type == 65)
                    {
                        npc.Velocity.X = npc.Velocity.X * 0.94f;
                        if ((double)npc.Velocity.X > -0.2 && (double)npc.Velocity.X < 0.2)
                        {
                            npc.Velocity.X = 0f;
                        }
                    }
                    else
                    {
                        npc.Velocity.Y = (float)Main.rand.Next(-50, -20) * 0.1f;
                        npc.Velocity.X = (float)Main.rand.Next(-20, 20) * 0.1f;
                        npc.netUpdate = true;
                    }
                }
                npc.Velocity.Y = npc.Velocity.Y + 0.3f;
                if (npc.Velocity.Y > 10f)
                {
                    npc.Velocity.Y = 10f;
                }
                npc.ai[0] = 1f;
            }
            npc.rotation = npc.Velocity.Y * (float)npc.direction * 0.1f;
            if ((double)npc.rotation < -0.2)
            {
                npc.rotation = -0.2f;
            }
            if ((double)npc.rotation > 0.2)
            {
                npc.rotation = 0.2f;
                return;
            }
        }
예제 #4
0
        // 4
        private void AIEoC(NPC npc, bool flag)
        {
            if (npc.target < 0 || npc.target == 255 || Main.players[npc.target].dead || !Main.players[npc.target].Active)
            {
                npc.TargetClosest(true);
            }
            bool dead = Main.players[npc.target].dead;
            float num6 = npc.Position.X + (float)(npc.Width / 2) - Main.players[npc.target].Position.X - (float)(Main.players[npc.target].Width / 2);
            float num7 = npc.Position.Y + (float)npc.Height - 59f - Main.players[npc.target].Position.Y - (float)(Main.players[npc.target].Height / 2);
            float num8 = (float)Math.Atan2((double)num7, (double)num6) + 1.57f;
            if (num8 < 0f)
            {
                num8 += 6.283f;
            }
            else
            {
                if ((double)num8 > 6.283)
                {
                    num8 -= 6.283f;
                }
            }
            float num9 = 0f;
            if (npc.ai[0] == 0f && npc.ai[1] == 0f)
            {
                num9 = 0.02f;
            }
            if (npc.ai[0] == 0f && npc.ai[1] == 2f && npc.ai[2] > 40f)
            {
                num9 = 0.05f;
            }
            if (npc.ai[0] == 3f && npc.ai[1] == 0f)
            {
                num9 = 0.05f;
            }
            if (npc.ai[0] == 3f && npc.ai[1] == 2f && npc.ai[2] > 40f)
            {
                num9 = 0.08f;
            }
            if (npc.rotation < num8)
            {
                if ((double)(num8 - npc.rotation) > 3.1415)
                {
                    npc.rotation -= num9;
                }
                else
                {
                    npc.rotation += num9;
                }
            }
            else
            {
                if (npc.rotation > num8)
                {
                    if ((double)(npc.rotation - num8) > 3.1415)
                    {
                        npc.rotation += num9;
                    }
                    else
                    {
                        npc.rotation -= num9;
                    }
                }
            }
            if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9)
            {
                npc.rotation = num8;
            }
            if (npc.rotation < 0f)
            {
                npc.rotation += 6.283f;
            }
            else
            {
                if ((double)npc.rotation > 6.283)
                {
                    npc.rotation -= 6.283f;
                }
            }
            if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9)
            {
                npc.rotation = num8;
            }
            if (Main.dayTime || dead)
            {
                npc.Velocity.Y = npc.Velocity.Y - 0.04f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            else
            {
                if (npc.ai[0] == 0f)
                {
                    if (npc.ai[1] == 0f)
                    {
                        float num11 = 5f;
                        float num12 = 0.04f;
                        Vector2 vector = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                        float num13 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector.X;
                        float num14 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - 200f - vector.Y;
                        float num15 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14));
                        float num16 = num15;
                        num15 = num11 / num15;
                        num13 *= num15;
                        num14 *= num15;
                        if (npc.Velocity.X < num13)
                        {
                            npc.Velocity.X = npc.Velocity.X + num12;
                            if (npc.Velocity.X < 0f && num13 > 0f)
                            {
                                npc.Velocity.X = npc.Velocity.X + num12;
                            }
                        }
                        else
                        {
                            if (npc.Velocity.X > num13)
                            {
                                npc.Velocity.X = npc.Velocity.X - num12;
                                if (npc.Velocity.X > 0f && num13 < 0f)
                                {
                                    npc.Velocity.X = npc.Velocity.X - num12;
                                }
                            }
                        }
                        if (npc.Velocity.Y < num14)
                        {
                            npc.Velocity.Y = npc.Velocity.Y + num12;
                            if (npc.Velocity.Y < 0f && num14 > 0f)
                            {
                                npc.Velocity.Y = npc.Velocity.Y + num12;
                            }
                        }
                        else
                        {
                            if (npc.Velocity.Y > num14)
                            {
                                npc.Velocity.Y = npc.Velocity.Y - num12;
                                if (npc.Velocity.Y > 0f && num14 < 0f)
                                {
                                    npc.Velocity.Y = npc.Velocity.Y - num12;
                                }
                            }
                        }
                        npc.ai[2] += 1f;
                        if (npc.ai[2] >= 600f)
                        {
                            npc.ai[1] = 1f;
                            npc.ai[2] = 0f;
                            npc.ai[3] = 0f;
                            npc.target = 255;
                            npc.netUpdate = true;
                        }
                        else
                        {
                            if (npc.Position.Y + (float)npc.Height < Main.players[npc.target].Position.Y && num16 < 500f)
                            {
                                if (!Main.players[npc.target].dead)
                                {
                                    npc.ai[3] += 1f;
                                }
                                if (npc.ai[3] >= 110f)
                                {
                                    npc.ai[3] = 0f;
                                    npc.rotation = num8;
                                    float num17 = 5f;
                                    float num18 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector.X;
                                    float num19 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector.Y;
                                    float num20 = (float)Math.Sqrt((double)(num18 * num18 + num19 * num19));
                                    num20 = num17 / num20;
                                    Vector2 vector2 = vector;
                                    Vector2 vector3;
                                    vector3.X = num18 * num20;
                                    vector3.Y = num19 * num20;
                                    vector2.X += vector3.X * 10f;
                                    vector2.Y += vector3.Y * 10f;

                                    int num21 = NPC.NewNPC((int)vector2.X, (int)vector2.Y, 5, 0);
                                    Main.npcs[num21].Velocity.X = vector3.X;
                                    Main.npcs[num21].Velocity.Y = vector3.Y;
                                    if (num21 < MAX_NPCS)
                                    {
                                        NetMessage.SendData(23, -1, -1, "", num21, 0f, 0f, 0f, 0);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (npc.ai[1] == 1f)
                        {
                            npc.rotation = num8;
                            float num22 = 6f;
                            Vector2 vector4 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                            float num23 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector4.X;
                            float num24 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector4.Y;
                            float num25 = (float)Math.Sqrt((double)(num23 * num23 + num24 * num24));
                            num25 = num22 / num25;
                            npc.Velocity.X = num23 * num25;
                            npc.Velocity.Y = num24 * num25;
                            npc.ai[1] = 2f;
                        }
                        else
                        {
                            if (npc.ai[1] == 2f)
                            {
                                npc.ai[2] += 1f;
                                if (npc.ai[2] >= 40f)
                                {
                                    npc.Velocity.X = npc.Velocity.X * 0.98f;
                                    npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                                    if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                                    {
                                        npc.Velocity.X = 0f;
                                    }
                                    if ((double)npc.Velocity.Y > -0.1 && (double)npc.Velocity.Y < 0.1)
                                    {
                                        npc.Velocity.Y = 0f;
                                    }
                                }
                                else
                                {
                                    npc.rotation = (float)Math.Atan2((double)npc.Velocity.Y, (double)npc.Velocity.X) - 1.57f;
                                }
                                if (npc.ai[2] >= 150f)
                                {
                                    npc.ai[3] += 1f;
                                    npc.ai[2] = 0f;
                                    npc.target = 255;
                                    npc.rotation = num8;
                                    if (npc.ai[3] >= 3f)
                                    {
                                        npc.ai[1] = 0f;
                                        npc.ai[3] = 0f;
                                    }
                                    else
                                    {
                                        npc.ai[1] = 1f;
                                    }
                                }
                            }
                        }
                    }
                    if ((double)npc.life < (double)npc.lifeMax * 0.5)
                    {
                        npc.ai[0] = 1f;
                        npc.ai[1] = 0f;
                        npc.ai[2] = 0f;
                        npc.ai[3] = 0f;
                        npc.netUpdate = true;
                        return;
                    }
                }
                else
                {
                    if (npc.ai[0] == 1f || npc.ai[0] == 2f)
                    {
                        if (npc.ai[0] == 1f)
                        {
                            npc.ai[2] += 0.005f;
                            if ((double)npc.ai[2] > 0.5)
                            {
                                npc.ai[2] = 0.5f;
                            }
                        }
                        else
                        {
                            npc.ai[2] -= 0.005f;
                            if (npc.ai[2] < 0f)
                            {
                                npc.ai[2] = 0f;
                            }
                        }
                        npc.rotation += npc.ai[2];
                        npc.ai[1] += 1f;
                        if (npc.ai[1] == 100f)
                        {
                            npc.ai[0] += 1f;
                            npc.ai[1] = 0f;
                            if (npc.ai[0] == 3f)
                            {
                                npc.ai[2] = 0f;
                            }
                        }
                        npc.Velocity.X = npc.Velocity.X * 0.98f;
                        npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                        if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                        {
                            npc.Velocity.X = 0f;
                        }
                        if ((double)npc.Velocity.Y > -0.1 && (double)npc.Velocity.Y < 0.1)
                        {
                            npc.Velocity.Y = 0f;
                            return;
                        }
                    }
                    else
                    {
                        npc.damage = 23;
                        npc.defense = 0;
                        if (npc.ai[1] == 0f)
                        {
                            float num26 = 6f;
                            float num27 = 0.07f;
                            Vector2 vector5 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                            float num28 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector5.X;
                            float num29 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - 120f - vector5.Y;
                            float num30 = (float)Math.Sqrt((double)(num28 * num28 + num29 * num29));
                            num30 = num26 / num30;
                            num28 *= num30;
                            num29 *= num30;
                            if (npc.Velocity.X < num28)
                            {
                                npc.Velocity.X = npc.Velocity.X + num27;
                                if (npc.Velocity.X < 0f && num28 > 0f)
                                {
                                    npc.Velocity.X = npc.Velocity.X + num27;
                                }
                            }
                            else
                            {
                                if (npc.Velocity.X > num28)
                                {
                                    npc.Velocity.X = npc.Velocity.X - num27;
                                    if (npc.Velocity.X > 0f && num28 < 0f)
                                    {
                                        npc.Velocity.X = npc.Velocity.X - num27;
                                    }
                                }
                            }
                            if (npc.Velocity.Y < num29)
                            {
                                npc.Velocity.Y = npc.Velocity.Y + num27;
                                if (npc.Velocity.Y < 0f && num29 > 0f)
                                {
                                    npc.Velocity.Y = npc.Velocity.Y + num27;
                                }
                            }
                            else
                            {
                                if (npc.Velocity.Y > num29)
                                {
                                    npc.Velocity.Y = npc.Velocity.Y - num27;
                                    if (npc.Velocity.Y > 0f && num29 < 0f)
                                    {
                                        npc.Velocity.Y = npc.Velocity.Y - num27;
                                    }
                                }
                            }
                            npc.ai[2] += 1f;
                            if (npc.ai[2] >= 200f)
                            {
                                npc.ai[1] = 1f;
                                npc.ai[2] = 0f;
                                npc.ai[3] = 0f;
                                npc.target = 255;
                                npc.netUpdate = true;
                                return;
                            }
                        }
                        else
                        {
                            if (npc.ai[1] == 1f)
                            {
                                npc.rotation = num8;
                                float num31 = 6.8f;
                                Vector2 vector6 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                                float num32 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector6.X;
                                float num33 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector6.Y;
                                float num34 = (float)Math.Sqrt((double)(num32 * num32 + num33 * num33));
                                num34 = num31 / num34;
                                npc.Velocity.X = num32 * num34;
                                npc.Velocity.Y = num33 * num34;
                                npc.ai[1] = 2f;
                                return;
                            }
                            if (npc.ai[1] == 2f)
                            {
                                npc.ai[2] += 1f;
                                if (npc.ai[2] >= 40f)
                                {
                                    npc.Velocity.X = npc.Velocity.X * 0.97f;
                                    npc.Velocity.Y = npc.Velocity.Y * 0.97f;
                                    if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                                    {
                                        npc.Velocity.X = 0f;
                                    }
                                    if ((double)npc.Velocity.Y > -0.1 && (double)npc.Velocity.Y < 0.1)
                                    {
                                        npc.Velocity.Y = 0f;
                                    }
                                }
                                else
                                {
                                    npc.rotation = (float)Math.Atan2((double)npc.Velocity.Y, (double)npc.Velocity.X) - 1.57f;
                                }
                                if (npc.ai[2] >= 130f)
                                {
                                    npc.ai[3] += 1f;
                                    npc.ai[2] = 0f;
                                    npc.target = 255;
                                    npc.rotation = num8;
                                    if (npc.ai[3] >= 3f)
                                    {
                                        npc.ai[1] = 0f;
                                        npc.ai[3] = 0f;
                                        return;
                                    }
                                    npc.ai[1] = 1f;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
 // 10
 private void AICursedSkull(NPC npc, bool flag)
 {
     float num110 = 1f;
     float num111 = 0.011f;
     npc.TargetClosest(true);
     Vector2 vector12 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
     float num112 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector12.X;
     float num113 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector12.Y;
     float num114 = (float)Math.Sqrt((double)(num112 * num112 + num113 * num113));
     float num115 = num114;
     npc.ai[1] += 1f;
     if (npc.ai[1] > 600f)
     {
         num111 *= 8f;
         num110 = 4f;
         if (npc.ai[1] > 650f)
         {
             npc.ai[1] = 0f;
         }
     }
     else
     {
         if (num115 < 250f)
         {
             npc.ai[0] += 0.9f;
             if (npc.ai[0] > 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y + 0.019f;
             }
             else
             {
                 npc.Velocity.Y = npc.Velocity.Y - 0.019f;
             }
             if (npc.ai[0] < -100f || npc.ai[0] > 100f)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.019f;
             }
             else
             {
                 npc.Velocity.X = npc.Velocity.X - 0.019f;
             }
             if (npc.ai[0] > 200f)
             {
                 npc.ai[0] = -200f;
             }
         }
     }
     if (num115 > 350f)
     {
         num110 = 5f;
         num111 = 0.3f;
     }
     else
     {
         if (num115 > 300f)
         {
             num110 = 3f;
             num111 = 0.2f;
         }
         else
         {
             if (num115 > 250f)
             {
                 num110 = 1.5f;
                 num111 = 0.1f;
             }
         }
     }
     num114 = num110 / num114;
     num112 *= num114;
     num113 *= num114;
     if (Main.players[npc.target].dead)
     {
         num112 = (float)npc.direction * num110 / 2f;
         num113 = -num110 / 2f;
     }
     if (npc.Velocity.X < num112)
     {
         npc.Velocity.X = npc.Velocity.X + num111;
     }
     else
     {
         if (npc.Velocity.X > num112)
         {
             npc.Velocity.X = npc.Velocity.X - num111;
         }
     }
     if (npc.Velocity.Y < num113)
     {
         npc.Velocity.Y = npc.Velocity.Y + num111;
     }
     else
     {
         if (npc.Velocity.Y > num113)
         {
             npc.Velocity.Y = npc.Velocity.Y - num111;
         }
     }
     if (num112 > 0f)
     {
         npc.spriteDirection = -1;
         npc.rotation = (float)Math.Atan2((double)num113, (double)num112);
     }
     if (num112 < 0f)
     {
         npc.spriteDirection = 1;
         npc.rotation = (float)Math.Atan2((double)num113, (double)num112) + 3.14f;
         return;
     }
 }
예제 #6
0
        // 24
        private void AIBird(NPC npc, bool flag)
        {
            npc.noGravity = true;
            if (npc.ai[0] == 0f)
            {
                npc.noGravity = false;
                npc.TargetClosest(true);
                if (npc.Velocity.X != 0f || npc.Velocity.Y < 0f || (double)npc.Velocity.Y > 0.3)
                {
                    npc.ai[0] = 1f;
                    npc.netUpdate = true;
                    npc.direction = -npc.direction;
                }
                else
                {
                    Rectangle rectangle7 = new Rectangle((int)Main.players[npc.target].Position.X,
                        (int)Main.players[npc.target].Position.Y, Main.players[npc.target].Width, Main.players[npc.target].Height);
                    Rectangle rectangle8 = new Rectangle((int)npc.Position.X - 100, (int)npc.Position.Y - 100, npc.Width + 200, npc.Height + 200);
                    if (rectangle8.Intersects(rectangle7) || npc.life < npc.lifeMax)
                    {
                        npc.ai[0] = 1f;
                        npc.Velocity.Y = npc.Velocity.Y - 6f;
                        npc.netUpdate = true;
                        npc.direction = -npc.direction;
                    }
                }
            }
            else
            {
                if (!Main.players[npc.target].dead)
                {
                    if (npc.collideX)
                    {
                        npc.direction *= -1;
                        npc.Velocity.X = npc.oldVelocity.X * -0.5f;
                        if (npc.direction == -1 && npc.Velocity.X > 0f && npc.Velocity.X < 2f)
                            npc.Velocity.X = 2f;
                        if (npc.direction == 1 && npc.Velocity.X < 0f && npc.Velocity.X > -2f)
                            npc.Velocity.X = -2f;
                    }
                    if (npc.collideY)
                    {
                        npc.Velocity.Y = npc.oldVelocity.Y * -0.5f;
                        if (npc.Velocity.Y > 0f && npc.Velocity.Y < 1f)
                            npc.Velocity.Y = 1f;
                        if (npc.Velocity.Y < 0f && npc.Velocity.Y > -1f)
                            npc.Velocity.Y = -1f;
                    }
                    if (npc.direction == -1 && npc.Velocity.X > -3f)
                    {
                        npc.Velocity.X = npc.Velocity.X - 0.1f;
                        if (npc.Velocity.X > 3f)
                            npc.Velocity.X = npc.Velocity.X - 0.1f;
                        else if (npc.Velocity.X > 0f)
                            npc.Velocity.X = npc.Velocity.X - 0.05f;

                        if (npc.Velocity.X < -3f)
                            npc.Velocity.X = -3f;
                    }
                    else
                    {
                        if (npc.direction == 1 && npc.Velocity.X < 3f)
                        {
                            npc.Velocity.X = npc.Velocity.X + 0.1f;
                            if (npc.Velocity.X < -3f)
                                npc.Velocity.X = npc.Velocity.X + 0.1f;
                            else if (npc.Velocity.X < 0f)
                                npc.Velocity.X = npc.Velocity.X + 0.05f;

                            if (npc.Velocity.X > 3f)
                                npc.Velocity.X = 3f;
                        }
                    }
                    int num276 = (int)((npc.Position.X + (float)(npc.Width / 2)) / 16f) + npc.direction;
                    int num277 = (int)((npc.Position.Y + (float)npc.Height) / 16f);
                    bool flag30 = true;
                    int num278 = 15;
                    bool flag31 = false;
                    for (int num279 = num277; num279 < num277 + num278; num279++)
                    {
                        if ((Main.tile.At(num276, num279).Active && Main.tileSolid[(int)Main.tile.At(num276, num279).Type]) || Main.tile.At(num276, num279).Liquid > 0)
                        {
                            if (num279 < num277 + 5)flag31 = true;

                            flag30 = false;
                            break;
                        }
                    }
                    if (flag30)
                        npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                    else
                        npc.Velocity.Y = npc.Velocity.Y - 0.1f;
                    if (flag31)
                        npc.Velocity.Y = npc.Velocity.Y - 0.2f;
                    if (npc.Velocity.Y > 3f)
                        npc.Velocity.Y = 3f;
                    if (npc.Velocity.Y < -4f)
                        npc.Velocity.Y = -4f;
                }
            }
            if (npc.wet)
            {
                if (npc.Velocity.Y > 0f)
                    npc.Velocity.Y = npc.Velocity.Y * 0.95f;

                npc.Velocity.Y = npc.Velocity.Y - 0.5f;

                if (npc.Velocity.Y < -4f)
                    npc.Velocity.Y = -4f;

                npc.TargetClosest(true);
                return;
            }
        }
예제 #7
0
        static bool InvokeNpcCreationHook(int x, int y, string type, out NPC npc)
        {
            npc = null;

            if (!WorldModify.gen)
            {
                var ctx = new HookContext
                {
                };

                var args = new HookArgs.NpcCreation
                {
                    X = x, Y = y,
                    Name = type,
                };

                HookPoints.NpcCreation.Invoke (ref ctx, ref args);

                if (ctx.Result == HookResult.IGNORE)
                    return false;

                npc = args.CreatedNpc;
            }

            return true;
        }
예제 #8
0
 // 8
 private void AIWizard(NPC npc, bool flag)
 {
     npc.TargetClosest(true);
     npc.Velocity.X = npc.Velocity.X * 0.93f;
     if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
     {
         npc.Velocity.X = 0f;
     }
     if (npc.ai[0] == 0f)
     {
         npc.ai[0] = 500f;
     }
     if (npc.ai[2] != 0f && npc.ai[3] != 0f)
     {
         npc.Position.X = npc.ai[2] * 16f - (float)(npc.Width / 2) + 8f;
         npc.Position.Y = npc.ai[3] * 16f - (float)npc.Height;
         npc.Velocity.X = 0f;
         npc.Velocity.Y = 0f;
         npc.ai[2] = 0f;
         npc.ai[3] = 0f;
     }
     npc.ai[0] += 1f;
     if (npc.ai[0] == 100f || npc.ai[0] == 200f || npc.ai[0] == 300f)
     {
         npc.ai[1] = 30f;
         npc.netUpdate = true;
     }
     else
     {
         if (npc.ai[0] >= 650f)
         {
             npc.ai[0] = 1f;
             int num90 = (int)Main.players[npc.target].Position.X / 16;
             int num91 = (int)Main.players[npc.target].Position.Y / 16;
             int num92 = (int)npc.Position.X / 16;
             int num93 = (int)npc.Position.Y / 16;
             int num94 = 20;
             int num95 = 0;
             bool flag14 = false;
             if (Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) + Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 2000f)
             {
                 num95 = 100;
                 flag14 = true;
             }
             while (!flag14 && num95 < 100)
             {
                 num95++;
                 int num96 = Main.rand.Next(num90 - num94, num90 + num94);
                 int num97 = Main.rand.Next(num91 - num94, num91 + num94);
                 for (int num98 = num97; num98 < num91 + num94; num98++)
                 {
                     if ((num98 < num91 - 4 || num98 > num91 + 4 || num96 < num90 - 4 || num96 > num90 + 4) && (num98 < num93 - 1 || num98 > num93 + 1 || num96 < num92 - 1 || num96 > num92 + 1) && Main.tile.At(num96, num98).Active)
                     {
                         bool flag15 = true;
                         if (npc.Type == 32 && Main.tile.At(num96, num98 - 1).Wall == 0)
                         {
                             flag15 = false;
                         }
                         else
                         {
                             if (Main.tile.At(num96, num98 - 1).Lava)
                             {
                                 flag15 = false;
                             }
                         }
                         if (flag15 && Main.tileSolid[(int)Main.tile.At(num96, num98).Type] && !Collision.SolidTiles(num96 - 1, num96 + 1, num98 - 4, num98 - 1))
                         {
                             npc.ai[1] = 20f;
                             npc.ai[2] = (float)num96;
                             npc.ai[3] = (float)num98;
                             flag14 = true;
                             break;
                         }
                     }
                 }
             }
             npc.netUpdate = true;
         }
     }
     if (npc.ai[1] > 0f)
     {
         npc.ai[1] -= 1f;
         if (npc.ai[1] == 25f)
         {
             if (npc.Type == 29 || npc.Type == 45)
             {
                 NPC.NewNPC((int)npc.Position.X + npc.Width / 2, (int)npc.Position.Y - 8, 30, 0);
             }
             else
             {
                 if (npc.Type == 32)
                 {
                     NPC.NewNPC((int)npc.Position.X + npc.Width / 2, (int)npc.Position.Y - 8, 33, 0);
                 }
                 else
                 {
                     NPC.NewNPC((int)npc.Position.X + npc.Width / 2 + npc.direction * 8, (int)npc.Position.Y + 20, 25, 0);
                 }
             }
         }
     }
     if (npc.Type == 29 || npc.Type == 45)
     {
         if (Main.rand.Next(5) == 0)
         {
             return;
         }
     }
     else
     {
         if (npc.Type == 32)
         {
             if (Main.rand.Next(2) == 0)
             {
                 return;
             }
         }
         else
         {
             if (Main.rand.Next(2) == 0)
             {
                 return;
             }
         }
     }
 }
예제 #9
0
 // 9
 private void AISphere(NPC npc, bool flag)
 {
     if (npc.target == 255)
     {
         npc.TargetClosest(true);
         float num102 = 6f;
         if (npc.Type == 25)
         {
             num102 = 5f;
         }
         Vector2 vector11 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
         float num103 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector11.X;
         float num104 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector11.Y;
         float num105 = (float)Math.Sqrt((double)(num103 * num103 + num104 * num104));
         num105 = num102 / num105;
         npc.Velocity.X = num103 * num105;
         npc.Velocity.Y = num104 * num105;
     }
     if (npc.timeLeft > 100)
     {
         npc.timeLeft = 100;
     }
     npc.rotation += 0.4f * (float)npc.direction;
     return;
 }
예제 #10
0
        // 31
        private void AISpazmatism(NPC npc, bool flag)
        {
            if (npc.target < 0 || npc.target == 255 || Main.players[npc.target].dead || !Main.players[npc.target].Active)
            {
                npc.TargetClosest(true);
            }
            bool dead3 = Main.players[npc.target].dead;
            float num355 = npc.Position.X + (float)(npc.Width / 2) - Main.players[npc.target].Position.X - (float)(Main.players[npc.target].Width / 2);
            float num356 = npc.Position.Y + (float)npc.Height - 59f - Main.players[npc.target].Position.Y - (float)(Main.players[npc.target].Height / 2);
            float num357 = (float)Math.Atan2((double)num356, (double)num355) + 1.57f;

            if (num357 < 0f)
                num357 += 6.283f;
            else if ((double)num357 > 6.283)
                num357 -= 6.283f;

            float num358 = 0.15f;
            if (npc.rotation < num357)
            {
                if ((double)(num357 - npc.rotation) > 3.1415)
                    npc.rotation -= num358;
                else
                    npc.rotation += num358;
            }
            else if (npc.rotation > num357)
            {
                if ((double)(npc.rotation - num357) > 3.1415)
                    npc.rotation += num358;
                else
                    npc.rotation -= num358;
            }
            if (npc.rotation > num357 - num358 && npc.rotation < num357 + num358)
                npc.rotation = num357;

            if (npc.rotation < 0f)
                npc.rotation += 6.283f;
            else if ((double)npc.rotation > 6.283)
                npc.rotation -= 6.283f;

            if (npc.rotation > num357 - num358 && npc.rotation < num357 + num358)
                npc.rotation = num357;

            if (Main.dayTime || dead3)
            {
                npc.Velocity.Y = npc.Velocity.Y - 0.04f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            else
            {
                if (npc.ai[0] == 0f)
                {
                    if (npc.ai[1] == 0f)
                    {
                        npc.TargetClosest(true);
                        float num360 = 12f;
                        float num361 = 0.4f;
                        int num362 = 1;
                        if (npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)Main.players[npc.target].Width)
                            num362 = -1;

                        Vector2 vector36 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                        float num363 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) + (float)(num362 * 400) - vector36.X;
                        float num364 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector36.Y;
                        float num365 = (float)Math.Sqrt((double)(num363 * num363 + num364 * num364));
                        num365 = num360 / num365;
                        num363 *= num365;
                        num364 *= num365;
                        if (npc.Velocity.X < num363)
                        {
                            npc.Velocity.X = npc.Velocity.X + num361;
                            if (npc.Velocity.X < 0f && num363 > 0f)
                                npc.Velocity.X = npc.Velocity.X + num361;
                        }
                        else
                        {
                            if (npc.Velocity.X > num363)
                            {
                                npc.Velocity.X = npc.Velocity.X - num361;
                                if (npc.Velocity.X > 0f && num363 < 0f)
                                    npc.Velocity.X = npc.Velocity.X - num361;
                            }
                        }
                        if (npc.Velocity.Y < num364)
                        {
                            npc.Velocity.Y = npc.Velocity.Y + num361;
                            if (npc.Velocity.Y < 0f && num364 > 0f)
                                npc.Velocity.Y = npc.Velocity.Y + num361;
                        }
                        else
                        {
                            if (npc.Velocity.Y > num364)
                            {
                                npc.Velocity.Y = npc.Velocity.Y - num361;
                                if (npc.Velocity.Y > 0f && num364 < 0f)
                                    npc.Velocity.Y = npc.Velocity.Y - num361;
                            }
                        }
                        npc.ai[2] += 1f;
                        if (npc.ai[2] >= 600f)
                        {
                            npc.ai[1] = 1f;
                            npc.ai[2] = 0f;
                            npc.ai[3] = 0f;
                            npc.target = 255;
                            npc.netUpdate = true;
                        }
                        else
                        {
                            if (!Main.players[npc.target].dead)
                                npc.ai[3] += 1f;

                            if (npc.ai[3] >= 60f)
                            {
                                npc.ai[3] = 0f;
                                vector36 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                                num363 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector36.X;
                                num364 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector36.Y;

                                float num366 = 12f;
                                int num367 = 25;
                                int num368 = 96;
                                num365 = (float)Math.Sqrt((double)(num363 * num363 + num364 * num364));
                                num365 = num366 / num365;
                                num363 *= num365;
                                num364 *= num365;
                                num363 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                num364 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                vector36.X += num363 * 4f;
                                vector36.Y += num364 * 4f;
                                Projectile.NewProjectile(vector36.X, vector36.Y, num363, num364, num368, num367, 0f, Main.myPlayer);
                            }
                        }
                    }
                    else
                    {
                        if (npc.ai[1] == 1f)
                        {
                            npc.rotation = num357;
                            float num369 = 13f;
                            Vector2 vector37 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                            float num370 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector37.X;
                            float num371 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector37.Y;
                            float num372 = (float)Math.Sqrt((double)(num370 * num370 + num371 * num371));
                            num372 = num369 / num372;
                            npc.Velocity.X = num370 * num372;
                            npc.Velocity.Y = num371 * num372;
                            npc.ai[1] = 2f;
                        }
                        else
                        {
                            if (npc.ai[1] == 2f)
                            {
                                npc.ai[2] += 1f;
                                if (npc.ai[2] >= 8f)
                                {
                                    npc.Velocity.X = npc.Velocity.X * 0.9f;
                                    npc.Velocity.Y = npc.Velocity.Y * 0.9f;
                                    if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                                    {
                                        npc.Velocity.X = 0f;
                                    }
                                    if ((double)npc.Velocity.Y > -0.1 && (double)npc.Velocity.Y < 0.1)
                                    {
                                        npc.Velocity.Y = 0f;
                                    }
                                }
                                else
                                {
                                    npc.rotation = (float)Math.Atan2((double)npc.Velocity.Y, (double)npc.Velocity.X) - 1.57f;
                                }
                                if (npc.ai[2] >= 42f)
                                {
                                    npc.ai[3] += 1f;
                                    npc.ai[2] = 0f;
                                    npc.target = 255;
                                    npc.rotation = num357;
                                    if (npc.ai[3] >= 10f)
                                    {
                                        npc.ai[1] = 0f;
                                        npc.ai[3] = 0f;
                                    }
                                    else
                                    {
                                        npc.ai[1] = 1f;
                                    }
                                }
                            }
                        }
                    }
                    if ((double)npc.life < (double)npc.lifeMax * 0.5)
                    {
                        npc.ai[0] = 1f;
                        npc.ai[1] = 0f;
                        npc.ai[2] = 0f;
                        npc.ai[3] = 0f;
                        npc.netUpdate = true;
                        return;
                    }
                }
                else
                {
                    if (npc.ai[0] == 1f || npc.ai[0] == 2f)
                    {
                        if (npc.ai[0] == 1f)
                        {
                            npc.ai[2] += 0.005f;
                            if ((double)npc.ai[2] > 0.5)
                            {
                                npc.ai[2] = 0.5f;
                            }
                        }
                        else
                        {
                            npc.ai[2] -= 0.005f;
                            if (npc.ai[2] < 0f)
                            {
                                npc.ai[2] = 0f;
                            }
                        }
                        npc.rotation += npc.ai[2];
                        npc.ai[1] += 1f;
                        if (npc.ai[1] == 100f)
                        {
                            npc.ai[0] += 1f;
                            npc.ai[1] = 0f;
                            if (npc.ai[0] == 3f)
                            {
                                npc.ai[2] = 0f;
                            }
                        }

                        npc.Velocity.X = npc.Velocity.X * 0.98f;
                        npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                        if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                        {
                            npc.Velocity.X = 0f;
                        }
                        if ((double)npc.Velocity.Y > -0.1 && (double)npc.Velocity.Y < 0.1)
                        {
                            npc.Velocity.Y = 0f;
                            return;
                        }
                    }
                    else
                    {
                        //npc.soundHit = 4;
                        npc.damage = (int)((double)npc.defDamage * 1.5);
                        npc.defense = npc.defDefense + 25;
                        if (npc.ai[1] == 0f)
                        {
                            float num375 = 4f;
                            float num376 = 0.1f;
                            int num377 = 1;
                            if (npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)Main.players[npc.target].Width)
                            {
                                num377 = -1;
                            }
                            Vector2 vector38 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                            float num378 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) + (float)(num377 * 180) - vector38.X;
                            float num379 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector38.Y;
                            float num380 = (float)Math.Sqrt((double)(num378 * num378 + num379 * num379));
                            num380 = num375 / num380;
                            num378 *= num380;
                            num379 *= num380;
                            if (npc.Velocity.X < num378)
                            {
                                npc.Velocity.X = npc.Velocity.X + num376;
                                if (npc.Velocity.X < 0f && num378 > 0f)
                                {
                                    npc.Velocity.X = npc.Velocity.X + num376;
                                }
                            }
                            else
                            {
                                if (npc.Velocity.X > num378)
                                {
                                    npc.Velocity.X = npc.Velocity.X - num376;
                                    if (npc.Velocity.X > 0f && num378 < 0f)
                                    {
                                        npc.Velocity.X = npc.Velocity.X - num376;
                                    }
                                }
                            }
                            if (npc.Velocity.Y < num379)
                            {
                                npc.Velocity.Y = npc.Velocity.Y + num376;
                                if (npc.Velocity.Y < 0f && num379 > 0f)
                                {
                                    npc.Velocity.Y = npc.Velocity.Y + num376;
                                }
                            }
                            else
                            {
                                if (npc.Velocity.Y > num379)
                                {
                                    npc.Velocity.Y = npc.Velocity.Y - num376;
                                    if (npc.Velocity.Y > 0f && num379 < 0f)
                                    {
                                        npc.Velocity.Y = npc.Velocity.Y - num376;
                                    }
                                }
                            }
                            npc.ai[2] += 1f;
                            if (npc.ai[2] >= 400f)
                            {
                                npc.ai[1] = 1f;
                                npc.ai[2] = 0f;
                                npc.ai[3] = 0f;
                                npc.target = 255;
                                npc.netUpdate = true;
                            }
                            if (Collision.CanHit(npc.Position, npc.Width, npc.Height, Main.players[npc.target].Position, Main.players[npc.target].Width, Main.players[npc.target].Height))
                            {
                                npc.localAI[2] += 1f;
                                if (npc.localAI[2] > 22f)
                                {
                                    npc.localAI[2] = 0f;
                                }
                                npc.localAI[1] += 1f;
                                if ((double)npc.life < (double)npc.lifeMax * 0.75)
                                {
                                    npc.localAI[1] += 1f;
                                }
                                if ((double)npc.life < (double)npc.lifeMax * 0.5)
                                {
                                    npc.localAI[1] += 1f;
                                }
                                if ((double)npc.life < (double)npc.lifeMax * 0.25)
                                {
                                    npc.localAI[1] += 1f;
                                }
                                if ((double)npc.life < (double)npc.lifeMax * 0.1)
                                {
                                    npc.localAI[1] += 2f;
                                }
                                if (npc.localAI[1] > 8f)
                                {
                                    npc.localAI[1] = 0f;
                                    float num381 = 6f;
                                    int num382 = 30;
                                    int num383 = 101;
                                    vector38 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                                    num378 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector38.X;
                                    num379 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector38.Y;
                                    num380 = (float)Math.Sqrt((double)(num378 * num378 + num379 * num379));
                                    num380 = num381 / num380;
                                    num378 *= num380;
                                    num379 *= num380;
                                    num379 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                    num378 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                    num379 += npc.Velocity.Y * 0.5f;
                                    num378 += npc.Velocity.X * 0.5f;
                                    vector38.X -= num378 * 1f;
                                    vector38.Y -= num379 * 1f;
                                    Projectile.NewProjectile(vector38.X, vector38.Y, num378, num379, num383, num382, 0f, Main.myPlayer);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (npc.ai[1] == 1f)
                            {
                                npc.rotation = num357;
                                float num384 = 14f;
                                Vector2 vector39 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                                float num385 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector39.X;
                                float num386 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector39.Y;
                                float num387 = (float)Math.Sqrt((double)(num385 * num385 + num386 * num386));
                                num387 = num384 / num387;
                                npc.Velocity.X = num385 * num387;
                                npc.Velocity.Y = num386 * num387;
                                npc.ai[1] = 2f;
                                return;
                            }
                            if (npc.ai[1] == 2f)
                            {
                                npc.ai[2] += 1f;
                                if (npc.ai[2] >= 50f)
                                {
                                    npc.Velocity.X = npc.Velocity.X * 0.93f;
                                    npc.Velocity.Y = npc.Velocity.Y * 0.93f;
                                    if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                                    {
                                        npc.Velocity.X = 0f;
                                    }
                                    if ((double)npc.Velocity.Y > -0.1 && (double)npc.Velocity.Y < 0.1)
                                    {
                                        npc.Velocity.Y = 0f;
                                    }
                                }
                                else
                                {
                                    npc.rotation = (float)Math.Atan2((double)npc.Velocity.Y, (double)npc.Velocity.X) - 1.57f;
                                }
                                if (npc.ai[2] >= 80f)
                                {
                                    npc.ai[3] += 1f;
                                    npc.ai[2] = 0f;
                                    npc.target = 255;
                                    npc.rotation = num357;
                                    if (npc.ai[3] >= 6f)
                                    {
                                        npc.ai[1] = 0f;
                                        npc.ai[3] = 0f;
                                        return;
                                    }
                                    npc.ai[1] = 1f;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #11
0
        // 22
        private void AISlowDebuffFlying(NPC npc, bool flag)
        {
            bool flag25 = false;
            if (npc.justHit)
            {
                npc.ai[2] = 0f;
            }
            if (npc.ai[2] >= 0f)
            {
                int num258 = 16;
                bool flag26 = false;
                bool flag27 = false;
                if (npc.Position.X > npc.ai[0] - (float)num258 && npc.Position.X < npc.ai[0] + (float)num258)
                {
                    flag26 = true;
                }
                else
                {
                    if ((npc.Velocity.X < 0f && npc.direction > 0) || (npc.Velocity.X > 0f && npc.direction < 0))
                    {
                        flag26 = true;
                    }
                }
                num258 += 24;
                if (npc.Position.Y > npc.ai[1] - (float)num258 && npc.Position.Y < npc.ai[1] + (float)num258)
                {
                    flag27 = true;
                }
                if (flag26 && flag27)
                {
                    npc.ai[2] += 1f;
                    if (npc.ai[2] >= 30f && num258 == 16)
                    {
                        flag25 = true;
                    }
                    if (npc.ai[2] >= 60f)
                    {
                        npc.ai[2] = -200f;
                        npc.direction *= -1;
                        npc.Velocity.X = npc.Velocity.X * -1f;
                        npc.collideX = false;
                    }
                }
                else
                {
                    npc.ai[0] = npc.Position.X;
                    npc.ai[1] = npc.Position.Y;
                    npc.ai[2] = 0f;
                }
                npc.TargetClosest(true);
            }
            else
            {
                npc.ai[2] += 1f;
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) > npc.Position.X + (float)(npc.Width / 2))
                {
                    npc.direction = -1;
                }
                else
                {
                    npc.direction = 1;
                }
            }
            int num259 = (int)((npc.Position.X + (float)(npc.Width / 2)) / 16f) + npc.direction * 2;
            int num260 = (int)((npc.Position.Y + (float)npc.Height) / 16f);
            bool flag28 = true;
            bool flag29 = false;
            int num261 = 3;
            if (npc.Type == 122)
            {
                if (npc.justHit)
                {
                    npc.ai[3] = 0f;
                    npc.localAI[1] = 0f;
                }
                float num262 = 7f;
                Vector2 vector27 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                float num263 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector27.X;
                float num264 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector27.Y;
                float num265 = (float)Math.Sqrt((double)(num263 * num263 + num264 * num264));
                num265 = num262 / num265;
                num263 *= num265;
                num264 *= num265;
                if (npc.ai[3] == 32f)
                {
                    int num266 = 25;
                    int num267 = 84;
                    Projectile.NewProjectile(vector27.X, vector27.Y, num263, num264, num267, num266, 0f, Main.myPlayer);
                }
                num261 = 8;
                if (npc.ai[3] > 0f)
                {
                    npc.ai[3] += 1f;
                    if (npc.ai[3] >= 64f)
                    {
                        npc.ai[3] = 0f;
                    }
                }
                if (npc.ai[3] == 0f)
                {
                    npc.localAI[1] += 1f;
                    if (npc.localAI[1] > 120f && Collision.CanHit(npc.Position, npc.Width, npc.Height, Main.players[npc.target].Position, Main.players[npc.target].Width, Main.players[npc.target].Height))
                    {
                        npc.localAI[1] = 0f;
                        npc.ai[3] = 1f;
                        npc.netUpdate = true;
                    }
                }
            }
            else if (npc.Type == 75)
                    num261 = 4;

            for (int num269 = num260; num269 < num260 + num261; num269++)
            {
                if ((Main.tile.At(num259, num269).Active && Main.tileSolid[(int)Main.tile.At(num259, num269).Type]) || Main.tile.At(num259, num269).Liquid > 0)
                {
                    if (num269 <= num260 + 1)flag29 = true;

                    flag28 = false;
                    break;
                }
            }
            if (flag25)
            {
                flag29 = false;
                flag28 = true;
            }
            if (flag28)
            {
                if (npc.Type == 75)
                {
                    npc.Velocity.Y = npc.Velocity.Y + 0.2f;
                    if (npc.Velocity.Y > 2f)
                        npc.Velocity.Y = 2f;
                }
                else
                {
                    npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                    if (npc.Velocity.Y > 3f)
                        npc.Velocity.Y = 3f;
                }
            }
            else
            {
                if (npc.Type == 75)
                {
                    if ((npc.directionY < 0 && npc.Velocity.Y > 0f) || flag29)
                        npc.Velocity.Y = npc.Velocity.Y - 0.2f;
                }
                else
                {
                    if (npc.directionY < 0 && npc.Velocity.Y > 0f)
                        npc.Velocity.Y = npc.Velocity.Y - 0.1f;
                }
                if (npc.Velocity.Y < -4f)
                    npc.Velocity.Y = -4f;
            }
            if (npc.Type == 75 && npc.wet)
            {
                npc.Velocity.Y = npc.Velocity.Y - 0.2f;
                if (npc.Velocity.Y < -2f)
                    npc.Velocity.Y = -2f;
            }
            if (npc.collideX)
            {
                npc.Velocity.X = npc.oldVelocity.X * -0.4f;
                if (npc.direction == -1 && npc.Velocity.X > 0f && npc.Velocity.X < 1f)
                    npc.Velocity.X = 1f;

                if (npc.direction == 1 && npc.Velocity.X < 0f && npc.Velocity.X > -1f)
                    npc.Velocity.X = -1f;
            }
            if (npc.collideY)
            {
                npc.Velocity.Y = npc.oldVelocity.Y * -0.25f;
                if (npc.Velocity.Y > 0f && npc.Velocity.Y < 1f)
                    npc.Velocity.Y = 1f;

                if (npc.Velocity.Y < 0f && npc.Velocity.Y > -1f)
                    npc.Velocity.Y = -1f;
            }
            float num270 = 2f;
            if (npc.Type == 75)
            {
                num270 = 3f;
            }
            if (npc.direction == -1 && npc.Velocity.X > -num270)
            {
                npc.Velocity.X = npc.Velocity.X - 0.1f;
                if (npc.Velocity.X > num270)
                    npc.Velocity.X = npc.Velocity.X - 0.1f;
                else if (npc.Velocity.X > 0f)
                        npc.Velocity.X = npc.Velocity.X + 0.05f;

                if (npc.Velocity.X < -num270)
                    npc.Velocity.X = -num270;
            }
            else if (npc.direction == 1 && npc.Velocity.X < num270)
            {
                npc.Velocity.X = npc.Velocity.X + 0.1f;
                if (npc.Velocity.X < -num270)
                    npc.Velocity.X = npc.Velocity.X + 0.1f;
                else if (npc.Velocity.X < 0f)
                    npc.Velocity.X = npc.Velocity.X - 0.05f;

                if (npc.Velocity.X > num270)
                    npc.Velocity.X = num270;
            }
            if (npc.directionY == -1 && (double)npc.Velocity.Y > -1.5)
            {
                npc.Velocity.Y = npc.Velocity.Y - 0.04f;
                if ((double)npc.Velocity.Y > 1.5)
                    npc.Velocity.Y = npc.Velocity.Y - 0.05f;
                else if (npc.Velocity.Y > 0f)
                    npc.Velocity.Y = npc.Velocity.Y + 0.03f;

                if ((double)npc.Velocity.Y < -1.5)
                    npc.Velocity.Y = -1.5f;
            }
            else if (npc.directionY == 1 && (double)npc.Velocity.Y < 1.5)
            {
                npc.Velocity.Y = npc.Velocity.Y + 0.04f;
                if ((double)npc.Velocity.Y < -1.5)
                    npc.Velocity.Y = npc.Velocity.Y + 0.05f;
                else if (npc.Velocity.Y < 0f)
                    npc.Velocity.Y = npc.Velocity.Y - 0.03f;

                if ((double)npc.Velocity.Y > 1.5)
                    npc.Velocity.Y = 1.5f;
            }
        }
예제 #12
0
        public static int NewNPC(int x, int y, NPC npc, int npcIndex)
        {
            npc.Position.X = (float)(x - npc.Width / 2);
            npc.Position.Y = (float)(y - npc.Height);
            npc.Active = true;
            npc.timeLeft = (int)((double)NPC.active_TIME * 1.25);
            npc.wet = Collision.WetCollision(npc.Position, npc.Width, npc.Height);

            Main.npcs[npcIndex] = npc;

            return npcIndex;
        }
예제 #13
0
        // 1
        private void AISlime(NPC npc, bool flagg)
        {
            bool flag = (!Main.dayTime) || (npc.life != npc.lifeMax) || (npc.Position.Y > Main.worldSurface * 16.0) || (npc.Type == 81);

            if (npc.ai[2] > 1f)
            {
                npc.ai[2] -= 1f;
            }
            if (npc.wet)
            {
                if (this.collideY)
                {
                    this.Velocity.Y = -2f;
                }
                if (npc.Velocity.Y < 0f && npc.ai[3] == npc.Position.X)
                {
                    npc.direction *= -1;
                    npc.ai[2] = 200f;
                }
                if (npc.Velocity.Y > 0f)
                {
                    npc.ai[3] = npc.Position.X;
                }
                if (npc.Type == 59)
                {
                    if (npc.Velocity.Y > 2f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y * 0.9f;
                    }
                    else
                    {
                        if (npc.directionY < 0)
                        {
                            npc.Velocity.Y = npc.Velocity.Y - 0.8f;
                        }
                    }
                    npc.Velocity.Y = npc.Velocity.Y - 0.5f;
                    if (npc.Velocity.Y < -10f)
                    {
                        npc.Velocity.Y = -10f;
                    }
                }
                else
                {
                    if (npc.Velocity.Y > 2f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y * 0.9f;
                    }
                    npc.Velocity.Y = npc.Velocity.Y - 0.5f;
                    if (npc.Velocity.Y < -4f)
                    {
                        npc.Velocity.Y = -4f;
                    }
                }
                if (npc.ai[2] == 1f && flag)
                {
                    npc.TargetClosest(true);
                }
            }
            npc.aiAction = 0;
            if (npc.ai[2] == 0f)
            {
                npc.ai[0] = -100f;
                npc.ai[2] = 1f;
                npc.TargetClosest(true);
            }
            if (npc.Velocity.Y == 0f)
            {
                if (npc.ai[3] == npc.Position.X)
                {
                    npc.direction *= -1;
                    npc.ai[2] = 200f;
                }
                npc.ai[3] = 0f;
                npc.Velocity.X = npc.Velocity.X * 0.8f;
                if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
                {
                    npc.Velocity.X = 0f;
                }
                if (flag)
                {
                    npc.ai[0] += 1f;
                }
                npc.ai[0] += 1f;
                if (npc.Type == 59)
                {
                    npc.ai[0] += 2f;
                }
                if (npc.Type == 71)
                {
                    npc.ai[0] += 3f;
                }
                if (this.Type == 138)
                {
                    this.ai[0] += 2f;
                }
                if (this.Type == 81)
                {
                    if (this.scale >= 0f)
                    {
                        this.ai[0] += 4f;
                    }
                    else
                    {
                        this.ai[0] += 1f;
                    }
                }
                if (npc.ai[0] >= 0f)
                {
                    npc.netUpdate = true;
                    if (flag && npc.ai[2] == 1f)
                    {
                        npc.TargetClosest(true);
                    }
                    if (npc.ai[1] == 2f)
                    {
                        npc.Velocity.Y = -8f;
                        if (npc.Type == 59)
                        {
                            npc.Velocity.Y = npc.Velocity.Y - 2f;
                        }
                        npc.Velocity.X = npc.Velocity.X + (float)(3 * npc.direction);
                        if (npc.Type == 59)
                        {
                            npc.Velocity.X = npc.Velocity.X + 0.5f * (float)npc.direction;
                        }
                        npc.ai[0] = -200f;
                        npc.ai[1] = 0f;
                        npc.ai[3] = npc.Position.X;
                    }
                    else
                    {
                        npc.Velocity.Y = -6f;
                        npc.Velocity.X = npc.Velocity.X + (float)(2 * npc.direction);
                        if (npc.Type == 59)
                        {
                            npc.Velocity.X = npc.Velocity.X + (float)(2 * npc.direction);
                        }
                        npc.ai[0] = -120f;
                        npc.ai[1] += 1f;
                    }

                    if (this.Type == 141)
                    {
                        this.Velocity.Y = this.Velocity.Y * 1.3f;
                        this.Velocity.X = this.Velocity.X * 1.2f;
                        return;
                    }
                }
                else
                {
                    if (npc.ai[0] >= -30f)
                    {
                        npc.aiAction = 1;
                        return;
                    }
                }
            }
            else
            {
                if (npc.target < 255 && ((npc.direction == 1 && npc.Velocity.X < 3f) || (npc.direction == -1 && npc.Velocity.X > -3f)))
                {
                    if ((npc.direction == -1 && (double)npc.Velocity.X < 0.1) || (npc.direction == 1 && (double)npc.Velocity.X > -0.1))
                    {
                        npc.Velocity.X = npc.Velocity.X + 0.2f * (float)npc.direction;
                        return;
                    }
                    npc.Velocity.X = npc.Velocity.X * 0.93f;
                    return;
                }
            }
        }
예제 #14
0
 // 32
 private void AISkeletronPrime(NPC npc, bool flag)
 {
     npc.damage = npc.defDamage;
     npc.defense = npc.defDefense;
     if (npc.ai[0] == 0f)
     {
         npc.TargetClosest(true);
         npc.ai[0] = 1f;
         if (npc.Type != 68)
         {
             int num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 128, npc.whoAmI);
             Main.npcs[num388].ai[0] = -1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].netUpdate = true;
             num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 129, npc.whoAmI);
             Main.npcs[num388].ai[0] = 1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].netUpdate = true;
             num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 130, npc.whoAmI);
             Main.npcs[num388].ai[0] = -1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].ai[3] = 150f;
             Main.npcs[num388].netUpdate = true;
             num388 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 131, npc.whoAmI);
             Main.npcs[num388].ai[0] = 1f;
             Main.npcs[num388].ai[1] = (float)npc.whoAmI;
             Main.npcs[num388].target = npc.target;
             Main.npcs[num388].netUpdate = true;
             Main.npcs[num388].ai[3] = 150f;
         }
     }
     if (npc.Type == 68 && npc.ai[1] != 3f && npc.ai[1] != 2f)
     {
         npc.ai[1] = 2f;
     }
     if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 6000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 6000f)
     {
         npc.TargetClosest(true);
         if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 6000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 6000f)
         {
             npc.ai[1] = 3f;
         }
     }
     if (Main.dayTime && npc.ai[1] != 3f && npc.ai[1] != 2f)
     {
         npc.ai[1] = 2f;
     }
     if (npc.ai[1] == 0f)
     {
         npc.ai[2] += 1f;
         if (npc.ai[2] >= 600f)
         {
             npc.ai[2] = 0f;
             npc.ai[1] = 1f;
             npc.TargetClosest(true);
             npc.netUpdate = true;
         }
         npc.rotation = npc.Velocity.X / 15f;
         if (npc.Position.Y > Main.players[npc.target].Position.Y - 200f)
         {
             if (npc.Velocity.Y > 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y * 0.98f;
             }
             npc.Velocity.Y = npc.Velocity.Y - 0.1f;
             if (npc.Velocity.Y > 2f)
             {
                 npc.Velocity.Y = 2f;
             }
         }
         else
         {
             if (npc.Position.Y < Main.players[npc.target].Position.Y - 500f)
             {
                 if (npc.Velocity.Y < 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                 }
                 npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                 if (npc.Velocity.Y < -2f)
                 {
                     npc.Velocity.Y = -2f;
                 }
             }
         }
         if (npc.Position.X + (float)(npc.Width / 2) > Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) + 100f)
         {
             if (npc.Velocity.X > 0f)
             {
                 npc.Velocity.X = npc.Velocity.X * 0.98f;
             }
             npc.Velocity.X = npc.Velocity.X - 0.1f;
             if (npc.Velocity.X > 8f)
             {
                 npc.Velocity.X = 8f;
             }
         }
         if (npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - 100f)
         {
             if (npc.Velocity.X < 0f)
             {
                 npc.Velocity.X = npc.Velocity.X * 0.98f;
             }
             npc.Velocity.X = npc.Velocity.X + 0.1f;
             if (npc.Velocity.X < -8f)
             {
                 npc.Velocity.X = -8f;
                 return;
             }
         }
     }
     else
     {
         if (npc.ai[1] == 1f)
         {
             npc.defense *= 2;
             npc.damage *= 2;
             npc.ai[2] += 1f;
             if (npc.ai[2] >= 400f)
             {
                 npc.ai[2] = 0f;
                 npc.ai[1] = 0f;
             }
             npc.rotation += (float)npc.direction * 0.3f;
             Vector2 vector40 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
             float num389 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector40.X;
             float num390 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector40.Y;
             float num391 = (float)Math.Sqrt((double)(num389 * num389 + num390 * num390));
             num391 = 2f / num391;
             npc.Velocity.X = num389 * num391;
             npc.Velocity.Y = num390 * num391;
             return;
         }
         if (npc.ai[1] == 2f)
         {
             npc.damage = 9999;
             npc.defense = 9999;
             npc.rotation += (float)npc.direction * 0.3f;
             Vector2 vector41 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
             float num392 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector41.X;
             float num393 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector41.Y;
             float num394 = (float)Math.Sqrt((double)(num392 * num392 + num393 * num393));
             num394 = 8f / num394;
             npc.Velocity.X = num392 * num394;
             npc.Velocity.Y = num393 * num394;
             return;
         }
         if (npc.ai[1] == 3f)
         {
             npc.Velocity.Y = npc.Velocity.Y + 0.1f;
             if (npc.Velocity.Y < 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y * 0.95f;
             }
             npc.Velocity.X = npc.Velocity.X * 0.95f;
             if (npc.timeLeft > 500)
             {
                 npc.timeLeft = 500;
                 return;
             }
         }
     }
 }
예제 #15
0
        // 11
        private void AISkeletronHead(NPC npc, bool flag)
        {
            if (npc.ai[0] == 0f)
            {
                npc.TargetClosest(true);
                npc.ai[0] = 1f;
                if (npc.Type != 68)
                {
                    int num116 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 36, npc.whoAmI);
                    Main.npcs[num116].ai[0] = -1f;
                    Main.npcs[num116].ai[1] = (float)npc.whoAmI;
                    Main.npcs[num116].target = npc.target;
                    Main.npcs[num116].netUpdate = true;
                    num116 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)npc.Position.Y + npc.Height / 2, 36, npc.whoAmI);
                    Main.npcs[num116].ai[0] = 1f;
                    Main.npcs[num116].ai[1] = (float)npc.whoAmI;
                    Main.npcs[num116].ai[3] = 150f;
                    Main.npcs[num116].target = npc.target;
                    Main.npcs[num116].netUpdate = true;
                }
            }
            if (npc.Type == 68 && npc.ai[1] != 3f && npc.ai[1] != 2f)
            {
                npc.ai[1] = 2f;
            }
            if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 2000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 2000f)
            {
                npc.TargetClosest(true);
                if (Main.players[npc.target].dead || Math.Abs(npc.Position.X - Main.players[npc.target].Position.X) > 2000f || Math.Abs(npc.Position.Y - Main.players[npc.target].Position.Y) > 2000f)
                {
                    npc.ai[1] = 3f;
                }
            }
            if (Main.dayTime && npc.ai[1] != 3f && npc.ai[1] != 2f)
            {
                npc.ai[1] = 2f;
            }
            if (npc.ai[1] == 0f)
            {
                npc.defense = 10;
                npc.ai[2] += 1f;
                if (npc.ai[2] >= 800f)
                {
                    npc.ai[2] = 0f;
                    npc.ai[1] = 1f;
                    npc.TargetClosest(true);
                    npc.netUpdate = true;
                }
                npc.rotation = npc.Velocity.X / 15f;
                if (npc.Position.Y > Main.players[npc.target].Position.Y - 250f)
                {
                    if (npc.Velocity.Y > 0f)
                    {
                        npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                    }
                    npc.Velocity.Y = npc.Velocity.Y - 0.02f;
                    if (npc.Velocity.Y > 2f)
                    {
                        npc.Velocity.Y = 2f;
                    }
                }
                else
                {
                    if (npc.Position.Y < Main.players[npc.target].Position.Y - 250f)
                    {
                        if (npc.Velocity.Y < 0f)
                        {
                            npc.Velocity.Y = npc.Velocity.Y * 0.98f;
                        }
                        npc.Velocity.Y = npc.Velocity.Y + 0.02f;
                        if (npc.Velocity.Y < -2f)
                        {
                            npc.Velocity.Y = -2f;
                        }
                    }
                }
                if (npc.Position.X + (float)(npc.Width / 2) > Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2))
                {
                    if (npc.Velocity.X > 0f)
                    {
                        npc.Velocity.X = npc.Velocity.X * 0.98f;
                    }
                    npc.Velocity.X = npc.Velocity.X - 0.05f;
                    if (npc.Velocity.X > 8f)
                    {
                        npc.Velocity.X = 8f;
                    }
                }
                if (npc.Position.X + (float)(npc.Width / 2) < Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2))
                {
                    if (npc.Velocity.X < 0f)
                    {
                        npc.Velocity.X = npc.Velocity.X * 0.98f;
                    }
                    npc.Velocity.X = npc.Velocity.X + 0.05f;
                    if (npc.Velocity.X < -8f)
                    {
                        npc.Velocity.X = -8f;
                    }
                }
            }
            else
            {
                if (npc.ai[1] == 1f)
                {
                    npc.defense = 0;
                    npc.ai[2] += 1f;

                    if (npc.ai[2] >= 400f)
                    {
                        npc.ai[2] = 0f;
                        npc.ai[1] = 0f;
                    }
                    npc.rotation += (float)npc.direction * 0.3f;
                    Vector2 vector13 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                    float num117 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector13.X;
                    float num118 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector13.Y;
                    float num119 = (float)Math.Sqrt((double)(num117 * num117 + num118 * num118));
                    num119 = 1.5f / num119;
                    npc.Velocity.X = num117 * num119;
                    npc.Velocity.Y = num118 * num119;
                }
                else
                {
                    if (npc.ai[1] == 2f)
                    {
                        npc.damage = 9999;
                        npc.defense = 9999;
                        npc.rotation += (float)npc.direction * 0.3f;
                        Vector2 vector14 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                        float num120 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector14.X;
                        float num121 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector14.Y;
                        float num122 = (float)Math.Sqrt((double)(num120 * num120 + num121 * num121));
                        num122 = 8f / num122;
                        npc.Velocity.X = num120 * num122;
                        npc.Velocity.Y = num121 * num122;
                    }
                    else
                    {
                        if (npc.ai[1] == 3f)
                        {
                            npc.Velocity.Y = npc.Velocity.Y + 0.1f;
                            if (npc.Velocity.Y < 0f)
                            {
                                npc.Velocity.Y = npc.Velocity.Y * 0.95f;
                            }
                            npc.Velocity.X = npc.Velocity.X * 0.95f;
                            if (npc.timeLeft > 500)
                            {
                                npc.timeLeft = 500;
                            }
                        }
                    }
                }
            }
            if (npc.ai[1] != 2f && npc.ai[1] != 3f && npc.Type != 68)
            {
                return;
            }
        }
예제 #16
0
        // 27
        private void AIWallOfFlesh(NPC npc, bool flag)
        {
            if (npc.Position.X < 160f || npc.Position.X > (float)((Main.maxTilesX - 10) * 16))
                npc.Active = false;

            if (npc.localAI[0] == 0f)
            {
                npc.localAI[0] = 1f;
                Main.WallOfFlesh_B = -1;
                Main.WallOfFlesh_T = -1;
            }
            npc.ai[1] += 1f;

            if (npc.ai[2] == 0f)
            {
                if ((double)npc.life < (double)npc.lifeMax * 0.5)
                    npc.ai[1] += 1f;

                if ((double)npc.life < (double)npc.lifeMax * 0.2)
                    npc.ai[1] += 1f;

                if (npc.ai[1] > 2700f)
                    npc.ai[2] = 1f;
            }
            if (npc.ai[2] > 0f && npc.ai[1] > 60f)
            {
                int num285 = 3;
                if ((double)npc.life < (double)npc.lifeMax * 0.3)
                    num285++;

                npc.ai[2] += 1f;
                npc.ai[1] = 0f;
                if (npc.ai[2] > (float)num285)
                    npc.ai[2] = 0f;

                int num286 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)(npc.Position.Y + (float)(npc.Height / 2) + 20f), 117, 1);
                Main.npcs[num286].Velocity.X = (float)(npc.direction * 8);
            }
            npc.localAI[3] += 1f;
            if (npc.localAI[3] >= (float)(600 + Main.rand.Next(1000)))
            {
                npc.localAI[3] = (float)(-(float)Main.rand.Next(200));
            }
            Main.WallOfFlesh = npc.whoAmI;
            int num287 = (int)(npc.Position.X / 16f);
            int num288 = (int)((npc.Position.X + (float)npc.Width) / 16f);
            int num289 = (int)((npc.Position.Y + (float)(npc.Height / 2)) / 16f);
            int num290 = 0;
            int tileY = num289 + 7;
            while (num290 < 15 && tileY > Main.maxTilesY - 200)
            {
                tileY++;
                for (int num292 = num287; num292 <= num288; num292++)
                {
                    try
                    {
                        if (WorldModify.SolidTile(num292, tileY) || Main.tile.At(num292, tileY).Liquid > 0)
                            num290++;
                    }
                    catch
                    {
                        num290 += 15;
                    }
                }
            }
            tileY += 4;

            if (Main.WallOfFlesh_B == -1)
                Main.WallOfFlesh_B = tileY * 16;
            else if (Main.WallOfFlesh_B > tileY * 16)
            {
                Main.WallOfFlesh_B--;
                if (Main.WallOfFlesh_B < tileY * 16)
                    Main.WallOfFlesh_B = tileY * 16;
            }
            else if (Main.WallOfFlesh_B < tileY * 16)
            {
                Main.WallOfFlesh_B++;
                if (Main.WallOfFlesh_B > tileY * 16)
                {
                    Main.WallOfFlesh_B = tileY * 16;
                }
            }
            num290 = 0;
            tileY = num289 - 7;
            while (num290 < 15 && tileY < Main.maxTilesY - 10)
            {
                tileY--;
                for (int tileX = num287; tileX <= num288; tileX++)
                {
                    try
                    {
                        if (WorldModify.SolidTile(tileX, tileY) || Main.tile.At(tileX, tileY).Liquid > 0)
                        {
                            num290++;
                        }
                    }
                    catch
                    {
                        num290 += 15;
                    }
                }
            }
            tileY -= 4;

            if (Main.WallOfFlesh_T == -1)
                Main.WallOfFlesh_T = tileY * 16;

            else if (Main.WallOfFlesh_T > tileY * 16)
            {
                Main.WallOfFlesh_T--;

                if (Main.WallOfFlesh_T < tileY * 16)
                    Main.WallOfFlesh_T = tileY * 16;
            }
            else if (Main.WallOfFlesh_T < tileY * 16)
            {
                Main.WallOfFlesh_T++;

                if (Main.WallOfFlesh_T > tileY * 16)
                    Main.WallOfFlesh_T = tileY * 16;
            }

            float num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2 - npc.Height / 2);
            if (npc.Position.Y > num294 + 1f)
                npc.Velocity.Y = -1f;
            else if (npc.Position.Y < num294 - 1f)
                    npc.Velocity.Y = 1f;

            npc.Velocity.Y = 0f;
            npc.Position.Y = num294;

            float num295 = 1.5f;
            if ((double)npc.life < (double)npc.lifeMax * 0.75)
            {
                num295 += 0.25f;
            }
            if ((double)npc.life < (double)npc.lifeMax * 0.5)
                num295 += 0.4f;

            if ((double)npc.life < (double)npc.lifeMax * 0.25)
                num295 += 0.5f;

            if ((double)npc.life < (double)npc.lifeMax * 0.1)
                num295 += 0.6f;

            if (npc.Velocity.X == 0f)
            {
                npc.TargetClosest(true);
                npc.Velocity.X = (float)npc.direction;
            }
            if (npc.Velocity.X < 0f)
            {
                npc.Velocity.X = -num295;
                npc.direction = -1;
            }
            else
            {
                npc.Velocity.X = num295;
                npc.direction = 1;
            }
            npc.spriteDirection = npc.direction;
            Vector2 vector29 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
            float num296 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector29.X;
            float num297 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector29.Y;
            float num298 = (float)Math.Sqrt((double)(num296 * num296 + num297 * num297));
            num296 *= num298;
            num297 *= num298;
            if (npc.direction > 0)
            {
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) > npc.Position.X + (float)(npc.Width / 2))
                    npc.rotation = (float)Math.Atan2((double)(-(double)num297), (double)(-(double)num296)) + 3.14f;
                else
                    npc.rotation = 0f;
            }
            else
            {
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) < npc.Position.X + (float)(npc.Width / 2))
                    npc.rotation = (float)Math.Atan2((double)num297, (double)num296) + 3.14f;
                else
                    npc.rotation = 0f;
            }
            if (npc.localAI[0] == 1f)
            {
                npc.localAI[0] = 2f;
                num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2);
                num294 = (num294 + (float)Main.WallOfFlesh_T) / 2f;
                int num299 = NPC.NewNPC((int)npc.Position.X, (int)num294, 114, npc.whoAmI);
                Main.npcs[num299].ai[0] = 1f;
                num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2);
                num294 = (num294 + (float)Main.WallOfFlesh_B) / 2f;
                num299 = NPC.NewNPC((int)npc.Position.X, (int)num294, 114, npc.whoAmI);
                Main.npcs[num299].ai[0] = -1f;
                num294 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2);
                num294 = (num294 + (float)Main.WallOfFlesh_B) / 2f;
                for (int num300 = 0; num300 < 11; num300++)
                {
                    num299 = NPC.NewNPC((int)npc.Position.X, (int)num294, 115, npc.whoAmI);
                    Main.npcs[num299].ai[0] = (float)num300 * 0.1f - 0.05f;
                }
                return;
            }
        }
예제 #17
0
        // 28
        private void AIWallOfFlesh_Eye(NPC npc, bool flag)
        {
            if (Main.WallOfFlesh < 0)
            {
                npc.Active = false;
                return;
            }

            npc.realLife = Main.WallOfFlesh;
            npc.TargetClosest(true);
            npc.Position.X = Main.npcs[Main.WallOfFlesh].Position.X;
            npc.direction = Main.npcs[Main.WallOfFlesh].direction;
            npc.spriteDirection = npc.direction;
            float num301 = (float)((Main.WallOfFlesh_B + Main.WallOfFlesh_T) / 2);
            if (npc.ai[0] > 0f)
            {
                num301 = (num301 + (float)Main.WallOfFlesh_T) / 2f;
            }
            else
            {
                num301 = (num301 + (float)Main.WallOfFlesh_B) / 2f;
            }
            num301 -= (float)(npc.Height / 2);
            if (npc.Position.Y > num301 + 1f)
            {
                npc.Velocity.Y = -1f;
            }
            else
            {
                if (npc.Position.Y < num301 - 1f)
                {
                    npc.Velocity.Y = 1f;
                }
                else
                {
                    npc.Velocity.Y = 0f;
                    npc.Position.Y = num301;
                }
            }
            if (npc.Velocity.Y > 5f)
            {
                npc.Velocity.Y = 5f;
            }
            if (npc.Velocity.Y < -5f)
            {
                npc.Velocity.Y = -5f;
            }
            Vector2 vector30 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
            float num302 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector30.X;
            float num303 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector30.Y;
            float num304 = (float)Math.Sqrt((double)(num302 * num302 + num303 * num303));
            num302 *= num304;
            num303 *= num304;
            bool flag33 = true;
            if (npc.direction > 0)
            {
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) > npc.Position.X + (float)(npc.Width / 2))
                {
                    npc.rotation = (float)Math.Atan2((double)(-(double)num303), (double)(-(double)num302)) + 3.14f;
                }
                else
                {
                    npc.rotation = 0f;
                    flag33 = false;
                }
            }
            else
            {
                if (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) < npc.Position.X + (float)(npc.Width / 2))
                {
                    npc.rotation = (float)Math.Atan2((double)num303, (double)num302) + 3.14f;
                }
                else
                {
                    npc.rotation = 0f;
                    flag33 = false;
                }
            }
            int num305 = 4;
            npc.localAI[1] += 1f;
            if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.75)
            {
                npc.localAI[1] += 1f;
                num305++;
            }
            if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.5)
            {
                npc.localAI[1] += 1f;
                num305++;
            }
            if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.25)
            {
                npc.localAI[1] += 1f;
                num305 += 2;
            }
            if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.1)
            {
                npc.localAI[1] += 2f;
                num305 += 3;
            }
            if (npc.localAI[2] == 0f)
            {
                if (npc.localAI[1] > 600f)
                {
                    npc.localAI[2] = 1f;
                    npc.localAI[1] = 0f;
                    return;
                }
            }
            else
            {
                if (npc.localAI[1] > 45f && Collision.CanHit(npc.Position, npc.Width, npc.Height, Main.players[npc.target].Position, Main.players[npc.target].Width, Main.players[npc.target].Height))
                {
                    npc.localAI[1] = 0f;
                    npc.localAI[2] += 1f;
                    if (npc.localAI[2] >= (float)num305)
                    {
                        npc.localAI[2] = 0f;
                    }
                    if (flag33)
                    {
                        float num306 = 9f;
                        int num307 = 11;
                        int num308 = 83;
                        if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.5)
                        {
                            num307++;
                            num306 += 1f;
                        }
                        if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.25)
                        {
                            num307++;
                            num306 += 1f;
                        }
                        if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.1)
                        {
                            num307 += 2;
                            num306 += 2f;
                        }
                        vector30 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
                        num302 = Main.players[npc.target].Position.X + (float)Main.players[npc.target].Width * 0.5f - vector30.X;
                        num303 = Main.players[npc.target].Position.Y + (float)Main.players[npc.target].Height * 0.5f - vector30.Y;
                        num304 = (float)Math.Sqrt((double)(num302 * num302 + num303 * num303));
                        num304 = num306 / num304;
                        num302 *= num304;
                        num303 *= num304;
                        vector30.X += num302;
                        vector30.Y += num303;
                        Projectile.NewProjectile(vector30.X, vector30.Y, num302, num303, num308, num307, 0f, Main.myPlayer);
                        return;
                    }
                }
            }
        }
예제 #18
0
 // 20
 private void AISpikedBall(NPC npc, bool flag)
 {
     if (npc.ai[0] == 0f)
     {
         npc.TargetClosest(true);
         npc.direction *= -1;
         npc.directionY *= -1;
         npc.Position.Y = npc.Position.Y + (float)(npc.Height / 2 + 8);
         npc.ai[1] = npc.Position.X + (float)(npc.Width / 2);
         npc.ai[2] = npc.Position.Y + (float)(npc.Height / 2);
         if (npc.direction == 0)
         {
             npc.direction = 1;
         }
         if (npc.directionY == 0)
         {
             npc.directionY = 1;
         }
         npc.ai[3] = 1f + (float)Main.rand.Next(15) * 0.1f;
         npc.Velocity.Y = (float)(npc.directionY * 6) * npc.ai[3];
         npc.ai[0] += 1f;
         npc.netUpdate = true;
         return;
     }
     else
     {
         float num186 = 6f * npc.ai[3];
         float num187 = 0.2f * npc.ai[3];
         float num188 = num186 / num187 / 2f;
         if (npc.ai[0] >= 1f && npc.ai[0] < (float)((int)num188))
         {
             npc.Velocity.Y = (float)npc.directionY * num186;
             npc.ai[0] += 1f;
             return;
         }
         if (npc.ai[0] >= (float)((int)num188))
         {
             npc.netUpdate = true;
             npc.Velocity.Y = 0f;
             npc.directionY *= -1;
             npc.Velocity.X = num186 * (float)npc.direction;
             npc.ai[0] = -1f;
             return;
         }
         if (npc.directionY > 0)
         {
             if (npc.Velocity.Y >= num186)
             {
                 npc.netUpdate = true;
                 npc.directionY *= -1;
                 npc.Velocity.Y = num186;
             }
         }
         else
         {
             if (npc.directionY < 0 && npc.Velocity.Y <= -num186)
             {
                 npc.directionY *= -1;
                 npc.Velocity.Y = -num186;
             }
         }
         if (npc.direction > 0)
         {
             if (npc.Velocity.X >= num186)
             {
                 npc.direction *= -1;
                 npc.Velocity.X = num186;
             }
         }
         else
         {
             if (npc.direction < 0 && npc.Velocity.X <= -num186)
             {
                 npc.direction *= -1;
                 npc.Velocity.X = -num186;
             }
         }
         npc.Velocity.X = npc.Velocity.X + num187 * (float)npc.direction;
         npc.Velocity.Y = npc.Velocity.Y + num187 * (float)npc.directionY;
         return;
     }
 }
예제 #19
0
 // 6
 private void AIWorm(NPC npc, bool flag)
 {
     if (npc.target < 0 || npc.target == 255 || Main.players[npc.target].dead)
     {
         npc.TargetClosest(true);
     }
     if (Main.players[npc.target].dead && npc.timeLeft > 10)
     {
         npc.timeLeft = 10;
     }
     if ((npc.Type == 7 || npc.Type == 8 || npc.Type == 10 || npc.Type == 11 || npc.Type == 13 || npc.Type == 14 || npc.Type == 39 || npc.Type == 40) && npc.ai[0] == 0f)
     {
         if (npc.Type == 7 || npc.Type == 10 || npc.Type == 13 || npc.Type == 39)
         {
             npc.ai[2] = (float)Main.rand.Next(8, 13);
             if (npc.Type == 10)
             {
                 npc.ai[2] = (float)Main.rand.Next(4, 7);
             }
             if (npc.Type == 13)
             {
                 npc.ai[2] = (float)Main.rand.Next(45, 56);
             }
             if (npc.Type == 39)
             {
                 npc.ai[2] = (float)Main.rand.Next(12, 19);
             }
             npc.ai[0] = (float)NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)(npc.Position.Y + (float)npc.Height), npc.Type + 1, npc.whoAmI);
         }
         else
         {
             if ((npc.Type == 8 || npc.Type == 11 || npc.Type == 14 || npc.Type == 40) && npc.ai[2] > 0f)
             {
                 npc.ai[0] = (float)NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)(npc.Position.Y + (float)npc.Height), npc.Type, npc.whoAmI);
             }
             else
             {
                 npc.ai[0] = (float)NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)(npc.Position.Y + (float)npc.Height), npc.Type + 1, npc.whoAmI);
             }
         }
         Main.npcs[(int)npc.ai[0]].ai[1] = (float)npc.whoAmI;
         Main.npcs[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f;
         npc.netUpdate = true;
     }
     if ((npc.Type == 8 || npc.Type == 9 || npc.Type == 11 || npc.Type == 12 || npc.Type == 40 || npc.Type == 41) && (!Main.npcs[(int)npc.ai[1]].Active || Main.npcs[(int)npc.ai[1]].aiStyle != npc.aiStyle))
     {
         npc.life = 0;
         npc.HitEffect(0, 10.0);
         npc.Active = false;
     }
     if ((npc.Type == 7 || npc.Type == 8 || npc.Type == 10 || npc.Type == 11 || npc.Type == 39 || npc.Type == 40) && !Main.npcs[(int)npc.ai[0]].Active)
     {
         npc.life = 0;
         npc.HitEffect(0, 10.0);
         npc.Active = false;
     }
     if (npc.type == NPCType.N13_EATER_OF_WORLDS_HEAD || npc.type == NPCType.N14_EATER_OF_WORLDS_BODY || npc.type == NPCType.N15_EATER_OF_WORLDS_TAIL)
     {
         //If this segment has no segment before or after it, DIE!
         if (!Main.npcs[(int)npc.ai[1]].Active && !Main.npcs[(int)npc.ai[0]].Active)
         {
             npc.life = 0;
             npc.HitEffect(0, 10.0);
             npc.Active = false;
         }
         //If we are a head connected to nothing, DIE!
         if (npc.type == NPCType.N13_EATER_OF_WORLDS_HEAD && !Main.npcs[(int)npc.ai[0]].Active)
         {
             npc.life = 0;
             npc.HitEffect(0, 10.0);
             npc.Active = false;
         }
         //If we are a tail connected to nothing, DIE!
         if (npc.type == NPCType.N15_EATER_OF_WORLDS_TAIL && !Main.npcs[(int)npc.ai[1]].Active)
         {
             npc.life = 0;
             npc.HitEffect(0, 10.0);
             npc.Active = false;
         }
         //If the next segment forward has died, become a head
         if (npc.type == NPCType.N14_EATER_OF_WORLDS_BODY && !Main.npcs[(int)npc.ai[1]].Active)
         {
             npc.type = NPCType.N13_EATER_OF_WORLDS_HEAD;
             int num52 = npc.whoAmI;
             float num53 = (float)npc.life / (float)npc.lifeMax;
             float num54 = npc.ai[0];
             //npc.SetDefaults(npc.Type, -1f);
             //npc = Registries.NPC.Create(npc.Type); WTF!?
             Registries.NPC.SetDefaults(npc, 13); //FIXME: remember to tweak
             npc.Active = true;
             npc.life = (int)((float)npc.lifeMax * num53);
             npc.ai[0] = num54;
             npc.TargetClosest(true);
             npc.netUpdate = true;
             npc.whoAmI = num52;
         }
         //If the next segment behind us has died, become a tail
         if (npc.type == NPCType.N14_EATER_OF_WORLDS_BODY && !Main.npcs[(int)npc.ai[0]].Active)
         {
             npc.type = NPCType.N15_EATER_OF_WORLDS_TAIL;
             int num55 = npc.whoAmI;
             float num56 = (float)npc.life / (float)npc.lifeMax;
             float num57 = npc.ai[1];
             //npc.SetDefaults(npc.Type, -1f);
             //npc = Registries.NPC.Create(npc.Type);
             Registries.NPC.SetDefaults(npc, 14); //FIXME: remember to tweak
             npc.Active = true;
             npc.life = (int)((float)npc.lifeMax * num56);
             npc.ai[1] = num57;
             npc.TargetClosest(true);
             npc.netUpdate = true;
             npc.whoAmI = num55;
         }
         if (npc.life == 0)
         {
             bool flag6 = true;
             for (int l = 0; l < MAX_NPCS; l++)
             {
                 if (Main.npcs[l].Active && (Main.npcs[l].type == NPCType.N13_EATER_OF_WORLDS_HEAD ||
                                              Main.npcs[l].type == NPCType.N14_EATER_OF_WORLDS_BODY ||
                                              Main.npcs[l].type == NPCType.N15_EATER_OF_WORLDS_TAIL))
                 {
                     flag6 = false;
                     break;
                 }
             }
             if (flag6)
             {
                 npc.boss = true;
                 npc.NPCLoot();
             }
         }
     }
     if (!npc.Active)
     {
         NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0f, 0f, 0);
     }
     int num58 = (int)(npc.Position.X / 16f) - 1;
     int num59 = (int)((npc.Position.X + (float)npc.Width) / 16f) + 2;
     int num60 = (int)(npc.Position.Y / 16f) - 1;
     int num61 = (int)((npc.Position.Y + (float)npc.Height) / 16f) + 2;
     if (num58 < 0)
     {
         num58 = 0;
     }
     if (num59 > Main.maxTilesX)
     {
         num59 = Main.maxTilesX;
     }
     if (num60 < 0)
     {
         num60 = 0;
     }
     if (num61 > Main.maxTilesY)
     {
         num61 = Main.maxTilesY;
     }
     bool flag7 = false;
     for (int m = num58; m < num59; m++)
     {
         for (int n = num60; n < num61; n++)
         {
             if (Main.tile.At(m, n).Exists && ((Main.tile.At(m, n).Active && (Main.tileSolid[(int)Main.tile.At(m, n).Type] || (Main.tileSolidTop[(int)Main.tile.At(m, n).Type] && Main.tile.At(m, n).FrameY == 0))) || Main.tile.At(m, n).Liquid > 64))
             {
                 Vector2 vector9;
                 vector9.X = (float)(m * 16);
                 vector9.Y = (float)(n * 16);
                 if (npc.Position.X + (float)npc.Width > vector9.X && npc.Position.X < vector9.X + 16f && npc.Position.Y + (float)npc.Height > vector9.Y && npc.Position.Y < vector9.Y + 16f)
                 {
                     flag7 = true;
                     if (Main.rand.Next(40) == 0 && Main.tile.At(m, n).Active)
                     {
                         WorldModify.KillTile(m, n, true, true, false);
                     }
                     //if (Main.tile.At(m, n).Type == 2)
                     //{
                     //    byte arg_4656_0 = Main.tile.At(m, n - 1).Type;
                     //}
                 }
             }
         }
     }
     if (!flag7 && (npc.Type == 7 || npc.Type == 10 || npc.Type == 13 || npc.Type == 39))
     {
         Rectangle rectangle = new Rectangle((int)npc.Position.X, (int)npc.Position.Y, npc.Width, npc.Height);
         int num62 = 1000;
         bool flag8 = true;
         for (int num63 = 0; num63 < 255; num63++)
         {
             if (Main.players[num63].Active)
             {
                 Rectangle rectangle2 = new Rectangle((int)Main.players[num63].Position.X - num62, (int)Main.players[num63].Position.Y - num62, num62 * 2, num62 * 2);
                 if (rectangle.Intersects(rectangle2))
                 {
                     flag8 = false;
                     break;
                 }
             }
         }
         if (flag8)
         {
             flag7 = true;
         }
     }
     float num64 = 8f;
     float num65 = 0.07f;
     if (npc.Type == 10)
     {
         num64 = 6f;
         num65 = 0.05f;
     }
     if (npc.Type == 13)
     {
         num64 = 10f;
         num65 = 0.07f;
     }
     Vector2 vector10 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
     float num66 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector10.X;
     float num67 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector10.Y;
     float num68 = (float)Math.Sqrt((double)(num66 * num66 + num67 * num67));
     if (npc.ai[1] > 0f)
     {
         num66 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - vector10.X;
         num67 = Main.npcs[(int)npc.ai[1]].Position.Y + (float)(Main.npcs[(int)npc.ai[1]].Height / 2) - vector10.Y;
         npc.rotation = (float)Math.Atan2((double)num67, (double)num66) + 1.57f;
         num68 = (float)Math.Sqrt((double)(num66 * num66 + num67 * num67));
         num68 = (num68 - (float)npc.Width) / num68;
         num66 *= num68;
         num67 *= num68;
         npc.Velocity = default(Vector2);
         npc.Position.X = npc.Position.X + num66;
         npc.Position.Y = npc.Position.Y + num67;
         return;
     }
     if (!flag7)
     {
         npc.TargetClosest(true);
         npc.Velocity.Y = npc.Velocity.Y + 0.11f;
         if (npc.Velocity.Y > num64)
         {
             npc.Velocity.Y = num64;
         }
         if ((double)(Math.Abs(npc.Velocity.X) + Math.Abs(npc.Velocity.Y)) < (double)num64 * 0.4)
         {
             if (npc.Velocity.X < 0f)
             {
                 npc.Velocity.X = npc.Velocity.X - num65 * 1.1f;
             }
             else
             {
                 npc.Velocity.X = npc.Velocity.X + num65 * 1.1f;
             }
         }
         else
         {
             if (npc.Velocity.Y == num64)
             {
                 if (npc.Velocity.X < num66)
                 {
                     npc.Velocity.X = npc.Velocity.X + num65;
                 }
                 else
                 {
                     if (npc.Velocity.X > num66)
                     {
                         npc.Velocity.X = npc.Velocity.X - num65;
                     }
                 }
             }
             else
             {
                 if (npc.Velocity.Y > 4f)
                 {
                     if (npc.Velocity.X < 0f)
                     {
                         npc.Velocity.X = npc.Velocity.X + num65 * 0.9f;
                     }
                     else
                     {
                         npc.Velocity.X = npc.Velocity.X - num65 * 0.9f;
                     }
                 }
             }
         }
     }
     else
     {
         if (npc.soundDelay == 0)
         {
             float num69 = num68 / 40f;
             if (num69 < 10f)
             {
                 num69 = 10f;
             }
             if (num69 > 20f)
             {
                 num69 = 20f;
             }
             npc.soundDelay = (int)num69;
         }
         num68 = (float)Math.Sqrt((double)(num66 * num66 + num67 * num67));
         float num70 = Math.Abs(num66);
         float num71 = Math.Abs(num67);
         num68 = num64 / num68;
         num66 *= num68;
         num67 *= num68;
         if ((npc.Type == 13 || npc.Type == 7) && !Main.players[npc.target].zoneEvil)
         {
             bool flag9 = true;
             for (int num72 = 0; num72 < 255; num72++)
             {
                 if (Main.players[num72].Active && !Main.players[num72].dead && Main.players[num72].zoneEvil)
                 {
                     flag9 = false;
                 }
             }
             if (flag9)
             {
                 if ((double)(npc.Position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0)
                 {
                     npc.Active = false;
                     int num73 = (int)npc.ai[0];
                     while (num73 > 0 && num73 < MAX_NPCS && Main.npcs[num73].Active && Main.npcs[num73].aiStyle == npc.aiStyle)
                     {
                         int num74 = (int)Main.npcs[num73].ai[0];
                         Main.npcs[num73].Active = false;
                         npc.life = 0;
                         NetMessage.SendData(23, -1, -1, "", num73, 0f, 0f, 0f, 0);
                         num73 = num74;
                     }
                     NetMessage.SendData(23, -1, -1, "", npc.whoAmI, 0f, 0f, 0f, 0);
                 }
                 num66 = 0f;
                 num67 = num64;
             }
         }
         if ((npc.Velocity.X > 0f && num66 > 0f) || (npc.Velocity.X < 0f && num66 < 0f) || (npc.Velocity.Y > 0f && num67 > 0f) || (npc.Velocity.Y < 0f && num67 < 0f))
         {
             if (npc.Velocity.X < num66)
             {
                 npc.Velocity.X = npc.Velocity.X + num65;
             }
             else
             {
                 if (npc.Velocity.X > num66)
                 {
                     npc.Velocity.X = npc.Velocity.X - num65;
                 }
             }
             if (npc.Velocity.Y < num67)
             {
                 npc.Velocity.Y = npc.Velocity.Y + num65;
             }
             else
             {
                 if (npc.Velocity.Y > num67)
                 {
                     npc.Velocity.Y = npc.Velocity.Y - num65;
                 }
             }
         }
         else
         {
             if (num70 > num71)
             {
                 if (npc.Velocity.X < num66)
                 {
                     npc.Velocity.X = npc.Velocity.X + num65 * 1.1f;
                 }
                 else
                 {
                     if (npc.Velocity.X > num66)
                     {
                         npc.Velocity.X = npc.Velocity.X - num65 * 1.1f;
                     }
                 }
                 if ((double)(Math.Abs(npc.Velocity.X) + Math.Abs(npc.Velocity.Y)) < (double)num64 * 0.5)
                 {
                     if (npc.Velocity.Y > 0f)
                     {
                         npc.Velocity.Y = npc.Velocity.Y + num65;
                     }
                     else
                     {
                         npc.Velocity.Y = npc.Velocity.Y - num65;
                     }
                 }
             }
             else
             {
                 if (npc.Velocity.Y < num67)
                 {
                     npc.Velocity.Y = npc.Velocity.Y + num65 * 1.1f;
                 }
                 else
                 {
                     if (npc.Velocity.Y > num67)
                     {
                         npc.Velocity.Y = npc.Velocity.Y - num65 * 1.1f;
                     }
                 }
                 if ((double)(Math.Abs(npc.Velocity.X) + Math.Abs(npc.Velocity.Y)) < (double)num64 * 0.5)
                 {
                     if (npc.Velocity.X > 0f)
                     {
                         npc.Velocity.X = npc.Velocity.X + num65;
                     }
                     else
                     {
                         npc.Velocity.X = npc.Velocity.X - num65;
                     }
                 }
             }
         }
     }
     npc.rotation = (float)Math.Atan2((double)npc.Velocity.Y, (double)npc.Velocity.X) + 1.57f;
     return;
 }
예제 #20
0
 // 37
 private void AITheDestroyer(NPC npc, bool flag)
 {
     if (npc.ai[3] > 0f)
     {
         npc.realLife = (int)npc.ai[3];
     }
     if (npc.target < 0 || npc.target == 255 || Main.players[npc.target].dead)
     {
         npc.TargetClosest(true);
     }
     if (npc.Type > 134)
     {
         bool flag34 = false;
         if (npc.ai[1] <= 0f)
         {
             flag34 = true;
         }
         else
         {
             if (Main.npcs[(int)npc.ai[1]].life <= 0)
             {
                 flag34 = true;
             }
         }
         if (flag34)
         {
             npc.life = 0;
             npc.HitEffect(0, 10.0);
             npc.checkDead();
         }
     }
     if (npc.ai[0] == 0f && npc.Type == 134)
     {
         npc.ai[3] = (float)npc.whoAmI;
         npc.realLife = npc.whoAmI;
         int num447 = npc.whoAmI;
         int num448 = 80;
         for (int num449 = 0; num449 <= num448; num449++)
         {
             int num450 = 135;
             if (num449 == num448)
             {
                 num450 = 136;
             }
             int num451 = NPC.NewNPC((int)(npc.Position.X + (float)(npc.Width / 2)), (int)(npc.Position.Y + (float)npc.Height), num450, npc.whoAmI);
             Main.npcs[num451].ai[3] = (float)npc.whoAmI;
             Main.npcs[num451].realLife = npc.whoAmI;
             Main.npcs[num451].ai[1] = (float)num447;
             Main.npcs[num447].ai[0] = (float)num451;
             NetMessage.SendData(23, -1, -1, "", num451, 0f, 0f, 0f, 0);
             num447 = num451;
         }
     }
     if (npc.Type == 135)
     {
         npc.localAI[0] += (float)Main.rand.Next(4);
         if (npc.localAI[0] >= (float)Main.rand.Next(1400, 26000))
         {
             npc.localAI[0] = 0f;
             npc.TargetClosest(true);
             if (Collision.CanHit(npc.Position, npc.Width, npc.Height, Main.players[npc.target].Position, Main.players[npc.target].Width, Main.players[npc.target].Height))
             {
                 float num452 = 8f;
                 Vector2 vector56 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)(npc.Height / 2));
                 float num453 = Main.players[npc.target].Position.X + (float)Main.players[npc.target].Width * 0.5f - vector56.X + (float)Main.rand.Next(-20, 21);
                 float num454 = Main.players[npc.target].Position.Y + (float)Main.players[npc.target].Height * 0.5f - vector56.Y + (float)Main.rand.Next(-20, 21);
                 float num455 = (float)Math.Sqrt((double)(num453 * num453 + num454 * num454));
                 num455 = num452 / num455;
                 num453 *= num455;
                 num454 *= num455;
                 num453 += (float)Main.rand.Next(-20, 21) * 0.05f;
                 num454 += (float)Main.rand.Next(-20, 21) * 0.05f;
                 int num456 = 22;
                 int num457 = 100;
                 vector56.X += num453 * 5f;
                 vector56.Y += num454 * 5f;
                 int num458 = Projectile.NewProjectile(vector56.X, vector56.Y, num453, num454, num457, num456, 0f, Main.myPlayer);
                 Main.projectile[num458].timeLeft = 300;
                 npc.netUpdate = true;
             }
         }
     }
     int num459 = (int)(npc.Position.X / 16f) - 1;
     int num460 = (int)((npc.Position.X + (float)npc.Width) / 16f) + 2;
     int num461 = (int)(npc.Position.Y / 16f) - 1;
     int num462 = (int)((npc.Position.Y + (float)npc.Height) / 16f) + 2;
     if (num459 < 0)
     {
         num459 = 0;
     }
     if (num460 > Main.maxTilesX)
     {
         num460 = Main.maxTilesX;
     }
     if (num461 < 0)
     {
         num461 = 0;
     }
     if (num462 > Main.maxTilesY)
     {
         num462 = Main.maxTilesY;
     }
     bool flag35 = false;
     if (!flag35)
     {
         for (int num463 = num459; num463 < num460; num463++)
         {
             for (int num464 = num461; num464 < num462; num464++)
             {
                 if (((Main.tile.At(num463, num464).Active && (Main.tileSolid[(int)Main.tile.At(num463, num464).Type] ||
                     (Main.tileSolidTop[(int)Main.tile.At(num463, num464).Type] && Main.tile.At(num463, num464).FrameY == 0))) ||
                         Main.tile.At(num463, num464).Liquid > 64))
                 {
                     Vector2 vector57;
                     vector57.X = (float)(num463 * 16);
                     vector57.Y = (float)(num464 * 16);
                     if (npc.Position.X + (float)npc.Width > vector57.X && npc.Position.X < vector57.X + 16f && npc.Position.Y + (float)npc.Height > vector57.Y && npc.Position.Y < vector57.Y + 16f)
                     {
                         flag35 = true;
                         break;
                     }
                 }
             }
         }
     }
     if (!flag35)
     {
         npc.localAI[1] = 1f;
         if (npc.Type == 134)
         {
             Rectangle rectangle11 = new Rectangle((int)npc.Position.X, (int)npc.Position.Y, npc.Width, npc.Height);
             int num465 = 1000;
             bool flag36 = true;
             if (npc.Position.Y > Main.players[npc.target].Position.Y)
             {
                 for (int num466 = 0; num466 < 255; num466++)
                 {
                     if (Main.players[num466].Active)
                     {
                         Rectangle rectangle12 = new Rectangle((int)Main.players[num466].Position.X - num465, (int)Main.players[num466].Position.Y - num465, num465 * 2, num465 * 2);
                         if (rectangle11.Intersects(rectangle12))
                         {
                             flag36 = false;
                             break;
                         }
                     }
                 }
                 if (flag36)
                 {
                     flag35 = true;
                 }
             }
         }
     }
     else
     {
         npc.localAI[1] = 0f;
     }
     float num467 = 16f;
     if (Main.dayTime || Main.players[npc.target].dead)
     {
         flag35 = false;
         npc.Velocity.Y = npc.Velocity.Y + 1f;
         if ((double)npc.Position.Y > Main.worldSurface * 16.0)
         {
             npc.Velocity.Y = npc.Velocity.Y + 1f;
             num467 = 32f;
         }
         if ((double)npc.Position.Y > Main.rockLayer * 16.0)
         {
             for (int num468 = 0; num468 < 200; num468++)
             {
                 if (Main.npcs[num468].aiStyle == npc.aiStyle)
                 {
                     Main.npcs[num468].Active = false;
                 }
             }
         }
     }
     float num469 = 0.1f;
     float num470 = 0.15f;
     Vector2 vector58 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
     float num471 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2);
     float num472 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2);
     num471 = (float)((int)(num471 / 16f) * 16);
     num472 = (float)((int)(num472 / 16f) * 16);
     vector58.X = (float)((int)(vector58.X / 16f) * 16);
     vector58.Y = (float)((int)(vector58.Y / 16f) * 16);
     num471 -= vector58.X;
     num472 -= vector58.Y;
     float num473 = (float)Math.Sqrt((double)(num471 * num471 + num472 * num472));
     if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npcs.Length)
     {
         try
         {
             vector58 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
             num471 = Main.npcs[(int)npc.ai[1]].Position.X + (float)(Main.npcs[(int)npc.ai[1]].Width / 2) - vector58.X;
             num472 = Main.npcs[(int)npc.ai[1]].Position.Y + (float)(Main.npcs[(int)npc.ai[1]].Height / 2) - vector58.Y;
         }
         catch
         {
         }
         npc.rotation = (float)Math.Atan2((double)num472, (double)num471) + 1.57f;
         num473 = (float)Math.Sqrt((double)(num471 * num471 + num472 * num472));
         int num474 = (int)(44f * npc.scale);
         num473 = (num473 - (float)num474) / num473;
         num471 *= num473;
         num472 *= num473;
         npc.Velocity = default(Vector2);
         npc.Position.X = npc.Position.X + num471;
         npc.Position.Y = npc.Position.Y + num472;
         return;
     }
     if (!flag35)
     {
         npc.TargetClosest(true);
         npc.Velocity.Y = npc.Velocity.Y + 0.15f;
         if (npc.Velocity.Y > num467)
         {
             npc.Velocity.Y = num467;
         }
         if ((double)(Math.Abs(npc.Velocity.X) + Math.Abs(npc.Velocity.Y)) < (double)num467 * 0.4)
         {
             if (npc.Velocity.X < 0f)
             {
                 npc.Velocity.X = npc.Velocity.X - num469 * 1.1f;
             }
             else
             {
                 npc.Velocity.X = npc.Velocity.X + num469 * 1.1f;
             }
         }
         else
         {
             if (npc.Velocity.Y == num467)
             {
                 if (npc.Velocity.X < num471)
                 {
                     npc.Velocity.X = npc.Velocity.X + num469;
                 }
                 else
                 {
                     if (npc.Velocity.X > num471)
                     {
                         npc.Velocity.X = npc.Velocity.X - num469;
                     }
                 }
             }
             else
             {
                 if (npc.Velocity.Y > 4f)
                 {
                     if (npc.Velocity.X < 0f)
                     {
                         npc.Velocity.X = npc.Velocity.X + num469 * 0.9f;
                     }
                     else
                     {
                         npc.Velocity.X = npc.Velocity.X - num469 * 0.9f;
                     }
                 }
             }
         }
     }
     else
     {
         if (npc.soundDelay == 0)
         {
             float num475 = num473 / 40f;
             if (num475 < 10f)
             {
                 num475 = 10f;
             }
             if (num475 > 20f)
             {
                 num475 = 20f;
             }
             npc.soundDelay = (int)num475;
         }
         num473 = (float)Math.Sqrt((double)(num471 * num471 + num472 * num472));
         float num476 = Math.Abs(num471);
         float num477 = Math.Abs(num472);
         float num478 = num467 / num473;
         num471 *= num478;
         num472 *= num478;
         if (((npc.Velocity.X > 0f && num471 > 0f) || (npc.Velocity.X < 0f && num471 < 0f)) && ((npc.Velocity.Y > 0f && num472 > 0f) || (npc.Velocity.Y < 0f && num472 < 0f)))
         {
             if (npc.Velocity.X < num471)
             {
                 npc.Velocity.X = npc.Velocity.X + num470;
             }
             else
             {
                 if (npc.Velocity.X > num471)
                 {
                     npc.Velocity.X = npc.Velocity.X - num470;
                 }
             }
             if (npc.Velocity.Y < num472)
             {
                 npc.Velocity.Y = npc.Velocity.Y + num470;
             }
             else
             {
                 if (npc.Velocity.Y > num472)
                 {
                     npc.Velocity.Y = npc.Velocity.Y - num470;
                 }
             }
         }
         if ((npc.Velocity.X > 0f && num471 > 0f) || (npc.Velocity.X < 0f && num471 < 0f) || (npc.Velocity.Y > 0f && num472 > 0f) || (npc.Velocity.Y < 0f && num472 < 0f))
         {
             if (npc.Velocity.X < num471)
             {
                 npc.Velocity.X = npc.Velocity.X + num469;
             }
             else
             {
                 if (npc.Velocity.X > num471)
                 {
                     npc.Velocity.X = npc.Velocity.X - num469;
                 }
             }
             if (npc.Velocity.Y < num472)
             {
                 npc.Velocity.Y = npc.Velocity.Y + num469;
             }
             else
             {
                 if (npc.Velocity.Y > num472)
                 {
                     npc.Velocity.Y = npc.Velocity.Y - num469;
                 }
             }
             if ((double)Math.Abs(num472) < (double)num467 * 0.2 && ((npc.Velocity.X > 0f && num471 < 0f) || (npc.Velocity.X < 0f && num471 > 0f)))
             {
                 if (npc.Velocity.Y > 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y + num469 * 2f;
                 }
                 else
                 {
                     npc.Velocity.Y = npc.Velocity.Y - num469 * 2f;
                 }
             }
             if ((double)Math.Abs(num471) < (double)num467 * 0.2 && ((npc.Velocity.Y > 0f && num472 < 0f) || (npc.Velocity.Y < 0f && num472 > 0f)))
             {
                 if (npc.Velocity.X > 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X + num469 * 2f;
                 }
                 else
                 {
                     npc.Velocity.X = npc.Velocity.X - num469 * 2f;
                 }
             }
         }
         else
         {
             if (num476 > num477)
             {
                 if (npc.Velocity.X < num471)
                 {
                     npc.Velocity.X = npc.Velocity.X + num469 * 1.1f;
                 }
                 else
                 {
                     if (npc.Velocity.X > num471)
                     {
                         npc.Velocity.X = npc.Velocity.X - num469 * 1.1f;
                     }
                 }
                 if ((double)(Math.Abs(npc.Velocity.X) + Math.Abs(npc.Velocity.Y)) < (double)num467 * 0.5)
                 {
                     if (npc.Velocity.Y > 0f)
                     {
                         npc.Velocity.Y = npc.Velocity.Y + num469;
                     }
                     else
                     {
                         npc.Velocity.Y = npc.Velocity.Y - num469;
                     }
                 }
             }
             else
             {
                 if (npc.Velocity.Y < num472)
                 {
                     npc.Velocity.Y = npc.Velocity.Y + num469 * 1.1f;
                 }
                 else
                 {
                     if (npc.Velocity.Y > num472)
                     {
                         npc.Velocity.Y = npc.Velocity.Y - num469 * 1.1f;
                     }
                 }
                 if ((double)(Math.Abs(npc.Velocity.X) + Math.Abs(npc.Velocity.Y)) < (double)num467 * 0.5)
                 {
                     if (npc.Velocity.X > 0f)
                     {
                         npc.Velocity.X = npc.Velocity.X + num469;
                     }
                     else
                     {
                         npc.Velocity.X = npc.Velocity.X - num469;
                     }
                 }
             }
         }
     }
     npc.rotation = (float)Math.Atan2((double)npc.Velocity.Y, (double)npc.Velocity.X) + 1.57f;
     if (npc.Type == 134)
     {
         if (flag35)
         {
             if (npc.localAI[0] != 1f)
             {
                 npc.netUpdate = true;
             }
             npc.localAI[0] = 1f;
         }
         else
         {
             if (npc.localAI[0] != 0f)
             {
                 npc.netUpdate = true;
             }
             npc.localAI[0] = 0f;
         }
         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)) && !npc.justHit)
         {
             npc.netUpdate = true;
         }
     }
 }
예제 #21
0
        // 19
        private void AIAntlion(NPC npc, bool flag)
        {
            npc.TargetClosest(true);
            float num174 = 12f;
            Vector2 vector22 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
            float num175 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector22.X;
            float num176 = Main.players[npc.target].Position.Y - vector22.Y;
            float num177 = (float)Math.Sqrt((double)(num175 * num175 + num176 * num176));
            num177 = num174 / num177;
            num175 *= num177;
            num176 *= num177;
            bool flag18 = false;
            if (npc.directionY < 0)
            {
                npc.rotation = (float)(Math.Atan2((double)num176, (double)num175) + 1.57);
                flag18 = ((double)npc.rotation >= -1.2 && (double)npc.rotation <= 1.2);
                if ((double)npc.rotation < -0.8)
                {
                    npc.rotation = -0.8f;
                }
                else
                {
                    if ((double)npc.rotation > 0.8)
                    {
                        npc.rotation = 0.8f;
                    }
                }
                if (npc.Velocity.X != 0f)
                {
                    npc.Velocity.X = npc.Velocity.X * 0.9f;
                    if ((double)npc.Velocity.X > -0.1 || (double)npc.Velocity.X < 0.1)
                    {
                        npc.netUpdate = true;
                        npc.Velocity.X = 0f;
                    }
                }
            }
            if (npc.ai[0] > 0f)
            {
                npc.ai[0] -= 1f;
            }
            if (flag18 && npc.ai[0] == 0f && Collision.CanHit(npc.Position, npc.Width, npc.Height, Main.players[npc.target].Position, Main.players[npc.target].Width, Main.players[npc.target].Height))
            {
                npc.ai[0] = 200f;
                int num178 = 10;
                int num179 = 31;
                int num180 = Projectile.NewProjectile(vector22.X, vector22.Y, num175, num176, num179, num178, 0f, Main.myPlayer);
                Main.projectile[num180].ai[0] = 2f;
                Main.projectile[num180].timeLeft = 300;
                Main.projectile[num180].friendly = false;
                NetMessage.SendData(27, -1, -1, "", num180, 0f, 0f, 0f, 0);
                npc.netUpdate = true;
            }
            try
            {
                int num181 = (int)npc.Position.X / 16;
                int num182 = (int)(npc.Position.X + (float)(npc.Width / 2)) / 16;
                int num183 = (int)(npc.Position.X + (float)npc.Width) / 16;
                int num184 = (int)(npc.Position.Y + (float)npc.Height) / 16;
                bool flag19 = false;

                if ((Main.tile.At(num181, num184).Active && Main.tileSolid[
                    (int)Main.tile.At(num181, num184).Type]) ||
                        (Main.tile.At(num182, num184).Active && Main.tileSolid[
                            (int)Main.tile.At(num182, num184).Type]) ||
                                (Main.tile.At(num183, num184).Active && Main.tileSolid[
                                    (int)Main.tile.At(num183, num184).Type]))
                {
                    flag19 = true;
                }
                if (flag19)
                {
                    npc.noGravity = true;
                    npc.noTileCollide = true;
                    npc.Velocity.Y = -0.2f;
                }
                else
                {
                    npc.noGravity = false;
                    npc.noTileCollide = false;
                }
                return;
            }
            catch
            {
                return;
            }
        }
예제 #22
0
        // 29
        private void AITheHungry(NPC npc, bool flag)
        {
            if (npc.justHit)
                npc.ai[1] = 10f;

            if (Main.WallOfFlesh < 0)
            {
                npc.Active = false;
                return;
            }

            npc.TargetClosest(true);
            float num309 = 0.1f;
            float num310 = 300f;
            if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.25)
            {
                npc.damage = 75;
                npc.defense = 40;
                num310 = 900f;
            }
            else if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.5)
            {
                npc.damage = 60;
                npc.defense = 30;
                num310 = 700f;
            }
            else if ((double)Main.npcs[Main.WallOfFlesh].life < (double)Main.npcs[Main.WallOfFlesh].lifeMax * 0.75)
            {
                npc.damage = 45;
                npc.defense = 20;
                num310 = 500f;
            }

            float num311 = Main.npcs[Main.WallOfFlesh].Position.X + (float)(Main.npcs[Main.WallOfFlesh].Width / 2);
            float num312 = Main.npcs[Main.WallOfFlesh].Position.Y;
            float num313 = (float)(Main.WallOfFlesh_B - Main.WallOfFlesh_T);
            num312 = (float)Main.WallOfFlesh_T + num313 * npc.ai[0];
            npc.ai[2] += 1f;
            if (npc.ai[2] > 100f)
            {
                num310 = (float)((int)(num310 * 1.3f));

                if (npc.ai[2] > 200f)
                    npc.ai[2] = 0f;
            }

            Vector2 vector31 = new Vector2(num311, num312);
            float num314 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - (float)(npc.Width / 2) - vector31.X;
            float num315 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - (float)(npc.Height / 2) - vector31.Y;
            float num316 = (float)Math.Sqrt((double)(num314 * num314 + num315 * num315));
            if (npc.ai[1] == 0f)
            {
                if (num316 > num310)
                {
                    num316 = num310 / num316;
                    num314 *= num316;
                    num315 *= num316;
                }
                if (npc.Position.X < num311 + num314)
                {
                    npc.Velocity.X = npc.Velocity.X + num309;

                    if (npc.Velocity.X < 0f && num314 > 0f)
                        npc.Velocity.X = npc.Velocity.X + num309 * 2.5f;
                }
                else if (npc.Position.X > num311 + num314)
                {
                    npc.Velocity.X = npc.Velocity.X - num309;

                    if (npc.Velocity.X > 0f && num314 < 0f)
                        npc.Velocity.X = npc.Velocity.X - num309 * 2.5f;
                }
                if (npc.Position.Y < num312 + num315)
                {
                    npc.Velocity.Y = npc.Velocity.Y + num309;

                    if (npc.Velocity.Y < 0f && num315 > 0f)
                        npc.Velocity.Y = npc.Velocity.Y + num309 * 2.5f;
                }
                else if (npc.Position.Y > num312 + num315)
                {
                    npc.Velocity.Y = npc.Velocity.Y - num309;

                    if (npc.Velocity.Y > 0f && num315 < 0f)
                        npc.Velocity.Y = npc.Velocity.Y - num309 * 2.5f;
                }

                if (npc.Velocity.X > 4f)
                    npc.Velocity.X = 4f;
                if (npc.Velocity.X < -4f)
                    npc.Velocity.X = -4f;
                if (npc.Velocity.Y > 4f)
                    npc.Velocity.Y = 4f;
                if (npc.Velocity.Y < -4f)
                    npc.Velocity.Y = -4f;
            }
            else
            {
                if (npc.ai[1] > 0f)
                    npc.ai[1] -= 1f;
                else
                    npc.ai[1] = 0f;
            }

            if (num314 > 0f)
            {
                npc.spriteDirection = 1;
                npc.rotation = (float)Math.Atan2((double)num315, (double)num314);
            }
            if (num314 < 0f)
            {
                npc.spriteDirection = -1;
                npc.rotation = (float)Math.Atan2((double)num315, (double)num314) + 3.14f;
            }
        }
예제 #23
0
 // 21
 private void AIBlazingWheel(NPC npc, bool flag)
 {
     if (npc.ai[0] == 0f)
     {
         npc.TargetClosest(true);
         npc.directionY = 1;
         npc.ai[0] = 1f;
     }
     int num189 = 6;
     if (npc.ai[1] == 0f)
     {
         npc.rotation += (float)(npc.direction * npc.directionY) * 0.13f;
         if (npc.collideY)
         {
             npc.ai[0] = 2f;
         }
         if (!npc.collideY && npc.ai[0] == 2f)
         {
             npc.direction = -npc.direction;
             npc.ai[1] = 1f;
             npc.ai[0] = 1f;
         }
         if (npc.collideX)
         {
             npc.directionY = -npc.directionY;
             npc.ai[1] = 1f;
         }
     }
     else
     {
         npc.rotation -= (float)(npc.direction * npc.directionY) * 0.13f;
         if (npc.collideX)
         {
             npc.ai[0] = 2f;
         }
         if (!npc.collideX && npc.ai[0] == 2f)
         {
             npc.directionY = -npc.directionY;
             npc.ai[1] = 0f;
             npc.ai[0] = 1f;
         }
         if (npc.collideY)
         {
             npc.direction = -npc.direction;
             npc.ai[1] = 0f;
         }
     }
     npc.Velocity.X = (float)(num189 * npc.direction);
     npc.Velocity.Y = (float)(num189 * npc.directionY);
     return;
 }
예제 #24
0
 // 23
 private void AITool(NPC npc, bool flag)
 {
     npc.noGravity = true;
     npc.noTileCollide = true;
     if (npc.target < 0 || npc.target == 255 || Main.players[npc.target].dead)
     {
         npc.TargetClosest(true);
     }
     if (npc.ai[0] == 0f)
     {
         float num271 = 9f;
         Vector2 vector28 = new Vector2(npc.Position.X + (float)npc.Width * 0.5f, npc.Position.Y + (float)npc.Height * 0.5f);
         float num272 = Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2) - vector28.X;
         float num273 = Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2) - vector28.Y;
         float num274 = (float)Math.Sqrt((double)(num272 * num272 + num273 * num273));
         num274 = num271 / num274;
         num272 *= num274;
         num273 *= num274;
         npc.Velocity.X = num272;
         npc.Velocity.Y = num273;
         npc.rotation = (float)Math.Atan2((double)npc.Velocity.Y, (double)npc.Velocity.X) + 0.785f;
         npc.ai[0] = 1f;
         npc.ai[1] = 0f;
         return;
     }
     if (npc.ai[0] == 1f)
     {
         if (npc.justHit)
         {
             npc.ai[0] = 2f;
             npc.ai[1] = 0f;
         }
         npc.Velocity *= 0.99f;
         npc.ai[1] += 1f;
         if (npc.ai[1] >= 100f)
         {
             npc.ai[0] = 2f;
             npc.ai[1] = 0f;
             npc.Velocity.X = 0f;
             npc.Velocity.Y = 0f;
             return;
         }
     }
     else
     {
         if (npc.justHit)
         {
             npc.ai[0] = 2f;
             npc.ai[1] = 0f;
         }
         npc.Velocity *= 0.96f;
         npc.ai[1] += 1f;
         float num275 = npc.ai[1] / 120f;
         num275 = 0.1f + num275 * 0.4f;
         npc.rotation += num275 * (float)npc.direction;
         if (npc.ai[1] >= 120f)
         {
             npc.netUpdate = true;
             npc.ai[0] = 0f;
             npc.ai[1] = 0f;
             return;
         }
     }
 }
예제 #25
0
 // 2
 private void AIDemonEye(NPC npc, bool flag)
 {
     npc.noGravity = true;
     if (npc.collideX)
     {
         npc.Velocity.X = npc.oldVelocity.X * -0.5f;
         if (npc.direction == -1 && npc.Velocity.X > 0f && npc.Velocity.X < 2f)
         {
             npc.Velocity.X = 2f;
         }
         if (npc.direction == 1 && npc.Velocity.X < 0f && npc.Velocity.X > -2f)
         {
             npc.Velocity.X = -2f;
         }
     }
     if (npc.collideY)
     {
         npc.Velocity.Y = npc.oldVelocity.Y * -0.5f;
         if (npc.Velocity.Y > 0f && npc.Velocity.Y < 1f)
         {
             npc.Velocity.Y = 1f;
         }
         if (npc.Velocity.Y < 0f && npc.Velocity.Y > -1f)
         {
             npc.Velocity.Y = -1f;
         }
     }
     if (Main.dayTime && (double)npc.Position.Y <= Main.worldSurface * 16.0 && npc.Type == 2)
     {
         if (npc.timeLeft > 10)
         {
             npc.timeLeft = 10;
         }
         npc.directionY = -1;
         if (npc.Velocity.Y > 0f)
         {
             npc.direction = 1;
         }
         npc.direction = -1;
         if (npc.Velocity.X > 0f)
         {
             npc.direction = 1;
         }
     }
     else
     {
         npc.TargetClosest(true);
     }
     if (npc.direction == -1 && npc.Velocity.X > -4f)
     {
         npc.Velocity.X = npc.Velocity.X - 0.1f;
         if (npc.Velocity.X > 4f)
         {
             npc.Velocity.X = npc.Velocity.X - 0.1f;
         }
         else
         {
             if (npc.Velocity.X > 0f)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.05f;
             }
         }
         if (npc.Velocity.X < -4f)
         {
             npc.Velocity.X = -4f;
         }
     }
     else
     {
         if (npc.direction == 1 && npc.Velocity.X < 4f)
         {
             npc.Velocity.X = npc.Velocity.X + 0.1f;
             if (npc.Velocity.X < -4f)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.1f;
             }
             else
             {
                 if (npc.Velocity.X < 0f)
                 {
                     npc.Velocity.X = npc.Velocity.X - 0.05f;
                 }
             }
             if (npc.Velocity.X > 4f)
             {
                 npc.Velocity.X = 4f;
             }
         }
     }
     if (npc.directionY == -1 && (double)npc.Velocity.Y > -1.5)
     {
         npc.Velocity.Y = npc.Velocity.Y - 0.04f;
         if ((double)npc.Velocity.Y > 1.5)
         {
             npc.Velocity.Y = npc.Velocity.Y - 0.05f;
         }
         else
         {
             if (npc.Velocity.Y > 0f)
             {
                 npc.Velocity.Y = npc.Velocity.Y + 0.03f;
             }
         }
         if ((double)npc.Velocity.Y < -1.5)
         {
             npc.Velocity.Y = -1.5f;
         }
     }
     else
     {
         if (npc.directionY == 1 && (double)npc.Velocity.Y < 1.5)
         {
             npc.Velocity.Y = npc.Velocity.Y + 0.04f;
             if ((double)npc.Velocity.Y < -1.5)
             {
                 npc.Velocity.Y = npc.Velocity.Y + 0.05f;
             }
             else
             {
                 if (npc.Velocity.Y < 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y - 0.03f;
                 }
             }
             if ((double)npc.Velocity.Y > 1.5)
             {
                 npc.Velocity.Y = 1.5f;
             }
         }
     }
     if (npc.wet)
     {
         if (npc.Velocity.Y > 0f)
         {
             npc.Velocity.Y = npc.Velocity.Y * 0.95f;
         }
         npc.Velocity.Y = npc.Velocity.Y - 0.5f;
         if (npc.Velocity.Y < -4f)
         {
             npc.Velocity.Y = -4f;
         }
         npc.TargetClosest(true);
         return;
     }
 }
예제 #26
0
 // 26
 private void AIUnicorn(NPC npc, bool flag)
 {
     int num281 = 30;
     bool flag32 = false;
     if (npc.Velocity.Y == 0f && ((npc.Velocity.X > 0f && npc.direction < 0) || (npc.Velocity.X < 0f && npc.direction > 0)))
     {
         flag32 = true;
         npc.ai[3] += 1f;
     }
     if (npc.Position.X == npc.oldPosition.X || npc.ai[3] >= (float)num281 || flag32)
     {
         npc.ai[3] += 1f;
     }
     else
     {
         if (npc.ai[3] > 0f)
         {
             npc.ai[3] -= 1f;
         }
     }
     if (npc.ai[3] > (float)(num281 * 10))
     {
         npc.ai[3] = 0f;
     }
     if (npc.justHit)
     {
         npc.ai[3] = 0f;
     }
     if (npc.ai[3] == (float)num281)
     {
         npc.netUpdate = true;
     }
     if (npc.ai[3] < (float)num281)
     {
         npc.TargetClosest(true);
     }
     else
     {
         if (npc.Velocity.X == 0f)
         {
             if (npc.Velocity.Y == 0f)
             {
                 npc.ai[0] += 1f;
                 if (npc.ai[0] >= 2f)
                 {
                     npc.direction *= -1;
                     npc.spriteDirection = npc.direction;
                     npc.ai[0] = 0f;
                 }
             }
         }
         else
         {
             npc.ai[0] = 0f;
         }
         npc.directionY = -1;
         if (npc.direction == 0)
         {
             npc.direction = 1;
         }
     }
     float num282 = 6f;
     if (npc.Velocity.Y == 0f || npc.wet || (npc.Velocity.X <= 0f && npc.direction < 0) || (npc.Velocity.X >= 0f && npc.direction > 0))
     {
         if (npc.Velocity.X < -num282 || npc.Velocity.X > num282)
         {
             if (npc.Velocity.Y == 0f)
             {
                 npc.Velocity *= 0.8f;
             }
         }
         else
         {
             if (npc.Velocity.X < num282 && npc.direction == 1)
             {
                 npc.Velocity.X = npc.Velocity.X + 0.07f;
                 if (npc.Velocity.X > num282)
                 {
                     npc.Velocity.X = num282;
                 }
             }
             else
             {
                 if (npc.Velocity.X > -num282 && npc.direction == -1)
                 {
                     npc.Velocity.X = npc.Velocity.X - 0.07f;
                     if (npc.Velocity.X < -num282)
                     {
                         npc.Velocity.X = -num282;
                     }
                 }
             }
         }
     }
     if (npc.Velocity.Y == 0f)
     {
         int num283 = (int)((npc.Position.X + (float)(npc.Width / 2) + (float)((npc.Width / 2 + 2) * npc.direction) + npc.Velocity.X * 5f) / 16f);
         int num284 = (int)((npc.Position.Y + (float)npc.Height - 15f) / 16f);
         if ((npc.Velocity.X < 0f && npc.spriteDirection == -1) || (npc.Velocity.X > 0f && npc.spriteDirection == 1))
         {
             if (Main.tile.At(num283, num284 - 2).Active && Main.tileSolid[(int)Main.tile.At(num283, num284 - 2).Type])
             {
                 if (Main.tile.At(num283, num284 - 3).Active && Main.tileSolid[(int)Main.tile.At(num283, num284 - 3).Type])
                 {
                     npc.Velocity.Y = -8.5f;
                     npc.netUpdate = true;
                     return;
                 }
                 npc.Velocity.Y = -7.5f;
                 npc.netUpdate = true;
                 return;
             }
             else
             {
                 if (Main.tile.At(num283, num284 - 1).Active && Main.tileSolid[(int)Main.tile.At(num283, num284 - 1).Type])
                 {
                     npc.Velocity.Y = -7f;
                     npc.netUpdate = true;
                     return;
                 }
                 if (Main.tile.At(num283, num284).Active && Main.tileSolid[(int)Main.tile.At(num283, num284).Type])
                 {
                     npc.Velocity.Y = -6f;
                     npc.netUpdate = true;
                     return;
                 }
                 if ((npc.directionY < 0 || Math.Abs(npc.Velocity.X) > 3f) && (!Main.tile.At(num283, num284 + 1).Active || !Main.tileSolid[(int)Main.tile.At(num283, num284 + 1).Type]) && (!Main.tile.At(num283 + npc.direction, num284 + 1).Active || !Main.tileSolid[(int)Main.tile.At(num283 + npc.direction, num284 + 1).Type]))
                 {
                     npc.Velocity.Y = -8f;
                     npc.netUpdate = true;
                     return;
                 }
             }
         }
     }
 }
예제 #27
0
        // 3
        private void AIFighter(NPC npc, bool flag)
        {
            int num3 = 60;
            bool flag2 = false;
            if (npc.Velocity.Y == 0f && ((npc.Velocity.X > 0f && npc.direction < 0) || (npc.Velocity.X < 0f && npc.direction > 0)))
            {
                flag2 = true;
            }
            if (npc.Position.X == npc.oldPosition.X || npc.ai[3] >= (float)num3 || flag2)
            {
                npc.ai[3] += 1f;
            }
            else
            {
                if ((double)Math.Abs(npc.Velocity.X) > 0.9 && npc.ai[3] > 0f)
                {
                    npc.ai[3] -= 1f;
                }
            }
            if (npc.ai[3] > (float)(num3 * 10))
            {
                npc.ai[3] = 0f;
            }
            if (npc.justHit)
            {
                npc.ai[3] = 0f;
            }
            if (npc.ai[3] == (float)num3)
            {
                npc.netUpdate = true;
            }
            if ((!Main.dayTime || (double)npc.Position.Y > Main.worldSurface * 16.0 || npc.Type == 26 || npc.Type == 27 || npc.Type == 28 || npc.Type == 31 || npc.Type == 47 || npc.Type == 67 || npc.Type == 73) && npc.ai[3] < (float)num3)
            {
                npc.TargetClosest(true);
            }
            else
            {
                if (Main.dayTime && (double)(npc.Position.Y / 16f) < Main.worldSurface && npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                }
                if (npc.Velocity.X == 0f)
                {
                    if (npc.Velocity.Y == 0f)
                    {
                        npc.ai[0] += 1f;
                        if (npc.ai[0] >= 2f)
                        {
                            npc.direction *= -1;
                            npc.spriteDirection = npc.direction;
                            npc.ai[0] = 0f;
                        }
                    }
                }
                else
                {
                    npc.ai[0] = 0f;
                }
                if (npc.direction == 0)
                {
                    npc.direction = 1;
                }
            }
            if (npc.Type == 27)
            {
                if (npc.Velocity.X < -2f || npc.Velocity.X > 2f)
                {
                    if (npc.Velocity.Y == 0f)
                    {
                        npc.Velocity *= 0.8f;
                    }
                }
                else
                {
                    if (npc.Velocity.X < 2f && npc.direction == 1)
                    {
                        npc.Velocity.X = npc.Velocity.X + 0.07f;
                        if (npc.Velocity.X > 2f)
                        {
                            npc.Velocity.X = 2f;
                        }
                    }
                    else
                    {
                        if (npc.Velocity.X > -2f && npc.direction == -1)
                        {
                            npc.Velocity.X = npc.Velocity.X - 0.07f;
                            if (npc.Velocity.X < -2f)
                            {
                                npc.Velocity.X = -2f;
                            }
                        }
                    }
                }
            }
            else
            {
                if (npc.Type == 21 || npc.Type == 26 || npc.Type == 31 || npc.Type == 47 || npc.Type == 73)
                {
                    if (npc.Velocity.X < -1.5f || npc.Velocity.X > 1.5f)
                    {
                        if (npc.Velocity.Y == 0f)
                        {
                            npc.Velocity *= 0.8f;
                        }
                    }
                    else
                    {
                        if (npc.Velocity.X < 1.5f && npc.direction == 1)
                        {
                            npc.Velocity.X = npc.Velocity.X + 0.07f;
                            if (npc.Velocity.X > 1.5f)
                            {
                                npc.Velocity.X = 1.5f;
                            }
                        }
                        else
                        {
                            if (npc.Velocity.X > -1.5f && npc.direction == -1)
                            {
                                npc.Velocity.X = npc.Velocity.X - 0.07f;
                                if (npc.Velocity.X < -1.5f)
                                {
                                    npc.Velocity.X = -1.5f;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (npc.Type == 67)
                    {
                        if (npc.Velocity.X < -0.5f || npc.Velocity.X > 0.5f)
                        {
                            if (npc.Velocity.Y == 0f)
                            {
                                npc.Velocity *= 0.7f;
                            }
                        }
                        else
                        {
                            if (npc.Velocity.X < 0.5f && npc.direction == 1)
                            {
                                npc.Velocity.X = npc.Velocity.X + 0.03f;
                                if (npc.Velocity.X > 0.5f)
                                {
                                    npc.Velocity.X = 0.5f;
                                }
                            }
                            else
                            {
                                if (npc.Velocity.X > -0.5f && npc.direction == -1)
                                {
                                    npc.Velocity.X = npc.Velocity.X - 0.03f;
                                    if (npc.Velocity.X < -0.5f)
                                    {
                                        npc.Velocity.X = -0.5f;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (npc.Velocity.X < -1f || npc.Velocity.X > 1f)
                        {
                            if (npc.Velocity.Y == 0f)
                            {
                                npc.Velocity *= 0.8f;
                            }
                        }
                        else
                        {
                            if (npc.Velocity.X < 1f && npc.direction == 1)
                            {
                                npc.Velocity.X = npc.Velocity.X + 0.07f;
                                if (npc.Velocity.X > 1f)
                                {
                                    npc.Velocity.X = 1f;
                                }
                            }
                            else
                            {
                                if (npc.Velocity.X > -1f && npc.direction == -1)
                                {
                                    npc.Velocity.X = npc.Velocity.X - 0.07f;
                                    if (npc.Velocity.X < -1f)
                                    {
                                        npc.Velocity.X = -1f;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (npc.Velocity.Y != 0f)
            {
                npc.ai[1] = 0f;
                npc.ai[2] = 0f;
                return;
            }
            int tileX = (int)((npc.Position.X + (float)(npc.Width / 2) + (float)(15 * npc.direction)) / 16f);
            int tileY = (int)((npc.Position.Y + (float)npc.Height - 15f) / 16f);

            if (!(npc.Type == 47 || npc.Type == 67))
            {
                if (Main.tile.At(tileX, tileY - 1).Active && Main.tile.At(tileX, tileY - 1).Type == 10)
                {
                    npc.ai[2] += 1f;
                    npc.ai[3] = 0f;
                    if (npc.ai[2] >= 60f)
                    {
                        if (!Main.bloodMoon && npc.Type == 3)
                        {
                            npc.ai[1] = 0f;
                        }
                        npc.Velocity.X = 0.5f * (float)(-(float)npc.direction);
                        npc.ai[1] += 1f;
                        if (npc.Type == 27)
                        {
                            npc.ai[1] += 1f;
                        }
                        if (npc.Type == 31)
                        {
                            npc.ai[1] += 6f;
                        }
                        npc.ai[2] = 0f;
                        bool flag4 = false;
                        if (npc.ai[1] >= 10f)
                        {
                            flag4 = true;
                            npc.ai[1] = 10f;
                        }
                        WorldModify.KillTile(tileX, tileY - 1, true, false, false);
                        if (flag4)
                        {
                            if (npc.Type == 26)
                            {
                                WorldModify.KillTile(tileX, tileY - 1, false, false, false);
                                NetMessage.SendData(17, -1, -1, "", 0, (float)tileX, (float)(tileY - 1), 0f, 0);
                                return;
                            }
                            else
                            {
                                bool flag5 = WorldModify.OpenDoor(tileX, tileY, npc.direction, npc);
                                if (!flag5)
                                {
                                    npc.ai[3] = (float)num3;
                                    npc.netUpdate = true;
                                }
                                else
                                {
                                    NetMessage.SendData(19, -1, -1, "", 0, (float)tileX, (float)tileY, (float)npc.direction, 0);
                                    return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if ((npc.Velocity.X < 0f && npc.spriteDirection == -1) || (npc.Velocity.X > 0f && npc.spriteDirection == 1))
                    {
                        if (Main.tile.At(tileX, tileY - 2).Active && Main.tileSolid[(int)Main.tile.At(tileX, tileY - 2).Type])
                        {
                            if (Main.tile.At(tileX, tileY - 3).Active && Main.tileSolid[(int)Main.tile.At(tileX, tileY - 3).Type])
                            {
                                npc.Velocity.Y = -8f;
                                npc.netUpdate = true;
                            }
                            else
                            {
                                npc.Velocity.Y = -7f;
                                npc.netUpdate = true;
                            }
                        }
                        else
                        {
                            if (Main.tile.At(tileX, tileY - 1).Active && Main.tileSolid[(int)Main.tile.At(tileX, tileY - 1).Type])
                            {
                                npc.Velocity.Y = -6f;
                                npc.netUpdate = true;
                            }
                            else
                            {
                                if (Main.tile.At(tileX, tileY).Active && Main.tileSolid[(int)Main.tile.At(tileX, tileY).Type])
                                {
                                    npc.Velocity.Y = -5f;
                                    npc.netUpdate = true;
                                }
                                else
                                {
                                    if (npc.directionY < 0 && npc.Type != 67 && (!Main.tile.At(tileX, tileY + 1).Active || !Main.tileSolid[(int)Main.tile.At(tileX, tileY + 1).Type]) && (!Main.tile.At(tileX + npc.direction, tileY + 1).Active || !Main.tileSolid[(int)Main.tile.At(tileX + npc.direction, tileY + 1).Type]))
                                    {
                                        npc.Velocity.Y = -8f;
                                        npc.Velocity.X = npc.Velocity.X * 1.5f;
                                        npc.netUpdate = true;
                                    }
                                    else
                                    {
                                        npc.ai[1] = 0f;
                                        npc.ai[2] = 0f;
                                    }
                                }
                            }
                        }
                    }
                    if ((npc.Type == 31 || npc.Type == 47) && npc.Velocity.Y == 0f && Math.Abs(npc.Position.X + (float)(npc.Width / 2) - (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2))) < 100f && Math.Abs(npc.Position.Y + (float)(npc.Height / 2) - (Main.players[npc.target].Position.Y + (float)(Main.players[npc.target].Height / 2))) < 50f && ((npc.direction > 0 && npc.Velocity.X >= 1f) || (npc.direction < 0 && npc.Velocity.X <= -1f)))
                    {
                        npc.Velocity.X = npc.Velocity.X * 2f;
                        if (npc.Velocity.X > 3f)
                        {
                            npc.Velocity.X = 3f;
                        }
                        if (npc.Velocity.X < -3f)
                        {
                            npc.Velocity.X = -3f;
                        }
                        npc.Velocity.Y = -4f;
                        npc.netUpdate = true;
                        return;
                    }
                }
            }
        }
예제 #28
0
 // 0
 private void AIUnknown(NPC npc, bool flag)
 {
     npc.Velocity.X = npc.Velocity.X * 0.93f;
     if ((double)npc.Velocity.X > -0.1 && (double)npc.Velocity.X < 0.1)
     {
         npc.Velocity.X = 0f;
         return;
     }
 }
 /// <summary>
 /// Add buff to npc
 /// </summary>
 /// <param name="type">Tyep of buff</param>
 /// <param name="npc">NPC to add to</param>
 public void StatusNPC(int type, NPC npc)
 {
     switch (type)
     {
         case 121:
             if (Main.rand.Next(2) == 0)
                 npc.AddBuff(24, 180, false);
             return;
         case 122:
             if (Main.rand.Next(10) == 0)
                 npc.AddBuff(24, 180, false);
             return;
         case 190:
             if (Main.rand.Next(4) == 0)
                 npc.AddBuff(20, 420, false);
             return;
         case 217:
             if(Main.rand.Next(5) == 0)
                 npc.AddBuff(24, 180, false);
             return;
     }
 }
예제 #30
0
 // 17
 private void AIVulture(NPC npc, bool flag)
 {
     npc.noGravity = true;
     if (npc.ai[0] == 0f)
     {
         npc.noGravity = false;
         npc.TargetClosest(true);
         if (npc.Velocity.X != 0f || npc.Velocity.Y < 0f || (double)npc.Velocity.Y > 0.3)
         {
             npc.ai[0] = 1f;
             npc.netUpdate = true;
         }
         else
         {
             Rectangle rectangle5 = new Rectangle((int)Main.players[npc.target].Position.X, (int)Main.players[npc.target].Position.Y, Main.players[npc.target].Width, Main.players[npc.target].Height);
             Rectangle rectangle6 = new Rectangle((int)npc.Position.X - 100, (int)npc.Position.Y - 100, npc.Width + 200, npc.Height + 200);
             if (rectangle6.Intersects(rectangle5) || npc.life < npc.lifeMax)
             {
                 npc.ai[0] = 1f;
                 npc.Velocity.Y = npc.Velocity.Y - 6f;
                 npc.netUpdate = true;
             }
         }
     }
     else
     {
         if (!Main.players[npc.target].dead)
         {
             if (npc.collideX)
             {
                 npc.Velocity.X = npc.oldVelocity.X * -0.5f;
                 if (npc.direction == -1 && npc.Velocity.X > 0f && npc.Velocity.X < 2f)
                 {
                     npc.Velocity.X = 2f;
                 }
                 if (npc.direction == 1 && npc.Velocity.X < 0f && npc.Velocity.X > -2f)
                 {
                     npc.Velocity.X = -2f;
                 }
             }
             if (npc.collideY)
             {
                 npc.Velocity.Y = npc.oldVelocity.Y * -0.5f;
                 if (npc.Velocity.Y > 0f && npc.Velocity.Y < 1f)
                 {
                     npc.Velocity.Y = 1f;
                 }
                 if (npc.Velocity.Y < 0f && npc.Velocity.Y > -1f)
                 {
                     npc.Velocity.Y = -1f;
                 }
             }
             npc.TargetClosest(true);
             if (npc.direction == -1 && npc.Velocity.X > -3f)
             {
                 npc.Velocity.X = npc.Velocity.X - 0.1f;
                 if (npc.Velocity.X > 3f)
                 {
                     npc.Velocity.X = npc.Velocity.X - 0.1f;
                 }
                 else
                 {
                     if (npc.Velocity.X > 0f)
                     {
                         npc.Velocity.X = npc.Velocity.X - 0.05f;
                     }
                 }
                 if (npc.Velocity.X < -3f)
                 {
                     npc.Velocity.X = -3f;
                 }
             }
             else
             {
                 if (npc.direction == 1 && npc.Velocity.X < 3f)
                 {
                     npc.Velocity.X = npc.Velocity.X + 0.1f;
                     if (npc.Velocity.X < -3f)
                     {
                         npc.Velocity.X = npc.Velocity.X + 0.1f;
                     }
                     else
                     {
                         if (npc.Velocity.X < 0f)
                         {
                             npc.Velocity.X = npc.Velocity.X + 0.05f;
                         }
                     }
                     if (npc.Velocity.X > 3f)
                     {
                         npc.Velocity.X = 3f;
                     }
                 }
             }
             float num165 = Math.Abs(npc.Position.X + (float)(npc.Width / 2) - (Main.players[npc.target].Position.X + (float)(Main.players[npc.target].Width / 2)));
             float num166 = Main.players[npc.target].Position.Y - (float)(npc.Height / 2);
             if (num165 > 50f)
             {
                 num166 -= 100f;
             }
             if (npc.Position.Y < num166)
             {
                 npc.Velocity.Y = npc.Velocity.Y + 0.05f;
                 if (npc.Velocity.Y < 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y + 0.01f;
                 }
             }
             else
             {
                 npc.Velocity.Y = npc.Velocity.Y - 0.05f;
                 if (npc.Velocity.Y > 0f)
                 {
                     npc.Velocity.Y = npc.Velocity.Y - 0.01f;
                 }
             }
             if (npc.Velocity.Y < -3f)
             {
                 npc.Velocity.Y = -3f;
             }
             if (npc.Velocity.Y > 3f)
             {
                 npc.Velocity.Y = 3f;
             }
         }
     }
     if (npc.wet)
     {
         if (npc.Velocity.Y > 0f)
         {
             npc.Velocity.Y = npc.Velocity.Y * 0.95f;
         }
         npc.Velocity.Y = npc.Velocity.Y - 0.5f;
         if (npc.Velocity.Y < -4f)
         {
             npc.Velocity.Y = -4f;
         }
         npc.TargetClosest(true);
         return;
     }
 }