示例#1
0
        public override bool PreAI(NPC npc)
        {
            EModeGlobalNPC.retiBoss = npc.whoAmI;

            if (FargoSoulsWorld.SwarmActive)
            {
                return(true);
            }

            NPC spazmatism = FargoSoulsUtil.NPCExists(EModeGlobalNPC.spazBoss, NPCID.Spazmatism);

            if (!ForcedPhase2OnSpawn) //start phase 2
            {
                ForcedPhase2OnSpawn = true;
                npc.ai[0]           = 1f;
                npc.ai[1]           = 0.0f;
                npc.ai[2]           = 0.0f;
                npc.ai[3]           = 0.0f;
                npc.netUpdate       = true;
            }

            if (npc.life <= npc.lifeMax / 2 || npc.dontTakeDamage)
            {
                npc.dontTakeDamage = npc.life == 1 || !npc.HasValidTarget;
                if (npc.life != 1 && npc.HasValidTarget)
                {
                    npc.dontTakeDamage = false;
                }
                //become vulnerable again when both twins at low life
                if (npc.dontTakeDamage && npc.HasValidTarget && (spazmatism == null || spazmatism.life == 1))
                {
                    npc.dontTakeDamage = false;
                }
            }

            if (Main.dayTime)
            {
                if (npc.velocity.Y > 0)
                {
                    npc.velocity.Y = 0;
                }

                npc.velocity.Y    -= 0.5f;
                npc.dontTakeDamage = true;

                if (spazmatism != null)
                {
                    if (npc.timeLeft < 60)
                    {
                        npc.timeLeft = 60;
                    }

                    if (spazmatism.timeLeft < 60)
                    {
                        spazmatism.timeLeft = 60;
                    }

                    npc.TargetClosest(false);
                    spazmatism.TargetClosest(false);
                    if (npc.Distance(Main.player[npc.target].Center) > 2000 && spazmatism.Distance(Main.player[spazmatism.target].Center) > 2000)
                    {
                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            npc.active = false;
                            if (Main.netMode == NetmodeID.Server)
                            {
                                NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI);
                            }
                            spazmatism.active = false;
                            if (Main.netMode == NetmodeID.Server)
                            {
                                NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, EModeGlobalNPC.spazBoss);
                            }
                        }
                    }
                }

                return(true);
            }

            if (npc.ai[0] < 4f) //going to phase 3
            {
                if (npc.life <= npc.lifeMax / 2)
                {
                    //npc.ai[0] = 4f;
                    npc.ai[0]     = 604f; //initiate spin immediately
                    npc.netUpdate = true;
                    Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0);

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <GlowRingHollow>(), 0, 0f, Main.myPlayer, 11, npc.whoAmI);
                    }
                }
            }
            else //in phase 3
            {
                /*if (npc.life == 1 && --Counter1 < 0) //when brought to 1hp, begin shooting dark stars
                 * {
                 *  Counter1 = 240;
                 *  if (Main.netMode != NetmodeID.MultiplayerClient && npc.HasPlayerTarget)
                 *  {
                 *      Vector2 distance = Main.player[npc.target].Center - npc.Center;
                 *      distance.Normalize();
                 *      distance *= 10f;
                 *      for (int i = 0; i < 12; i++)
                 *          Projectile.NewProjectile(npc.Center, distance.RotatedBy(2 * Math.PI / 12 * i),
                 *              ModContent.ProjectileType<DarkStar>(), npc.damage / 5, 0f, Main.myPlayer);
                 *  }
                 * }*/

                //dust code
                if (Main.rand.Next(4) < 3)
                {
                    int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 90, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 3.5f);
                    Main.dust[dust].noGravity   = true;
                    Main.dust[dust].velocity   *= 1.8f;
                    Main.dust[dust].velocity.Y -= 0.5f;
                    if (Main.rand.NextBool(4))
                    {
                        Main.dust[dust].noGravity = false;
                        Main.dust[dust].scale    *= 0.5f;
                    }
                }

                if (npc.localAI[1] >= (npc.ai[1] == 0 ? 175 : 55)) //hijacking vanilla laser code
                {
                    npc.localAI[1] = 0;
                    Vector2 vel  = npc.DirectionTo(Main.player[npc.target].Center);
                    int     proj = Projectile.NewProjectile(npc.Center + (npc.width - 24) * vel, vel, ModContent.ProjectileType <DarkStarHoming>(), npc.damage / 4, 0f, Main.myPlayer, -1, 1f);
                    if (proj != Main.maxProjectiles)
                    {
                        Main.projectile[proj].timeLeft = 120;
                    }
                }

                if (DeathrayState == 0 || DeathrayState == 3) //not doing deathray, grow arena
                {
                    AuraRadiusCounter--;
                    if (AuraRadiusCounter < 0)
                    {
                        AuraRadiusCounter = 0;
                    }
                }
                else //doing deathray, shrink arena
                {
                    AuraRadiusCounter++;
                    if (AuraRadiusCounter > 180)
                    {
                        AuraRadiusCounter = 180;
                    }
                }

                float auraDistance = 2000 - 1200 * AuraRadiusCounter / 180f;
                if (FargoSoulsWorld.MasochistModeReal)
                {
                    auraDistance *= 0.75f;
                }
                EModeGlobalNPC.Aura(npc, auraDistance, true, DustID.Fire, default, ModContent.BuffType <Oiled>(), BuffID.OnFire, BuffID.Burning);
        public override void AI()
        {
            Player           player    = Main.player[Projectile.owner];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if (player.dead)
            {
                modPlayer.BrainMinion = false;
            }
            if (modPlayer.BrainMinion)
            {
                Projectile.timeLeft = 2;
            }

            int Brain = -1;

            for (int i = 0; i < Main.projectile.Length; i++)
            {
                if (Main.projectile[i].type == ModContent.ProjectileType <BrainMinion>() && Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner)
                {
                    Brain = i;
                }
            }
            if (Brain == -1)
            {
                Projectile.Kill();
            }
            else
            {
                for (int index = 0; index < 1000; ++index)
                {
                    if (index != Projectile.whoAmI && Main.projectile[index].active && (Main.projectile[index].owner == Projectile.owner && Main.projectile[index].type == Projectile.type) && (double)Math.Abs((float)(Projectile.position.X - Main.projectile[index].position.X)) + (double)Math.Abs((float)(Projectile.position.Y - Main.projectile[index].position.Y)) < (double)Projectile.width)
                    {
                        if (Projectile.position.X < Main.projectile[index].position.X)
                        {
                            Projectile.velocity.X -= 0.2f;
                        }
                        else
                        {
                            Projectile.velocity.X += 0.2f;
                        }
                        if (Projectile.position.Y < Main.projectile[index].position.Y)
                        {
                            Projectile.velocity.Y -= 0.2f;
                        }
                        else
                        {
                            Projectile.velocity.Y += 0.2f;
                        }
                    }
                }

                NPC  targetnpc  = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000, true));
                bool targetting = targetnpc != null;
                if (!targetting || Projectile.ai[0] > 0)
                {
                    float movespeed = Math.Max(Projectile.Distance(Main.projectile[Brain].Center) / 40f, 10f);

                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(Main.projectile[Brain].Center) * movespeed, 0.04f);
                    if (Projectile.Hitbox.Intersects(Main.projectile[Brain].Hitbox))
                    {
                        Projectile.ai[0] = 0;
                    }
                }
                if (targetting && Projectile.ai[0] == 0)
                {
                    float movespeed = Math.Max(Projectile.Distance(targetnpc.Center) / 40f, 14f);

                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(targetnpc.Center) * movespeed, 0.05f);
                }
            }
        }
