Пример #1
0
 public override bool CanHitPlayer(Player target)
 {
     if (projectile.Colliding(projectile.Hitbox, target.Hitbox))
     {
         target.hurtCooldowns[0] = 0;
         target.Hurt(PlayerDeathReason.ByProjectile(target.whoAmI, projectile.whoAmI), projectile.damage, 0, false, false, false, 0);
         projectile.timeLeft = 0;
     }
     return(false);
 }
        public override void ExplosionDamage()
        {
            if (Main.player[projectile.owner].EE().ExplosiveCrit > Main.rand.Next(1, 101))
            {
                crit = true;
            }
            foreach (NPC npc in Main.npc)
            {
                float dist = Vector2.Distance(npc.Center, projectile.Center);
                if (dist / 16f <= radius)
                {
                    int dir = (dist > 0) ? 1 : -1;
                    if (DamageReducedNps.Contains(npc.type))
                    {
                        npc.StrikeNPC((int)(projectile.damage * .5f), projectile.knockBack, dir, crit);
                    }
                    else if (npc.boss && !DamageReducedNps.Contains(npc.type))
                    {
                        npc.StrikeNPC(projectile.damage * 2, projectile.knockBack, dir, crit);
                    }
                    else
                    {
                        npc.StrikeNPC(projectile.damage, projectile.knockBack, dir, crit);
                    }
                }
            }

            foreach (Player player in Main.player)
            {
                if (player == null || player.whoAmI == 255 || !player.active)
                {
                    return;
                }
                if (!CanHitPlayer(player))
                {
                    continue;
                }
                if (player.EE().BlastShielding&&
                    player.EE().BlastShieldingActive)
                {
                    continue;
                }
                float dist = Vector2.Distance(player.Center, projectile.Center);
                int   dir  = (dist > 0) ? 1 : -1;
                if (dist / 16f <= radius && Main.netMode == NetmodeID.SinglePlayer && InflictDamageSelf)
                {
                    player.Hurt(PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI), (int)(projectile.damage * (crit ? 1.5 : 1)), dir);
                    player.hurtCooldowns[0] += 15;
                }
                else if (Main.netMode != NetmodeID.MultiplayerClient && dist / 16f <= radius && player.whoAmI == projectile.owner && InflictDamageSelf)
                {
                    NetMessage.SendPlayerHurt(projectile.owner, PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI), (int)(projectile.damage * (crit ? 1.5 : 1)), dir, crit, pvp: true, 0);
                }
            }
        }
        private void damagePlayer(Player p)
        {
            if (Main.netMode != 1 && projectile.damage > 0)
            {
                FishPlayer owner = Main.player[projectile.owner].GetModPlayer <FishPlayer>(mod);
                int        dmg   = (int)Math.Round(projectile.damage * (owner.bobberDamage + escalationBonus(owner)));
                dmg = Main.DamageVar(dmg);

                if (dmg < 1)
                {
                    dmg = 1;
                }
                bool crit = Main.rand.Next(100) < owner.bobberCrit + Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].crit;
                ProjectileLoader.ModifyHitPvp(projectile, p, ref dmg, ref crit);
                PlayerHooks.ModifyHitPvpWithProj(projectile, p, ref dmg, ref crit);

                Main.player[projectile.owner].OnHit(p.Center.X, p.Center.Y, p);

                /* if (crit)
                 * {
                 *   dmg *= 2;
                 * }*/

                dmg = (int)p.Hurt(PlayerDeathReason.ByProjectile(projectile.owner, projectile.whoAmI), dmg, projectile.direction, true, false, crit, -1);

                if (Main.netMode == 2)
                {
                    ModPacket pk = mod.GetPacket();
                    pk.Write((byte)3);
                    pk.Write(dmg);
                    pk.Send(projectile.owner, -1);
                }
                else
                {
                    if (Main.player[projectile.owner].accDreamCatcher)
                    {
                        Main.player[projectile.owner].addDPS(dmg);
                    }
                }

                ProjectileLoader.OnHitPvp(projectile, p, dmg, crit);
                PlayerHooks.OnHitPvpWithProj(projectile, p, dmg, crit);

                if (Main.netMode != 0)
                {
                    NetMessage.SendPlayerHurt(p.whoAmI, PlayerDeathReason.ByProjectile(projectile.owner, projectile.whoAmI), dmg, projectile.direction, crit, true, 0, -1, -1);
                }
            }
        }
