public override void AI()
        {
            if (++Projectile.localAI[0] == 0)
            {
                for (int index1 = 0; index1 < 30; ++index1)
                {
                    int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 157, 0f, 0f, 0, new Color(), 2f);
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].velocity *= 5f;
                }
            }

            Lighting.AddLight(Projectile.Center, 0.1f, 0.4f, 0.2f);
            Projectile.scale  = (Main.mouseTextColor / 200f - 0.35f) * 0.2f + 0.95f;
            Projectile.scale *= 2.5f;

            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <MutantMark2>());

            if (byIdentity != -1)
            {
                Vector2 offset = new Vector2(100, 0).RotatedBy(Projectile.ai[1]);
                Projectile.Center = Main.projectile[byIdentity].Center + offset;

                Projectile.localAI[1] = Math.Max(0, 150 - Main.projectile[byIdentity].ai[1]) / 150; //rampup
                Projectile.ai[1]     += 0.15f * Projectile.localAI[1];

                if (Projectile.localAI[1] > 1f) //clamp it for use in draw
                {
                    Projectile.localAI[1] = 1f;
                }
            }

            Projectile.rotation = Projectile.ai[1] + (float)Math.PI / 2f;
        }
Esempio n. 2
0
        public override void AI()
        {
            Projectile.hide = false;
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[1], ModContent.ProjectileType <TrueEyeL>());

            if (byIdentity != -1)
            {
                Projectile.Center = Main.projectile[byIdentity].Center - Vector2.UnitY * 6f;
            }
            else if (Projectile.owner == Main.myPlayer && Projectile.localAI[0] > 5)
            {
                Projectile.Kill();
                return;
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            if (Projectile.localAI[0] == 0f)
            {
                SoundEngine.PlaySound(new SoundStyle("Terraria/Sounds/Zombie_104") with {
                    Volume = 0.75f, Pitch = 0
                }, Projectile.Center);
Esempio n. 3
0
        public override void Kill(int timeLeft)
        {
            Player player = Main.player[Projectile.owner];

            if (player.slotsMinions + Projectile.minionSlots > player.maxMinions && Projectile.owner == Main.myPlayer)
            {
                int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], Projectile.type, ModContent.ProjectileType <EaterHead>());
                if (byIdentity != -1)
                {
                    Projectile Projectile1 = Main.projectile[byIdentity];
                    if (Projectile1.type != ModContent.ProjectileType <EaterHead>())
                    {
                        Projectile1.localAI[1] = Projectile.localAI[1];
                    }
                    int byIdentity2 = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.localAI[1], Projectile.type, ModContent.ProjectileType <EaterHead>());
                    if (byIdentity2 != -1)
                    {
                        Projectile1           = Main.projectile[byIdentity2];
                        Projectile1.ai[0]     = Projectile.ai[0];
                        Projectile1.ai[1]     = 1f;
                        Projectile1.netUpdate = true;
                    }
                }
            }
        }
        public override void AI()
        {
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.localAI[0], ModContent.ProjectileType <BlenderYoyoProj>());

            if (byIdentity == -1)
            {
                if (Projectile.owner == Main.myPlayer && Projectile.rotation > 0)
                {
                    Projectile.Kill();
                    return;
                }
            }
            else
            {
                Projectile proj = Main.projectile[byIdentity];

                //rotation mumbo jumbo
                float distanceFromPlayer = 150 + 150 * (1 - (float)Math.Cos(Projectile.localAI[1])); // + Projectile.ai[0] * 32;

                Vector2 offset = new Vector2(distanceFromPlayer, 0f).RotatedBy(Projectile.ai[1]);

                Vector2 oldCenter  = Projectile.Center - offset;
                Vector2 desiredPos = proj.Center + offset;
                Projectile.position += Vector2.Lerp(oldCenter, proj.Center, 0.05f) - oldCenter;
                Projectile.position += (Main.player[Projectile.owner].position - Main.player[Projectile.owner].oldPosition) / 2;
                Projectile.Center    = Vector2.Lerp(Projectile.Center, desiredPos, 0.05f);

                float rotation = MathHelper.Pi / 20 / Projectile.MaxUpdates * 0.75f;
                Projectile.ai[1] += rotation;
                if (Projectile.ai[1] > MathHelper.Pi)
                {
                    Projectile.ai[1]    -= MathHelper.TwoPi;
                    Projectile.netUpdate = true;
                }

                Projectile.localAI[1] += MathHelper.TwoPi / 120 / Projectile.MaxUpdates; // * (0.5f + 1.5f * Projectile.ai[0] / 5);
                if (Projectile.localAI[1] > MathHelper.Pi)
                {
                    Projectile.localAI[1] -= MathHelper.TwoPi;
                }

                Projectile.damage    = (int)(proj.damage * 0.5);
                Projectile.knockBack = proj.knockBack;
            }

            Projectile.timeLeft++;
            Projectile.rotation += 0.25f / Projectile.MaxUpdates;

            if (soundtimer > 0)
            {
                soundtimer--;
            }
        }
Esempio n. 5
0
        public override void AI()
        {
            //dust!
            int dustId = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 15, Projectile.velocity.X * 0.2f,
                                      Projectile.velocity.Y * 0.2f, 100, default(Color), 2f);

            Main.dust[dustId].noGravity = true;
            int dustId3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 15, Projectile.velocity.X * 0.2f,
                                       Projectile.velocity.Y * 0.2f, 100, default(Color), 2f);

            Main.dust[dustId3].noGravity = true;

            Player  projOwner          = Main.player[Projectile.owner];
            Vector2 ownerMountedCenter = projOwner.RotatedRelativePoint(projOwner.MountedCenter);

            Projectile.direction = projOwner.direction;
            projOwner.heldProj   = Projectile.whoAmI;
            projOwner.itemTime   = projOwner.itemAnimation;
            Projectile.Center    = ownerMountedCenter;

            if (projOwner.itemAnimation == 0)
            {
                Projectile.Kill();
            }
            Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.ToRadians(135f);
            if (Projectile.spriteDirection == -1)
            {
                Projectile.rotation -= MathHelper.ToRadians(90f);
            }

            scaletimer++;

            if (Projectile.localAI[0] == 0)
            {
                Projectile.localAI[0] = Projectile.damage;
            }

            Projectile.damage = (int)Projectile.localAI[0];
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <Dash>());

            if (byIdentity != -1)
            {
                if (Main.projectile[byIdentity].localAI[0] != 0) //if dash has slowed down for some reason, do less damage
                {
                    Projectile.damage    /= 2;
                    Projectile.localAI[1] = 1;
                }
            }
        }
        public override void AI()
        {
            //the important part
            int ai1        = (int)Projectile.ai[1];
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, ai1, ModContent.ProjectileType <SparklingDevi>());

            if (byIdentity != -1)
            {
                Projectile devi = Main.projectile[byIdentity];
                if (Projectile.timeLeft > 15)
                {
                    Vector2 offset = new Vector2(0, -360).RotatedBy(Math.PI / 4 * devi.spriteDirection);
                    Projectile.Center   = devi.Center + offset;
                    Projectile.rotation = (float)Math.PI / 4 * devi.spriteDirection - (float)Math.PI / 4;
                }
                else //swinging down
                {
                    if (Projectile.timeLeft == 15) //confirm facing the right direction with right offset
                    {
                        Projectile.rotation = (float)Math.PI / 4 * devi.spriteDirection - (float)Math.PI / 4;
                    }

                    Projectile.rotation -= (float)Math.PI / 15 * devi.spriteDirection * 0.75f;
                    Vector2 offset = new Vector2(0, -360).RotatedBy(Projectile.rotation + (float)Math.PI / 4);
                    Projectile.Center = devi.Center + offset;
                }

                Projectile.spriteDirection = -devi.spriteDirection;

                Projectile.localAI[1] = devi.velocity.ToRotation();

                if (Projectile.localAI[0] == 0)
                {
                    Projectile.localAI[0] = 1;
                    if (Projectile.owner == Main.myPlayer)
                    {
                        Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, -1, -14);
                    }
                    SoundEngine.PlaySound(SoundID.Item92, Projectile.Center);

                    MakeDust();
                }
            }
            else if (Projectile.owner == Main.myPlayer && Projectile.timeLeft < 60)
            {
                Projectile.Kill();
                return;
            }
        }
        public override void AI()
        {
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <MutantTrueEyeR>());

            if (byIdentity != -1)
            {
                if (Projectile.timeLeft > 295)
                {
                    if (Main.projectile[byIdentity].ai[1] == 0f) //stop following true eye if true eye lost target & isn't preparing to charge
                    {
                        Projectile.ai[0]     = -1f;
                        Projectile.velocity  = Vector2.Zero;
                        Projectile.netUpdate = true;
                    }
                    else
                    {
                        Projectile.velocity = Main.projectile[byIdentity].velocity;
                    }
                }
            }

            if (Projectile.alpha > 200)
            {
                Projectile.alpha = 200;
            }
            Projectile.alpha -= 5;
            if (Projectile.alpha < 0)
            {
                Projectile.alpha = 0;
            }
            Projectile.scale = 1f - Projectile.alpha / 255f;

            Projectile.frameCounter++;
            if (Projectile.frameCounter >= 6)
            {
                Projectile.frameCounter = 0;
                Projectile.frame++;
                if (Projectile.frame > 1)
                {
                    Projectile.frame = 0;
                }
            }
        }
