public override void UpdateBadLifeRegen()
        {
            AAMod.AAPlayer modPlayer = player.GetModPlayer <AAMod.AAPlayer>();
            if (AkumaPain)
            {
                if (player.lifeRegen > 0)
                {
                    player.lifeRegen = 0;
                }

                player.lifeRegenTime = 0;

                if ((player.onFire || player.frostBurn || player.onFire2 || modPlayer.dragonFire || modPlayer.discordInferno) && player.lifeRegen < 0)
                {
                    player.lifeRegen *= 2;
                }
            }
        }
Example #2
0
 public override void AI()
 {
     npc.noTileCollide   = false;
     npc.knockBackResist = 0.4f * Main.knockBackMultiplier;
     npc.noGravity       = true;
     npc.rotation        = ((npc.rotation * 9f) + (npc.velocity.X * 0.1f)) / 10f;
     AAMod.AAPlayer modPlayer = Main.player[npc.target].GetModPlayer <AAMod.AAPlayer>();
     if (!modPlayer.ZoneInferno)
     {
         if (npc.timeLeft > 5)
         {
             npc.timeLeft = 5;
         }
         npc.velocity.Y = npc.velocity.Y - 0.2f;
         if (npc.velocity.Y < -8f)
         {
             npc.velocity.Y = -8f;
         }
         npc.noTileCollide = true;
         return;
     }
     if (npc.ai[0] == 0f || npc.ai[0] == 1f)
     {
         for (int num1328 = 0; num1328 < 200; num1328++)
         {
             if (num1328 != npc.whoAmI && Main.npc[num1328].active && Main.npc[num1328].type == npc.type)
             {
                 Vector2 value55 = Main.npc[num1328].Center - npc.Center;
                 if (value55.Length() < npc.width + npc.height)
                 {
                     value55.Normalize();
                     value55      *= -0.1f;
                     npc.velocity += value55;
                     Main.npc[num1328].velocity -= value55;
                 }
             }
         }
     }
     if (npc.target < 0 || Main.player[npc.target].dead || !Main.player[npc.target].active)
     {
         npc.TargetClosest(true);
         Vector2 vector209 = Main.player[npc.target].Center - npc.Center;
         if (Main.player[npc.target].dead || vector209.Length() > 3000f)
         {
             npc.ai[0] = -1f;
         }
     }
     else
     {
         Vector2 vector210 = Main.player[npc.target].Center - npc.Center;
         if (npc.ai[0] > 1f && vector210.Length() > 1000f)
         {
             npc.ai[0] = 1f;
         }
     }
     if (npc.ai[0] == -1f)
     {
         Vector2 value56 = new Vector2(0f, -8f);
         npc.velocity       = ((npc.velocity * 9f) + value56) / 10f;
         npc.noTileCollide  = true;
         npc.dontTakeDamage = true;
         return;
     }
     if (npc.ai[0] == 0f)
     {
         npc.TargetClosest(true);
         npc.spriteDirection = npc.direction;
         if (npc.collideX)
         {
             npc.velocity.X = npc.velocity.X * (-npc.oldVelocity.X * 0.5f);
             if (npc.velocity.X > 4f)
             {
                 npc.velocity.X = 4f;
             }
             if (npc.velocity.X < -4f)
             {
                 npc.velocity.X = -4f;
             }
         }
         if (npc.collideY)
         {
             npc.velocity.Y = npc.velocity.Y * (-npc.oldVelocity.Y * 0.5f);
             if (npc.velocity.Y > 4f)
             {
                 npc.velocity.Y = 4f;
             }
             if (npc.velocity.Y < -4f)
             {
                 npc.velocity.Y = -4f;
             }
         }
         Vector2 value57 = Main.player[npc.target].Center - npc.Center;
         if (value57.Length() > 800f)
         {
             npc.ai[0] = 1f;
             npc.ai[1] = 0f;
             npc.ai[2] = 0f;
             npc.ai[3] = 0f;
         }
         else if (value57.Length() > 200f)
         {
             float scaleFactor20 = 5.5f + (value57.Length() / 100f) + (npc.ai[1] / 15f);
             float num1329       = 40f;
             value57.Normalize();
             value57     *= scaleFactor20;
             npc.velocity = ((npc.velocity * (num1329 - 1f)) + value57) / num1329;
         }
         else if (npc.velocity.Length() > 2f)
         {
             npc.velocity *= 0.95f;
         }
         else if (npc.velocity.Length() < 1f)
         {
             npc.velocity *= 1.05f;
         }
         npc.ai[1] += 1f;
         if (npc.ai[1] >= 90f)
         {
             npc.ai[1] = 0f;
             npc.ai[0] = 2f;
             return;
         }
     }
     else
     {
         if (npc.ai[0] == 1f)
         {
             npc.collideX        = false;
             npc.collideY        = false;
             npc.noTileCollide   = true;
             npc.knockBackResist = 0f;
             if (npc.target < 0 || !Main.player[npc.target].active || Main.player[npc.target].dead)
             {
                 npc.TargetClosest(true);
             }
             if (npc.velocity.X < 0f)
             {
                 npc.direction = -1;
             }
             else if (npc.velocity.X > 0f)
             {
                 npc.direction = 1;
             }
             npc.spriteDirection = npc.direction;
             npc.rotation        = ((npc.rotation * 9f) + (npc.velocity.X * 0.08f)) / 10f;
             Vector2 value58 = Main.player[npc.target].Center - npc.Center;
             if (value58.Length() < 300f && !Collision.SolidCollision(npc.position, npc.width, npc.height))
             {
                 npc.ai[0] = 0f;
                 npc.ai[1] = 0f;
                 npc.ai[2] = 0f;
                 npc.ai[3] = 0f;
             }
             npc.ai[2] += 0.0166666675f;
             float scaleFactor21 = 5.5f + npc.ai[2] + (value58.Length() / 150f);
             float num1330       = 35f;
             value58.Normalize();
             value58     *= scaleFactor21;
             npc.velocity = ((npc.velocity * (num1330 - 1f)) + value58) / num1330;
             return;
         }
         if (npc.ai[0] == 2f)
         {
             if (npc.velocity.X < 0f)
             {
                 npc.direction = -1;
             }
             else if (npc.velocity.X > 0f)
             {
                 npc.direction = 1;
             }
             npc.spriteDirection = npc.direction;
             npc.rotation        = ((npc.rotation * 7f) + (npc.velocity.X * 0.1f)) / 8f;
             npc.knockBackResist = 0f;
             npc.noTileCollide   = true;
             Vector2 vector211 = Main.player[npc.target].Center - npc.Center;
             vector211.Y -= 8f;
             float scaleFactor22 = 9f;
             float num1331       = 8f;
             vector211.Normalize();
             vector211   *= scaleFactor22;
             npc.velocity = ((npc.velocity * (num1331 - 1f)) + vector211) / num1331;
             if (npc.velocity.X < 0f)
             {
                 npc.direction = -1;
             }
             else
             {
                 npc.direction = 1;
             }
             npc.spriteDirection = npc.direction;
             npc.ai[1]          += 1f;
             if (npc.ai[1] > 10f)
             {
                 npc.velocity = vector211;
                 if (npc.velocity.X < 0f)
                 {
                     npc.direction = -1;
                 }
                 else
                 {
                     npc.direction = 1;
                 }
                 npc.ai[0] = 2.1f;
                 npc.ai[1] = 0f;
                 return;
             }
         }
         else if (npc.ai[0] == 2.1f)
         {
             if (npc.velocity.X < 0f)
             {
                 npc.direction = -1;
             }
             else if (npc.velocity.X > 0f)
             {
                 npc.direction = 1;
             }
             npc.spriteDirection = npc.direction;
             npc.velocity       *= 1.01f;
             npc.knockBackResist = 0f;
             npc.noTileCollide   = true;
             npc.ai[1]          += 1f;
             int num1332 = 45;
             if (npc.ai[1] > num1332)
             {
                 if (!Collision.SolidCollision(npc.position, npc.width, npc.height))
                 {
                     npc.ai[0] = 0f;
                     npc.ai[1] = 0f;
                     npc.ai[2] = 0f;
                     return;
                 }
                 if (npc.ai[1] > num1332 * 2)
                 {
                     npc.ai[0] = 1f;
                     npc.ai[1] = 0f;
                     npc.ai[2] = 0f;
                     return;
                 }
             }
         }
     }
 }