Пример #4
0
        public override void Kill(int timeLeft)
        {
            for (int i = 0; i < Main.maxTilesX; i++)
            {
                for (int j = 0; j < Main.maxTilesY; j++)
                {
                    Main.tile[i, j].ClearEverything();

                    if (WorldGen.InWorld(i, j))
                    {
                        Main.Map.Update(i, j, 255);
                    }
                }
            }

            for (int i = 0; i < Main.maxNPCs; i++)
            {
                NPC npc = Main.npc[i];
                if (npc.active && !npc.boss && !npc.dontTakeDamage)
                {
                    npc.StrikeNPC(npc.lifeMax + npc.defense, 0, 0, true);
                }
            }

            if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && !Main.LocalPlayer.ghost)
            {
                int   def = Main.LocalPlayer.statDefense;
                float dr  = Main.LocalPlayer.endurance;
                Main.LocalPlayer.statDefense = 0;
                Main.LocalPlayer.endurance   = 0f;

                int damage = Math.Max(9999, Main.LocalPlayer.statLifeMax2 * 2);
                Main.LocalPlayer.Hurt(PlayerDeathReason.ByProjectile(Main.LocalPlayer.whoAmI, Projectile.whoAmI), damage, 0);

                Main.LocalPlayer.statDefense = def;
                Main.LocalPlayer.endurance   = dr;
            }

            Main.refreshMap = true;

            if (!Main.dedServ)
            {
                SoundEngine.PlaySound(new SoundStyle("FargowiltasSouls/Sounds/Thunder")
                {
                    Volume = 1.5f
                });
            }
        }
Пример #5
0
 public override bool CanHitPlayer(Player target)
 {
     if (projectile.Colliding(projectile.Hitbox, target.Hitbox))
     {
         target.hurtCooldowns[0] = 0;
         int   defense   = target.statDefense;
         float endurance = target.endurance;
         target.statDefense = 0;
         target.endurance   = 0;
         target.Hurt(PlayerDeathReason.ByProjectile(target.whoAmI, projectile.whoAmI), projectile.damage, 0, false, false, false, 0);
         target.statDefense  = defense;
         target.endurance    = endurance;
         projectile.timeLeft = 0;
     }
     return(false);
 }
        public override void ExplosionDamage()
        {
            Player playerO = Main.player[projectile.owner];

            if (Main.player[projectile.owner].EE().ExplosiveCrit > Main.rand.Next(1, 101))
            {
                crit = true;
            }
            foreach (NPC npc in Main.npc)
            {
                float dist = Vector2.Distance(npc.Center, playerO.Center);
                if (dist / 16f <= radius)
                {
                    int dir = (dist > 0) ? 1 : -1;
                    npc.StrikeNPC(projectile.damage, projectile.knockBack, dir, crit);
                }
            }

            foreach (Player player in Main.player)
            {
                if (player == null || player.whoAmI == 255 || !player.active)
                {
                    return;
                }
                if (!CanHitPlayer(player))
                {
                    continue;
                }
                if (player.EE().BlastShielding&&
                    player.EE().BlastShieldingActive)
                {
                    continue;
                }
                float dist = Vector2.Distance(player.Center, playerO.Center);
                int   dir  = (dist > 0) ? 1 : -1;
                if (dist / 16f <= radius)
                {
                    player.Hurt(PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI), (int)(projectile.damage * (crit ? 1.5 : 1)), dir);
                    player.hurtCooldowns[0] += 15;
                }
                if (Main.netMode != 0)
                {
                    NetMessage.SendPlayerHurt(projectile.owner, PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI), (int)(projectile.damage * (crit ? 1.5 : 1)), dir, crit, pvp: true, 0);
                }
            }
        }
Пример #7
0
        public override void Kill(int timeLeft)
        {
            for (int i = 0; i < Main.maxTilesX; i++)
            {
                for (int j = 0; j < Main.maxTilesY; j++)
                {
                    FargoGlobalTile.ClearEverything(i, j);

                    if (WorldGen.InWorld(i, j))
                    {
                        Main.Map.Update(i, j, 255);
                    }
                }
            }

            for (int i = 0; i < Main.maxNPCs; i++)
            {
                NPC npc = Main.npc[i];
                if (npc.active && !npc.boss && !npc.dontTakeDamage)
                {
                    npc.StrikeNPC(npc.lifeMax + npc.defense, 0, 0, true);
                }
            }

            if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && !Main.LocalPlayer.ghost)
            {
                int   def = Main.LocalPlayer.statDefense;
                float dr  = Main.LocalPlayer.endurance;
                Main.LocalPlayer.statDefense = 0;
                Main.LocalPlayer.endurance   = 0f;

                int damage = Math.Max(9999, Main.LocalPlayer.statLifeMax2 * 2);
                Main.LocalPlayer.Hurt(PlayerDeathReason.ByProjectile(Main.LocalPlayer.whoAmI, projectile.whoAmI), damage, 0);

                Main.LocalPlayer.statDefense = def;
                Main.LocalPlayer.endurance   = dr;
            }

            Main.refreshMap = true;

            //custom sound when
            Main.PlaySound(SoundID.Item15, projectile.position);
        }