Esempio n. 8
0
        public override void AI()
        {
            if (++Projectile.localAI[0] == 0)
            {
                for (int index1 = 0; index1 < 30; ++index1)
                {
                    int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool() ? 107 : 157, 0f, 0f, 0, new Color(), 2f);
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].velocity *= 5f;
                }
            }

            Lighting.AddLight(Projectile.Center, 0.1f, 0.4f, 0.2f);
            Projectile.scale  = (Main.mouseTextColor / 200f - 0.35f) * 0.2f + 0.95f;
            Projectile.scale *= 1.5f;

            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <MutantBoss.MutantMark2>());

            if (byIdentity != -1)
            {
                Vector2 offset = new Vector2(100, 0).RotatedBy(Projectile.ai[1]);
                Projectile.Center = Main.projectile[byIdentity].Center + offset;

                Projectile.localAI[1] = Math.Max(0, 150 - Main.projectile[byIdentity].ai[1]) / 150; //rampup
                if (Projectile.localAI[1] > 1f)                                                     //clamp it for use in draw
                {
                    Projectile.localAI[1] = 1f;
                }
                Projectile.ai[1] += 0.15f * Projectile.localAI[1];
            }

            Projectile.rotation = Projectile.ai[1] + (float)Math.PI / 2f;

            if (Projectile.localAI[0] > 20)
            {
                Projectile.localAI[0] = 1;
                NPC plantera = FargoSoulsUtil.NPCExists(NPC.plantBoss, NPCID.Plantera);
                if (plantera != null && Projectile.Distance(plantera.Center) < 1600f && Main.netMode != NetmodeID.MultiplayerClient)
                {
                    Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, 4f * Projectile.ai[1].ToRotationVector2(), ModContent.ProjectileType <CrystalLeafShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
                }
            }
        }