示例#3
0
        public override void AI()
        {
            NPC head = FargoSoulsUtil.NPCExists(NPC.ai[2], ModContent.NPCType <EarthChampion>());

            if (head == null)
            {
                NPC.life = 0;
                NPC.checkDead();
                NPC.active = false;
                return;
            }

            NPC.lifeMax    = head.lifeMax;
            NPC.damage     = head.damage;
            NPC.defDamage  = head.defDamage;
            NPC.defense    = head.defense;
            NPC.defDefense = head.defDefense;
            NPC.target     = head.target;

            NPC.life = NPC.lifeMax;

            Player  player = Main.player[NPC.target];
            Vector2 targetPos;

            NPC.direction  = NPC.spriteDirection = (int)NPC.ai[3];
            NPC.localAI[3] = 0;

            switch ((int)NPC.ai[0])
            {
            case -1:     //healing
                targetPos    = head.Center;
                targetPos.Y += head.height;
                targetPos.X += head.width * NPC.ai[3] / 2;

                if (NPC.ai[3] > 0)
                {
                    NPC.rotation = (float)Math.PI / 4 - (float)Math.PI / 2;
                }
                else
                {
                    NPC.rotation = (float)Math.PI / 4;
                }

                if (NPC.ai[1] == 120)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        const int max          = 8;
                        float     baseRotation = MathHelper.TwoPi / max * Main.rand.NextFloat();
                        for (int i = 0; i < max; i++)
                        {
                            float rotation = baseRotation + MathHelper.TwoPi / max * (i + Main.rand.NextFloat(-0.5f, 0.5f));
                            Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType <EarthChainBlast2>(), 0, 0f, Main.myPlayer, rotation, 3);
                        }
                    }
                }

                if (++NPC.ai[1] > 120)     //clench fist as boss heals
                {
                    Movement(targetPos, 0.6f, 32f);

                    NPC.localAI[3] = 1;

                    if (NPC.ai[3] > 0)
                    {
                        NPC.rotation = -(float)Math.PI / 4 - (float)Math.PI / 2;
                    }
                    else
                    {
                        NPC.rotation = -(float)Math.PI / 4 + (float)Math.PI;
                    }

                    if (NPC.ai[1] > 240)
                    {
                        NPC.ai[0]++;
                        NPC.ai[1]     = 0;
                        NPC.netUpdate = true;
                    }
                }
                else
                {
                    Movement(targetPos, 1.2f, 32f);
                }
                break;

            case 0:     //float near head
                NPC.noTileCollide = true;

                targetPos    = head.Center;
                targetPos.Y += 250;
                targetPos.X += 300 * -NPC.ai[3];
                Movement(targetPos, 0.8f, 32f);

                NPC.rotation = 0;

                if (++NPC.ai[1] > 60)
                {
                    NPC.ai[0]++;
                    NPC.ai[1]     = 0;
                    NPC.netUpdate = true;
                }
                break;

            case 1:                  //dashes
                if (++NPC.ai[1] < 0) //do nothing lol
                {
                    NPC.rotation   = NPC.velocity.ToRotation() - (float)Math.PI / 2;
                    NPC.localAI[3] = 1;
                }
                else if (NPC.ai[1] < 75)     //hover near a side
                {
                    NPC.rotation = 0;

                    targetPos = player.Center + player.DirectionTo(NPC.Center) * 400;
                    if (NPC.ai[3] < 0 && targetPos.X < player.Center.X + 400)     //stay on your original side
                    {
                        targetPos.X = player.Center.X + 400;
                    }
                    if (NPC.ai[3] > 0 && targetPos.X > player.Center.X - 400)
                    {
                        targetPos.X = player.Center.X - 400;
                    }

                    if (NPC.Distance(targetPos) > 50)
                    {
                        Movement(targetPos, head.localAI[2] == 1 ? 2.4f : 1.2f, 32f);
                    }

                    if (head.localAI[2] == 1)
                    {
                        NPC.position += player.velocity / 3f;
                    }
                }
                else if (NPC.ai[1] < 120)     //prepare to dash, enable hitbox
                {
                    if (head.localAI[2] == 1)
                    {
                        NPC.position += player.velocity / 10f;
                    }

                    NPC.localAI[3] = 1;
                    NPC.velocity  *= NPC.localAI[2] == 1 ? 0.8f : 0.95f;
                    NPC.rotation   = NPC.DirectionTo(player.Center).ToRotation() - (float)Math.PI / 2;
                }
                else if (NPC.ai[1] == 120)     //dash
                {
                    NPC.localAI[3] = 1;
                    NPC.velocity   = NPC.DirectionTo(player.Center) * (head.localAI[2] == 1 ? 20 : 16);
                }
                else     //while dashing
                {
                    NPC.velocity *= 1.02f;

                    NPC.localAI[3] = 1;
                    NPC.rotation   = NPC.velocity.ToRotation() - (float)Math.PI / 2;

                    for (int i = 0; i < 5; i++)     //flame jet behind self
                    {
                        int d = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, -NPC.velocity.X * 0.25f, -NPC.velocity.Y * 0.25f, Scale: 3f);
                        Main.dust[d].position -= Vector2.Normalize(NPC.velocity) * NPC.width / 2;
                        Main.dust[d].noGravity = true;
                        Main.dust[d].velocity *= 4f;
                    }

                    //passed player, prepare another dash
                    if ((++NPC.localAI[1] > 60 && NPC.Distance(player.Center) > 1000) ||
                        (NPC.ai[3] > 0 ?
                         NPC.Center.X > Math.Min(head.Center.X, player.Center.X) + 300 : NPC.Center.X < Math.Max(head.Center.X, player.Center.X) - 300))
                    {
                        NPC.ai[1]      = head.localAI[2] == 1 ? 15 : 0;
                        NPC.localAI[1] = 0;
                        NPC.netUpdate  = true;

                        if (head.localAI[2] == 1 && FargoSoulsWorld.EternityMode)     //explosion chain
                        {
                            //NPC.ai[1] -= 30;

                            if (Main.netMode != NetmodeID.MultiplayerClient)
                            {
                                Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + (Vector2.Normalize(NPC.velocity) * 100), Vector2.Zero, ModContent.ProjectileType <EarthChainBlast>(), FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer, NPC.velocity.ToRotation(), 7);
                            }
                        }

                        NPC.velocity = Vector2.Normalize(NPC.velocity) * 0.1f;
                    }
                }

                if (++NPC.localAI[0] > 660)     //proceed
                {
                    NPC.ai[0]++;
                    NPC.ai[1]      = 0;
                    NPC.localAI[0] = 0;
                    NPC.netUpdate  = true;
                }
                break;

            case 2:
                goto case 0;

            case 3:     //petal shots
                if (NPC.ai[3] > 0)
                {
                    targetPos    = player.Center;
                    targetPos.Y += player.velocity.Y * 60;
                    targetPos.X  = player.Center.X - 400;

                    if (NPC.Distance(targetPos) > 50)
                    {
                        Movement(targetPos, 0.4f, 32f);
                    }
                }
                else
                {
                    targetPos    = player.Center;
                    targetPos.X += 400;
                    targetPos.Y += 600 * (float)Math.Sin(2 * Math.PI / 77 * NPC.ai[1]);

                    Movement(targetPos, 0.8f, 32f);
                }

                if (++NPC.localAI[0] > (head.localAI[2] == 1 ? 18 : 24))
                {
                    NPC.localAI[0] = 0;
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.UnitX * NPC.ai[3], ModContent.ProjectileType <FlowerPetal>(),
                                                 FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer, head.localAI[2] == 1 && FargoSoulsWorld.EternityMode ? 0 : 1);
                    }
                }

                NPC.position.X += NPC.velocity.X;     //move faster horizontally

                if (++NPC.ai[1] > 360)
                {
                    NPC.ai[0]++;
                    NPC.ai[1]      = 0;
                    NPC.localAI[0] = 0;
                    NPC.netUpdate  = true;
                }
                break;

            case 4:
                goto case 0;

            case 5:     //slam three times
            case 6:
            case 7:
                if (++NPC.ai[1] < 90)     //float over head
                {
                    NPC.noTileCollide = true;

                    targetPos    = head.Center;
                    targetPos.Y -= head.height;
                    targetPos.X += 50 * -NPC.ai[3];
                    Movement(targetPos, 2.0f, 32f);

                    NPC.rotation = 0;
                }
                else if (NPC.ai[1] == 90)     //dash down
                {
                    NPC.velocity   = Vector2.UnitY * (head.localAI[2] == 1 ? 36 : 24);
                    NPC.localAI[0] = player.position.Y;
                    NPC.netUpdate  = true;
                }
                else
                {
                    NPC.localAI[3] = 1;

                    if (NPC.ai[3] > 0)
                    {
                        NPC.rotation = -(float)Math.PI / 2;
                    }
                    else
                    {
                        NPC.rotation = (float)Math.PI / 2;
                    }

                    if (NPC.position.Y + NPC.height > NPC.localAI[0])     //become solid to smash on tiles
                    {
                        NPC.noTileCollide = false;
                    }

                    //extra checks to prevent noclipping
                    if (!NPC.noTileCollide)
                    {
                        if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height) ||
                            NPC.position.Y + NPC.height > Main.maxTilesY * 16 - 16)
                        {
                            NPC.velocity.Y = 0;
                        }
                    }

                    if (NPC.velocity.Y == 0)     //we've hit something
                    {
                        if (NPC.localAI[0] != 0)
                        {
                            NPC.localAI[0] = 0;

                            if (Main.netMode != NetmodeID.MultiplayerClient)     //spawn geysers and bombs
                            {
                                Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ProjectileID.DD2ExplosiveTrapT3Explosion, 0, 0f, Main.myPlayer);
                                Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType <FuseBomb>(), FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer);

                                if (head.localAI[2] == 1 && FargoSoulsWorld.EternityMode)
                                {
                                    for (int i = 0; i < 4; i++)
                                    {
                                        Vector2 vel = Vector2.Normalize(NPC.oldVelocity).RotatedBy(Math.PI * 2 / 4 * (NPC.ai[3] < 0 ? i : i + 0.5));
                                        Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, 1.5f * vel, ModContent.ProjectileType <EarthPalladOrb>(), FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer);
                                    }
                                }
                                else
                                {
                                    Vector2 spawnPos = NPC.Center;
                                    for (int i = 0; i <= 3; i++)
                                    {
                                        int tilePosX = (int)spawnPos.X / 16 + 250 * i / 16 * (int)-NPC.ai[3];
                                        int tilePosY = (int)spawnPos.Y / 16;    // + 1;

                                        Projectile.NewProjectile(NPC.GetSource_FromThis(), tilePosX * 16 + 8, tilePosY * 16 + 8, 0f, 0f, ModContent.ProjectileType <EarthGeyser>(), FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer, NPC.whoAmI);
                                    }
                                }
                            }
                        }

                        NPC.localAI[1]++;

                        if (NPC.localAI[1] > (head.localAI[2] == 1 ? 20 : 30))     //proceed after short pause
                        {
                            NPC.netUpdate = true;
                            NPC.ai[0]++;
                            NPC.ai[1]      = 0;
                            NPC.localAI[0] = 0;
                            NPC.localAI[1] = 0;
                            NPC.velocity   = Vector2.Zero;

                            for (int i = 0; i < Main.maxNPCs; i++)     //find the other hand
                            {
                                if (Main.npc[i].active && Main.npc[i].type == NPC.type && i != NPC.whoAmI && Main.npc[i].ai[2] == NPC.ai[2])
                                {
                                    Main.npc[i].velocity   = Vector2.Zero;
                                    Main.npc[i].ai[0]      = NPC.ai[0];
                                    Main.npc[i].ai[1]      = NPC.ai[1];
                                    Main.npc[i].localAI[0] = NPC.localAI[0];
                                    Main.npc[i].localAI[1] = NPC.localAI[1];
                                    Main.npc[i].netUpdate  = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                break;

            case 8:     //wait while head does fireballs
                NPC.noTileCollide = true;

                /*targetPos.X = head.Center.X + 330 * -NPC.ai[3];
                 * targetPos.Y = player.Center.Y;
                 * if (head.localAI[2] == 1) //if p2 and player is behind where hand should be, f**k them up
                 * {
                 *  if (Math.Sign(player.Center.X - targetPos.X) == Math.Sign(-NPC.ai[3]))
                 *      targetPos.X = player.Center.X;
                 * }
                 * if (NPC.Distance(targetPos) > 30)
                 *  Movement(targetPos, 0.8f, 32f);
                 *
                 * if (++NPC.localAI[0] > 120 && head.localAI[2] == 1)
                 *  NPC.localAI[3] = 1;*/

                targetPos = head.Center + Vector2.UnitX * -NPC.ai[3] * ((head.localAI[2] == 1 ? 450 : 600) + 500f * (1f - Math.Min(1f, NPC.localAI[1] / 240f)));
                if (NPC.Distance(targetPos) > 25)
                {
                    Movement(targetPos, 0.8f, 32f);
                }

                NPC.rotation = MathHelper.PiOver2 * -NPC.ai[3] + MathHelper.Pi;

                if (++NPC.localAI[1] > 90 && NPC.localAI[1] % 6 == 0)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        int p = Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + Vector2.UnitY * Main.rand.NextFloat(50, 100), Vector2.Zero, ModContent.ProjectileType <MoonLordSunBlast>(), FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer, Vector2.UnitY.ToRotation(), 16);
                        if (p != Main.maxProjectiles)
                        {
                            Main.projectile[p].localAI[0] = 2f;
                        }
                    }
                }

                if (NPC.ai[1] > 60)     //grace period over, if head reverts back then leave this state
                {
                    if (head.ai[0] != 1)
                    {
                        NPC.ai[0]++;
                        NPC.ai[1]      = 0;
                        NPC.localAI[0] = 0;
                        NPC.localAI[1] = 0;
                        NPC.netUpdate  = true;
                    }
                }
                else
                {
                    NPC.ai[1]++;

                    if (head.ai[0] == 0)     //just entered here, change head to shoot fireballs
                    {
                        head.ai[0]     = 1;
                        head.netUpdate = true;
                    }
                }
                break;

            case 9:
                goto case 0;

            case 10:     //crystal bomb drop
                if (head.localAI[2] == 1)
                {
                    NPC.position += player.velocity / 2;
                }

                if (NPC.ai[3] > 0)
                {
                    targetPos    = player.Center;
                    targetPos.Y  = player.Center.Y - 400;
                    targetPos.X += player.velocity.X * 60;

                    if (NPC.Distance(targetPos) > 50)
                    {
                        Movement(targetPos, 0.6f, 32f);
                    }

                    NPC.rotation = (float)Math.PI / 2;
                }
                else
                {
                    targetPos    = player.Center;
                    targetPos.Y -= 300;
                    targetPos.X += 1000 * (float)Math.Sin(2 * Math.PI / 77 * NPC.ai[1]);

                    Movement(targetPos, 1.8f, 32f);

                    NPC.rotation = -(float)Math.PI / 2;

                    NPC.localAI[0] += 0.5f;
                }

                if (++NPC.localAI[0] > 60 && NPC.ai[1] > 120)
                {
                    NPC.localAI[0] = 0;
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.UnitY * 2f, ModContent.ProjectileType <CrystalBomb>(),
                                                 FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer, player.position.Y);
                    }
                }

                if (++NPC.ai[1] > 600)
                {
                    NPC.ai[0]++;
                    NPC.ai[1]      = 0;
                    NPC.localAI[0] = 0;
                    NPC.netUpdate  = true;
                }
                break;

            default:
                NPC.ai[0] = 0;
                goto case 0;
            }
        }
示例#4
0
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], NPCID.Retinazer);

            if (npc != null)
            {
                Vector2 offset = new Vector2(npc.width - 24, 0).RotatedBy(npc.rotation + 1.57079633);
                Projectile.Center = npc.Center + offset;

                if (npc.GetEModeNPCMod <Retinazer>().DeathrayState >= 3 && Projectile.localAI[0] < maxTime - 30)
                {
                    Projectile.localAI[0] = maxTime - 30;
                }
            }
            else
            {
                Projectile.Kill();
                return;
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            if (Projectile.localAI[0] == 0f)
            {
                SoundEngine.PlaySound(new Terraria.Audio.SoundStyle("Terraria/Sounds/Zombie_104"), Projectile.Center);
            }
            float num801 = 1f;

            Projectile.localAI[0] += 1f;
            if (Projectile.localAI[0] >= maxTime)
            {
                Projectile.Kill();
                return;
            }
            Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * 3.14159274f / maxTime) * 10f * num801;
            if (Projectile.scale > num801)
            {
                Projectile.scale = num801;
            }
            //float num804 = Projectile.velocity.ToRotation();
            //num804 += Projectile.ai[0];
            //Projectile.rotation = num804 - 1.57079637f;
            float num804 = npc.rotation;

            Projectile.rotation = num804;
            num804 += 1.57079637f;
            Projectile.velocity = num804.ToRotationVector2();
            float   num805        = 3f;
            float   num806        = (float)Projectile.width;
            Vector2 samplingPoint = Projectile.Center;

            if (vector78.HasValue)
            {
                samplingPoint = vector78.Value;
            }
            float[] array3 = new float[(int)num805];
            Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 2400f, array3);
            float num807 = 0f;
            int   num3;

            for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1)
            {
                num807 += array3[num808];
                num3    = num808;
            }
            num807 /= num805;
            float amount = 0.5f;

            Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount);
            Vector2 vector79 = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f);

            for (int num809 = 0; num809 < 2; num809 = num3 + 1)
            {
                float   num810   = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f;
                float   num811   = (float)Main.rand.NextDouble() * 2f + 2f;
                Vector2 vector80 = new Vector2((float)Math.Cos((double)num810) * num811, (float)Math.Sin((double)num810) * num811);
                int     num812   = Dust.NewDust(vector79, 0, 0, 244, vector80.X, vector80.Y, 0, default(Color), 1f);
                Main.dust[num812].noGravity = true;
                Main.dust[num812].scale     = 1.7f;
                num3 = num809;
            }
            if (Main.rand.NextBool(5))
            {
                Vector2 value29 = Projectile.velocity.RotatedBy(1.5707963705062866, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)Projectile.width;
                int     num813  = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 244, 0f, 0f, 100, default(Color), 1.5f);
                Dust    dust    = Main.dust[num813];
                dust.velocity *= 0.5f;
                Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y);
            }
            //DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f);
            //Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], (float)Projectile.width * Projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight));
        }