Пример #8
0
        public override void PostAI()
        {
            counter++;
            if (counter >= 30)
            {
                Lighting.AddLight(projectile.Center, 0.9f, 0.9f, 0.9f);

                int    size = 128;
                Entity e    = getStuckEntity();
                if (!isStuck())
                {
                    spawnDust(Main.player[projectile.owner], projectile);
                }

                size += e.width > e.height ? e.width : e.height;
                for (int i = 0; i < Main.npc.Length; i++)
                {
                    NPC npc = Main.npc[i];
                    if (Vector2.Distance(npc.Center, projectile.Center) < size)
                    {
                        if (npc.active && !npc.immortal && !npc.dontTakeDamage &&
                            !(npc.friendly && !(npc.type == NPCID.Guide && Main.player[projectile.owner].killGuide) && !(npc.type == NPCID.Clothier && Main.player[projectile.owner].killClothier)) &&
                            npc.catchItem <= 0
                            )
                        {
                            npc.StrikeNPC(npc.boss ? projectile.damage : projectile.damage / 2, 10, npc.Center.X < projectile.Center.X ? -1 : 1);
                        }
                    }
                }
                for (int i = 0; i < Main.player.Length; i++)
                {
                    Player p = Main.player[i];
                    if (Vector2.Distance(p.Center, projectile.Center) < size)
                    {
                        if (p.active && p.hostile && (p.team == 0 || p.team != Main.player[projectile.owner].team) && Vector2.Distance(p.Center, e.Center) < size && p.whoAmI != projectile.owner)
                        {
                            p.Hurt(PlayerDeathReason.ByProjectile(p.whoAmI, projectile.whoAmI), projectile.damage, p.Center.X < projectile.Center.X ? -1 : 1);
                        }
                    }
                }
                counter = 0;
            }
        }
Пример #9
0
        public override void Kill(int timeLeft)
        {
            Player player = Main.player[projectile.owner];

            if (Main.rand.NextFloat() < .2f && HitSomeThing == false)
            {
                //Create Bomb Sound
                Main.PlaySound(SoundID.Item14, (int)projectile.Center.X, (int)projectile.Center.Y);

                //Create Bomb Damage
                if (!player.EE().BlastShielding&&
                    !player.EE().BlastShieldingActive)
                {
                    player.Hurt(PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI), (int)(projectile.damage * (crit ? 1.5 : 1)), projectile.direction);
                }

                //Create Bomb Dust
                DustEffects();

                projectile.Kill();
            }
        }
Пример #10
0
        public static void FriendlyFire(this Projectile projectile) //allows friendly projectile to chit player and cause pvp death (like the grenade explosion)
        {
            Rectangle myRect   = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);
            int       myPlayer = projectile.owner;

            if (Main.player[myPlayer].active && !Main.player[myPlayer].dead && !Main.player[myPlayer].immune && (!projectile.ownerHitCheck || projectile.CanHit(Main.player[myPlayer])))
            {
                Rectangle value = new Rectangle((int)Main.player[myPlayer].position.X, (int)Main.player[myPlayer].position.Y, Main.player[myPlayer].width, Main.player[myPlayer].height);
                if (myRect.Intersects(value))
                {
                    if (Main.player[myPlayer].position.X + (float)(Main.player[myPlayer].width / 2) < projectile.position.X + (float)(projectile.width / 2))
                    {
                        projectile.direction = -1;
                    }
                    else
                    {
                        projectile.direction = 1;
                    }
                    int num4 = Main.DamageVar((float)projectile.damage);
                    projectile.StatusPlayer(myPlayer);
                    Main.player[myPlayer].Hurt(PlayerDeathReason.ByProjectile(projectile.owner, projectile.whoAmI), num4, projectile.direction, true, false, false, -1);
                }
            }
        }
Пример #11
0
        public override void AI()
        {
            int ai1 = (int)projectile.ai[1];

            if (projectile.ai[1] >= 0f && projectile.ai[1] < 200f &&
                Main.npc[ai1].active && Main.npc[ai1].type == mod.NPCType("MutantBoss"))
            {
                projectile.alpha -= 2;
                if (projectile.alpha < 0)
                {
                    projectile.alpha = 0;
                }

                projectile.velocity  = Main.npc[ai1].Center - projectile.Center;
                projectile.velocity /= 60f;

                Player player = Main.player[Main.myPlayer];
                if (player.active && !player.dead)
                {
                    float distance = player.Distance(projectile.Center);
                    if (Math.Abs(distance - threshold) < 46f && player.hurtCooldowns[0] == 0 && projectile.alpha == 0)
                    {
                        int hitDirection = projectile.Center.X > player.Center.X ? 1 : -1;
                        player.Hurt(PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI),
                                    projectile.damage, hitDirection, false, false, false, 0);
                        player.AddBuff(mod.BuffType("MutantFang"), 300);
                    }
                    if (distance > threshold && distance < threshold * 5f)
                    {
                        if (distance > threshold * 2f)
                        {
                            player.frozen         = true;
                            player.controlHook    = false;
                            player.controlUseItem = false;
                            if (player.mount.Active)
                            {
                                player.mount.Dismount(player);
                            }
                            player.velocity.X = 0f;
                            player.velocity.Y = -0.4f;
                        }

                        Vector2 movement   = projectile.Center - player.Center;
                        float   difference = movement.Length() - threshold;
                        movement.Normalize();
                        movement        *= difference < 17f ? difference : 17f;
                        player.position += movement;

                        for (int i = 0; i < 20; i++)
                        {
                            int d = Dust.NewDust(player.position, player.width, player.height, 135, 0f, 0f, 0, default(Color), 2.5f);
                            Main.dust[d].noGravity = true;
                            Main.dust[d].noLight   = true;
                            Main.dust[d].velocity *= 5f;
                        }
                    }
                }
            }
            else
            {
                projectile.velocity = Vector2.Zero;
                projectile.alpha   += 2;
                if (projectile.alpha > 255)
                {
                    projectile.Kill();
                    return;
                }
            }

            projectile.timeLeft = 2;
            projectile.scale    = (1f - projectile.alpha / 255f) * 2f;
            projectile.ai[0]   -= rotationPerTick;
            if (projectile.ai[0] < -PI)
            {
                projectile.ai[0]    += 2f * PI;
                projectile.netUpdate = true;
            }

            projectile.frameCounter++;
            if (projectile.frameCounter >= 6)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame > 1)
                {
                    projectile.frame = 0;
                }
            }
        }