Esempio n. 9
0
        public override void AI()
        {
            int   maxTime       = 60;
            float alphaModifier = 3;

            switch ((int)Projectile.ai[0])
            {
            case 0:     //abom flaming scythe telegraph, sticks to abom and follows his line of sight to player w/ offset
            {
                color         = Color.Yellow;
                maxTime       = 30;
                alphaModifier = 10;

                NPC abom = FargoSoulsUtil.NPCExists(Projectile.localAI[1], ModContent.NPCType <NPCs.AbomBoss.AbomBoss>());
                if (abom != null)
                {
                    Projectile.Center   = abom.Center;
                    Projectile.rotation = abom.DirectionTo(Main.player[abom.target].Center).ToRotation() + Projectile.ai[1];
                }
            }
            break;

            case 1:     //abom split sickle box telegraph, hides until after the sickles split
            {
                color               = Color.Yellow;
                maxTime             = 90 + 60;
                Projectile.rotation = Projectile.ai[1];
                alphaModifier       = 1;
                if (counter < 90)
                {
                    alphaModifier = 0;
                }
                else
                {
                    Projectile.velocity = Vector2.Zero;
                }
            }
            break;

            case 2:     //devi sparkling love, decelerates alongside energy hearts
            {
                color               = Color.HotPink;
                maxTime             = 90;
                Projectile.rotation = Projectile.ai[1];
                alphaModifier       = 1;
                if (Projectile.velocity != Vector2.Zero)
                {
                    if (counter == 0)
                    {
                        Projectile.localAI[1] = -Projectile.velocity.Length() / maxTime;
                    }

                    float speed = Projectile.velocity.Length();
                    speed += Projectile.localAI[1];
                    Projectile.velocity = Vector2.Normalize(Projectile.velocity) * speed;
                }
            }
            break;

            case 3:     //abom laevateinn 1&2 telegraph, swing around to where actual sword will spawn
            {
                color         = Color.Yellow;
                maxTime       = 60;
                alphaModifier = 6f;

                NPC abom = FargoSoulsUtil.NPCExists(Projectile.localAI[1], ModContent.NPCType <NPCs.AbomBoss.AbomBoss>());
                if (abom != null)
                {
                    Projectile.Center = abom.Center;
                    if (counter == 0)
                    {
                        Projectile.rotation = abom.DirectionTo(Main.player[abom.target].Center).ToRotation();
                    }
                    float targetRot = abom.DirectionTo(Main.player[abom.target].Center).ToRotation() + Projectile.ai[1];
                    while (targetRot < -(float)Math.PI)
                    {
                        targetRot += 2f * (float)Math.PI;
                    }
                    while (targetRot > (float)Math.PI)
                    {
                        targetRot -= 2f * (float)Math.PI;
                    }
                    Projectile.rotation = Projectile.rotation.AngleLerp(targetRot, 0.05f);
                }
            }
            break;

            case 4:     //abom laevateinn 3 telegraph, swing around to where actual sword will spawn but slower
            {
                color         = Color.Yellow;
                maxTime       = 150;
                alphaModifier = 7f;

                NPC abom = FargoSoulsUtil.NPCExists(Projectile.localAI[1], ModContent.NPCType <NPCs.AbomBoss.AbomBoss>());
                if (abom != null)
                {
                    Projectile.Center = abom.Center;
                    float targetRot = Projectile.ai[1];
                    while (targetRot < -(float)Math.PI)
                    {
                        targetRot += 2f * (float)Math.PI;
                    }
                    while (targetRot > (float)Math.PI)
                    {
                        targetRot -= 2f * (float)Math.PI;
                    }
                    Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(targetRot, 0.05f).ToRotationVector2();
                }

                Projectile.position -= Projectile.velocity;
                Projectile.rotation  = Projectile.velocity.ToRotation();
            }
            break;

            case 5:     //abom cirno, slide in to a halt from outside
            {
                color         = new Color(0, 1f, 1f);
                maxTime       = 120;
                alphaModifier = 4f;

                NPC abom = FargoSoulsUtil.NPCExists(Projectile.localAI[1], ModContent.NPCType <NPCs.AbomBoss.AbomBoss>());
                if (abom != null)
                {
                    Vector2 targetPos = abom.Center + Vector2.UnitX * Projectile.ai[1];
                    Projectile.Center = Vector2.Lerp(Projectile.Center, targetPos, 0.03f);
                }

                Projectile.position -= Projectile.velocity;
                Projectile.rotation  = Projectile.velocity.ToRotation();
            }
            break;

            case 6:     //eridanus vortex lightning starting angles
            {
                Projectile.GetGlobalProjectile <FargoSoulsGlobalProjectile>().TimeFreezeImmune = true;

                color   = new Color(51, 255, 191);
                maxTime = 90;

                Player p = FargoSoulsUtil.PlayerExists(Projectile.ai[1]);
                if (p != null)
                {
                    Projectile.rotation = Projectile.DirectionTo(p.Center).ToRotation();
                }
                else
                {
                    Projectile.ai[1] = Player.FindClosest(Projectile.Center, 0, 0);
                }

                Projectile.position -= Projectile.velocity;
                Projectile.rotation += Projectile.velocity.ToRotation();         //yes, PLUS because rotation is set up there, velocity is the offset
            }
            break;

            case 7:     //celestial pillar explode
            {
                Projectile.GetGlobalProjectile <FargoSoulsGlobalProjectile>().TimeFreezeImmune = true;

                switch ((int)Projectile.ai[1])
                {
                case 0: color = Color.Magenta; break;            //nebula

                case 1: color = Color.Orange; break;             //solar

                case 2: color = new Color(51, 255, 191); break;  //vortex

                default: color = Color.SkyBlue; break;           //stardust
                }
                maxTime       = 20;
                alphaModifier = 2;

                Projectile.position -= Projectile.velocity;
                Projectile.rotation  = Projectile.velocity.ToRotation();

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

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            Vector2 speed = (8f * (j + 1) + 4f) * Projectile.velocity;
                            Projectile.NewProjectile(Projectile.InheritSource(Projectile), Projectile.Center, speed, ModContent.ProjectileType <CelestialFragment>(), Projectile.damage, 0f, Main.myPlayer, Projectile.ai[1]);
                        }
                    }
                }
            }
            break;

            case 8:     //prime limbs
            {
                color   = new Color(51, 255, 191, 0);
                maxTime = 60;

                NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], NPCID.PrimeCannon, NPCID.PrimeLaser, NPCID.PrimeSaw, NPCID.PrimeVice);
                if (npc != null)
                {
                    Projectile.Center   = npc.Center;
                    Projectile.rotation = npc.rotation + MathHelper.PiOver2;
                }
                else
                {
                    Projectile.Kill();
                    return;
                }

                Projectile.position -= Projectile.velocity;
                Projectile.rotation += Projectile.velocity.ToRotation();         //yes, PLUS because rotation is set up there, velocity is the offset
            }
            break;

            case 9:     //reti telegraph
            {
                color         = Color.Red;
                maxTime       = 120;
                alphaModifier = 2;

                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;
                    Projectile.rotation = npc.rotation + MathHelper.PiOver2;
                }
                else
                {
                    Projectile.Kill();
                    return;
                }
            }
            break;

            case 10:     //deviantt shadowbeam telegraph
            {
                color         = Color.Purple;
                maxTime       = 90;
                alphaModifier = 2;

                NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], ModContent.NPCType <NPCs.DeviBoss.DeviBoss>());
                if (npc != null)
                {
                    Projectile.Center   = npc.Center;
                    Projectile.rotation = npc.localAI[0];
                }
                else
                {
                    Projectile.Kill();
                    return;
                }
            }
            break;

            case 11:     //destroyer telegraphs
            {
                maxTime       = 90;
                alphaModifier = 2;

                NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], NPCID.TheDestroyerBody, NPCID.TheDestroyerTail);
                if (npc == null)
                {
                    Projectile.Kill();
                    return;
                }

                NPC destroyer = FargoSoulsUtil.NPCExists(npc.realLife, NPCID.TheDestroyer);
                if (destroyer == null || destroyer.GetEModeNPCMod <Destroyer>().IsCoiling)
                {
                    Projectile.Kill();
                    return;
                }

                color               = npc.ai[2] == 0 ? Color.Red : Color.Yellow;
                Projectile.Center   = npc.Center;
                Projectile.rotation = Projectile.localAI[1];

                if (counter == 0)
                {
                    Projectile.localAI[0] = Main.rand.NextFloat(0.9f, 1.1f);
                }

                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    if (npc.ai[2] == 0)
                    {
                        if (counter == maxTime)
                        {
                            Projectile.NewProjectile(Projectile.InheritSource(Projectile),
                                                     Projectile.Center, Projectile.rotation.ToRotationVector2(),
                                                     Projectile.type,
                                                     Projectile.damage, Projectile.knockBack, Projectile.owner, 16f);

                            Projectile.NewProjectile(Projectile.InheritSource(Projectile),
                                                     Projectile.Center, Projectile.localAI[0] * Projectile.rotation.ToRotationVector2(),
                                                     ModContent.ProjectileType <DestroyerLaser>(),
                                                     Projectile.damage, Projectile.knockBack, Projectile.owner);
                        }
                    }
                    else
                    {
                        if (counter > maxTime - 20 && counter % 10 == 0)
                        {
                            Projectile.NewProjectile(Projectile.InheritSource(Projectile),
                                                     Projectile.Center, Projectile.rotation.ToRotationVector2(),
                                                     Projectile.type,
                                                     Projectile.damage, Projectile.knockBack, Projectile.owner, 16f);

                            Projectile.NewProjectile(Projectile.InheritSource(Projectile),
                                                     Projectile.Center, Projectile.localAI[0] * Projectile.rotation.ToRotationVector2(),
                                                     ModContent.ProjectileType <DarkStarHoming>(),
                                                     Projectile.damage, Projectile.knockBack, Projectile.owner, -1, 1f);
                        }
                    }
                }
            }
            break;

            case 12:     //wof vanilla laser telegraph
            {
                color         = Color.Purple;
                maxTime       = 645;
                drawLayers    = 4;
                alphaModifier = -1;

                NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], NPCID.WallofFleshEye);
                if (npc != null && (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 (counter < npc.localAI[1])
                    {
                        counter = (int)npc.localAI[1];
                    }

                    Projectile.alpha = (int)(255 * Math.Cos(Math.PI / 2 / maxTime * counter));
                }
                else
                {
                    Projectile.Kill();
                    return;
                }
            }
            break;

            case 13:     //mutant final spark tell
            {
                color            = new Color(51, 255, 191);
                maxTime          = 90;
                alphaModifier    = counter > maxTime / 2 ? 6 : 3;
                Projectile.scale = 4f;

                NPC mutant = FargoSoulsUtil.NPCExists(Projectile.ai[1], ModContent.NPCType <NPCs.MutantBoss.MutantBoss>());
                if (mutant != null)
                {
                    float targetRot = MathHelper.WrapAngle(mutant.ai[3]);
                    Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(targetRot, 0.12f * (float)Math.Pow((float)counter / maxTime, 3f)).ToRotationVector2();
                }

                Projectile.position -= Projectile.velocity;
                Projectile.rotation  = Projectile.velocity.ToRotation();
            }
            break;

            case 14:     //moon lord vortex telegraph
            {
                color         = new Color(51, 255, 191);
                maxTime       = 180;
                alphaModifier = 5;

                Projectile vortex = FargoSoulsUtil.ProjectileExists(FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, Projectile.ai[1], ModContent.ProjectileType <MoonLordVortex>()));
                if (vortex != null)
                {
                    Projectile.Center = vortex.Center;

                    Projectile.position -= Projectile.velocity;
                    Projectile.rotation  = Projectile.velocity.ToRotation();
                }
                else if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    Projectile.Kill();
                    return;
                }
            }
            break;

            case 15:     //nebula pillar distortion fields
            {
                color            = Color.Purple;
                maxTime          = 270;
                alphaModifier    = 4;
                drawLayers       = 4;
                Projectile.scale = 24f;

                Projectile.rotation = Projectile.ai[1];

                if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && !Main.LocalPlayer.ghost &&
                    Projectile.Colliding(Projectile.Hitbox, Main.LocalPlayer.Hitbox))
                {
                    Main.LocalPlayer.AddBuff(BuffID.VortexDebuff, 2);
                }
            }
            break;

            case 16:     //destroyer blue laser line up true telegraph
            {
                color         = Color.SkyBlue;
                maxTime       = 45;
                alphaModifier = 3;

                Projectile.rotation  = Projectile.velocity.ToRotation();
                Projectile.position -= Projectile.velocity;
            }
            break;

            case 17:     //moon lord nebula distortion field
            {
                color            = Color.Purple;
                maxTime          = 270;
                alphaModifier    = 2;
                drawLayers       = 3;
                Projectile.scale = 24f;

                NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], NPCID.MoonLordCore);
                if (npc == null)
                {
                    Projectile.Kill();
                    return;
                }
                else
                {
                    if (counter == 0)
                    {
                        for (int i = 0; i < Main.maxProjectiles; i++)
                        {
                            if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType <LunarRitual>() && Main.projectile[i].ai[1] == npc.whoAmI)
                            {
                                Projectile.localAI[1] = i;
                                break;
                            }
                        }
                    }

                    Projectile ritual = FargoSoulsUtil.ProjectileExists(Projectile.localAI[1], ModContent.ProjectileType <LunarRitual>());
                    if (ritual != null && ritual.ai[1] == npc.whoAmI)
                    {
                        Projectile.Center      = ritual.Center;
                        Projectile.position.X += Projectile.localAI[0];
                        Projectile.position.Y += 1500;
                    }
                    Projectile.rotation = -MathHelper.PiOver2;

                    if (npc.GetEModeNPCMod <MoonLordCore>().VulnerabilityState <= 2)
                    {
                        if (counter > maxTime / 2)
                        {
                            counter = maxTime / 2;
                        }
                    }
                    else
                    {
                        if (counter < maxTime - 60)
                        {
                            counter = maxTime - 60;
                        }
                    }
                }

                if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && !Main.LocalPlayer.ghost &&
                    Projectile.Colliding(Projectile.Hitbox, Main.LocalPlayer.Hitbox))
                {
                    Main.LocalPlayer.AddBuff(BuffID.VortexDebuff, 2);
                }
            }
            break;

            case 18:     //cultist arena new visual
            {
                color            = Color.Cyan * 0.75f;
                maxTime          = 60;
                alphaModifier    = 2;
                Projectile.scale = 3f;

                NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[1], NPCID.CultistBoss);
                if (npc != null)
                {
                    if (counter > maxTime / 2)
                    {
                        counter = maxTime / 2;
                    }

                    if (npc.ai[0] == 5)
                    {
                        //in here so it doesnt kill itself as soon as it spawns
                        if (counter > 0 && npc.ai[1] == 1f && Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Projectile.Kill();
                            return;
                        }

                        int ritual = (int)npc.ai[2];
                        if (ritual > -1 && ritual < Main.maxProjectiles && Main.projectile[ritual].active && Main.projectile[ritual].type == ProjectileID.CultistRitual)
                        {
                            if (counter == 0)
                            {
                                Vector2 offset = Projectile.Center - Main.projectile[ritual].Center;
                                Projectile.localAI[0] = offset.X;
                                Projectile.localAI[1] = offset.Y;
                            }

                            Projectile.Center = Main.projectile[ritual].Center + new Vector2(Projectile.localAI[0], Projectile.localAI[1]);
                        }
                    }
                }

                Projectile.position -= Projectile.velocity;
                Projectile.rotation  = Projectile.velocity.ToRotation();
            }
            break;

            case 19:     //timber head squrrl warning
            {
                color            = new Color(93, 255, 241, 0) * 0.75f;
                alphaModifier    = 1;
                Projectile.scale = 2f;

                maxTime = 20 * 2;
                if (counter < maxTime / 2)         //effectively start at max brightness then fade
                {
                    counter = maxTime / 2;
                }

                Projectile.position -= Projectile.velocity;
                Projectile.rotation  = Projectile.velocity.ToRotation();
            }
            break;

            default:
                Main.NewText("glow line: you shouldnt be seeing this text, show terry");
                break;
            }

            if (++counter > maxTime)
            {
                Projectile.Kill();
                return;
            }

            if (alphaModifier >= 0)
            {
                Projectile.alpha = 255 - (int)(255 * Math.Sin(Math.PI / maxTime * counter) * alphaModifier);
                if (Projectile.alpha < 0)
                {
                    Projectile.alpha = 0;
                }
            }

            color.A = 0;
        }
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[1], ModContent.ProjectileType <RefractorBlaster2Held>());

            if (byIdentity != -1)
            {
                Projectile.damage    = Main.player[Projectile.owner].GetWeaponDamage(Main.player[Projectile.owner].HeldItem);
                Projectile.knockBack = Main.player[Projectile.owner].GetWeaponKnockback(Main.player[Projectile.owner].HeldItem, Main.player[Projectile.owner].HeldItem.knockBack);

                float rotation = Main.player[Projectile.owner].itemRotation + (Main.player[Projectile.owner].direction < 0 ? MathHelper.Pi : 0);
                Projectile.velocity = rotation.ToRotationVector2();
                Projectile.Center   = Main.player[Projectile.owner].MountedCenter + 87f * Projectile.velocity;

                Projectile.timeLeft++;
                float   rotdir   = (Projectile.ai[0] > 0) ? 1 : -1;
                Vector2 vel      = Projectile.velocity.RotatedBy(rotdir * MathHelper.Pi / 6);
                float   windup   = Math.Min(1f, Spinup);
                float   rotspeed = windup * 1.5f * 6f;

                Projectile.velocity = vel.RotatedBy(Math.Sin(Projectile.localAI[0] * rotspeed + (Math.Abs(Projectile.ai[0]) / 6 * MathHelper.TwoPi))
                                                    * rotdir * MathHelper.Pi / 14 * windup);
            }
            else if (Projectile.localAI[0] > 0.05f) //leeway for mp lag
            {
                Projectile.Kill();
                return;
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            float num801 = .2f;

            Projectile.localAI[0] += 0.01f;
            Projectile.scale       = Math.Min(Projectile.localAI[0], 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;
            //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, 2000f, array3);
            //for (int i = 0; i < array3.Length; i++) array3[i] = Projectile.localAI[0] * Projectile.ai[1];
            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));

            Projectile.position -= Projectile.velocity;
            Projectile.rotation  = Projectile.velocity.ToRotation() - 1.57079637f;

            DelegateMethods.v3_1 = new Vector3(0.8f, 0f, 0);
            Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * (Projectile.localAI[1]), 10, DelegateMethods.CastLight);
        }
        public override void AI()
        {
            Player           player    = Main.player[Projectile.owner];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if ((int)Main.time % 120 == 0)
            {
                Projectile.netUpdate = true;
            }

            int num1038 = 30;

            bool    flag67      = false;
            Vector2 value67     = Vector2.Zero;
            Vector2 arg_2D865_0 = Vector2.Zero;
            float   num1052     = 0f;

            if (Projectile.ai[1] == 1f)
            {
                Projectile.ai[1]     = 0f;
                Projectile.netUpdate = true;
            }

            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], Projectile.type, ModContent.ProjectileType <DestroyerHead2>());

            if (byIdentity >= 0 && Main.projectile[byIdentity].active)
            {
                flag67  = true;
                value67 = Main.projectile[byIdentity].Center;
                Vector2 arg_2D957_0 = Main.projectile[byIdentity].velocity;
                num1052 = Main.projectile[byIdentity].rotation;
                float num1053     = MathHelper.Clamp(Main.projectile[byIdentity].scale, 0f, 50f);
                int   arg_2D9AD_0 = Main.projectile[byIdentity].alpha;
                if (arg_2D9AD_0 == 0)
                {
                    Projectile.alpha -= 84;
                    if (Projectile.alpha < 0)
                    {
                        Projectile.alpha = 0;
                    }
                }
                Main.projectile[byIdentity].localAI[0] = Projectile.localAI[0] + 1f;
                if (Main.projectile[byIdentity].type != ModContent.ProjectileType <DestroyerHead2>())
                {
                    Main.projectile[byIdentity].localAI[1] = Projectile.identity;
                }
            }

            if (!flag67)
            {
                return;
            }

            //Projectile.alpha -= 42;
            //if (Projectile.alpha < 0) Projectile.alpha = 0;
            Projectile.velocity = Vector2.Zero;
            Vector2 vector134 = value67 - Projectile.Center;

            if (num1052 != Projectile.rotation)
            {
                float num1056 = MathHelper.WrapAngle(num1052 - Projectile.rotation);
                vector134 = vector134.RotatedBy(num1056 * 0.1f, default(Vector2));
            }

            Projectile.rotation = vector134.ToRotation() + 1.57079637f;
            Projectile.position = Projectile.Center;
            Projectile.width    = Projectile.height = (int)(num1038 * Projectile.scale);
            Projectile.Center   = Projectile.position;
            if (vector134 != Vector2.Zero)
            {
                Projectile.Center = value67 - Vector2.Normalize(vector134) * 36;
            }
            Projectile.spriteDirection = vector134.X > 0f ? 1 : -1;

            if (--attackTimer <= 0)
            {
                attackTimer = Main.rand.Next(90) + 90;
            }

            if (attackTimer == 1)
            {
                if (Projectile.owner == Main.myPlayer)
                {
                    int         selectedTarget = -1; //pick target
                    const float maxRange       = 750f;
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        if (Main.npc[i].CanBeChasedBy(Projectile) && Collision.CanHit(Projectile.Center, 0, 0, Main.npc[i].Center, 0, 0))
                        {
                            if (Projectile.Distance(Main.npc[i].Center) <= maxRange && Main.rand.NextBool()) //random because destroyer
                            {
                                selectedTarget = i;
                            }
                        }
                    }

                    if (selectedTarget != -1) //shoot
                    {
                        FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.DirectionTo(Main.npc[selectedTarget].Center).RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)),
                                                           ModContent.ProjectileType <DarkStarHomingFriendly>(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner, selectedTarget);
                    }
                }
            }
        }