示例#5
0
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], ModContent.NPCType <NatureChampionHead>());

            if (npc == null)
            {
                Projectile.Kill();
                return;
            }
            else
            {
                Projectile.Center = npc.Center;
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            if (Projectile.localAI[0] == 0f)
            {
                SoundEngine.PlaySound(new Terraria.Audio.SoundStyle("Terraria/Sounds/Zombie_104"), Projectile.Center);
            }
            float num801 = 1f;

            Projectile.localAI[0] += 1f;
            if (Projectile.localAI[0] >= maxTime)
            {
                Projectile.Kill();
                return;
            }
            Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * 3.14159274f / maxTime) * 10f * num801;
            if (Projectile.scale > num801)
            {
                Projectile.scale = num801;
            }
            float num804 = Projectile.velocity.ToRotation();

            num804 += Projectile.ai[0];
            Projectile.rotation = num804 - 1.57079637f;
            //float num804 = Main.npc[(int)Projectile.ai[1]].ai[3] - 1.57079637f + Projectile.ai[0];
            //if (Projectile.ai[0] != 0f) num804 -= (float)Math.PI;
            //Projectile.rotation = num804;
            //num804 += 1.57079637f;
            Projectile.velocity = num804.ToRotationVector2();
            float   num805        = 3f;
            float   num806        = (float)Projectile.width;
            Vector2 samplingPoint = Projectile.Center;

            if (vector78.HasValue)
            {
                samplingPoint = vector78.Value;
            }
            float[] array3 = new float[(int)num805];
            //Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 3000f, array3);
            for (int i = 0; i < array3.Length; i++)
            {
                array3[i] = 3000f;
            }
            float num807 = 0f;
            int   num3;

            for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1)
            {
                num807 += array3[num808];
                num3    = num808;
            }
            num807 /= num805;
            float amount = 0.5f;

            Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount);
            Vector2 vector79 = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f);

            for (int num809 = 0; num809 < 2; num809 = num3 + 1)
            {
                float   num810   = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f;
                float   num811   = (float)Main.rand.NextDouble() * 2f + 2f;
                Vector2 vector80 = new Vector2((float)Math.Cos((double)num810) * num811, (float)Math.Sin((double)num810) * num811);
                int     num812   = Dust.NewDust(vector79, 0, 0, 244, vector80.X, vector80.Y, 0, default(Color), 1f);
                Main.dust[num812].noGravity = true;
                Main.dust[num812].scale     = 1.7f;
                num3 = num809;
            }
            if (Main.rand.NextBool(5))
            {
                Vector2 value29 = Projectile.velocity.RotatedBy(1.5707963705062866, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)Projectile.width;
                int     num813  = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 244, 0f, 0f, 100, default(Color), 1.5f);
                Dust    dust    = Main.dust[num813];
                dust.velocity *= 0.5f;
                Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y);
            }
            //DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f);
            //Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], (float)Projectile.width * Projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight));

            npc.rotation  = Projectile.velocity.ToRotation();
            npc.direction = npc.spriteDirection = Projectile.velocity.X > 0 ? 1 : -1;
            if (Projectile.velocity.X < 0)
            {
                npc.rotation += (float)Math.PI * 1.25f;
            }
            else
            {
                npc.rotation -= (float)Math.PI * .25f;
            }
            Projectile.position += new Vector2(14 * npc.spriteDirection, 28).RotatedBy(npc.rotation);
        }
示例#6
0
        public override int GetVulnerabilityState(NPC npc)
        {
            NPC core = FargoSoulsUtil.NPCExists(npc.ai[3], NPCID.MoonLordCore);

            return(core == null ? -1 : core.GetEModeNPCMod <MoonLordCore>().VulnerabilityState);
        }