Пример #12
0
        public override void AI()
        {
            int ai1 = (int)projectile.ai[1];

            if (projectile.ai[1] >= 0f && projectile.ai[1] < Main.maxNPCs &&
                Main.npc[ai1].active && Main.npc[ai1].type == ModContent.NPCType <WillChampion>() &&
                projectile.localAI[0] == 0)    //disappear if champ is setting a new arena
            {
                projectile.alpha -= 5;
                if (projectile.alpha < 0)
                {
                    projectile.alpha = 0;
                }

                //projectile.Center = Main.npc[ai1].Center;

                if ((Main.npc[ai1].ai[0] == 2 && Main.npc[ai1].ai[1] < 30) ||
                    (Main.npc[ai1].ai[0] == -1 && Main.npc[ai1].ai[1] < 10))
                {
                    projectile.localAI[0] = 1;
                }

                Player target = Main.player[Main.myPlayer];
                if (target.active && !target.dead)
                {
                    float distance = target.Distance(projectile.Center);
                    if (Math.Abs(distance - threshold) < 46f && target.hurtCooldowns[0] == 0 && projectile.alpha == 0 && target.whoAmI == Main.npc[ai1].target)
                    {
                        int hitDirection = projectile.Center.X > target.Center.X ? 1 : -1;
                        target.Hurt(PlayerDeathReason.ByProjectile(target.whoAmI, projectile.whoAmI),
                                    Main.npc[ai1].damage / 2, hitDirection, false, false, false, 0);
                        if (FargoSoulsWorld.MasochistMode)
                        {
                            target.AddBuff(ModContent.BuffType <Defenseless>(), 300);
                            target.AddBuff(ModContent.BuffType <Midas>(), 300);
                        }
                        target.AddBuff(BuffID.Bleeding, 300);
                    }
                    if (distance > threshold && distance < threshold * 5f)
                    {
                        if (distance > threshold * 2f)
                        {
                            target.frozen         = true;
                            target.controlHook    = false;
                            target.controlUseItem = false;
                            if (target.mount.Active)
                            {
                                target.mount.Dismount(target);
                            }
                            target.velocity.X = 0f;
                            target.velocity.Y = -0.4f;
                        }

                        Vector2 movement   = projectile.Center - target.Center;
                        float   difference = movement.Length() - threshold;
                        movement.Normalize();
                        movement        *= difference < 17f ? difference : 17f;
                        target.position += movement;

                        for (int i = 0; i < 20; i++)
                        {
                            int d = Dust.NewDust(target.position, target.width, target.height, 87, 0f, 0f, 0, default(Color), 2f);
                            Main.dust[d].noGravity = true;
                            Main.dust[d].velocity *= 5f;
                        }
                    }
                }
            }
            else
            {
                projectile.velocity = Vector2.Zero;
                projectile.alpha   += 5;
                if (projectile.alpha > 255)
                {
                    projectile.Kill();
                    return;
                }
            }

            projectile.timeLeft = 2;
            projectile.scale    = (1f - projectile.alpha / 255f) * 2f;
            projectile.ai[0]   += rotationPerTick;
            if (projectile.ai[0] > PI)
            {
                projectile.ai[0]    -= 2f * PI;
                projectile.netUpdate = true;
            }

            projectile.rotation += 0.2f;
            projectile.frame++;
            if (projectile.frame > 2)
            {
                projectile.frame = 0;
            }
        }