Esempio n. 12
0
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <PhantasmalRing>());

            if (byIdentity != -1)
            {
                Projectile.Center    = Main.projectile[byIdentity].Center;
                Projectile.position += Vector2.UnitX.RotatedBy(2 * Math.PI / 7 * Projectile.ai[1] + Main.projectile[byIdentity].ai[0]) * 350 * 0.25f;
                if (Projectile.whoAmI < Main.projectile[byIdentity].whoAmI)
                {
                    Projectile.position += Main.player[Main.projectile[byIdentity].owner].position - Main.player[Main.projectile[byIdentity].owner].oldPosition;
                }
            }
            else if (Projectile.owner == Main.myPlayer && Projectile.localAI[0] > 5)
            {
                Projectile.Kill();
                return;
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            if (Projectile.localAI[0] == 0f)
            {
                SoundEngine.PlaySound(SoundID.Item12, Projectile.Center);
            }
            float num801 = 0.5f;

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

            //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, DelegateMethods.CastLight);
        }
        public override void AI()
        {
            if ((int)Main.time % 120 == 0)
            {
                Projectile.netUpdate = true;
            }

            int num1038 = 30;

            //dust!
            int dustId = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 2f), Projectile.width, Projectile.height + 5, 62, Projectile.velocity.X * 0.2f,
                                      Projectile.velocity.Y * 0.2f, 100, default(Color), 2f);

            Main.dust[dustId].noGravity = true;
            int dustId3 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 2f), Projectile.width, Projectile.height + 5, 62, Projectile.velocity.X * 0.2f,
                                       Projectile.velocity.Y * 0.2f, 100, default(Color), 2f);

            Main.dust[dustId3].noGravity = true;

            bool    flag67      = false;
            Vector2 value67     = Vector2.Zero;
            Vector2 arg_2D865_0 = Vector2.Zero;
            float   num1052     = 0f;

            if (Projectile.ai[1] == 1f)
            {
                Projectile.ai[1]     = 0f;
                Projectile.netUpdate = true;
            }

            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <MutantDestroyerBody>());

            if (byIdentity >= 0 && Main.projectile[byIdentity].active)
            {
                flag67  = true;
                value67 = Main.projectile[byIdentity].Center;
                Vector2 arg_2D957_0 = Main.projectile[byIdentity].velocity;
                num1052 = Main.projectile[byIdentity].rotation;
                float num1053     = MathHelper.Clamp(Main.projectile[byIdentity].scale, 0f, 50f);
                int   arg_2D9AD_0 = Main.projectile[byIdentity].alpha;
                Main.projectile[byIdentity].localAI[0] = Projectile.localAI[0] + 1f;
                Projectile.timeLeft = Main.projectile[byIdentity].timeLeft;
            }

            if (!flag67)
            {
                return;
            }

            Projectile.alpha -= 42;
            if (Projectile.alpha < 0)
            {
                Projectile.alpha = 0;
            }
            Projectile.velocity = Vector2.Zero;
            Vector2 vector134 = value67 - Projectile.Center;

            if (num1052 != Projectile.rotation)
            {
                float num1056 = MathHelper.WrapAngle(num1052 - Projectile.rotation);
                vector134 = vector134.RotatedBy(num1056 * 0.1f, default(Vector2));
            }

            Projectile.rotation = vector134.ToRotation() + 1.57079637f;
            Projectile.position = Projectile.Center;
            Projectile.width    = Projectile.height = (int)(num1038 * Projectile.scale);
            Projectile.Center   = Projectile.position;
            if (vector134 != Vector2.Zero)
            {
                Projectile.Center = value67 - Vector2.Normalize(vector134) * 36;
            }
            Projectile.spriteDirection = vector134.X > 0f ? 1 : -1;
        }
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[1], ModContent.ProjectileType <MiniSaucer>());

            if (byIdentity != -1)
            {
                Projectile.Center = Main.projectile[byIdentity].Center;
            }
            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 = 0.4f;

            Projectile.localAI[0] += 1f;
            if (Projectile.localAI[0] >= maxTime)
            {
                Projectile.Kill();
                return;
            }
            Projectile.scale = num801; /*(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;
            Projectile.velocity = num804.ToRotationVector2();
            float   num805        = 3f;
            float   num806        = (float)Projectile.width;
            Vector2 samplingPoint = Projectile.Center;

            if (vector78.HasValue)
            {
                samplingPoint = vector78.Value;
            }
            const int yOffset = 250;

            samplingPoint.Y += yOffset;
            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 + yOffset, 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));

            Projectile.position -= Projectile.velocity;
        }
Esempio n. 15
0
        public override void AI()
        {
            if (Projectile.localAI[0] == 0)
            {
                SoundEngine.PlaySound(SoundID.Item92, Projectile.Center);
                Projectile.rotation = Projectile.velocity.ToRotation();

                SoundEngine.PlaySound(SoundID.Item89, Projectile.position);

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

                for (int num615 = 0; num615 < 20; num615++)
                {
                    int num616 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default(Color), 1.5f);
                    Main.dust[num616].velocity *= 1.4f;
                }

                for (int num617 = 0; num617 < 40; num617++)
                {
                    int num618 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default(Color), 3.5f);
                    Main.dust[num618].noGravity = true;
                    Main.dust[num618].velocity *= 7f;
                    num618 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f);
                    Main.dust[num618].velocity *= 3f;
                }

                for (int num619 = 0; num619 < 2; num619++)
                {
                    float scaleFactor9 = 0.4f;
                    if (num619 == 1)
                    {
                        scaleFactor9 = 0.8f;
                    }
                    int num620 = Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, default(Vector2), Main.rand.Next(61, 64));
                    Main.gore[num620].velocity *= scaleFactor9;
                    Gore gore97 = Main.gore[num620];
                    gore97.velocity.X = gore97.velocity.X + 1f;
                    Gore gore98 = Main.gore[num620];
                    gore98.velocity.Y           = gore98.velocity.Y + 1f;
                    num620                      = Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, default(Vector2), Main.rand.Next(61, 64));
                    Main.gore[num620].velocity *= scaleFactor9;
                    Gore gore99 = Main.gore[num620];
                    gore99.velocity.X = gore99.velocity.X - 1f;
                    Gore gore100 = Main.gore[num620];
                    gore100.velocity.Y          = gore100.velocity.Y + 1f;
                    num620                      = Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, default(Vector2), Main.rand.Next(61, 64));
                    Main.gore[num620].velocity *= scaleFactor9;
                    Gore gore101 = Main.gore[num620];
                    gore101.velocity.X = gore101.velocity.X + 1f;
                    Gore gore102 = Main.gore[num620];
                    gore102.velocity.Y          = gore102.velocity.Y - 1f;
                    num620                      = Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, default(Vector2), Main.rand.Next(61, 64));
                    Main.gore[num620].velocity *= scaleFactor9;
                    Gore gore103 = Main.gore[num620];
                    gore103.velocity.X = gore103.velocity.X - 1f;
                    Gore gore104 = Main.gore[num620];
                    gore104.velocity.Y = gore104.velocity.Y - 1f;
                }


                for (int k = 0; k < 20; k++) //make visual dust
                {
                    Vector2 dustPos = Projectile.position;
                    dustPos.X += Main.rand.Next(Projectile.width);
                    dustPos.Y += Main.rand.Next(Projectile.height);

                    for (int i = 0; i < 15; i++)
                    {
                        int dust = Dust.NewDust(dustPos, 32, 32, 31, 0f, 0f, 100, default(Color), 3f);
                        Main.dust[dust].velocity *= 1.4f;
                    }

                    for (int i = 0; i < 10; i++)
                    {
                        int dust = Dust.NewDust(dustPos, 32, 32, DustID.Torch, 0f, 0f, 100, default(Color), 3.5f);
                        Main.dust[dust].noGravity = true;
                        Main.dust[dust].velocity *= 7f;
                        dust = Dust.NewDust(dustPos, 32, 32, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f);
                        Main.dust[dust].velocity *= 3f;
                    }

                    float scaleFactor9 = 0.5f;
                    for (int j = 0; j < 4; j++)
                    {
                        int gore = Gore.NewGore(Projectile.GetSource_FromThis(), dustPos, default(Vector2), Main.rand.Next(61, 64));
                        Main.gore[gore].velocity   *= scaleFactor9;
                        Main.gore[gore].velocity.X += 1f;
                        Main.gore[gore].velocity.Y += 1f;
                    }
                }

                const int num226 = 30;
                for (int num227 = 0; num227 < num226; num227++)
                {
                    Vector2 vector6 = Vector2.UnitX * 40f;
                    vector6 = vector6.RotatedBy(((num227 - (num226 / 2 - 1)) * 6.28318548f / num226), default(Vector2)) + Projectile.Center;
                    Vector2 vector7 = vector6 - Projectile.Center;
                    int     num228  = Dust.NewDust(vector6 + vector7, 0, 0, DustID.Torch, 0f, 0f, 0, default(Color), 3f);
                    Main.dust[num228].noGravity = true;
                    Main.dust[num228].velocity  = vector7;
                }
            }

            NPC        moonLord = FargoSoulsUtil.NPCExists(NPCs.EModeGlobalNPC.moonBoss, NPCID.MoonLordCore);
            Projectile arena    = FargoSoulsUtil.ProjectileExists(FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, Projectile.ai[0], ModContent.ProjectileType <LunarRitual>()));

            if (moonLord != null && arena != null && moonLord.ai[0] != 2f)
            {
                if (moonLord.GetEModeNPCMod <MoonLordCore>().VulnerabilityState == 4)
                {
                    Projectile.timeLeft = 60;
                }

                float orbitRange = Math.Abs(Projectile.ai[1]) + 400f * moonLord.life / moonLord.lifeMax;

                if (++Projectile.localAI[0] < 60)
                {
                    Vector2 desiredPosition = arena.Center + Projectile.velocity * orbitRange;
                    Projectile.Center = Vector2.Lerp(Projectile.Center, desiredPosition, 0.05f);

                    Projectile.position += arena.velocity;
                    Projectile.position -= Projectile.velocity;

                    Projectile.alpha -= 10;
                    if (Projectile.alpha < 0)
                    {
                        Projectile.alpha = 0;
                    }
                }
                else
                {
                    Projectile.alpha     = 0;
                    Projectile.velocity  = Vector2.Zero;
                    Projectile.rotation += MathHelper.ToRadians(3.5f) * Math.Min(1f, (Projectile.localAI[0] - 60) / 180) * Math.Sign(Projectile.ai[1]);
                    Projectile.Center    = arena.Center + orbitRange * Projectile.rotation.ToRotationVector2();
                }
            }
            else if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                Projectile.Kill();
            }
        }
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[1], ModContent.ProjectileType <StyxGazer>(), ModContent.ProjectileType <StyxGazerArmor>());

            if (byIdentity != -1)
            {
                Projectile.Center    = Main.projectile[byIdentity].Center;
                Projectile.position += Main.projectile[byIdentity].velocity * 75;
                Projectile.velocity  = Main.projectile[byIdentity].velocity.RotatedBy(Projectile.ai[0]);
            }
            else if (Projectile.owner == Main.myPlayer && Projectile.localAI[0] > 5)
            {
                Projectile.Kill();
                return;
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            //if (Projectile.localAI[0] == 0f)
            //{
            //   SoundEngine.PlaySound(new SoundStyle("Terraria/Sounds/Zombie_104") with { Volume = 0.6f, Pitch = 0 }, 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) * num801 * 6f;
            if (Projectile.scale > num801)
            {
                Projectile.scale = num801;
            }
            float num804 = Projectile.velocity.ToRotation();

            /*if (Main.npc[ai1].velocity != Vector2.Zero)
             *  num804 += Projectile.ai[0];*/
            Projectile.rotation = 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] = 100f;
            }
            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);

            if (Main.rand.NextBool())
            {
                int d = Dust.NewDust(Projectile.position + Projectile.velocity * Main.rand.NextFloat(100), Projectile.width, Projectile.height, 87, 0f, 0f, 0, default(Color), 1.5f);
                Main.dust[d].noGravity = true;
                Main.dust[d].velocity *= 4f;
            }
        }