示例#7
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoPlayer>().SkeletronArms)
            {
                projectile.timeLeft = 2;
            }

            if (projectile.damage == 0)
            {
                projectile.damage = 18;
                if (player.GetModPlayer <FargoPlayer>().SupremeDeathbringerFairy)
                {
                    projectile.damage = 24;
                }
                if (player.GetModPlayer <FargoPlayer>().MasochistSoul)
                {
                    projectile.damage = 48;
                }
                projectile.damage = (int)(projectile.damage * player.minionDamage);
            }

            //tentacle head movement (homing)
            Vector2 playerVel = player.position - player.oldPosition;

            projectile.position += playerVel;
            projectile.ai[0]++;
            if (projectile.ai[0] >= 0f)
            {
                Vector2 home = player.Center;
                home.X -= 200f;
                home.Y -= 50f;
                Vector2 distance = home - projectile.Center;
                float   range    = distance.Length();
                distance.Normalize();
                if (projectile.ai[0] == 0f)
                {
                    if (range > 15f)
                    {
                        projectile.ai[0] = -1f; //if in fast mode, stay fast until back in range
                        if (range > 1300f)
                        {
                            projectile.Kill();
                            return;
                        }
                    }
                    else
                    {
                        projectile.velocity.Normalize();
                        projectile.velocity *= 3f + Main.rand.NextFloat(3f);
                        projectile.netUpdate = true;
                    }
                }
                else
                {
                    distance /= 8f;
                }
                if (range > 120f) //switch to fast return mode
                {
                    projectile.ai[0]     = -1f;
                    projectile.netUpdate = true;
                }
                projectile.velocity += distance;
                if (range > 30f)
                {
                    projectile.velocity *= 0.96f;
                }

                if (projectile.ai[0] > 90f) //attack nearby enemy
                {
                    projectile.ai[0] = 20f;
                    NPC npc = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 400));
                    if (npc != null)
                    {
                        projectile.velocity = npc.Center - projectile.Center;
                        projectile.velocity.Normalize();
                        projectile.velocity *= 16f;
                        projectile.velocity += npc.velocity / 2f;
                        projectile.velocity -= playerVel / 2f;
                        projectile.ai[0]    *= -1f;
                    }
                    projectile.netUpdate = true;
                }
            }

            Vector2 angle = player.Center - projectile.Center;

            angle.X            -= 200f;
            angle.Y            += 180f;
            projectile.rotation = (float)Math.Atan2(angle.Y, angle.X) + (float)Math.PI / 2f;
        }
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1]);
            if (npc == null || !npc.CanBeChasedBy())
            {
                Projectile.ai[1] = FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000);
                Projectile.netUpdate = true;
            }

            Projectile.ai[0]++;
            if (Projectile.ai[0] <= 50)
            {
                if (Main.rand.NextBool(4))
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position = Projectile.Center - spinningpoint * Main.rand.Next(10, 21);
                    dust.velocity = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 4f;
                    dust.scale = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn = 0.5f;
                }
                if (Main.rand.NextBool(4))
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position = Projectile.Center - spinningpoint * 30f;
                    dust.velocity = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 2f;
                    dust.scale = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn = 0.5f;
                }
            }
            else if (Projectile.ai[0] <= 90)
            {
                Projectile.scale = (Projectile.ai[0] - 50) / 40;
                Projectile.alpha = 255 - (int)(255 * Projectile.scale);
                Projectile.rotation = Projectile.rotation - 0.1570796f;
                if (Main.rand.NextBool())
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position = Projectile.Center - spinningpoint * Main.rand.Next(10, 21);
                    dust.velocity = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 6f;
                    dust.scale = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn = 0.5f;
                    dust.customData = Projectile.Center;
                }
                if (Main.rand.NextBool())
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position = Projectile.Center - spinningpoint * 30f;
                    dust.velocity = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 3f;
                    dust.scale = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn = 0.5f;
                    dust.customData = Projectile.Center;
                }

                /*Vector2 rotationVector2 = Main.npc[ai1].Center - Projectile.Center;
                rotationVector2.Normalize(); //Projectile.ai[1].ToRotationVector2();
                Vector2 vector2_1 = rotationVector2.RotatedBy(1.57079637050629, new Vector2()) * (Main.rand.NextBool()).ToDirectionInt() * (float)Main.rand.Next(10, 21);
                Vector2 vector2_2 = (rotationVector2 * Main.rand.Next(-80, 81) - vector2_1) / 10f;
                int Type = Utils.SelectRandom<int>(Main.rand, new int[2] { 229, 229 });
                Dust d = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, Type, 0.0f, 0.0f, 0, new Color(), 1f)];
                d.noGravity = true;
                d.position = Projectile.Center + vector2_1;
                d.velocity = vector2_2;
                d.scale = 0.5f + Main.rand.NextFloat();
                d.fadeIn = 0.5f;*/
                if (Projectile.ai[0] == 90 && Projectile.ai[1] != -1 && Main.netMode != NetmodeID.MultiplayerClient && npc != null)
                {
                    Vector2 rotationVector2 = npc.Center - Projectile.Center;
                    rotationVector2.Normalize();

                    Vector2 vector2_3 = rotationVector2 * 8f;
                    float ai_1 = Main.rand.Next(80);

                    int p = Player.FindClosest(Projectile.Center, 0, 0);
                    if (p != -1 && Main.player[p].active && !Main.player[p].dead && !Main.player[p].ghost && Projectile.Distance(Main.player[p].Center) < 1000)
                    {
                        Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X - vector2_3.X, Projectile.Center.Y - vector2_3.Y, vector2_3.X, vector2_3.Y,
                          ModContent.ProjectileType<LightningArc>(), Projectile.damage, Projectile.knockBack, Projectile.owner,
                          rotationVector2.ToRotation(), ai_1);
                    }
                }
            }
            else if (Projectile.ai[0] <= 120)
            {
                Projectile.scale = 1f;
                Projectile.alpha = 0;
                Projectile.rotation = Projectile.rotation - (float)Math.PI / 60f;
                if (Main.rand.NextBool())
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position = Projectile.Center - spinningpoint * Main.rand.Next(10, 21);
                    dust.velocity = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 6f;
                    dust.scale = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn = 0.5f;
                    dust.customData = Projectile.Center;
                }
                else
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position = Projectile.Center - spinningpoint * 30f;
                    dust.velocity = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 3f;
                    dust.scale = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn = 0.5f;
                    dust.customData = Projectile.Center;
                }
            }
            else
            {
                Projectile.scale = (float)(1.0 - (Projectile.ai[0] - 120.0) / 60.0);
                Projectile.alpha = 255 - (int)(255 * Projectile.scale);
                Projectile.rotation = Projectile.rotation - (float)Math.PI / 30f;
                if (Projectile.alpha >= 255)
                    Projectile.Kill();
                for (int index = 0; index < 2; ++index)
                {
                    switch (Main.rand.Next(3))
                    {
                        case 0:
                            Vector2 spinningpoint1 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale;
                            Dust dust1 = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint1 * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                            dust1.noGravity = true;
                            dust1.position = Projectile.Center - spinningpoint1 * Main.rand.Next(10, 21);
                            dust1.velocity = spinningpoint1.RotatedBy(1.57079637050629, new Vector2()) * 6f;
                            dust1.scale = 0.5f + Main.rand.NextFloat();
                            dust1.fadeIn = 0.5f;
                            dust1.customData = Projectile.Center;
                            break;
                        case 1:
                            Vector2 spinningpoint2 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale;
                            Dust dust2 = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint2 * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                            dust2.noGravity = true;
                            dust2.position = Projectile.Center - spinningpoint2 * 30f;
                            dust2.velocity = spinningpoint2.RotatedBy(-1.57079637050629, new Vector2()) * 3f;
                            dust2.scale = 0.5f + Main.rand.NextFloat();
                            dust2.fadeIn = 0.5f;
                            dust2.customData = Projectile.Center;
                            break;
                    }
                }
            }
        }
        public override void AI()
        {
            //the important part
            NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[0], ModContent.NPCType <NPCs.DeviBoss.DeviBoss>());

            if (npc != null)
            {
                if (Projectile.localAI[0] == 0)
                {
                    Projectile.localAI[0] = 1;
                    Projectile.localAI[1] = Projectile.DirectionFrom(npc.Center).ToRotation();
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, -1, -17);
                    }
                }

                //not important part
                if (Projectile.alpha > 0)
                {
                    Projectile.alpha -= 4;
                    if (Projectile.alpha < 0)
                    {
                        Projectile.alpha = 0;
                    }
                }

                //important again
                if (++Projectile.localAI[0] > 31)
                {
                    Projectile.localAI[0] = 1;
                    if (++scaleCounter < 3)
                    {
                        Projectile.position = Projectile.Center;

                        Projectile.width  *= 2;
                        Projectile.height *= 2;
                        Projectile.scale  *= 2;

                        Projectile.Center = Projectile.position;

                        MakeDust();

                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, -1, -16 + scaleCounter);
                        }

                        SoundEngine.PlaySound(SoundID.Item92, Projectile.Center);
                    }
                }

                Vector2 offset = new Vector2(Projectile.ai[1], 0).RotatedBy(npc.ai[3] + Projectile.localAI[1]);
                Projectile.Center = npc.Center + offset * Projectile.scale;
            }
            else
            {
                Projectile.Kill();
                return;
            }

            if (Projectile.timeLeft == 8)
            {
                SoundEngine.PlaySound(SoundID.NPCDeath6, Projectile.Center);
                SoundEngine.PlaySound(SoundID.Item92, Projectile.Center);

                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, -1, -14);
                }

                if (!Main.dedServ && Main.LocalPlayer.active)
                {
                    Main.LocalPlayer.GetModPlayer <FargoSoulsPlayer>().Screenshake = 30;
                }

                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    /*for (int i = 0; i < 8; i++)
                     * {
                     *  Vector2 target = 400 * Vector2.UnitX.RotatedBy(Math.PI / 4 * i + Math.PI / 8);
                     *  Vector2 speed = 2 * target / 90;
                     *  float acceleration = -speed.Length() / 90;
                     *  float rotation = speed.ToRotation() + (float)Math.PI / 2;
                     *  Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, speed, ModContent.ProjectileType<DeviEnergyHeart>(), Projectile.damage, 0f, Main.myPlayer, rotation, acceleration);
                     * }*/
                    for (int i = 0; i < 8; i++)
                    {
                        Vector2 target       = 600 * Vector2.UnitX.RotatedBy(Math.PI / 4 * i);
                        Vector2 speed        = 2 * target / 90;
                        float   acceleration = -speed.Length() / 90;
                        float   rotation     = speed.ToRotation();
                        Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, speed, ModContent.ProjectileType <DeviEnergyHeart>(),
                                                 (int)(Projectile.damage * 0.75), 0f, Main.myPlayer, rotation + MathHelper.PiOver2, acceleration);

                        Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, Vector2.Zero, ModContent.ProjectileType <GlowLine>(), Projectile.damage, 0f, Main.myPlayer, 2, rotation);
                        Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, speed, ModContent.ProjectileType <GlowLine>(), Projectile.damage, 0f, Main.myPlayer, 2, rotation + MathHelper.PiOver2);
                        Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, speed, ModContent.ProjectileType <GlowLine>(), Projectile.damage, 0f, Main.myPlayer, 2, rotation - MathHelper.PiOver2);
                    }
                }
            }

            Projectile.direction = Projectile.spriteDirection = npc.direction;
            Projectile.rotation  = npc.ai[3] + Projectile.localAI[1] + (float)Math.PI / 2 + (float)Math.PI / 4;
            if (Projectile.spriteDirection >= 0)
            {
                Projectile.rotation -= (float)Math.PI / 2;
            }
        }
        public override void AI()
        {
            Projectile.velocity = Vector2.Zero;

            if (!firsttick)
            {
                for (int i = 0; i < 8; i++)
                {
                    Vector2 dir = Vector2.UnitX.RotatedBy(2 * (float)Math.PI / 8 * i);
                    Vector2 vel = Vector2.Normalize(dir);
                    Projectile.NewProjectile(Terraria.Entity.InheritSource(Projectile), Projectile.Center, vel, ModContent.ProjectileType <TerraLightningOrbDeathray>(),
                                             Projectile.damage, 0, Main.myPlayer, dir.ToRotation(), Projectile.whoAmI);
                }
                Projectile.rotation = Projectile.localAI[0];
                firsttick           = true;
            }

            if (Projectile.localAI[0] > 0) //rotate fast, then slow down over time
            {
                Projectile.rotation += Projectile.localAI[1] * (6 - Projectile.scale) * 0.012f;
            }

            NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[0], ModContent.NPCType <NPCs.Champions.TerraChampion>());

            if (npc != null)
            {
                Projectile.alpha -= 10;
                if (Projectile.alpha < 0)
                {
                    Projectile.alpha = 0;
                }

                Projectile.velocity = 4f * Projectile.DirectionTo(Main.player[npc.target].Center);

                if (++Projectile.ai[1] > 60) //grow
                {
                    Projectile.ai[1]     = 0;
                    Projectile.netUpdate = true;

                    Projectile.position = Projectile.Center;

                    Projectile.width  = (int)(Projectile.width / Projectile.scale);
                    Projectile.height = (int)(Projectile.height / Projectile.scale);

                    Projectile.scale++;

                    Projectile.width  = (int)(Projectile.width * Projectile.scale);
                    Projectile.height = (int)(Projectile.height * Projectile.scale);

                    Projectile.Center = Projectile.position;

                    MakeDust();
                    SoundEngine.PlaySound(SoundID.Item92, Projectile.Center);
                }
            }
            else
            {
                if (Projectile.timeLeft < 2)
                {
                    Projectile.timeLeft = 2;
                }

                Projectile.alpha += 10;
                if (Projectile.alpha > 255)
                {
                    Projectile.alpha = 255;
                    Projectile.Kill();
                }
            }

            Lighting.AddLight(Projectile.Center, 0.4f, 0.85f, 0.9f);
            Projectile.frameCounter++;
            if (Projectile.frameCounter > 3)
            {
                Projectile.frameCounter = 0;
                Projectile.frame++;
                if (Projectile.frame > 3)
                {
                    Projectile.frame = 0;
                }
            }

            if (Main.rand.NextBool(3))
            {
                float num11 = (float)(Main.rand.NextDouble() * 1.0 - 0.5); //vanilla dust :echbegone:
                if ((double)num11 < -0.5)
                {
                    num11 = -0.5f;
                }
                if ((double)num11 > 0.5)
                {
                    num11 = 0.5f;
                }
                Vector2 vector21 = new Vector2((float)-Projectile.width * 0.2f * Projectile.scale, 0.0f).RotatedBy((double)num11 * 6.28318548202515, new Vector2()).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2());
                int     index21  = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 226, (float)(-(double)Projectile.velocity.X / 3.0), (float)(-(double)Projectile.velocity.Y / 3.0), 150, Color.Transparent, 0.7f);
                Main.dust[index21].position  = Projectile.Center + vector21 * Projectile.scale;
                Main.dust[index21].velocity  = Vector2.Normalize(Main.dust[index21].position - Projectile.Center) * 2f;
                Main.dust[index21].noGravity = true;
                float num1 = (float)(Main.rand.NextDouble() * 1.0 - 0.5);
                if ((double)num1 < -0.5)
                {
                    num1 = -0.5f;
                }
                if ((double)num1 > 0.5)
                {
                    num1 = 0.5f;
                }
                Vector2 vector2 = new Vector2((float)-Projectile.width * 0.6f * Projectile.scale, 0.0f).RotatedBy((double)num1 * 6.28318548202515, new Vector2()).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2());
                int     index2  = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 226, (float)(-(double)Projectile.velocity.X / 3.0), (float)(-(double)Projectile.velocity.Y / 3.0), 150, Color.Transparent, 0.7f);
                Main.dust[index2].velocity  = Vector2.Zero;
                Main.dust[index2].position  = Projectile.Center + vector2 * Projectile.scale;
                Main.dust[index2].noGravity = true;
            }
        }
        public override void AI()
        {
            const int startup = 100;

            if (Projectile.localAI[0] == 0)
            {
                Projectile.localAI[0] = 1;
                Projectile.localAI[1] = Projectile.velocity.Length() / startup;

                Projectile.hide = false;
                Projectile.rotation = 2f * Main.rand.NextFloat(MathHelper.TwoPi) * (Main.rand.NextBool() ? -1 : 1);
                Projectile.frame = Main.rand.Next(Main.projFrames[Projectile.type]);
            }

            if (++dustTimer == 15)
            {
                MakeDust();
                SoundEngine.PlaySound(SoundID.Item71, Projectile.Center);
            }

            if (Projectile.ai[0] == -1) //fly forward
            {
                if (++Projectile.localAI[0] <= startup)
                {
                    Projectile.velocity = (Projectile.velocity.Length() - Projectile.localAI[1]) * Vector2.Normalize(Projectile.velocity);

                    Projectile.rotation = MathHelper.Lerp(Projectile.rotation, Projectile.ai[1] > 0 ? 0 : MathHelper.Pi, 0.05f);
                    Projectile.spriteDirection = (int)Projectile.ai[1];

                    if (Projectile.localAI[0] == startup)
                        SoundEngine.PlaySound(SoundID.Item71, Projectile.Center);
                }
                else
                {
                    Projectile.velocity = 36f * Projectile.ai[1] * Vector2.UnitX;
                    Projectile.rotation = Projectile.velocity.ToRotation();
                }
            }
            else //hover around mothron
            {
                NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[0], NPCID.Mothron);
                if (npc == null || (npc.ai[0] < 3f && dustTimer > 15))
                {
                    Projectile.Kill();
                    return;
                }
                else
                {
                    Projectile.timeLeft++;

                    const float rotationPerTick = MathHelper.TwoPi / 60f;

                    Projectile.spriteDirection = Math.Sign(Projectile.ai[1]);
                    Projectile.ai[1] += rotationPerTick * Projectile.spriteDirection;
                    Projectile.rotation = Projectile.ai[1];

                    float distance = 120;
                    if (Projectile.spriteDirection < 0)
                        distance *= 2;
                    Projectile.Center = npc.Center + distance * Projectile.ai[1].ToRotationVector2();

                    if (npc.ai[0] < 4f)
                        Projectile.alpha -= 4;
                }
            }

            Projectile.alpha -= 4;
            if (Projectile.alpha < 0)
                Projectile.alpha = 0;
        }
示例#12
0
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[0]);

            if (npc != null)
            {
                projectile.Center = npc.Center;
            }

            float scale            = 12f;
            int   maxTime          = 30;
            bool  customScaleAlpha = false;

            switch ((int)projectile.ai[1])
            {
            case -23:     //eridanus general punch telegraph
            {
                customScaleAlpha = true;
                maxTime          = 90;
                float modifier = projectile.localAI[0] / maxTime;
                color            = new Color(51, 255, 191) * modifier;
                projectile.alpha = (int)(255f * (1f - modifier));
                projectile.scale = 3f * 9f * (1f - modifier);
            }
            break;

            case -22:     //wof vanilla laser telegraph
            {
                customScaleAlpha = true;
                maxTime          = 645;

                if (npc != null && npc.type == NPCID.WallofFleshEye && (npc.GetEModeNPCMod <WallofFleshEye>().HasTelegraphedNormalLasers || Main.netMode == NetmodeID.MultiplayerClient))
                {
                    projectile.rotation = npc.rotation + (npc.direction > 0 ? 0 : MathHelper.Pi);
                    projectile.velocity = projectile.rotation.ToRotationVector2();
                    projectile.Center   = npc.Center + (npc.width - 52) * Vector2.UnitX.RotatedBy(projectile.rotation);

                    if (projectile.localAI[0] < npc.localAI[1])
                    {
                        projectile.localAI[0] = (int)npc.localAI[1];
                    }

                    float modifier = (float)Math.Cos(Math.PI / 2 / maxTime * projectile.localAI[0]);

                    color            = new Color(255, 0, 255, 100) * (1f - modifier);
                    projectile.alpha = (int)(255f * modifier);
                    projectile.scale = 18f * modifier;
                }
                else
                {
                    projectile.Kill();
                    return;
                }
            }
            break;

            case -21:     //default but small, devi uses this for becoming back money
                scale   = 4f;
                maxTime = 60;
                break;

            case -20:     //eridanus punch windup
            {
                customScaleAlpha = true;
                maxTime          = 200;
                float modifier = projectile.localAI[0] / maxTime;
                color            = new Color(51, 255, 191) * modifier;
                projectile.alpha = (int)(255f * (1f - modifier));
                projectile.scale = 3f * 6f * (1f - modifier);
            }
            break;

            case -19:     //abom dash
                color   = Color.Yellow;
                color.A = 0;
                scale   = 18f;
                break;

            case -18:     //eridanus timestop
                scale   = 36f;
                maxTime = 120;
                break;

            case -17:     //devi smallest pink
                scale = 6f;
                goto case -16;

            case -16:     //devi scaling pink
                color = new Color(255, 51, 153, 0);
                break;

            case -15:     //devi scaling pink
                scale = 18f;
                goto case -16;

            case -14:     //deviantt biggest pink
                scale = 24f;
                goto case -16;

            case -13:     //wof reticle
                color   = new Color(93, 255, 241, 0);
                scale   = 6f;
                maxTime = 15;
                break;

            case -12:     //nature shroomite blue
                color   = new Color(0, 0, 255, 0);
                maxTime = 45;
                break;

            case -11:     //nature chlorophyte green
                color   = new Color(0, 255, 0, 0);
                maxTime = 45;
                break;

            case -10:     //nature frost cyan
                color   = new Color(0, 255, 255, 0);
                maxTime = 45;
                break;

            case -9:     //nature rain yellow
                color   = new Color(255, 255, 0, 0);
                maxTime = 45;
                break;

            case -8:     //nature molten orange
                color   = new Color(255, 127, 40, 0);
                maxTime = 45;
                break;

            case -7:     //nature crimson red
                color   = new Color(255, 0, 0, 0);
                maxTime = 45;
                break;

            case -6:     //will, spirit champ yellow
                color = new Color(255, 255, 0, 0);
                scale = 18f;
                break;

            case -5:     //shadow champ purple
                color = new Color(200, 0, 255, 0);
                scale = 18f;
                break;

            case -4:     //life champ yellow
                color   = new Color(255, 255, 0, 0);
                scale   = 18f;
                maxTime = 60;
                break;

            case -3:     //earth champ orange
                color   = new Color(255, 100, 0, 0);
                scale   = 18f;
                maxTime = 60;
                break;

            case -2:     //ml teal cyan
                color = new Color(51, 255, 191, 0);
                scale = 18f;
                break;

            case -1:     //purple shadowbeam
                color   = new Color(200, 0, 200, 0);
                maxTime = 60;
                break;

            case NPCID.EyeofCthulhu:
                color   = new Color(51, 255, 191, 0);
                maxTime = 45;
                break;

            case NPCID.QueenBee:
                color   = new Color(255, 255, 100, 0);
                maxTime = 45;
                break;

            case NPCID.WallofFleshEye:
                color   = new Color(93, 255, 241, 0);
                scale   = 12f;
                maxTime = 30;
                break;

            case NPCID.Retinazer:
                color   = new Color(255, 0, 0, 0);
                scale   = 24f;
                maxTime = 60;
                break;

            case NPCID.PrimeSaw:
            case NPCID.PrimeVice:
                color   = new Color(255, 0, 0, 0);
                scale   = 12f;
                maxTime = 30;
                break;

            case NPCID.CultistBoss:
                color = new Color(255, 127, 40, 0);
                break;

            case NPCID.MoonLordHand:
            case NPCID.MoonLordHead:
            case NPCID.MoonLordCore:
                color   = new Color(51, 255, 191, 0);
                scale   = 12f;
                maxTime = 60;
                break;

            default:
                break;
            }

            if (++projectile.localAI[0] > maxTime)
            {
                projectile.Kill();
                return;
            }

            if (!customScaleAlpha)
            {
                projectile.scale = scale * (float)Math.Sin(Math.PI / 2 * projectile.localAI[0] / maxTime);
                projectile.alpha = (int)(255f * projectile.localAI[0] / maxTime);
            }

            if (projectile.alpha < 0)
            {
                projectile.alpha = 0;
            }
            if (projectile.alpha > 255)
            {
                projectile.alpha = 255;
            }
        }