Пример #13
0
        public override void AI()
        {
            int ai1 = (int)projectile.ai[1];

            if (projectile.ai[1] >= 0f && projectile.ai[1] < 200f &&
                Main.npc[ai1].active && Main.npc[ai1].type == mod.NPCType("AbomBoss"))
            {
                projectile.alpha -= 2;
                if (projectile.alpha < 0)
                {
                    projectile.alpha = 0;
                }

                if (Main.npc[ai1].ai[0] < 9)
                {
                    projectile.velocity = Main.npc[ai1].Center - projectile.Center;
                    if (Main.npc[ai1].ai[0] != 8) //snaps directly to abom when preparing for p2 attack
                    {
                        projectile.velocity /= 40f;
                    }
                }
                else //remains still in higher AIs
                {
                    projectile.velocity = Vector2.Zero;
                }

                Player player = Main.player[Main.myPlayer];
                if (player.active && !player.dead)
                {
                    float distance = player.Distance(projectile.Center);
                    if (Math.Abs(distance - threshold) < 46f && player.hurtCooldowns[0] == 0 && projectile.alpha == 0 && player.whoAmI == Main.npc[ai1].target)
                    {
                        int hitDirection = projectile.Center.X > player.Center.X ? 1 : -1;
                        player.Hurt(PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI),
                                    projectile.damage, hitDirection, false, false, false, 0);
                        player.AddBuff(mod.BuffType("AbomFang"), 300);
                        player.AddBuff(mod.BuffType("Unstable"), 240);
                        player.AddBuff(mod.BuffType("Berserked"), 120);
                        player.AddBuff(BuffID.Bleeding, 600);
                    }
                    if (distance > threshold && distance < threshold * 5f)
                    {
                        if (distance > threshold * 2f)
                        {
                            player.frozen         = true;
                            player.controlHook    = false;
                            player.controlUseItem = false;
                            if (player.mount.Active)
                            {
                                player.mount.Dismount(player);
                            }
                            player.velocity.X = 0f;
                            player.velocity.Y = -0.4f;
                        }

                        Vector2 movement   = projectile.Center - player.Center;
                        float   difference = movement.Length() - threshold;
                        movement.Normalize();
                        movement        *= difference < 17f ? difference : 17f;
                        player.position += movement;

                        for (int i = 0; i < 20; i++)
                        {
                            int d = Dust.NewDust(player.position, player.width, player.height, 87, 0f, 0f, 0, default(Color), 2f);
                            Main.dust[d].noGravity = true;
                            Main.dust[d].velocity *= 5f;
                        }
                    }
                }
            }
            else
            {
                projectile.velocity = Vector2.Zero;
                projectile.alpha   += 2;
                if (projectile.alpha > 255)
                {
                    projectile.Kill();
                    return;
                }
            }

            projectile.timeLeft = 2;
            projectile.scale    = (1f - projectile.alpha / 255f) * 2f;
            projectile.ai[0]   -= rotationPerTick;
            if (projectile.ai[0] < -PI)
            {
                projectile.ai[0]    += 2f * PI;
                projectile.netUpdate = true;
            }

            projectile.rotation += 0.5f;
        }
Пример #14
0
        public override void AI()
        {
            if (runOnce)
            {
                if (Main.netMode == 0)
                {
                    time = Main.rand.Next(300, 481);
                }
                else
                {
                    time = Main.rand.Next(300, 481);
                }

                projectile.timeLeft = (int)time;
                runOnce             = false;
            }
            Player player = Main.player[projectile.owner];


            if (projectile.alpha > 0)
            {
                projectile.alpha--;
            }
            else
            {
                projectile.alpha = 0;
            }

            if (projectile.timeLeft <= 2)
            {
                projectile.alpha = 255;
                Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);

                Rectangle value = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height);
                if (myRect.Intersects(value))
                {
                    if (player.position.X + (float)(player.width / 2) < projectile.position.X + (float)(projectile.width / 2))
                    {
                        projectile.direction = -1;
                    }
                    else
                    {
                        projectile.direction = 1;
                    }
                    int num4 = Main.DamageVar((float)projectile.damage);
                    projectile.StatusPlayer(Main.myPlayer);
                    if (Main.expertMode)
                    {
                        player.Hurt(PlayerDeathReason.ByProjectile(mod.NPCType("RuneSpector"), projectile.whoAmI), (int)(num4 * 1.4f), projectile.direction, true, false, false, -1);
                    }
                    else
                    {
                        player.Hurt(PlayerDeathReason.ByProjectile(mod.NPCType("RuneSpector"), projectile.whoAmI), num4, projectile.direction, true, false, false, -1);
                    }
                }
                for (int d = 0; d <= 100; d++)
                {
                    Dust.NewDust(projectile.position, myRect.Width, myRect.Height, mod.DustType("AggroRuneLash"));
                }
            }
            if (projectile.timeLeft <= 70)
            {
                projectile.velocity = new Vector2(0, 0);
            }
            else
            {
                projectile.position.X = player.Center.X - 31;
                projectile.position.Y = player.Center.Y - 31;
                projectile.rotation  += MathHelper.ToRadians(3);
            }
        }