Esempio n. 17
0
        public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            //to fix tail disapearing meme
            float slotsUsed = 0;

            Main.projectile.Where(x => x.active && x.owner == player.whoAmI && x.minionSlots > 0).ToList().ForEach(x => { slotsUsed += x.minionSlots; });

            if (player.maxMinions - slotsUsed < 1)
            {
                return(false);
            }

            int headCheck = -1;
            int tailCheck = -1;

            for (int i = 0; i < Main.maxProjectiles; i++)
            {
                Projectile proj = Main.projectile[i];
                if (proj.active && proj.owner == player.whoAmI)
                {
                    if (headCheck == -1 && proj.type == ModContent.ProjectileType <EaterHead>())
                    {
                        headCheck = i;
                    }
                    if (tailCheck == -1 && proj.type == ModContent.ProjectileType <EaterTail>())
                    {
                        tailCheck = i;
                    }
                    if (headCheck != -1 && tailCheck != -1)
                    {
                        break;
                    }
                }
            }

            //initial spawn
            if (headCheck == -1 && tailCheck == -1)
            {
                int current = FargoSoulsUtil.NewSummonProjectile(source, position, Vector2.Zero, ModContent.ProjectileType <EaterHead>(), Item.damage, knockback, player.whoAmI, 0f, 0);

                int previous = 0;

                for (int i = 0; i < 4; i++)
                {
                    current  = FargoSoulsUtil.NewSummonProjectile(source, position, Vector2.Zero, ModContent.ProjectileType <EaterBody>(), Item.damage, knockback, player.whoAmI, Main.projectile[current].identity, 0);
                    previous = current;
                }

                current = FargoSoulsUtil.NewSummonProjectile(source, position, Vector2.Zero, ModContent.ProjectileType <EaterTail>(), Item.damage, knockback, player.whoAmI, Main.projectile[current].identity, 0);

                Main.projectile[previous].localAI[1] = Main.projectile[current].identity;
                Main.projectile[previous].netUpdate  = true;
            }
            //spawn more body segments
            else
            {
                int previous = (int)Main.projectile[tailCheck].ai[0];
                int current  = 0;

                for (int i = 0; i < 4; i++)
                {
                    int prevUUID = FargoSoulsUtil.GetProjectileByIdentity(player.whoAmI, Main.projectile[previous].identity);
                    current = FargoSoulsUtil.NewSummonProjectile(source, position, velocity, ModContent.ProjectileType <EaterBody>(),
                                                                 Item.damage, knockback, player.whoAmI, prevUUID, 0);

                    previous = current;
                }

                Main.projectile[current].localAI[1] = Main.projectile[tailCheck].identity;

                Main.projectile[tailCheck].ai[0]     = FargoSoulsUtil.GetProjectileByIdentity(player.whoAmI, Main.projectile[current].identity);
                Main.projectile[tailCheck].netUpdate = true;
                Main.projectile[tailCheck].ai[1]     = 1f;
            }

            return(false);
        }