示例#13
0
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[0], ModContent.NPCType <NPCs.AbomBoss.AbomBoss>());

            if (npc == null)
            {
                projectile.Kill();
                return;
            }

            Vector2 target = npc.Center;

            target.X += (npc.localAI[3] > 1 ? 1200 : 2000) * (float)Math.Sin(2 * Math.PI / 720 * projectile.ai[1]++);
            target.Y -= 1100;

            Vector2 distance = target - projectile.Center;
            float   length   = distance.Length();

            if (length > 100f)
            {
                distance           /= 8f;
                projectile.velocity = (projectile.velocity * 23f + distance) / 24f;
            }
            else
            {
                if (projectile.velocity.Length() < 12f)
                {
                    projectile.velocity *= 1.05f;
                }
            }

            /*projectile.localAI[0]++;
             * if (projectile.localAI[0] > 45)
             * {
             *  projectile.localAI[0] = 0f;
             *  if (projectile.owner == Main.myPlayer)
             *  {
             *      Vector2 vel = distance;
             *      vel.Normalize();
             *      vel *= 9f;
             *      Projectile.NewProjectile(projectile.Center, vel, ModContent.ProjectileType<FrostWave>(),
             *          projectile.damage, projectile.knockBack, projectile.owner);
             *  }
             * }*/

            if (++projectile.localAI[0] > 90 && ++projectile.localAI[1] > (npc.localAI[3] > 1 ? 4 : 2)) //spray shards
            {
                Main.PlaySound(SoundID.Item27, projectile.position);
                projectile.localAI[1] = 0f;
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    if (Math.Abs(npc.Center.X - projectile.Center.X) > 400)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            Vector2 speed = new Vector2(Main.rand.Next(-1000, 1001), Main.rand.Next(-1000, 1001));
                            speed.Normalize();
                            speed *= 8f;
                            Projectile.NewProjectile(projectile.Center + speed * 4f, speed, ModContent.ProjectileType <AbomFrostShard>(), projectile.damage, projectile.knockBack, projectile.owner);
                        }
                    }
                    if (Main.player[npc.target].active && !Main.player[npc.target].dead && Main.player[npc.target].Center.Y < projectile.Center.Y)
                    {
                        Main.PlaySound(SoundID.Item120, projectile.position);
                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Vector2 vel = projectile.DirectionTo(Main.player[npc.target].Center + new Vector2(Main.rand.Next(-200, 201), Main.rand.Next(-200, 201))) * 12f;
                            Projectile.NewProjectile(projectile.Center, vel, ModContent.ProjectileType <AbomFrostWave>(), projectile.damage, projectile.knockBack, projectile.owner);
                        }
                    }
                }
            }

            projectile.rotation += projectile.velocity.Length() / 12f * (projectile.velocity.X > 0 ? -0.2f : 0.2f);
            if (++projectile.frameCounter > 3)
            {
                if (++projectile.frame >= 6)
                {
                    projectile.frame = 0;
                }
                projectile.frameCounter = 0;
            }
        }
        public override void AI()
        {
            Player           player    = Main.player[Projectile.owner];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if (player.dead)
            {
                modPlayer.BigBrainMinion = false;
            }
            if (modPlayer.BigBrainMinion)
            {
                Projectile.timeLeft = 2;
            }

            Projectile.frameCounter++;
            if (Projectile.frameCounter >= 8)
            {
                Projectile.frameCounter = 0;
                Projectile.frame        = (Projectile.frame + 1) % 12;
            }

            float slotsModifier = Math.Min(Projectile.minionSlots / MaxMinionSlots, 1f);

            Projectile.ai[0] += 0.1f + 0.3f * slotsModifier;
            Projectile.alpha  = (int)(Math.Cos(Projectile.ai[0] / 0.4f * MathHelper.TwoPi / 180) * 60) + 60;

            float oldScale = Projectile.scale;

            Projectile.scale = 0.75f + 0.5f * slotsModifier;

            Projectile.position = Projectile.Center;
            Projectile.width    = (int)(Projectile.width * Projectile.scale / oldScale);
            Projectile.height   = (int)(Projectile.height * Projectile.scale / oldScale);
            Projectile.Center   = Projectile.position;

            NPC  targetnpc  = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000, center: Main.player[Projectile.owner].MountedCenter));
            bool targetting = targetnpc != null; //targetting code, prioritize targetted npcs, then look for closest if none is found

            if (targetting)
            {
                if (++Projectile.localAI[0] > 5)
                {
                    Projectile.localAI[0] = 0;

                    if (Projectile.owner == Main.myPlayer)
                    {
                        const float speed  = 18f;
                        int         damage = (int)(Projectile.originalDamage * Projectile.scale); //damage directly proportional to Projectile scale, change later???
                        int         type   = ModContent.ProjectileType <BigBrainIllusion>();

                        //Vector2 spawnpos = targetnpc.Center + Main.rand.NextVector2CircularEdge(150, 150);
                        //Projectile.NewProjectile(spawnpos, speed * Vector2.Normalize(targetnpc.Center - spawnpos), type, damage, Projectile.knockBack, Projectile.owner, Projectile.scale);

                        Vector2 spawnFromMe = Main.player[Projectile.owner].Center + (Projectile.Center - Main.player[Projectile.owner].Center).RotatedBy(MathHelper.TwoPi / 4 * Main.rand.Next(4));
                        Vector2 vel         = speed * Vector2.Normalize(targetnpc.Center + targetnpc.velocity * 15 - spawnFromMe);
                        FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), spawnFromMe, vel, type, damage, Projectile.knockBack, Projectile.owner, Projectile.scale);
                    }
                }
            }

            Projectile.Center = player.Center + new Vector2(0, (200 + Projectile.alpha) * Projectile.scale).RotatedBy(Projectile.ai[1] + Projectile.ai[0] / MathHelper.TwoPi);
        }
        public override void AI()
        {
            Projectile.velocity = Vector2.Zero;

            if (FargoSoulsUtil.NPCExists(Projectile.ai[0], ModContent.NPCType <NPCs.Champions.TerraChampion>()) != null)
            {
                Projectile.alpha -= 10;
                if (Projectile.alpha < 0)
                {
                    Projectile.alpha = 0;
                }

                /*if (Projectile.Distance(Main.player[Main.npc[ai0].target].Center) > 600)
                 * {
                 *  Projectile.velocity = 3f * Projectile.DirectionTo(Main.player[Main.npc[ai0].target].Center);
                 * }*/
            }
            else
            {
                Projectile.alpha += 10;
                if (Projectile.alpha > 255)
                {
                    Projectile.alpha = 255;
                    Projectile.Kill();
                }
            }

            Projectile.timeLeft = 2;

            Lighting.AddLight(Projectile.Center, 0.4f, 0.85f, 0.9f);
            Projectile.frameCounter++;
            if (Projectile.frameCounter > 3)
            {
                Projectile.frameCounter = 0;
                Projectile.frame++;
                if (Projectile.frame > 3)
                {
                    Projectile.frame = 0;
                }
            }

            if (Main.rand.NextBool(3))
            {
                float num11 = (float)(Main.rand.NextDouble() * 1.0 - 0.5); //vanilla dust :echbegone:
                if ((double)num11 < -0.5)
                {
                    num11 = -0.5f;
                }
                if ((double)num11 > 0.5)
                {
                    num11 = 0.5f;
                }
                Vector2 vector21 = new Vector2((float)-Projectile.width * 0.2f * Projectile.scale, 0.0f).RotatedBy((double)num11 * 6.28318548202515, new Vector2()).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2());
                int     index21  = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 226, (float)(-(double)Projectile.velocity.X / 3.0), (float)(-(double)Projectile.velocity.Y / 3.0), 150, Color.Transparent, 0.7f);
                Main.dust[index21].position  = Projectile.Center + vector21 * Projectile.scale;
                Main.dust[index21].velocity  = Vector2.Normalize(Main.dust[index21].position - Projectile.Center) * 2f;
                Main.dust[index21].noGravity = true;
                float num1 = (float)(Main.rand.NextDouble() * 1.0 - 0.5);
                if ((double)num1 < -0.5)
                {
                    num1 = -0.5f;
                }
                if ((double)num1 > 0.5)
                {
                    num1 = 0.5f;
                }
                Vector2 vector2 = new Vector2((float)-Projectile.width * 0.6f * Projectile.scale, 0.0f).RotatedBy((double)num1 * 6.28318548202515, new Vector2()).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2());
                int     index2  = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 226, (float)(-(double)Projectile.velocity.X / 3.0), (float)(-(double)Projectile.velocity.Y / 3.0), 150, Color.Transparent, 0.7f);
                Main.dust[index2].velocity  = Vector2.Zero;
                Main.dust[index2].position  = Projectile.Center + vector2 * Projectile.scale;
                Main.dust[index2].noGravity = true;
            }
        }