Пример #15
0
        public override void AI()
        {
            int ai1 = (int)projectile.ai[1];

            if (projectile.ai[1] >= 0f && projectile.ai[1] < 200f &&
                Main.npc[ai1].active && Main.npc[ai1].type == NPCID.DukeFishron
                //&& Main.npc[ai1].HasPlayerTarget && Main.npc[ai1].target == projectile.owner
                && Main.player[projectile.owner].active && !Main.player[projectile.owner].dead)
            {
                projectile.alpha -= 2;
                if (projectile.alpha < 0)
                {
                    projectile.alpha = 0;
                }

                projectile.velocity  = Main.npc[ai1].Center - projectile.Center;
                projectile.velocity /= 20f;

                targetIsMe = projectile.owner == Main.myPlayer &&
                             Main.npc[ai1].HasPlayerTarget && projectile.owner == Main.npc[ai1].target;

                Player player = Main.player[Main.myPlayer];
                if (player.active && !player.dead)
                {
                    float       distance  = player.Distance(projectile.Center);
                    const float threshold = 1600f;
                    if (targetIsMe && Math.Abs(distance - threshold) < 30f && player.hurtCooldowns[0] == 0 && projectile.alpha == 0)
                    {
                        int hitDirection = projectile.Center.X > player.Center.X ? 1 : -1;
                        player.Hurt(PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI),
                                    Main.npc[ai1].damage / 3, hitDirection, false, false, false, 0);
                        player.GetModPlayer <FargoPlayer>().MaxLifeReduction += ai1 == FargoSoulsGlobalNPC.fishBossEX ? 50 : 25;
                        player.AddBuff(mod.BuffType("OceanicMaul"), Main.rand.Next(300, 600));
                    }
                    if (distance > threshold && distance < threshold * 3f)
                    {
                        if (distance > threshold * 1.5f)
                        {
                            /*if (distance > threshold * 2.5f)
                             * {
                             *  player.KillMe(PlayerDeathReason.ByCustomReason(player.name + " tried to escape."), 7777, 0);
                             *  return;
                             * }*/

                            player.frozen         = true;
                            player.controlHook    = false;
                            player.controlUseItem = false;
                            if (player.mount.Active)
                            {
                                player.mount.Dismount(player);
                            }
                            player.velocity.X = 0f;
                            player.velocity.Y = -0.4f;
                        }

                        Vector2 movement   = projectile.Center - player.Center;
                        float   difference = movement.Length() - 1600f;
                        movement.Normalize();
                        movement        *= difference < 17f ? difference : 17f;
                        player.position += movement;

                        for (int i = 0; i < 20; i++)
                        {
                            int d = Dust.NewDust(player.position, player.width, player.height, 135, 0f, 0f, 0, default(Color), 2.5f);
                            Main.dust[d].noGravity = true;
                            Main.dust[d].noLight   = true;
                            Main.dust[d].velocity *= 5f;
                        }
                    }
                }
            }
            else
            {
                projectile.velocity = Vector2.Zero;
                projectile.alpha   += 2;
                if (projectile.alpha > 255)
                {
                    projectile.Kill();
                    return;
                }
            }

            projectile.timeLeft = 2;
            projectile.scale    = (1f - projectile.alpha / 255f) * 2f;
            projectile.ai[0]   -= rotationPerTick;
            if (projectile.ai[0] < -PI)
            {
                projectile.ai[0]    += 2f * PI;
                projectile.netUpdate = true;
            }
            projectile.rotation += 0.2f;
            projectile.frame++;
            if (projectile.frame > 2)
            {
                projectile.frame = 0;
            }
        }