Esempio n. 18
0
        public override void AI()
        {
            Player           player    = Main.player[Projectile.owner];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if ((int)Main.time % 120 == 0)
            {
                Projectile.netUpdate = true;
            }
            if (!player.active)
            {
                Projectile.active = false;
                return;
            }


            int num1038 = 10;

            if (player.dead)
            {
                modPlayer.EaterMinion = false;
            }
            if (modPlayer.EaterMinion)
            {
                Projectile.timeLeft = 2;
            }
            num1038 = 30;

            //D U S T

            /*if (Main.rand.NextBool(30))
             * {
             *  int num1039 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 0, default(Color), 2f);
             *  Main.dust[num1039].noGravity = true;
             *  Main.dust[num1039].fadeIn = 2f;
             *  Point point4 = Main.dust[num1039].position.ToTileCoordinates();
             *  if (WorldGen.InWorld(point4.X, point4.Y, 5) && WorldGen.SolidTile(point4.X, point4.Y))
             *  {
             *      Main.dust[num1039].noLight = true;
             *  }
             * }*/

            bool    flag67      = false;
            Vector2 value67     = Vector2.Zero;
            Vector2 arg_2D865_0 = Vector2.Zero;
            float   num1052     = 0f;

            if (Projectile.ai[1] == 1f)
            {
                Projectile.ai[1]     = 0f;
                Projectile.netUpdate = true;
            }

            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <EaterBody>());

            if (byIdentity >= 0 && Main.projectile[byIdentity].active)
            {
                flag67  = true;
                value67 = Main.projectile[byIdentity].Center;
                Vector2 arg_2D957_0 = Main.projectile[byIdentity].velocity;
                num1052 = Main.projectile[byIdentity].rotation;
                float num1053     = MathHelper.Clamp(Main.projectile[byIdentity].scale, 0f, 50f);
                int   arg_2D9AD_0 = Main.projectile[byIdentity].alpha;
                Main.projectile[byIdentity].localAI[0] = Projectile.localAI[0] + 1f;
                if (Main.projectile[byIdentity].type != ModContent.ProjectileType <EaterHead>())
                {
                    Main.projectile[byIdentity].localAI[1] = Projectile.identity;
                }
                if (Projectile.owner == player.whoAmI && Main.projectile[byIdentity].type == ModContent.ProjectileType <EaterHead>())
                {
                    Main.projectile[byIdentity].Kill();
                    Projectile.Kill();
                    return;
                }
            }

            if (!flag67)
            {
                return;
            }
            if (Projectile.alpha > 0)
            {
                for (int num1054 = 0; num1054 < 2; num1054++)
                {
                    int num1055 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 135, 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num1055].noGravity = true;
                    Main.dust[num1055].noLight   = true;
                }
            }

            Projectile.alpha -= 42;
            if (Projectile.alpha < 0)
            {
                Projectile.alpha = 0;
            }
            Projectile.velocity = Vector2.Zero;
            Vector2 vector134 = value67 - Projectile.Center;

            if (num1052 != Projectile.rotation)
            {
                float num1056 = MathHelper.WrapAngle(num1052 - Projectile.rotation);
                vector134 = vector134.RotatedBy(num1056 * 0.1f, default(Vector2));
            }

            Projectile.rotation = vector134.ToRotation() + 1.57079637f;
            Projectile.position = Projectile.Center;
            Projectile.width    = Projectile.height = (int)(num1038 * Projectile.scale);
            Projectile.Center   = Projectile.position;
            if (vector134 != Vector2.Zero)
            {
                Projectile.Center = value67 - Vector2.Normalize(vector134) * 35;
            }
            Projectile.spriteDirection = vector134.X > 0f ? 1 : -1;
        }