示例#16
0
        public override bool PreAI(NPC npc)
        {
            NPC mouth = FargoSoulsUtil.NPCExists(npc.realLife, NPCID.WallofFlesh);

            if (FargoSoulsWorld.SwarmActive || RepeatingAI || mouth == null)
            {
                return(true);
            }

            if (PreventAttacks > 0)
            {
                PreventAttacks--;
            }

            float maxTime = 540f;

            if (mouth.GetEModeNPCMod <WallofFlesh>().InDesperationPhase)
            {
                if (npc.ai[1] < maxTime - 180) //dont lower this if it's already telegraphing laser
                {
                    maxTime = 240f;
                }

                if (!FargoSoulsWorld.MasochistModeReal)
                {
                    npc.localAI[1] = -1f; //no more regular lasers
                    npc.localAI[2] = 0f;
                }
            }

            if (++npc.ai[1] >= maxTime)
            {
                npc.ai[1] = 0f;
                if (npc.ai[2] == 0f)
                {
                    npc.ai[2] = 1f;
                }
                else
                {
                    npc.ai[2] *= -1f;
                }

                if (npc.ai[2] > 0) //FIRE LASER
                {
                    Vector2 speed = Vector2.UnitX.RotatedBy(npc.ai[3]);
                    if (Main.netMode != NetmodeID.MultiplayerClient && PreventAttacks <= 0)
                    {
                        Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, speed, ModContent.ProjectileType <PhantasmalDeathrayWOF>(), FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 0f, Main.myPlayer, 0, npc.whoAmI);
                    }
                }
                else //ring dust to denote i am vulnerable now
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.type);
                    }
                }

                npc.netUpdate = true;
                NetSync(npc);
            }

            if (npc.ai[2] >= 0f)
            {
                npc.alpha          = 175;
                npc.dontTakeDamage = true;

                if (npc.ai[1] <= 90) //still firing laser rn
                {
                    RepeatingAI = true;
                    npc.AI();
                    RepeatingAI = false;

                    npc.localAI[1] = -1f;
                    npc.localAI[2] = 0f;

                    npc.rotation = npc.ai[3];
                    return(false);
                }
                else
                {
                    npc.ai[2] = 1;
                }
            }
            else
            {
                npc.alpha          = 0;
                npc.dontTakeDamage = false;

                if (npc.ai[1] == maxTime - 3 * 5 && Main.netMode != NetmodeID.MultiplayerClient)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient && PreventAttacks <= 0)
                    {
                        float ai0 = (npc.realLife != -1 && Main.npc[npc.realLife].velocity.X > 0) ? 1f : 0f;
                        Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType <WOFBlast>(), 0, 0f, Main.myPlayer, ai0, npc.whoAmI);
                    }
                }

                if (npc.ai[1] > maxTime - 180f)
                {
                    if (Main.rand.Next(4) < 3) //dust telegraphs switch
                    {
                        int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 88, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 114, default(Color), 3.5f);
                        Main.dust[dust].noGravity   = true;
                        Main.dust[dust].velocity   *= 1.8f;
                        Main.dust[dust].velocity.Y -= 0.5f;
                        if (Main.rand.NextBool(4))
                        {
                            Main.dust[dust].noGravity = false;
                            Main.dust[dust].scale    *= 0.5f;
                        }
                    }

                    float stopTime = maxTime - 90f;
                    if (npc.ai[1] == stopTime) //shoot warning dust in phase 2
                    {
                        int t = npc.HasPlayerTarget ? npc.target : npc.FindClosestPlayer();
                        if (t != -1)
                        {
                            if (npc.Distance(Main.player[t].Center) < 3000)
                            {
                                SoundEngine.PlaySound(SoundID.Roar, Main.player[t].Center);
                            }
                            npc.ai[2] = -2f;
                            npc.ai[3] = (npc.Center - Main.player[t].Center).ToRotation();
                            if (npc.realLife != -1 && Main.npc[npc.realLife].velocity.X > 0)
                            {
                                npc.ai[3] += (float)Math.PI;
                            }

                            Vector2 speed = Vector2.UnitX.RotatedBy(npc.ai[3]);
                            if (Main.netMode != NetmodeID.MultiplayerClient)
                            {
                                Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, speed, ModContent.ProjectileType <PhantasmalDeathrayWOFS>(), 0, 0f, Main.myPlayer, 0, npc.whoAmI);
                            }
                        }

                        npc.netUpdate = true;
                        NetSync(npc);
                    }
                    else if (npc.ai[1] > stopTime)
                    {
                        HasTelegraphedNormalLasers = false;

                        RepeatingAI = true;
                        npc.AI();
                        RepeatingAI = false;

                        npc.localAI[1] = -1f;
                        npc.localAI[2] = 0f;

                        npc.rotation = npc.ai[3];
                        return(false);
                    }
                }
            }

            //dont fire during mouth's special attacks (this is at bottom to override others)
            if (((mouth.GetEModeNPCMod <WallofFlesh>().InPhase2&& mouth.GetEModeNPCMod <WallofFlesh>().WorldEvilAttackCycleTimer < 240) || mouth.GetEModeNPCMod <WallofFlesh>().InDesperationPhase) && !FargoSoulsWorld.MasochistModeReal)
            {
                npc.localAI[1] = -90f;
                npc.localAI[2] = 0f;

                HasTelegraphedNormalLasers = false;
            }

            if (npc.localAI[2] > 1) //has shot at least one laser
            {
                HasTelegraphedNormalLasers = false;
            }
            else if (npc.localAI[1] >= 0f && !HasTelegraphedNormalLasers && npc.HasValidTarget) //telegraph for imminent laser
            {
                HasTelegraphedNormalLasers = true;
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, npc.whoAmI, -22);
                }
            }

            //if (NPC.FindFirstNPC(npc.type) == npc.whoAmI) FargoSoulsUtil.PrintAI(npc);

            return(true);
        }
示例#17
0
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoSoulsPlayer>().LunarCultist)
            {
                Projectile.timeLeft = 2;
            }

            if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && Projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy())
                {
                    Projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                Projectile.localAI[0]++;
                NPC npc = Main.npc[(int)Projectile.ai[0]];
                if (npc.CanBeChasedBy())
                {
                    if (Projectile.ai[1] % 2 != 0) //when attacking, check for emode ml
                    {
                        NPC moonLord = FargoSoulsUtil.NPCExists(NPCs.EModeGlobalNPC.moonBoss, NPCID.MoonLordCore);
                        if (moonLord != null)
                        {
                            switch (moonLord.GetEModeNPCMod <MoonLordCore>().VulnerabilityState)
                            {
                            case 0: Projectile.ai[1] = 1; break;

                            case 1: Projectile.ai[1] = 3; break;

                            case 2: Projectile.ai[1] = 5; break;

                            case 3: Projectile.ai[1] = 7; break;

                            default: break;
                            }
                        }
                    }

                    Projectile.localAI[1] = Projectile.ai[1] + 1;
                    switch ((int)Projectile.ai[1])
                    {
                    case 0:     //chase
                        Projectile.localAI[0] = 0f;
                        Projectile.velocity   = target - Projectile.Center;
                        float length = Projectile.velocity.Length();
                        if (length > 1000f)     //too far, lose target
                        {
                            Projectile.ai[0]     = -1f;
                            Projectile.ai[1]     = 1f;
                            Projectile.netUpdate = true;
                        }
                        else if (length > 24f)
                        {
                            Projectile.velocity.Normalize();
                            Projectile.velocity *= 24f;
                        }
                        else
                        {
                            Projectile.ai[1]++;
                        }
                        break;

                    case 1:     //shoot fireballs
                        Projectile.velocity = Vector2.Zero;
                        if (Projectile.localAI[0] <= 30 && Projectile.localAI[0] % 10 == 0)
                        {
                            SoundEngine.PlaySound(SoundID.Item34, Projectile.position);
                            Vector2 spawn = Projectile.Center;
                            spawn.X -= 30 * Projectile.spriteDirection;
                            spawn.Y += 12f;
                            Vector2 vel = (npc.Center - spawn).RotatedByRandom(Math.PI / 6);
                            vel.Normalize();
                            vel *= Main.rand.NextFloat(6f, 10f);
                            if (Projectile.owner == Main.myPlayer)
                            {
                                Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawn, vel, ModContent.ProjectileType <LunarCultistFireball>(), Projectile.damage, 9f, Projectile.owner, 0f, Projectile.ai[0]);
                            }
                        }
                        if (Projectile.localAI[0] > 60f)
                        {
                            Projectile.ai[1]++;
                            target    = npc.Center;
                            target.Y -= npc.height + 100;
                        }
                        break;

                    case 2: goto case 0;

                    case 3:     //lightning orb
                        Projectile.velocity = Vector2.Zero;
                        if (Projectile.localAI[0] == 15f)
                        {
                            SoundEngine.PlaySound(SoundID.Item121, Projectile.position);
                            Vector2 spawn = Projectile.Center;
                            spawn.Y -= 100;
                            if (Projectile.owner == Main.myPlayer)
                            {
                                Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawn, Vector2.Zero, ModContent.ProjectileType <LunarCultistLightningOrb>(), Projectile.damage, 8f, Projectile.owner, Projectile.whoAmI);
                            }
                        }
                        if (Projectile.localAI[0] > 90f)
                        {
                            Projectile.ai[1]++;
                            target    = npc.Center;
                            target.Y -= npc.height + 100;
                        }
                        break;

                    case 4: goto case 0;

                    case 5:     //ice mist
                        Projectile.velocity = Vector2.Zero;
                        if (Projectile.localAI[0] == 20f)
                        {
                            Vector2 spawn = Projectile.Center;
                            spawn.X -= 30 * Projectile.spriteDirection;
                            spawn.Y += 12f;
                            Vector2 vel = npc.Center - spawn;
                            vel.Normalize();
                            vel *= 4.25f;
                            if (Projectile.owner == Main.myPlayer)
                            {
                                Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawn, vel, ModContent.ProjectileType <LunarCultistIceMist>(), Projectile.damage, Projectile.knockBack * 2f, Projectile.owner);
                            }
                        }
                        if (Projectile.localAI[0] > 60f)
                        {
                            Projectile.ai[1]++;
                            target    = npc.Center;
                            target.Y -= npc.height + 100;
                        }
                        break;

                    case 6: goto case 0;

                    case 7:     //ancient visions
                        Projectile.velocity = Vector2.Zero;
                        if (Projectile.localAI[0] == 30f)
                        {
                            Vector2 spawn = Projectile.Center;
                            spawn.Y -= Projectile.height;
                            if (Projectile.owner == Main.myPlayer)
                            {
                                FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), spawn, Vector2.UnitX * -Projectile.spriteDirection * 12f, ModContent.ProjectileType <AncientVisionLunarCultist>(), Projectile.originalDamage, Projectile.knockBack * 3f, Projectile.owner);
                            }
                        }
                        if (Projectile.localAI[0] > 90f)
                        {
                            Projectile.ai[1]++;
                            target    = npc.Center;
                            target.Y -= npc.height + 100;
                        }
                        break;

                    /*case 8: goto case 0;
                     * case 9: //ancient light
                     *  Projectile.velocity = Vector2.Zero;
                     *  if (Projectile.localAI[0] == 30f)
                     *  {
                     *      Vector2 spawn = Projectile.Center;
                     *      spawn.X -= 30 * Projectile.spriteDirection;
                     *      spawn.Y += 12f;
                     *      Vector2 vel = npc.Center - spawn;
                     *      vel.Normalize();
                     *      vel *= 9f;
                     *      for (int i = -2; i <= 2; i++)
                     *      {
                     *          if (Projectile.owner == Main.myPlayer)
                     *              Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawn, vel.RotatedBy(Math.PI / 7 * i), ModContent.ProjectileType<LunarCultistLight>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, (Main.rand.NextFloat() - 0.5f) * 0.3f * 6.28318548202515f / 60f);
                     *      }
                     *  }
                     *  if (Projectile.localAI[0] > 60f)
                     *  {
                     *      Projectile.ai[1]++;
                     *      target = npc.Center;
                     *      target.Y -= npc.height + 100;
                     *  }
                     *  break;*/

                    default:
                        Projectile.ai[1] = 0f;
                        goto case 0;
                    }

                    if (Projectile.velocity.X == 0)
                    {
                        float distance = npc.Center.X - Projectile.Center.X;
                        if (distance != 0)
                        {
                            Projectile.spriteDirection = distance < 0 ? 1 : -1;
                        }
                    }
                    else
                    {
                        Projectile.spriteDirection = (Projectile.velocity.X < 0) ? 1 : -1;
                    }
                }
                else //forget target
                {
                    TargetEnemies();
                }
            }
            else //no target
            {
                if (Projectile.ai[1] == 0f) //follow player
                {
                    if (target == Vector2.Zero)
                    {
                        target    = Main.player[Projectile.owner].Center;
                        target.Y -= 100f;
                    }

                    Projectile.velocity = target - Projectile.Center;
                    float length = Projectile.velocity.Length();
                    if (length > 1500f) //teleport when too far away
                    {
                        Projectile.Center   = Main.player[Projectile.owner].Center;
                        Projectile.velocity = Vector2.Zero;
                        Projectile.ai[1]    = 1f;
                    }
                    else if (length > 24f)
                    {
                        Projectile.velocity.Normalize();
                        Projectile.velocity *= 24f;
                    }
                    else //in close enough range to stop
                    {
                        Projectile.ai[1] = 1f;
                    }
                }
                else //now above player, wait
                {
                    Projectile.velocity = Vector2.Zero;

                    Projectile.localAI[0]++;
                    if (Projectile.localAI[0] > 30)
                    {
                        TargetEnemies();
                        Projectile.localAI[0] = 0f;
                    }
                }

                if (Projectile.velocity.X == 0)
                {
                    float distance = Main.player[Projectile.owner].Center.X - Projectile.Center.X;
                    if (distance != 0)
                    {
                        Projectile.spriteDirection = distance < 0 ? 1 : -1;
                    }
                }
                else
                {
                    Projectile.spriteDirection = (Projectile.velocity.X < 0) ? 1 : -1;
                }
            }

            Projectile.frameCounter++;
            if (Projectile.frameCounter > 6)
            {
                Projectile.frameCounter = 0;
                Projectile.frame        = (Projectile.frame + 1) % 3;
                if (Projectile.ai[0] > -1f && Projectile.ai[0] < 200f)
                {
                    switch ((int)Projectile.ai[1])
                    {
                    case 1: Projectile.frame += 6; break;

                    case 3: Projectile.frame += 3; break;

                    case 5: Projectile.frame += 6; break;

                    case 7: Projectile.frame += 3; break;

                    case 9: Projectile.frame += 6; break;

                    default: break;
                    }
                }
            }
        }