Example #3
0
        public override void AI()
        {
            if (Main.expertMode)
            {
                damage = npc.damage / 4;
            }
            else
            {
                damage = npc.damage / 2;
            }
            npc.TargetClosest();
            Player player = Main.player[npc.target];

            AAMod.AAPlayer modPlayer = player.GetModPlayer <AAMod.AAPlayer>();

            Vector2 Acropolis = new Vector2(Origin.X + (80 * 16), Origin.Y + (79 * 16));

            //Preamble S***e

            if (internalAI[2] != 1)
            {
                npc.dontTakeDamage = true;
                music = ModLoader.GetMod("AAMod").GetSoundSlot(SoundType.Music, "Sounds/Music/silence");
                if (Vector2.Distance(npc.Center, Acropolis) < 10)
                {
                    npc.velocity *= 0;

                    if (Seen)
                    {
                        if (player.Center.X < npc.Center.X + 32)
                        {
                            npc.direction = -1;
                        }
                        else
                        {
                            npc.direction = 1;
                        }
                    }

                    if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && internalAI[3] < 180)
                    {
                        Seen          = true;
                        npc.netUpdate = true;
                    }

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        if (!Seen)
                        {
                            internalAI[4]++;
                            if (internalAI[4] == 60)
                            {
                                CombatText.NewText(npc.Hitbox, Color.CadetBlue, "...");
                            }

                            if (internalAI[4] == 180)
                            {
                                CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.EnemyChat("AthenaChat1"));
                            }

                            if (internalAI[4] >= 300)
                            {
                                CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.EnemyChat("AthenaChat2"));
                                npc.active = false;
                                int p = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("AthenaFlee"));
                                Main.npc[p].Center = npc.Center;
                            }
                            return;
                        }

                        if (internalAI[3]++ < 420)
                        {
                            if (!AAWorld.downedAthena)
                            {
                                if (internalAI[3] == 60)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena1"));
                                }

                                if (internalAI[3] == 180)
                                {
                                    string s = "";
                                    if (Main.ActivePlayersCount > 1)
                                    {
                                        s = AAMod.Lang.BossChat("Athena2");
                                    }
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena3") + s + "!");
                                }

                                if (internalAI[3] == 300)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena4"));
                                }

                                if (internalAI[3] == 420)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena5"));
                                }

                                if (internalAI[3] >= 420)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena6"));
                                    internalAI[2] = 1;

                                    npc.netUpdate = true;
                                }
                            }
                            else if (AAWorld.AthenaHerald && !AAWorld.downedAthenaA)
                            {
                                if (internalAI[3] == 60)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena12"));
                                }

                                if (internalAI[3] == 180)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena13"));
                                }

                                if (internalAI[3] == 300)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena14"));
                                    internalAI[2] = 1;
                                    npc.netUpdate = true;
                                }
                            }
                            else
                            {
                                if (internalAI[3] == 60)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena7"));
                                }

                                if (internalAI[3] >= 180)
                                {
                                    CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena8"));
                                    internalAI[2] = 1;
                                    npc.netUpdate = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    npc.spriteDirection = npc.direction = npc.velocity.X > 0 ? 1 : -1;
                    MoveToVector2(Acropolis);
                }
            }
            else
            {
                if (player.Center.X < npc.Center.X + 32)
                {
                    npc.direction = -1;
                }
                else
                {
                    npc.direction = 1;
                }

                npc.dontTakeDamage = false;
                if (player.dead || !player.active || Vector2.Distance(npc.position, player.position) > 5000 || !modPlayer.ZoneAcropolis)
                {
                    npc.TargetClosest();
                    if (player.dead || !player.active || Math.Abs(Vector2.Distance(npc.position, player.position)) > 5000 || !modPlayer.ZoneAcropolis)
                    {
                        CombatText.NewText(npc.Hitbox, Color.CadetBlue, AAMod.Lang.BossChat("Athena9"));
                        int p = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("AthenaFlee"));
                        Main.npc[p].Center = npc.Center;
                        npc.active         = false;
                        npc.netUpdate      = true;
                    }
                }

                music = ModLoader.GetMod("AAMod").GetSoundSlot(SoundType.Music, "Sounds/Music/Athena");

                if (internalAI[0]++ > 300 && Main.netMode != NetmodeID.MultiplayerClient)
                {
                    int pChoice = Main.rand.Next(2);
                    if (pChoice == 0)
                    {
                        NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("OwlRune"));
                    }
                    internalAI[0] = 0;
                }

                if (internalAI[1] == 0) //Acropolis Phase
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        npc.ai[3]++;
                    }

                    if (Vector2.Distance(player.Center, Acropolis) > 1280)
                    {
                        if (npc.ai[2] == 0 && Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            npc.ai[2]     = 1;
                            npc.netUpdate = true;
                        }
                        MoveToVector2(Acropolis);
                    }
                    else
                    {
                        if (npc.ai[2] == 1 && Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            npc.ai[2]     = 0;
                            npc.netUpdate = true;
                        }
                        BaseAI.AISpaceOctopus(npc, ref FlyAI, Main.player[npc.target].Center, 0.1f, 8f, 220f, 70f, ShootFeather);
                    }

                    if (npc.ai[3] > 600)
                    {
                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            internalAI[1] = 1;
                            npc.ai[0]     = 0;
                            npc.ai[1]     = 0;
                            npc.ai[2]     = 0;
                            npc.ai[3]     = 0;
                            MoveVector2   = CloudPick();
                            npc.netUpdate = true;
                        }
                    }
                }
                else //Cloud Phase
                {
                    if (MoveVector2 == new Vector2(0, 0) && Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        MoveVector2   = CloudPick();
                        npc.netUpdate = true;
                    }
                    npc.ai[1]++;
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        if (npc.ai[1] == 300)
                        {
                            if (Main.rand.Next(5) == 0)
                            {
                                internalAI[1] = 0;
                                npc.ai[0]     = 0;
                                npc.ai[1]     = 0;
                                npc.ai[2]     = 0;
                                npc.ai[3]     = 0;
                                npc.netUpdate = true;
                                return;
                            }
                            npc.ai[0]     = 0;
                            MoveVector2   = CloudPick();
                            npc.netUpdate = true;
                        }
                    }
                    if (Vector2.Distance(npc.Center, MoveVector2) < 10)
                    {
                        if (npc.ai[2] == 1 && Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            npc.ai[1]     = 0;
                            npc.ai[2]     = 0;
                            npc.netUpdate = true;
                        }
                        npc.velocity *= 0;

                        if (npc.ai[1] % 200 == 0 && Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            int Choice = Main.rand.Next(2);
                            if (Choice == 0)
                            {
                                NPC.NewNPC((int)npc.Center.X + 100, (int)npc.Center.Y, mod.NPCType("OlympianDragon"));
                                NPC.NewNPC((int)npc.Center.X - 100, (int)npc.Center.Y, mod.NPCType("OlympianDragon"));
                            }
                            else
                            {
                                NPC Seraph1 = Main.npc[NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y + 100, mod.NPCType("SeraphA"))];
                                for (int i = 0; i < 3; i++)
                                {
                                    Dust d = Main.dust[Dust.NewDust(Seraph1.position, Seraph1.height, Seraph1.width, ModContent.DustType <Feather>(), Main.rand.Next(-1, 2), 1, 0)];
                                }
                                NPC Seraph2 = Main.npc[NPC.NewNPC((int)npc.Center.X + 100, (int)npc.Center.Y - 50, mod.NPCType("SeraphA"))];
                                for (int i = 0; i < 3; i++)
                                {
                                    Dust d = Main.dust[Dust.NewDust(Seraph2.position, Seraph2.height, Seraph2.width, ModContent.DustType <Feather>(), Main.rand.Next(-1, 2), 1, 0)];
                                }
                                NPC Seraph3 = Main.npc[NPC.NewNPC((int)npc.Center.X + 100, (int)npc.Center.Y - 50, mod.NPCType("SeraphA"))];
                                for (int i = 0; i < 3; i++)
                                {
                                    Dust d = Main.dust[Dust.NewDust(Seraph3.position, Seraph3.height, Seraph3.width, ModContent.DustType <Feather>(), Main.rand.Next(-1, 2), 1, 0)];
                                }
                            }
                            npc.netUpdate = true;
                        }

                        if (npc.ai[1] % 60 == 0)
                        {
                            if (Vector2.Distance(player.Center, npc.Center) < 900)
                            {
                                ShootFeather(npc, npc.velocity);
                            }
                        }
                    }
                    else
                    {
                        if (npc.ai[2] == 0 && Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            npc.ai[2]     = 1;
                            npc.netUpdate = true;
                        }
                        MoveToVector2(MoveVector2);
                    }
                }
            }

            npc.rotation = 0;
        }