Esempio n. 19
0
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int ai1        = (int)Projectile.ai[1];
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, ai1, ModContent.ProjectileType <SparklingLove>());

            if (byIdentity != -1)
            {
                Projectile.Center = Main.projectile[byIdentity].Center;
            }
            else if (Projectile.owner == Main.myPlayer && Projectile.localAI[0] > 5)
            {
                Projectile.Kill();
                return;
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            if (Projectile.localAI[0] == 0f)
            {
                SoundEngine.PlaySound(SoundID.Item12, Projectile.Center);
                //SoundEngine.PlaySound(new SoundStyle("Terraria/Sounds/Zombie_104"), Projectile.Center);
            }
            float num801 = 0.5f;

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

            num804 += Projectile.ai[0];
            Projectile.rotation = 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] = 1000f;
            }
            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, 86, 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, 86, 0f, 0f, 100, default(Color), 1.5f);
             *  Dust dust = Main.dust[num813];
             *  dust.noGravity = true;
             *  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));
        }
Esempio n. 20
0
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[1], ModContent.ProjectileType <Retiglaive>());

            if (byIdentity != -1)
            {
                Projectile.Center = Main.projectile[byIdentity].Center;
            }
            else
            {
                if (Projectile.owner == Main.myPlayer && Projectile.localAI[0] > 5)
                {
                    Projectile.Kill();
                    return;
                }
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            if (Projectile.localAI[0] == 0f)
            {
                if (!Main.dedServ)
                {
                    SoundEngine.PlaySound(new SoundStyle("FargowiltasSouls/Sounds/Zombie_104")
                    {
                        Volume = 0.3f
                    }, Projectile.Center);
                }
            }
            float num801 = .3f;

            Projectile.localAI[0] += 1f;
            if (Projectile.localAI[0] >= maxTime)
            {
                Projectile.Kill();
                return;
            }
            Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * 3.14159274f / maxTime) * 3f * num801;
            if (Projectile.scale > num801)
            {
                Projectile.scale = num801;
            }
            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, 2000f, array3);
            //for (int i = 0; i < array3.Length; i++) array3[i] = Projectile.localAI[0] * Projectile.ai[1];
            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);

            Projectile.position -= Projectile.velocity;
            Projectile.rotation  = Projectile.velocity.ToRotation() - 1.57079637f;
        }
        public override void AI()
        {
            base.AI();

            Player player = Main.player[Projectile.owner];

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

            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }

            Projectile spear = FargoSoulsUtil.ProjectileExists(FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[1], ModContent.ProjectileType <HentaiSpearWand>()));

            if (spear != null)
            {
                Projectile.timeLeft = 2;
                float itemrotate = player.direction < 0 ? MathHelper.Pi : 0;
                if (Math.Abs(player.itemRotation) > Math.PI / 2)
                {
                    itemrotate = itemrotate == 0 ? MathHelper.Pi : 0;
                }
                Projectile.velocity = (player.itemRotation + itemrotate).ToRotationVector2();
                Projectile.Center   = spear.Center + Main.rand.NextVector2Circular(5, 5);

                Projectile.position += Projectile.velocity * 164 * spear.scale * 0.45f; //offset by part of spear's length (wand)

                Projectile.damage    = player.GetWeaponDamage(player.HeldItem);
                Projectile.knockBack = player.GetWeaponKnockback(player.HeldItem, player.HeldItem.knockBack);
            }
            else if (++Projectile.localAI[0] > 5) //leeway for mp lag
            {
                Projectile.Kill();
                return;
            }

            if (Projectile.localAI[0] == 0f)
            {
                if (!Main.dedServ)
                {
                    SoundEngine.PlaySound(new SoundStyle("FargowiltasSouls/Sounds/Zombie_104"), Projectile.Center);
                }
            }
            float num801 = 10f;

            if (Projectile.localAI[0] == maxTime / 2)
            {
                if (Projectile.owner == Main.myPlayer && !(player.controlUseTile && player.altFunctionUse == 2 && player.HeldItem.type == ModContent.ItemType <Items.Weapons.FinalUpgrades.HentaiSpear>()))
                {
                    Projectile.localAI[0] += 1f; //if stop firing, proceed to die
                }
                else
                {
                    Projectile.localAI[0] -= 1f; //otherwise, stay (also for multiplayer!)
                }
            }
            else
            {
                Projectile.localAI[0] += 1f;
            }

            if (Projectile.localAI[0] >= maxTime)
            {
                Projectile.Kill();
                return;
            }
            //Projectile.scale = num801;
            Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * 3.14159274f / maxTime) * 1.5f * num801;
            if (Projectile.scale > num801)
            {
                Projectile.scale = num801;
            }

            Projectile.scale    *= spear.scale / 1.3f;
            Projectile.position += TipOffset;

            //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;
            //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));

            Projectile.position -= Projectile.velocity;
            float oldRot = Projectile.rotation;

            Projectile.rotation = Projectile.velocity.ToRotation() - 1.57079637f;

            if (++Projectile.ai[0] > 60)
            {
                Projectile.ai[0] = 0;

                SoundEngine.PlaySound(SoundID.Item84, player.Center);

                if (Projectile.owner == Main.myPlayer)
                {
                    const int   ringMax  = 10;
                    const float speed    = 12f;
                    const float rotation = 0.5f;
                    for (int i = 0; i < ringMax; i++)
                    {
                        Vector2 vel = speed * Projectile.velocity.RotatedBy(2 * Math.PI / ringMax * i);
                        Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, vel, ModContent.ProjectileType <HentaiSphereRing>(),
                                                 Projectile.damage, Projectile.knockBack, Projectile.owner, rotation, speed);
                        Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, vel, ModContent.ProjectileType <HentaiSphereRing>(),
                                                 Projectile.damage, Projectile.knockBack, Projectile.owner, -rotation, speed);
                    }
                }
            }

            //if (--dustTimer < -1)
            //{
            //    dustTimer = 50;

            //    float diff = MathHelper.WrapAngle(Projectile.rotation - oldRot);
            //    //if (npc.HasPlayerTarget && Math.Abs(MathHelper.WrapAngle(npc.DirectionTo(Main.player[npc.target].Center).ToRotation() - Projectile.velocity.ToRotation())) < Math.Abs(diff)) diff = 0;
            //    diff *= 15f;

            //    const int ring = 220; //LAUGH
            //    for (int i = 0; i < ring; ++i)
            //    {
            //        Vector2 speed = Projectile.velocity.RotatedBy(diff) * 24f;

            //        Vector2 vector2 = (-Vector2.UnitY.RotatedBy(i * 3.14159274101257 * 2 / ring) * new Vector2(8f, 16f)).RotatedBy(Projectile.velocity.ToRotation() + diff);
            //        int index2 = Dust.NewDust(Main.player[Projectile.owner].Center, 0, 0, 111, 0.0f, 0.0f, 0, new Color(), 1f);
            //        Main.dust[index2].scale = 2.5f;
            //        Main.dust[index2].noGravity = true;
            //        Main.dust[index2].position = Main.player[Projectile.owner].Center;
            //        Main.dust[index2].velocity = vector2 * 2.5f + speed;

            //        index2 = Dust.NewDust(Main.player[Projectile.owner].Center, 0, 0, 111, 0.0f, 0.0f, 0, new Color(), 1f);
            //        Main.dust[index2].scale = 2.5f;
            //        Main.dust[index2].noGravity = true;
            //        Main.dust[index2].position = Main.player[Projectile.owner].Center;
            //        Main.dust[index2].velocity = vector2 * 1.75f + speed * 2;
            //    }
            //}
        }