示例#18
0
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[0], ModContent.NPCType <NPCs.MutantBoss.MutantBoss>());

            if (npc == null)
            {
                Projectile.Kill();
                return;
            }

            Projectile.Center   = npc.Center;
            Projectile.timeLeft = 2;

            if (--Projectile.ai[1] < 0)
            {
                Projectile.ai[1]     = 180;
                Projectile.netUpdate = true;
                switch ((int)Projectile.localAI[0]++)
                {
                case 0:
                    NPC.SpawnOnPlayer(npc.target, NPCID.EyeofCthulhu);
                    if (Main.dayTime)
                    {
                        Main.dayTime = false;
                        Main.time    = 0;
                        if (Main.netMode == NetmodeID.Server)
                        {
                            NetMessage.SendData(MessageID.WorldData);     //sync world
                        }
                    }
                    break;

                case 1:
                    NPC.SpawnOnPlayer(npc.target, NPCID.EaterofWorldsHead);
                    NPC.SpawnOnPlayer(npc.target, NPCID.BrainofCthulhu);
                    break;

                case 2:
                    NPC.SpawnOnPlayer(npc.target, NPCID.QueenBee);
                    break;

                case 3:
                    ManualSpawn(npc, NPCID.SkeletronHead);
                    if (Main.dayTime)
                    {
                        Main.dayTime = false;
                        Main.time    = 0;
                        if (Main.netMode == NetmodeID.Server)
                        {
                            NetMessage.SendData(MessageID.WorldData);     //sync world
                        }
                    }
                    break;

                case 4:
                    NPC.SpawnOnPlayer(npc.target, NPCID.Retinazer);
                    NPC.SpawnOnPlayer(npc.target, NPCID.Spazmatism);
                    if (Main.dayTime)
                    {
                        Main.dayTime = false;
                        Main.time    = 0;
                        if (Main.netMode == NetmodeID.Server)
                        {
                            NetMessage.SendData(MessageID.WorldData);     //sync world
                        }
                    }
                    break;

                case 5:
                    ManualSpawn(npc, NPCID.SkeletronPrime);
                    if (Main.dayTime)
                    {
                        Main.dayTime = false;
                        Main.time    = 0;
                        if (Main.netMode == NetmodeID.Server)
                        {
                            NetMessage.SendData(MessageID.WorldData);     //sync world
                        }
                    }
                    break;

                case 6:
                    NPC.SpawnOnPlayer(npc.target, NPCID.Plantera);
                    break;

                case 7:
                    ManualSpawn(npc, NPCID.Golem);
                    break;

                case 8:
                    ManualSpawn(npc, NPCID.DD2Betsy);
                    break;

                case 9:
                    ManualSpawn(npc, NPCID.DukeFishron);
                    break;

                case 10:
                    ManualSpawn(npc, NPCID.MoonLordCore);
                    break;

                default:
                    if (!Main.dayTime)
                    {
                        Main.dayTime = true;
                        Main.time    = 27000;
                        if (Main.netMode == NetmodeID.Server)
                        {
                            NetMessage.SendData(MessageID.WorldData);     //sync world
                        }
                    }
                    Projectile.Kill();
                    break;
                }
            }
        }
示例#19
0
        public override void AI()
        {
            NPC body = FargoSoulsUtil.NPCExists(npc.ai[1], ModContent.NPCType <NatureChampion>());

            if (body == null)
            {
                npc.life = 0;
                npc.checkDead();
                npc.active = false;
                return;
            }

            npc.target    = body.target;
            npc.realLife  = body.whoAmI;
            npc.position += body.velocity * 0.75f;

            Player  player = Main.player[npc.target];
            Vector2 targetPos;

            if (player.Center.X < npc.position.X)
            {
                npc.direction = npc.spriteDirection = -1;
            }
            else if (player.Center.X > npc.position.X + npc.width)
            {
                npc.direction = npc.spriteDirection = 1;
            }
            npc.rotation = 0;

            switch ((int)npc.ai[0])
            {
            case -3:     //crimson
                targetPos = player.Center - Vector2.UnitY * 250f;
                Movement(targetPos, 0.3f, 24f);

                if (++npc.ai[2] > 75)     //ichor periodically
                {
                    if (npc.ai[2] > 105)
                    {
                        npc.ai[2] = 0;
                    }

                    npc.velocity *= 0.99f;

                    if (++npc.localAI[1] > 2)     //rain piss
                    {
                        npc.localAI[1] = 0;
                        if (npc.localAI[0] > 60 && Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Projectile.NewProjectile(npc.Center + Main.rand.NextVector2Circular(npc.width / 2, npc.height / 2),
                                                     Vector2.UnitY * Main.rand.NextFloat(-4f, 0), ProjectileID.GoldenShowerHostile, npc.damage / 4, 0f, Main.myPlayer);
                        }
                    }
                }

                if (++npc.localAI[0] > 300)
                {
                    npc.ai[0]      = 0;
                    npc.localAI[0] = 0;
                    npc.ai[2]      = 0;
                    npc.localAI[1] = 0;
                    npc.netUpdate  = true;
                }
                break;

            case -2:     //molten
                /*if (++npc.ai[2] > 60)
                 * {
                 *  npc.ai[2] = 0;
                 *
                 *  Main.PlaySound(SoundID.Item, npc.Center, 14);
                 *
                 *  if (Main.netMode != NetmodeID.MultiplayerClient)
                 *  {
                 *      const int max = 12;
                 *      for (int i = 0; i < max; i++)
                 *      {
                 *          Vector2 speed = 20f * npc.DirectionTo(player.Center).RotatedBy(2 * Math.PI / max * i);
                 *          Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType<NatureFireball>(), npc.damage / 4, 0f, Main.myPlayer);
                 *      }
                 *  }
                 * }*/

                if (++npc.localAI[0] < 240)     //stay near
                {
                    targetPos = player.Center;
                    Movement(targetPos, 0.10f, 24f);

                    for (int i = 0; i < 20; i++)     //warning ring
                    {
                        Vector2 offset = new Vector2();
                        double  angle  = Main.rand.NextDouble() * 2d * Math.PI;
                        offset.X += (float)(Math.Sin(angle) * 400);
                        offset.Y += (float)(Math.Cos(angle) * 400);
                        Dust dust = Main.dust[Dust.NewDust(npc.Center + offset - new Vector2(4, 4), 0, 0, DustID.Fire, 0, 0, 100, Color.White, 2f)];
                        dust.velocity = npc.velocity;
                        if (Main.rand.NextBool(3))
                        {
                            dust.velocity += Vector2.Normalize(offset) * -5f;
                        }
                        dust.noGravity = true;
                    }
                }
                else if (npc.localAI[0] == 240)     //explode into attacks
                {
                    npc.velocity  = Vector2.Zero;
                    npc.netUpdate = true;

                    Main.PlaySound(SoundID.Roar, npc.Center, 0);

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <NatureExplosion>(), npc.damage / 4, 0f, Main.myPlayer);

                        const int max = 12;
                        for (int i = 0; i < max; i++)
                        {
                            Vector2 speed = 24f * npc.DirectionTo(player.Center).RotatedBy(2 * Math.PI / max * i);
                            Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <NatureFireball>(), npc.damage / 4, 0f, Main.myPlayer);
                        }
                    }
                }
                else if (npc.localAI[0] > 300)
                {
                    npc.ai[0]      = 0;
                    npc.ai[2]      = 0;
                    npc.localAI[0] = 0;
                    npc.netUpdate  = true;
                }
                break;

            case -1:     //rain
                targetPos = player.Center + npc.DirectionFrom(player.Center) * 300;
                Movement(targetPos, 0.25f, 24f);

                if (++npc.localAI[1] > 45)
                {
                    npc.localAI[1] = 0;

                    Main.PlaySound(SoundID.Item66, npc.Center);

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        /*Vector2 dir = Main.player[npc.target].Center - npc.Center;
                         * float ai1New = Main.rand.Next(100);
                         * Vector2 vel = Vector2.Normalize(dir.RotatedByRandom(Math.PI / 4)) * 6f;
                         * Projectile.NewProjectile(npc.Center, vel, ProjectileID.CultistBossLightningOrbArc,
                         *  npc.damage / 4, 0, Main.myPlayer, dir.ToRotation(), ai1New);*/

                        Vector2 speed = player.Center - npc.Center;
                        speed.Y -= 300;
                        speed   /= 40;
                        Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <NatureCloudMoving>(), npc.damage / 4, 0f, Main.myPlayer);
                    }
                }

                if (++npc.localAI[0] > 300)
                {
                    npc.ai[0]      = 0;
                    npc.localAI[0] = 0;
                    npc.ai[2]      = 0;
                    npc.localAI[1] = 0;
                    npc.netUpdate  = true;
                }
                break;

            case 0:     //float near body
            {
                Vector2 offset;
                offset.X  = 100f * npc.ai[3] - 50 * Math.Sign(npc.ai[3]);
                offset.Y  = -350 + 75f * Math.Abs(npc.ai[3]);
                targetPos = body.Center + offset;
                if (npc.Distance(targetPos) > 50)
                {
                    Movement(targetPos, 0.8f, 24f);
                }
            }
            break;

            case 1:     //frost
            {
                Vector2 offset;
                offset.X  = 100f * npc.ai[3] - 50 * Math.Sign(npc.ai[3]);
                offset.Y  = -350 + 75f * Math.Abs(npc.ai[3]);
                targetPos = body.Center + offset;
                if (npc.Distance(targetPos) > 50)
                {
                    Movement(targetPos, 0.8f, 24f);
                }

                if (++npc.ai[2] > 60)
                {
                    npc.ai[2] = 0;
                    //npc.localAI[1] = npc.localAI[1] == 1 ? -1 : 1;
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        const int max = 25;
                        for (int i = 0; i < max; i++)
                        {
                            Vector2 speed = Main.rand.NextFloat(1f, 3f) * Vector2.UnitX.RotatedBy(2 * Math.PI / max * (i + Main.rand.NextDouble()));
                            Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <NatureIcicle>(),
                                                     npc.damage / 4, 0f, Main.myPlayer, 60 + Main.rand.Next(20), 1f);// npc.localAI[1]);
                        }
                    }
                }

                if (++npc.localAI[0] > 300)
                {
                    npc.ai[0]      = 0;
                    npc.localAI[0] = 0;
                    npc.ai[2]      = 0;
                    npc.localAI[1] = 0;
                    npc.netUpdate  = true;
                }
            }
            break;

            case 2:     //chlorophyte
                targetPos = player.Center;
                Movement(targetPos, 0.12f, 24f);

                if (npc.ai[2] == 0)
                {
                    npc.ai[2] = 1;
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        const int   max      = 5;
                        const float distance = 125f;
                        float       rotation = 2f * (float)Math.PI / max;
                        for (int i = 0; i < max; i++)
                        {
                            Vector2 spawnPos = npc.Center + new Vector2(distance, 0f).RotatedBy(rotation * i);
                            Projectile.NewProjectile(spawnPos, Vector2.Zero, ModContent.ProjectileType <NatureCrystalLeaf>(), npc.damage / 4, 0f, Main.myPlayer, npc.whoAmI, rotation * i);
                        }
                    }
                }

                if (++npc.localAI[0] > 300)
                {
                    npc.ai[0]      = 0;
                    npc.localAI[0] = 0;
                    npc.ai[2]      = 0;
                    npc.localAI[1] = 0;
                    npc.netUpdate  = true;
                }
                break;

            case 3:     //shroomite
            {
                Vector2 offset;
                offset.X  = 100f * npc.ai[3] - 50 * Math.Sign(npc.ai[3]);
                offset.Y  = -350 + 75f * Math.Abs(npc.ai[3]);
                targetPos = body.Center + offset;
                if (npc.Distance(targetPos) > 50)
                {
                    Movement(targetPos, 0.8f, 24f);
                }

                if (++npc.ai[2] < 20)
                {
                    if (npc.localAI[0] > 60 && npc.ai[2] % 2 == 0)
                    {
                        Vector2 speed = player.Center - npc.Center;
                        speed.X += Main.rand.Next(-40, 41);
                        speed.Y += Main.rand.Next(-40, 41);
                        speed.Normalize();
                        speed *= 12.5f;
                        int delay = (int)(npc.Distance(player.Center) - 100) / 14;
                        if (delay < 0)
                        {
                            delay = 0;
                        }
                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Projectile.NewProjectile(npc.Center + Vector2.UnitY * 10, speed,
                                                     ModContent.ProjectileType <NatureBullet>(), npc.damage / 4, 0f, Main.myPlayer, delay);
                        }
                    }
                }

                if (npc.ai[2] > 60)
                {
                    npc.ai[2] = 0;
                }

                if (++npc.localAI[0] > 300)
                {
                    npc.ai[0]      = 0;
                    npc.localAI[0] = 0;
                    npc.ai[2]      = 0;
                    npc.localAI[1] = 0;
                    npc.netUpdate  = true;
                }
            }
            break;

            case 4:     //deathrays
            {
                Vector2 offset = -600 * Vector2.UnitY.RotatedBy(MathHelper.ToRadians(60 / 3) * npc.ai[3]);
                targetPos = body.Center + offset;
                Movement(targetPos, 0.8f, 24f);

                npc.direction = npc.spriteDirection = npc.Center.X < body.Center.X ? 1 : -1;

                if (++npc.ai[2] == 90)
                {
                    npc.netUpdate  = true;
                    npc.localAI[1] = npc.DirectionTo(body.Center - Vector2.UnitY * 300).ToRotation();

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.localAI[1]),
                                                 ModContent.ProjectileType <NatureDeathraySmall>(), npc.damage / 3, 0f, Main.myPlayer, 0f, npc.whoAmI);
                    }
                }
                else if (npc.ai[2] == 150)
                {
                    float ai0 = 2f * (float)Math.PI / 120 * Math.Sign(npc.ai[3]);
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.localAI[1]),
                                                 ModContent.ProjectileType <NatureDeathray>(), npc.damage / 3, 0f, Main.myPlayer, ai0, npc.whoAmI);
                    }
                }

                if (++npc.localAI[0] > 330)
                {
                    npc.ai[0]      = 0;
                    npc.localAI[0] = 0;
                    npc.ai[2]      = 0;
                    npc.localAI[1] = 0;
                    npc.netUpdate  = true;
                }
            }
            break;

            default:
                npc.ai[0] = 0;
                goto case 0;
            }

            if (npc.Distance(body.Center) > 1400) //try to prevent going too far from body, will cause neck to disappear
            {
                npc.Center = body.Center + body.DirectionTo(npc.Center) * 1400f;
            }
        }