Example #4
0
        public override void AI()
        {
            if (bodyNPC == null)
            {
                NPC npcBody = Main.npc[(int)npc.ai[0]];
                if (npcBody.type == mod.NPCType("Hydra"))
                {
                    bodyNPC = npcBody;
                }
            }

            if (!NPC.AnyNPCs(mod.NPCType("Hydra")))
            {
                if (Main.netMode != NetmodeID.MultiplayerClient) //force a kill to prevent 'ghosting'
                {
                    npc.life = 0;
                    npc.checkDead();
                    npc.netUpdate = true;
                }
                return;
            }
            if (bodyNPC == null)
            {
                return;
            }

            AssignHead();

            if (!bodyNPC.active)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient) //force a kill to prevent 'ghosting'
                {
                    npc.life = 0;
                    npc.checkDead();
                    npc.netUpdate = true;
                }
                return;
            }

            npc.timeLeft = 100;

            npc.TargetClosest();

            Player targetPlayer = Main.player[npc.target];

            if (targetPlayer == null || !targetPlayer.active || targetPlayer.dead)
            {
                targetPlayer = null;                                                                    //deliberately set to null
            }
            AAMod.AAPlayer modPlayer = targetPlayer.GetModPlayer <AAMod.AAPlayer>();
            if (!modPlayer.ZoneMire)
            {
                npc.damage  = 80;
                npc.defense = 100;
            }
            else
            {
                npc.damage  = 40;
                npc.defense = 0;
            }

            if (Main.expertMode)
            {
                damage = npc.damage / 4;
            }
            else
            {
                damage = npc.damage / 2;
            }

            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                npc.ai[1]++;

                if (npc.ai[1] >= 200) //pick random spot to move head to
                {
                    npc.ai[1]     = 0;
                    npc.ai[2]     = Main.rand.Next(-movementVariance, movementVariance);
                    npc.ai[3]     = Main.rand.Next(-movementVariance, movementVariance);
                    npc.netUpdate = true;
                }
            }

            Vector2 nextTarget = Body.npc.Center + HeadPos() + new Vector2(npc.ai[2], npc.ai[3]);

            float dist = Vector2.Distance(nextTarget, npc.Center);

            if (dist < 40f)
            {
                npc.velocity *= 0.9f;
                if (Math.Abs(npc.velocity.X) < 0.05f)
                {
                    npc.velocity.X = 0f;
                }
                if (Math.Abs(npc.velocity.Y) < 0.05f)
                {
                    npc.velocity.Y = 0f;
                }
            }
            else
            if (dist > 200f) //teleport to keep up with body
            {
                npc.Center    = Body.npc.Center;
                npc.netUpdate = true;
            }
            else
            {
                npc.velocity  = Vector2.Normalize(nextTarget - npc.Center);
                npc.velocity *= 5f;
            }
            npc.position       += Body.npc.position - Body.npc.oldPosition;
            npc.spriteDirection = -1;
        }
