Exemple #1
0
        public override void AI()
        {
            Player         player    = Main.player[projectile.owner];
            TerramonPlayer modPlayer = player.GetModPlayer <TerramonPlayer>();

            if (player.dead)
            {
                modPlayer.ResetEffects();
                modPlayer.ActivePetId = -1;
            }

            if (modPlayer.IsPetActive(GetType().Name))
            {
                projectile.timeLeft = 2;
            }
        }
        public override void AI()
        {
            //Fix shifted hitbox
            var rect = projectile.Hitbox;

            rect.X      -= rect.Width;
            rect.Y      -= rect.Height;
            rect.Width  *= 2;
            rect.Height *= 2;
            //Set flag if hovered
            highlighted = rect.Contains(Main.MouseWorld.ToPoint());

            if (!highlighted)
            {
                justHighlighted = false;
            }

            if (!Wild && !flying)
            {
                PuppyAI();
            }

            Player         player    = Main.player[projectile.owner];
            TerramonPlayer modPlayer = player.GetModPlayer <TerramonPlayer>();

            if (modPlayer.ActivePetShiny)
            {
                shiny = true;
            }
            else
            {
                shiny = false;
            }

            //Animations

            if (!Wild)
            {
                projectile.spriteDirection = projectile.velocity.X > 0 ? -1 : (projectile.velocity.X < 0 ? 1 : projectile.spriteDirection);

                if (highlighted && Main.mouseRight)
                {
                    if (Main.mouseRightRelease)
                    {
                        if (HoldingPotion())
                        {
                            UsePotion();
                        }
                        if (HoldingSuperPotion())
                        {
                            UseSuperPotion();
                        }
                        if (HoldingHyperPotion())
                        {
                            UseHyperPotion();
                        }
                        if (HoldingMaxPotion())
                        {
                            UseMaxPotion();
                        }
                        if (HoldingFullRestore())
                        {
                            UseFullRestore();
                        }
                    }
                }
            }

            if (projectile.velocity.X != 0 || projectile.velocity.Y > 1 && !Wild)
            {
                frameCounter++;
                if (frameCounter > 15)
                {
                    frame       += 1;
                    frameCounter = 0;
                    if (frame >= Main.projFrames[projectile.type])
                    {
                        frame = 0;
                    }
                }
            }
            else
            {
                frame        = 1;
                frameCounter = 0;
            }

            if (Wild)
            {
                frameCounter++;
                if (frameCounter > 15)
                {
                    frame       += 1;
                    frameCounter = 0;
                    if (frame >= Main.projFrames[projectile.type])
                    {
                        frame = 0;
                    }
                }
            }

            SpawnTime++;
            if (SpawnTime == 1 && player.active)
            {
                if (player.direction == -1) // direction right
                {
                    projectile.direction = -1;
                }
                else
                {
                    projectile.direction = 1;
                }

                string n = Regex.Replace(projectile.Name, nameMatcher, "$1 ");

                if (n == "Nidoran ♂")
                {
                    n = "Nidoranm";
                }
                if (n == "Nidoran ♀")
                {
                    n = "Nidoranf";
                }
                if (n == "Mr. Mime")
                {
                    n = "Mrmime";
                }

                if (!Main.dedServ)
                {
                    Main.PlaySound(ModContent.GetInstance <TerramonMod>()
                                   .GetLegacySoundSlot(SoundType.Custom, "Sounds/Cries/cry" + n).WithVolume(0.55f));
                }

                for (int i = 0; i < 18; i++)
                {
                    Dust.NewDust(projectile.position, projectile.width, projectile.height,
                                 mod.DustType("SmokeTransformDust"));
                }
            }

            /// <summary>
            /// Battling animations
            /// </summary>

            // Damage received

            if (damageReceived)
            {
                damageReceivedTimer++;
                if (damageReceivedTimer <= 10)
                {
                    flashFrame = true;
                }
                if (damageReceivedTimer >= 11 && damageReceivedTimer <= 20)
                {
                    flashFrame = false;
                }
                if (damageReceivedTimer >= 21 && damageReceivedTimer <= 30)
                {
                    flashFrame = true;
                }
                if (damageReceivedTimer >= 31 && damageReceivedTimer <= 40)
                {
                    flashFrame = false;
                }
                if (damageReceivedTimer >= 41 && damageReceivedTimer <= 50)
                {
                    flashFrame = true;
                }
                if (damageReceivedTimer >= 51 && damageReceivedTimer <= 60)
                {
                    flashFrame          = false;
                    damageReceived      = false;
                    damageReceivedTimer = 0;
                }
            }

            // Health restoration

            if (healedHealth)
            {
                healedHealthTimer++;
                if (healedHealthTimer < 90)
                {
                    for (int i = 0; i < 1; i++)
                    {
                        Dust dust1 = Dust.NewDustDirect(projectile.position + new Vector2(Main.rand.Next(-7, 7), Main.rand.Next(-7, 7)), projectile.width, projectile.height, 74, 0f, 0f, 0, Color.White, 0.75f);
                        dust1.alpha      = 100;
                        dust1.velocity.Y = -3f;
                        dust1.noGravity  = true;
                    }
                }
                else
                {
                    healedHealthTimer = 0;
                    healedHealth      = false;
                }
            }

            // Stat modified up

            if (statModifiedUp)
            {
                statModifiedUpTimer++;
                if (statModifiedUpTimer < 90)
                {
                    for (int i = 0; i < 1; i++)
                    {
                        Dust dust1 = Dust.NewDustDirect(projectile.position + new Vector2(Main.rand.Next(-7, 7), Main.rand.Next(-7, 7)), projectile.width, projectile.height, 182, 0f, 0f, 0, Color.White, 0.75f);
                        dust1.alpha      = 100;
                        dust1.velocity.Y = -1.7f;
                        dust1.noGravity  = true;
                    }
                }
                else
                {
                    statModifiedUpTimer = 0;
                    statModifiedUp      = false;
                }
            }

            // Stat modified down

            if (statModifiedDown)
            {
                statModifiedDownTimer++;
                if (statModifiedDownTimer < 90)
                {
                    for (int i = 0; i < 1; i++)
                    {
                        Dust dust1 = Dust.NewDustDirect(projectile.position + new Vector2(Main.rand.Next(-7, 7), Main.rand.Next(-7, 7)), projectile.width, projectile.height, 56, 0f, 0f, 0, Color.White, 0.75f);
                        dust1.alpha      = 100;
                        dust1.velocity.Y = 1.25f;
                        dust1.noGravity  = true;
                    }
                }
                else
                {
                    statModifiedDownTimer = 0;
                    statModifiedDown      = false;
                }
            }

            // Getting pumped (Currently obsolete)

            if (gettingPumped)
            {
                gettingPumped = false;
            }

            /// <summary>
            /// End battling animations
            /// </summary>

            if (hopTimer <= 1)
            {
                lockedPosX = projectile.position.X;
            }

            if (Wild)
            {
                hopTimer++;
                projectile.timeLeft = 5;
                //projectile.tileCollide = false;
                if (hopTimer >= 40 && hopTimer <= 48)
                {
                    projectile.velocity.Y += -0.4f;
                    jumping = true;
                }
                if (hopTimer >= 48)
                {
                    jumping = false;
                }
                if (hopTimer >= 62 && hopTimer <= 72)
                {
                    projectile.velocity.Y += -0.4f;
                    jumping = true;
                }
                if (hopTimer >= 72)
                {
                    jumping = false;
                }
                if (!jumping)
                {
                    projectile.velocity.Y = 1f;
                }
                projectile.position.X      = lockedPosX;
                projectile.spriteDirection = projectile.position.X > player.position.X ? 1 : -1;
                return;
            }

            if (!player.active)
            {
                projectile.timeLeft = 0;
            }


            if (player.dead)
            {
                modPlayer.ResetEffects();
                modPlayer.ActivePetId = -1;
            }

            if (modPlayer.IsPetActive(GetType().Name))
            {
                projectile.timeLeft = 2;
            }
            else if ((modPlayer.Battle?.awaitSync ?? false) || modPlayer.Battle?.WildNPC == this)
            {
                projectile.timeLeft = 2;
                Wild = true;
            }

            if (modPlayer.ActiveMove != null)
            {
                if (modPlayer.ActiveMove.OverrideAI(this, modPlayer))
                {
                    aiType = 0;
                }
            }
            else if (modPlayer.Battle?.AIOverride(this) != null) //If used inside battle
            {
                var t = modPlayer.Battle?.AIOverride(this);
                t.TurnAnimation = true;
                if (t.OverrideAI(this, modPlayer))
                {
                    aiType = 0;
                }

                t.TurnAnimation = false;
            }
            else if (aiType == 0)
            {
                aiType = mainAi;
            }

            if (modPlayer.Attacking)
            {
                AttackDuration++;
                if (AttackDuration < 60)
                {
                    if (projectile.type == ModContent.ProjectileType <Bulbasaur>())
                    {
                        Projectile.NewProjectile(projectile.position.X + 23, projectile.position.Y + 8, 0f, 0f,
                                                 ModContent.ProjectileType <AngerOverlay>(), 0, 0, Main.myPlayer);
                    }

                    AttackDuration = 0;
                }
                else
                {
                    // dont make any more.
                }
            }
            else
            {
            }
        }
        public override void AI()
        {
            Player         player    = Main.player[projectile.owner];
            TerramonPlayer modPlayer = player.GetModPlayer <TerramonPlayer>();

            if (modPlayer.ActivePetShiny)
            {
                shiny = true;
            }
            else
            {
                shiny = false;
            }

            //Animations

            projectile.spriteDirection = projectile.velocity.X > 0 ? -1 : (projectile.velocity.X < 0 ? 1 : projectile.spriteDirection);

            if (projectile.velocity.X != 0 || projectile.velocity.Y > 1)
            {
                frameCounter++;
                if (frameCounter > 15)
                {
                    frame       += 1;
                    frameCounter = 0;
                    if (frame >= Main.projFrames[projectile.type])
                    {
                        frame = 0;
                    }
                }
            }
            else
            {
                frame        = 1;
                frameCounter = 0;
            }

            SpawnTime++;
            if (SpawnTime == 1)
            {
                if (player.direction == -1) // direction right
                {
                    projectile.direction = -1;
                }
                else
                {
                    projectile.direction = 1;
                }
                if (!Main.dedServ)
                {
                    Main.PlaySound(ModContent.GetInstance <TerramonMod>().GetLegacySoundSlot(SoundType.Custom, "Sounds/Cries/Kanto/cry" + projectile.Name).WithVolume(0.55f));
                }

                for (int i = 0; i < 18; i++)
                {
                    Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("SmokeTransformDust"));
                }
            }

            if (player.dead)
            {
                modPlayer.ResetEffects();
                modPlayer.ActivePetId = -1;
            }

            if (modPlayer.IsPetActive(GetType().Name))
            {
                projectile.timeLeft = 2;
            }

            if (modPlayer.ActiveMove != null)
            {
                if (modPlayer.ActiveMove.OverrideAI(projectile, this, modPlayer))
                {
                    aiType = 0;
                }
            }
            else if (aiType == 0)
            {
                aiType = mainAi;
            }

            if (modPlayer.Attacking)
            {
                AttackDuration++;
                if (AttackDuration < 60)
                {
                    if (projectile.type == ModContent.ProjectileType <Bulbasaur>())
                    {
                        Projectile.NewProjectile(projectile.position.X + 23, projectile.position.Y + 8, 0f, 0f, ModContent.ProjectileType <AngerOverlay>(), 0, 0, Main.myPlayer);
                    }
                    AttackDuration = 0;
                }
                else
                {
                    // dont make any more.
                }
            }
            else
            {
            }
        }