示例#20
0
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[1], NPCID.MoonLordCore);

            if (npc != null && npc.ai[0] != 2f)
            {
                projectile.hide = false;

                projectile.alpha -= 2;
                if (projectile.alpha < 0)
                {
                    projectile.alpha = 0;
                }

                projectile.Center = npc.Center;

                projectile.localAI[0] = npc.GetEModeNPCMod <MoonLordCore>().VulnerabilityTimer / 56.25f; //number to hide
                projectile.localAI[0]--;

                switch (npc.GetEModeNPCMod <MoonLordCore>().VulnerabilityState) //match ML vulnerability to fragment
                {
                case 0: projectile.frame = 1; break;

                case 1: projectile.frame = 2; break;

                case 2: projectile.frame = 0; break;

                case 3: projectile.frame = 3; break;

                default: projectile.frame = 4; break;
                }
            }
            else
            {
                projectile.hide     = true;
                projectile.velocity = Vector2.Zero;
                projectile.alpha   += 2;
                if (projectile.alpha > 255)
                {
                    projectile.Kill();
                    return;
                }
            }

            projectile.timeLeft = 2;
            projectile.scale    = (1f - projectile.alpha / 255f) * 1.5f + (Main.mouseTextColor / 200f - 0.35f) * 0.25f; //throbbing
            if (projectile.scale < 0.1f)                                                                                //clamp scale
            {
                projectile.scale = 0.1f;
            }
            projectile.ai[0] += rotationPerTick;
            if (projectile.ai[0] > PI)
            {
                projectile.ai[0]    -= 2f * PI;
                projectile.netUpdate = true;
            }
            projectile.rotation = projectile.ai[0];

            /*projectile.frameCounter++;
             * if (projectile.frameCounter >= 6)
             * {
             *  projectile.frameCounter = 0;
             *  projectile.frame++;
             *  if (projectile.frame > 1)
             *      projectile.frame = 0;
             * }*/
        }
        public override void AI()
        {
            Vector2?vector78 = null;

            if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero)
            {
                projectile.velocity = -Vector2.UnitY;
            }
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[1], NPCID.WallofFleshEye);

            if (npc == null)
            {
                projectile.Kill();
                return;
            }
            else
            {
                projectile.Center = npc.Center + (npc.width - 48) * Vector2.UnitX.RotatedBy(npc.rotation + (npc.direction > 0 ? 0 : MathHelper.Pi));
            }
            if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero)
            {
                projectile.velocity = -Vector2.UnitY;
            }

            /*if (projectile.localAI[0] == 0f)
             * {
             *  Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 104, 1f, 0f);
             * }*/
            float num801 = 0.2f;

            projectile.localAI[0] += 1f;
            if (projectile.localAI[0] >= maxTime)
            {
                projectile.Kill();
                return;
            }
            projectile.scale = (float)Math.Sin(projectile.localAI[0] * 3.14159274f / maxTime) * 0.6f * num801;
            if (projectile.scale > num801)
            {
                projectile.scale = num801;
            }
            //float num804 = projectile.velocity.ToRotation();
            //num804 += projectile.ai[0];
            //projectile.rotation = num804 - 1.57079637f;

            projectile.velocity = (npc.rotation + (npc.direction > 0 ? 0 : MathHelper.Pi)).ToRotationVector2();
            projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2;

            float   num805        = 3f;
            float   num806        = (float)projectile.width;
            Vector2 samplingPoint = projectile.Center;

            if (vector78.HasValue)
            {
                samplingPoint = vector78.Value;
            }
            float[] array3 = new float[(int)num805];
            //Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 3000f, array3);
            for (int i = 0; i < array3.Length; i++)
            {
                array3[i] = 3000f;
            }
            float num807 = 0f;
            int   num3;

            for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1)
            {
                num807 += array3[num808];
                num3    = num808;
            }
            num807 /= num805;
            float amount = 0.5f;

            projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount);
            Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f);

            for (int num809 = 0; num809 < 2; num809 = num3 + 1)
            {
                float   num810   = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f;
                float   num811   = (float)Main.rand.NextDouble() * 2f + 2f;
                Vector2 vector80 = new Vector2((float)Math.Cos((double)num810) * num811, (float)Math.Sin((double)num810) * num811);
                int     num812   = Dust.NewDust(vector79, 0, 0, 244, vector80.X, vector80.Y, 0, default(Color), 1f);
                Main.dust[num812].noGravity = true;
                Main.dust[num812].scale     = 1.7f;
                num3 = num809;
            }
            if (Main.rand.NextBool(5))
            {
                Vector2 value29 = projectile.velocity.RotatedBy(1.5707963705062866, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)projectile.width;
                int     num813  = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 244, 0f, 0f, 100, default(Color), 1.5f);
                Dust    dust    = Main.dust[num813];
                dust.velocity *= 0.5f;
                Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y);
            }
            //DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f);
            //Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight));
        }
示例#22
0
        public override bool PreAI(NPC npc)
        {
            if (FargoSoulsWorld.SwarmActive)
            {
                return(true);
            }

            NPC core = FargoSoulsUtil.NPCExists(npc.ai[3], NPCID.MoonLordCore);

            if (core == null)
            {
                return(true);
            }

            if (!SpawnSynchronized && ++OnSpawnCounter > 2 && !Fargowiltas.Instance.MasomodeEXLoaded) //sync to other eyes of same core when spawned
            {
                SpawnSynchronized = true;
                OnSpawnCounter    = 0;
                for (int i = 0; i < Main.maxProjectiles; i++) //find ritual
                {
                    if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType <LunarRitual>() &&
                        Main.projectile[i].ai[1] == npc.ai[3])
                    {
                        RitualProj = i;
                        break;
                    }
                }
                for (int i = 0; i < Main.maxNPCs; i++) //eye sync
                {
                    if (Main.npc[i].active && Main.npc[i].type == NPCID.MoonLordFreeEye && Main.npc[i].ai[3] == npc.ai[3] && i != npc.whoAmI)
                    {
                        npc.ai[0]      = Main.npc[i].ai[0];
                        npc.ai[1]      = Main.npc[i].ai[1];
                        npc.ai[2]      = Main.npc[i].ai[2];
                        npc.ai[3]      = Main.npc[i].ai[3];
                        npc.localAI[0] = Main.npc[i].localAI[0];
                        npc.localAI[1] = Main.npc[i].localAI[1];
                        npc.localAI[2] = Main.npc[i].localAI[2];
                        npc.localAI[3] = Main.npc[i].localAI[3];
                        break;
                    }
                }
                npc.netUpdate = true;
                NetSync(npc);
            }

            if (core.dontTakeDamage && !FargoSoulsWorld.MasochistModeReal) //behave slower until p2 proper
            {
                SlowMode = !SlowMode;
                if (SlowMode)
                {
                    npc.position -= npc.velocity;
                    return(false);
                }
            }

            Projectile ritual = FargoSoulsUtil.ProjectileExists(RitualProj, ModContent.ProjectileType <LunarRitual>());

            if (ritual != null && ritual.ai[1] == npc.ai[3])
            {
                int threshold = (int)ritual.localAI[0] - 150;
                if (GetVulnerabilityState(npc) == 4)
                {
                    threshold = 800 - 150;
                }
                if (npc.Distance(ritual.Center) > threshold) //stay within ritual range
                {
                    npc.Center = Vector2.Lerp(npc.Center, ritual.Center + npc.DirectionFrom(ritual.Center) * threshold, 0.05f);
                }
            }

            return(true);
        }
        public override void AI()
        {
            projectile.hide = false; //to avoid edge case tick 1 wackiness

            //the important part
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[0], ModContent.NPCType <NPCs.AbomBoss.AbomBoss>());

            if (npc != null)
            {
                if (npc.ai[0] == 0)
                {
                    projectile.extraUpdates = 1;
                }

                if (projectile.localAI[0] == 0)
                {
                    projectile.localAI[1] = projectile.ai[1] / maxTime; //do this first
                }
                projectile.velocity = projectile.velocity.RotatedBy(projectile.ai[1]);
                projectile.ai[1]   -= projectile.localAI[1];
                projectile.Center   = npc.Center + new Vector2(60, 60).RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver4) * projectile.scale;
            }
            else
            {
                projectile.Kill();
                return;
            }

            if (projectile.localAI[0] == 0)
            {
                projectile.localAI[0] = 1;

                /*Vector2 basePos = projectile.Center - projectile.velocity * 141 / 2 * projectile.scale;
                 * for (int i = 0; i < 40; i++)
                 * {
                 *  int d = Dust.NewDust(basePos + projectile.velocity * Main.rand.NextFloat(127) * projectile.scale, 0, 0, 87, Scale: 3f);
                 *  Main.dust[d].velocity *= 4.5f;
                 *  Main.dust[d].noGravity = true;
                 * }*/

                Main.PlaySound(SoundID.Item71, projectile.Center);
            }

            /*if (projectile.timeLeft == maxTime - 20)
             * {
             *  if (Main.netMode != NetmodeID.MultiplayerClient)
             *  {
             *      int p = Player.FindClosest(projectile.Center, 0, 0);
             *      if (p != -1)
             *      {
             *          Vector2 vel = Main.rand.NextFloat(MathHelper.TwoPi).ToRotationVector2() * 30f;
             *          int max = 8;
             *          for (int i = 0; i < max; i++)
             *          {
             *              Projectile.NewProjectile(projectile.Center, vel.RotatedBy(MathHelper.TwoPi / max * i), ModContent.ProjectileType<AbomSickle3>(), projectile.damage, projectile.knockBack, projectile.owner, p);
             *          }
             *      }
             *  }
             * }*/

            projectile.Opacity = (float)Math.Min(1, (2 - projectile.extraUpdates) * Math.Sin(Math.PI * (maxTime - projectile.timeLeft) / maxTime));

            projectile.direction = projectile.spriteDirection = Math.Sign(projectile.ai[1]);
            projectile.rotation  = projectile.velocity.ToRotation() + MathHelper.ToRadians(projectile.direction < 0 ? 135 : 45);
            //Main.NewText(MathHelper.ToDegrees(projectile.velocity.ToRotation()) + " " + MathHelper.ToDegrees(projectile.ai[1]));
        }