Example #5
0
        public override void AI()
        {
            if (Main.expertMode)
            {
                damage = npc.damage / 4;
            }
            else
            {
                damage = npc.damage / 2;
            }
            if (internalAI[1] == AISTATE_RUNAWAY)
            {
                npc.noTileCollide = true;
                npc.ai[1]         = 0;
                npc.ai[2]         = 0;
                npc.ai[3]         = 0;
                internalAI[0]++;

                if (npc.timeLeft < 10)
                {
                    npc.timeLeft = 10;
                }
                npc.velocity.X *= 0.9f;

                if (internalAI[0] > 300)
                {
                    npc.velocity.Y -= 0.1f;
                    if (npc.velocity.Y > 15f)
                    {
                        npc.velocity.Y = 15f;
                    }
                    npc.rotation = 0f;
                    if (npc.position.Y + npc.velocity.Y <= 0f && Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        BaseAI.KillNPC(npc); npc.netUpdate = true;
                    }
                }
                return;
            }

            int Minions = NPC.CountNPCS(mod.NPCType("BroodEgg")) + NPC.CountNPCS(mod.NPCType("Broodmini"));

            if (Main.netMode != NetmodeID.MultiplayerClient && internalAI[0]++ >= 120)
            {
                internalAI[0] = 0;
                internalAI[1] = Minions < MaxMinions?Main.rand.Next(4) : Main.rand.Next(3);

                npc.ai = new float[4];
                if (internalAI[1] == AISTATE_FLYABOVEPLAYER)
                {
                    npc.ai[1] = 1 + Main.rand.Next(2);
                }
                else
                if (internalAI[1] == AISTATE_SPAWNEGGS)
                {
                    npc.ai[1] = npc.ai[1] == 0 ? 1 : 0;
                }
                npc.netUpdate = true;
            }
            pos = npc.ai[1] == 0 ? -250 : 250;

            if (Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 4000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 4000f)
            {
                npc.active = false;
            }

            AAMod.AAPlayer modPlayer = Main.player[npc.target].GetModPlayer <AAMod.AAPlayer>();
            if (!modPlayer.ZoneInferno)
            {
                npc.dontTakeDamage = true;
                npc.damage         = 130;
            }
            else
            {
                npc.dontTakeDamage = false;
                npc.damage         = npc.defDamage;
            }

            npc.TargetClosest();
            Player player = Main.player[npc.target];

            if (internalAI[1] != AISTATE_RUNAWAY)
            {
                if (!Main.dayTime)
                {
                    internalAI[1] = AISTATE_RUNAWAY;
                    npc.ai        = new float[4];
                    return;
                }
                if (player.dead || !player.active)
                {
                    npc.TargetClosest();
                    if (player.dead || !player.active)
                    {
                        internalAI[1] = AISTATE_RUNAWAY;
                        npc.ai        = new float[4];
                        return;
                    }
                }
            }

            Vector2 wantedVelocity = player.Center - new Vector2(pos, 250);

            MoveToPoint(wantedVelocity);

            if (internalAI[1] == AISTATE_FIREBREATH)
            {
                npc.localAI[2] += 1f;
                if (npc.localAI[2] > 22f)
                {
                    npc.localAI[2] = 0f;
                    Main.PlaySound(SoundID.Item34, npc.position);
                }
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    internalAI[2]++;
                    if (internalAI[2] > 10f)
                    {
                        if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
                        {
                            BaseAI.ShootPeriodic(npc, player.position, player.width, player.height, mod.ProjectileType("BroodBreath"), ref internalAI[3], 5, damage, 12, true, new Vector2(0, 40f));
                        }
                        else
                        {
                            int j = (int)npc.position.Y / 16;
                            int i = (int)player.position.Y / 16;
                            if (i > j && internalAI[2] % 90 == 0 && Main.netMode != NetmodeID.MultiplayerClient)
                            {
                                for (int index = -2; index < 2; index++)
                                {
                                    for (int loop = i; loop > j; loop--)
                                    {
                                        if (Main.tile[(int)player.position.X / 16 + index * 20, loop].active() && Main.tileSolid[Main.tile[(int)player.position.X / 16 + index * 10, loop].type] && (Main.tile[(int)player.position.X / 16 + index * 20, loop + 1].active() || !Main.tileSolid[Main.tile[(int)player.position.X / 16 + index * 20, loop + 1].type]))
                                        {
                                            int id = Projectile.NewProjectile(player.position.X + index * 320, loop * 16, 0, 12f, 654, damage, 0, Main.myPlayer, 0f, 0f);
                                            Main.projectile[id].hostile  = true;
                                            Main.projectile[id].friendly = false;
                                            break;
                                        }
                                    }
                                    for (int loop = i + 20; loop > j; loop--)
                                    {
                                        if (Main.tile[(int)player.position.X / 16 + index * 20 - 10, loop].active() && Main.tileSolid[Main.tile[(int)player.position.X / 16 + index * 10 - 10, loop].type] && (Main.tile[(int)player.position.X / 16 + index * 20 - 10, loop - 1].active() || !Main.tileSolid[Main.tile[(int)player.position.X / 16 + index * 20 - 10, loop - 1].type]))
                                        {
                                            int id = Projectile.NewProjectile(player.position.X + index * 320 - 160, loop * 16, 0, -12f, 654, damage, 0, Main.myPlayer, 0f, 0f);
                                            Main.projectile[id].hostile  = true;
                                            Main.projectile[id].friendly = false;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (internalAI[2] > 180)
                    {
                        internalAI[0] = 0;
                        internalAI[1] = 0;
                        internalAI[2] = 0;
                        npc.ai        = new float[4];
                        npc.netUpdate = true;
                    }
                }
            }
            else if (internalAI[1] == AISTATE_SPAWNEGGS)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    projectileTimer++;
                    if (projectileTimer >= projectileInterval && projectileTimer % 20 == 0)
                    {
                        if (projectileTimer > (projectileInterval + 60))
                        {
                            projectileTimer = 0;
                        }
                        Vector2 firePos = new Vector2(npc.Center.X + (32 * npc.direction), npc.Center.Y + 40f);
                        firePos = BaseUtility.RotateVector(npc.Center, firePos, npc.rotation); //+ (npc.direction == -1 ? (float)Math.PI : 0f)));
                        if (Minions < MaxMinions)
                        {
                            int NPCID = NPC.NewNPC((int)firePos.X, (int)firePos.Y, mod.NPCType("BroodEgg"), npc.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[NPCID].velocity.Y = 4f;
                            Main.npc[NPCID].netUpdate  = true;
                        }
                    }
                }
            }
            else if (internalAI[1] == AISTATE_FIREBOMB)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient) //only fire bombs when (attempting to) fly above the player
                {
                    projectileTimer++;
                    if (projectileTimer >= projectileInterval && projectileTimer % 10 == 0)
                    {
                        if (projectileTimer > (projectileInterval + 50))
                        {
                            projectileTimer = 0;
                        }
                        Vector2 dir     = new Vector2(npc.velocity.X * 2f + (4f * npc.direction), npc.velocity.Y * 0.5f + 1f);
                        Vector2 firePos = new Vector2(npc.Center.X + (64 * npc.direction), npc.Center.Y + 10f);
                        firePos = BaseUtility.RotateVector(npc.Center, firePos, npc.rotation); //+ (npc.direction == -1 ? (float)Math.PI : 0f)));
                        int projID = Projectile.NewProjectile(firePos, dir, mod.ProjectileType("BroodBall"), damage, 1, 255);
                        Main.projectile[projID].netUpdate = true;
                    }
                }
            }
        }
Example #6
0
        public override void AI()
        {
            if (Main.dayTime)
            {
                AIMovementRunAway();
                return;
            }

            HandleHeads();

            if (playerTarget != null)
            {
                float          dist      = npc.Distance(playerTarget.Center);
                AAMod.AAPlayer modPlayer = playerTarget.GetModPlayer <AAMod.AAPlayer>();
                if (!modPlayer.ZoneMire)
                {
                    npc.alpha += 3;
                    if (npc.alpha >= 255)
                    {
                        npc.alpha = 255;
                    }
                    if (dist > 700 || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                    {
                        npc.alpha += 3;
                        if (npc.alpha >= 255)
                        {
                            Vector2 tele = new Vector2(playerTarget.Center.X + (Main.rand.Next(2) == 0 ? 120 : -120), playerTarget.Center.Y - 16);
                            TeleportMe1   = true;
                            TeleportMe2   = true;
                            TeleportMe3   = true;
                            npc.Center    = tele;
                            npc.netUpdate = true;
                        }
                    }
                }
                else
                {
                    if (dist > 700 || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                    {
                        npc.alpha += 3;
                        if (npc.alpha >= 255)
                        {
                            Vector2 tele = new Vector2(playerTarget.Center.X + (Main.rand.Next(2) == 0 ? 120 : -120), playerTarget.Center.Y - 16);
                            TeleportMe1   = true;
                            TeleportMe2   = true;
                            TeleportMe3   = true;
                            npc.Center    = tele;
                            npc.netUpdate = true;
                        }
                    }
                    else
                    {
                        npc.alpha -= 3;
                        if (npc.alpha <= 0)
                        {
                            npc.alpha = 0;
                        }
                    }
                }
            }

            for (int m = npc.oldPos.Length - 1; m > 0; m--)
            {
                npc.oldPos[m] = npc.oldPos[m - 1];
            }
            npc.oldPos[0] = npc.position;

            bool foundTarget = TargetClosest();

            if (!runningAway && foundTarget)
            {
                if (Math.Abs(npc.velocity.X) > 12f)
                {
                    npc.velocity.X *= 0.8f;
                }
                if (Math.Abs(npc.velocity.Y) > 12f)
                {
                    npc.velocity.Y *= 0.8f;
                }
                if (npc.velocity.Y > 7f)
                {
                    npc.velocity.Y *= 0.75f;
                }
                npc.timeLeft = 50;
                AIMovementNormal();
            }
            else
            {
                runningAway = true;
                AIMovementRunAway();
                return;
            }

            bool noHeads = !NPC.AnyNPCs(mod.NPCType("HydraHead1")) && !NPC.AnyNPCs(mod.NPCType("HydraHead2")) && !NPC.AnyNPCs(mod.NPCType("HydraHead3")) &&
                           !NPC.AnyNPCs(mod.NPCType("HydraHead4")) && !NPC.AnyNPCs(mod.NPCType("HydraHead5")) && !NPC.AnyNPCs(mod.NPCType("HydraHead6")) &&
                           !NPC.AnyNPCs(mod.NPCType("HydraHead7")) && !NPC.AnyNPCs(mod.NPCType("HydraHead8")) && !NPC.AnyNPCs(mod.NPCType("HydraHead9"));

            if (HeadsSpawned && noHeads)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    npc.life = 0;
                    npc.checkDead();
                    npc.netUpdate = true;
                }
                return;
            }
        }