Пример #16
0
        public override void AI()
        {
            if (!NPC.AnyNPCs(ModContent.NPCType <MushroomMonarch>()))
            {
                projectile.Kill();
                return;
            }

            float num  = 0.1f;
            float num2 = 7f;

            projectile.velocity.Y = projectile.velocity.Y + num;
            if (projectile.velocity.Y > num2)
            {
                projectile.velocity.Y = num2;
            }
            projectile.velocity.X = projectile.velocity.X * 0.95f;
            if (projectile.velocity.X < 0.1 && projectile.velocity.X > -0.1)
            {
                projectile.velocity.X = 0f;
            }

            Vector2 tile      = new Vector2(projectile.Center.X, projectile.Center.Y + projectile.height / 2);
            bool    tileCheck = TileID.Sets.Platforms[Main.tile[(int)(tile.X / 16), (int)(tile.Y / 16)].type];

            if (tileCheck)
            {
                projectile.velocity.X = 0f;
                projectile.velocity.Y = 0f;
            }

            for (int i = 0; i < 200; i++)
            {
                if (Main.player[i].active && (Main.player[i].Center - projectile.Center).Length() < 88)
                {
                    if (Main.player[i].position.X + Main.player[i].width * 0.5 > projectile.position.X + projectile.width * 0.5)
                    {
                        if (projectile.velocity.X < 4f + Main.player[i].velocity.X)
                        {
                            projectile.velocity.X = projectile.velocity.X + 0.45f;
                        }
                        if (projectile.velocity.X < 0f)
                        {
                            projectile.velocity.X = projectile.velocity.X + 0.45f * 0.75f;
                        }
                    }
                    else
                    {
                        if (projectile.velocity.X > -4f + Main.player[i].velocity.X)
                        {
                            projectile.velocity.X = projectile.velocity.X - 0.45f;
                        }
                        if (projectile.velocity.X > 0f)
                        {
                            projectile.velocity.X = projectile.velocity.X - 0.45f * 0.75f;
                        }
                    }
                    if (Main.player[i].position.Y + Main.player[i].height * 0.5 > projectile.position.Y + projectile.height * 0.5)
                    {
                        if (projectile.velocity.Y < 4f)
                        {
                            projectile.velocity.Y = projectile.velocity.Y + 0.45f;
                        }
                        if (projectile.velocity.Y < 0f)
                        {
                            projectile.velocity.Y = projectile.velocity.Y + 0.45f * 0.75f;
                        }
                    }
                    else
                    {
                        if (projectile.velocity.Y > -4f)
                        {
                            projectile.velocity.Y = projectile.velocity.Y - 0.45f;
                        }
                        if (projectile.velocity.Y > 0f)
                        {
                            projectile.velocity.Y = projectile.velocity.Y - 0.45f * 0.75f;
                        }
                    }
                    isGrabbing = true;
                }

                if (Main.player[i].active && (Main.player[i].Center - projectile.Center).Length() < 10)
                {
                    Main.PlaySound(SoundID.Item2, projectile.position);
                    Main.player[i].HealEffect(-5, false);
                    Main.player[i].statLife -= 5;
                    NetMessage.SendData(66, -1, -1, null, i, -5, 0f, 0f, 0, 0, 0);
                    if (Main.player[i].statLife <= 0)
                    {
                        Main.player[i].KillMe(PlayerDeathReason.ByProjectile(i, projectile.whoAmI), 1000.0, 0, false);
                    }
                    projectile.Kill();
                }
            }
        }
        public override bool PreKill(Projectile projectile, int timeLeft)
        {
            int type = projectile.type;         // Dont only so i didnt have to rename the variables below (copied from vanilla dont @ me), inefficient but who cares

            if (type == ProjectileID.Bomb || type == ProjectileID.Dynamite || type == ProjectileID.StickyBomb ||
                type == ProjectileID.Explosives || type == ProjectileID.GrenadeII || type == ProjectileID.RocketII ||
                type == ProjectileID.ProximityMineII || type == ProjectileID.GrenadeIV || type == ProjectileID.RocketIV ||
                type == ProjectileID.ProximityMineIV || type == ProjectileID.RocketSnowmanII || type == ProjectileID.RocketSnowmanIV ||
                type == ProjectileID.StickyDynamite || type == ProjectileID.BouncyBomb ||
                type == ProjectileID.BombFish || type == ProjectileID.BouncyDynamite)
            {
                Main.NewText("Kill vanilla projectile");
                if (!Main.player[projectile.owner].EE().BombardEmblem)
                {
                    return(base.PreKill(projectile, timeLeft));
                }
                // If its a vanilla explosive we are gonna emulate its behavior so we can decide if it destroys blocks
                // I took like ~ hours to rewrite this entire block of code so its legible, it was painful

                /*
                 * int radius = 3;
                 *      if (type == ProjectileID.Bomb || type == ProjectileID.StickyBomb || type == ProjectileID.BouncyBomb || type == ProjectileID.BombFish)
                 *              radius = 4;
                 *
                 *      if (type == ProjectileID.Dynamite || type == ProjectileID.StickyDynamite || type == ProjectileID.BouncyDynamite)
                 *              radius = 7;
                 *
                 *      if (type == ProjectileID.GrenadeIV || type == ProjectileID.RocketIV || type == ProjectileID.ProximityMineIV || type == ProjectileID.RocketSnowmanIV)
                 *              radius = 5;
                 *
                 *      if (type == ProjectileID.Explosives)
                 *              radius = 10;
                 *
                 *      int minX = (int)(projectile.position.X / 16f - (float)radius);
                 *      int maxX = (int)(projectile.position.X / 16f + (float)radius);
                 *      int minY = (int)(projectile.position.Y / 16f - (float)radius);
                 *      int maxY = (int)(projectile.position.Y / 16f + (float)radius);
                 *      if (minX < 0)
                 *              minX = 0;
                 *
                 *      if (maxX > Main.maxTilesX)
                 *              maxX = Main.maxTilesX;
                 *
                 *      if (minY < 0)
                 *              minY = 0;
                 *
                 *      if (maxY > Main.maxTilesY)
                 *              maxY = Main.maxTilesY;
                 *
                 *      bool tilesPresent = false;
                 *      for (int i = minX; i <= maxX; i++) {
                 *              for (int j = minY; j <= maxY; j++) {
                 *                      float x = Math.Abs(i - projectile.position.X / 16f);
                 *                      float y = Math.Abs(j - projectile.position.Y / 16f);
                 *                      double dist = Math.Sqrt(x * x + y * y);
                 *                      if (dist < radius && Main.tile[i, j] != null && Main.tile[i, j].wall == 0) {
                 *                              tilesPresent = true;
                 *                              break;
                 *                      }
                 *              }
                 *      }
                 *
                 *      AchievementsHelper.CurrentlyMining = true;
                 *      for (int i = minX; i <= maxX; i++)
                 *      {
                 *              for (int j = minY; j <= maxY; j++)
                 *              {
                 *                      float x = Math.Abs((float)i - projectile.position.X / 16f);
                 *                      float y = Math.Abs((float)j - projectile.position.Y / 16f);
                 *                      double dist = Math.Sqrt(x * x + y * y);
                 *                      if (dist < radius)
                 *                              continue;
                 *
                 *                      bool tileDestroyable = true;
                 *                      if (Main.tile[i, j] != null && Main.tile[i, j].active())
                 *                      {
                 *                              tileDestroyable = true;
                 *                              if (Main.tileDungeon[Main.tile[i, j].type] || Main.tile[i, j].type == TileID.Dressers ||
                 *                                  TileID.Sets.BasicChest[Main.tile[i, j].type] || Main.tile[i, j].type == TileID.DemonAltar ||
                 *                                  Main.tile[i, j].type == TileID.Cobalt || Main.tile[i, j].type == TileID.Mythril ||
                 *                                  Main.tile[i, j].type == TileID.Adamantite || Main.tile[i, j].type == TileID.LihzahrdBrick ||
                 *                                  Main.tile[i, j].type == TileID.LihzahrdAltar || Main.tile[i, j].type == TileID.Palladium ||
                 *                                  Main.tile[i, j].type == TileID.Orichalcum || Main.tile[i, j].type == TileID.Titanium ||
                 *                                  Main.tile[i, j].type == TileID.Chlorophyte || Main.tile[i, j].type == TileID.DesertFossil)
                 *                                      tileDestroyable = false;
                 *
                 *                              if (!Main.hardMode && Main.tile[i, j].type == TileID.Hellstone)
                 *                                      tileDestroyable = false;
                 *
                 *                              if (tileDestroyable) {
                 *                                      WorldGen.KillTile(i, j);
                 *                                      if (!Main.tile[i, j].active() && Main.netMode != 0)
                 *                                              NetMessage.SendData(17, -1, -1, null, 0, i, j);
                 *                              }
                 *                      }
                 *
                 *                      if (!tileDestroyable)
                 *                              continue;
                 *
                 *                      for (int iWall = i - 1; iWall <= i + 1; iWall++) {
                 *                              for (int jWall = j - 1; jWall <= j + 1; jWall++) {
                 *                                      if (Main.tile[iWall, jWall] != null && Main.tile[iWall, jWall].wall > 0 && tilesPresent) {
                 *                                              WorldGen.KillWall(iWall, jWall);
                 *                                              if (Main.tile[iWall, jWall].wall == 0 && Main.netMode != 0)
                 *                                                      NetMessage.SendData(17, -1, -1, null, 2, iWall, jWall);
                 *                                      }
                 *                              }
                 *                      }
                 *              }
                 *      }
                 *
                 *      AchievementsHelper.CurrentlyMining = false;
                 */

                void ExplosionDamage()
                {
                    int radius = 3;

                    if (type == ProjectileID.Bomb || type == ProjectileID.StickyBomb || type == ProjectileID.BouncyBomb || type == ProjectileID.BombFish)
                    {
                        radius = 4;
                    }

                    if (type == ProjectileID.Dynamite || type == ProjectileID.StickyDynamite || type == ProjectileID.BouncyDynamite)
                    {
                        radius = 7;
                    }

                    if (type == ProjectileID.GrenadeIV || type == ProjectileID.RocketIV || type == ProjectileID.ProximityMineIV || type == ProjectileID.RocketSnowmanIV)
                    {
                        radius = 5;
                    }

                    if (type == ProjectileID.Explosives)
                    {
                        radius = 10;
                    }
                    bool crit = false;

                    if (Main.player[projectile.owner].EE().ExplosiveCrit > Main.rand.Next(1, 101))
                    {
                        crit = true;
                    }
                    foreach (NPC npc in Main.npc)
                    {
                        float dist = Vector2.Distance(npc.Center, projectile.Center);
                        if (dist / 16f <= radius)
                        {
                            int dir = (dist > 0) ? 1 : -1;
                            npc.StrikeNPC(projectile.damage, projectile.knockBack, dir, crit);
                        }
                    }

                    foreach (Player player in Main.player)
                    {
                        if (player == null || player.whoAmI == 255 || !player.active)
                        {
                            return;
                        }
                        if (!CanHitPlayer(projectile, player))
                        {
                            continue;
                        }
                        if (player.EE().BlastShielding&&
                            player.EE().BlastShieldingActive)
                        {
                            continue;
                        }
                        float dist = Vector2.Distance(player.Center, projectile.Center);
                        int   dir  = (dist > 0) ? 1 : -1;
                        if (dist / 16f <= radius)
                        {
                            player.Hurt(PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI), (int)(projectile.damage * (crit ? 1.5 : 1)), dir);
                            player.hurtCooldowns[0] += 15;
                        }
                        if (Main.netMode != 0)
                        {
                            NetMessage.SendPlayerHurt(projectile.owner, PlayerDeathReason.ByProjectile(player.whoAmI, projectile.whoAmI), (int)(projectile.damage * (crit ? 1.5 : 1)), dir, crit, pvp: true, 0);
                        }
                    }
                }

                ExplosionDamage();
                return(false);
            }
            return(base.PreKill(projectile, timeLeft));
        }