Esempio n. 22
0
        public override void AI()
        {
            Player           player    = Main.player[Projectile.owner];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if ((int)Main.time % 120 == 0)
            {
                Projectile.netUpdate = true;
            }

            int num1038 = 30;

            bool    flag67      = false;
            Vector2 value67     = Vector2.Zero;
            Vector2 arg_2D865_0 = Vector2.Zero;
            float   num1052     = 0f;

            if (Projectile.ai[1] == 1f)
            {
                Projectile.ai[1]     = 0f;
                Projectile.netUpdate = true;
            }

            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], ModContent.ProjectileType <DestroyerBody2>());

            if (byIdentity >= 0 && Main.projectile[byIdentity].active)
            {
                flag67  = true;
                value67 = Main.projectile[byIdentity].Center;
                Vector2 arg_2D957_0 = Main.projectile[byIdentity].velocity;
                num1052 = Main.projectile[byIdentity].rotation;
                float num1053     = MathHelper.Clamp(Main.projectile[byIdentity].scale, 0f, 50f);
                int   arg_2D9AD_0 = Main.projectile[byIdentity].alpha;
                if (arg_2D9AD_0 == 0)
                {
                    Projectile.alpha -= 84;
                    if (Projectile.alpha < 0)
                    {
                        Projectile.alpha = 0;
                    }
                }
                Main.projectile[byIdentity].localAI[0] = Projectile.localAI[0] + 1f;
            }

            if (!flag67)
            {
                return;
            }

            //Projectile.alpha -= 42;
            //if (Projectile.alpha < 0) Projectile.alpha = 0;
            Projectile.velocity = Vector2.Zero;
            Vector2 vector134 = value67 - Projectile.Center;

            if (num1052 != Projectile.rotation)
            {
                float num1056 = MathHelper.WrapAngle(num1052 - Projectile.rotation);
                vector134 = vector134.RotatedBy(num1056 * 0.1f, default(Vector2));
            }

            Projectile.rotation = vector134.ToRotation() + 1.57079637f;
            Projectile.position = Projectile.Center;
            Projectile.width    = Projectile.height = (int)(num1038 * Projectile.scale);
            Projectile.Center   = Projectile.position;
            if (vector134 != Vector2.Zero)
            {
                Projectile.Center = value67 - Vector2.Normalize(vector134) * 36;
            }
            Projectile.spriteDirection = vector134.X > 0f ? 1 : -1;
        }
        public override void AI()
        {
            Vector2?vector78 = null;

            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            int sword = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[1], ModContent.ProjectileType <AbomSword>());

            if (sword != -1)
            {
                Projectile.Center   = Main.projectile[sword].Center + Main.projectile[sword].velocity * 75;
                Projectile.velocity = Main.projectile[sword].velocity.RotatedBy(Projectile.ai[0]);
            }
            if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero)
            {
                Projectile.velocity = -Vector2.UnitY;
            }
            if (Projectile.localAI[0] == 0f)
            {
                //SoundEngine.PlaySound(new 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) * num801 * 6f;
            if (Projectile.scale > num801)
            {
                Projectile.scale = num801;
            }
            float num804 = Projectile.velocity.ToRotation();

            /*if (Main.npc[ai1].velocity != Vector2.Zero)
             *  num804 += Projectile.ai[0];*/
            Projectile.rotation = 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] = 100f;
            }
            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));

            /*if (Main.npc[ai1].velocity != Vector2.Zero && --counter < 0)
             * {
             *  counter = 5;
             *  if (Main.netMode != NetmodeID.MultiplayerClient) //spawn bonus projs
             *  {
             *      Vector2 spawnPos = Projectile.Center;
             *      Vector2 vel = Projectile.velocity.RotatedBy(Math.PI / 2 * Math.Sign(Projectile.ai[0]));
             *      const int max = 15;
             *      for (int i = 1; i <= max; i++)
             *      {
             *          spawnPos += Projectile.velocity * 3000f / max;
             *          Projectile.NewProjectile(spawnPos, vel, ModContent.ProjectileType<AbomSickle2>(), Projectile.damage, 0f, Projectile.owner);
             *      }
             *  }
             * }*/

            /*int d = Dust.NewDust(Projectile.position + Projectile.velocity * Main.rand.NextFloat(100), Projectile.width, Projectile.height, 87, 0f, 0f, 0, default(Color), 1.5f);
             * Main.dust[d].noGravity = true;
             * Main.dust[d].velocity *= 4f;*/
        }