예제 #1
0
        public override bool CanUseItem(Item item, Player player)
        {
            FargoPlayer modPlayer = player.GetModPlayer <FargoPlayer>();

            if (modPlayer.IronGuard)
            {
                //Main.NewText($"iron {modPlayer.ironShieldCD}, {modPlayer.ironShieldTimer}");
                modPlayer.IronGuard          = false;
                modPlayer.wasHoldingShield   = false;
                player.shield_parry_cooldown = 0; //prevent that annoying tick sound
                //check is necessary so if player does a real parry then switches to right click weapon, using it won't reset cooldowns
                if (modPlayer.ironShieldCD == 40 && modPlayer.ironShieldTimer == 20)
                {
                    modPlayer.ironShieldCD    = 0;
                    modPlayer.ironShieldTimer = 0;
                }
            }

            //dont use hotkeys in stasis
            if (player.HasBuff(ModContent.BuffType <GoldenStasis>()))
            {
                if (item.type == ItemID.RodofDiscord)
                {
                    player.ClearBuff(ModContent.BuffType <Buffs.Souls.GoldenStasis>());
                }
                else
                {
                    return(false);
                }
            }

            if (FargoSoulsWorld.MasochistMode)
            {
                if (item.type == ItemID.RodofDiscord &&
                    (modPlayer.LihzahrdCurse ||
                     (Framing.GetTileSafely(Main.MouseWorld).wall == WallID.LihzahrdBrickUnsafe &&
                      !player.buffImmune[ModContent.BuffType <Buffs.Masomode.LihzahrdCurse>()])))
                {
                    return(false);
                }

                if (modPlayer.LihzahrdCurse &&
                    (item.type == ItemID.WireKite || item.type == ItemID.WireCutter))
                {
                    return(false);
                }
            }

            if (item.magic && player.GetModPlayer <FargoPlayer>().ReverseManaFlow)
            {
                int damage = (int)(item.mana / (1f - player.endurance) + player.statDefense);
                player.Hurt(PlayerDeathReason.ByCustomReason(player.name + " was destroyed by their own magic."), damage, 0);
                player.immune     = false;
                player.immuneTime = 0;
            }

            if (modPlayer.BuilderMode && (item.createTile != -1 || item.createWall != -1) && item.type != ItemID.PlatinumCoin && item.type != ItemID.GoldCoin)
            {
                item.useTime      = 1;
                item.useAnimation = 1;
            }

            if (modPlayer.AdditionalAttacks && modPlayer.AdditionalAttacksTimer <= 0 && //non weapons and weapons with no ammo begone
                item.damage > 0 && player.HasAmmo(item, true) && !(item.mana > 0 && player.statMana < item.mana) &&
                item.type != ItemID.ExplosiveBunny && item.type != ItemID.Cannonball &&
                item.useTime > 0 && item.createTile == -1 && item.createWall == -1 && item.ammo == AmmoID.None && item.hammer == 0 && item.pick == 0 && item.axe == 0)
            {
                modPlayer.AdditionalAttacksTimer = 60;

                Vector2 position = player.Center;
                Vector2 velocity = Vector2.Normalize(Main.MouseWorld - position);

                if (modPlayer.BorealEnchant && player.GetToggleValue("Boreal") && player.whoAmI == Main.myPlayer)
                {
                    Vector2 vel = Vector2.Normalize(Main.MouseWorld - player.Center) * 17f;
                    int     p   = Projectile.NewProjectile(player.Center, vel, ProjectileID.SnowBallFriendly, (int)(item.damage * .5f), 1, Main.myPlayer);

                    int numSnowballs = 3;

                    if (modPlayer.WoodForce || modPlayer.WizardEnchant)
                    {
                        numSnowballs = 5;
                    }

                    if (p != 1000)
                    {
                        FargoGlobalProjectile.SplitProj(Main.projectile[p], numSnowballs, MathHelper.Pi / 10, 1);
                    }
                }

                if (modPlayer.CelestialRune && player.GetToggleValue("MasoCelest"))
                {
                    if (item.melee && item.pick == 0 && item.axe == 0 && item.hammer == 0) //fireball
                    {
                        Main.PlaySound(SoundID.Item34, position);
                        for (int i = 0; i < 3; i++)
                        {
                            Projectile.NewProjectile(position, velocity.RotatedByRandom(Math.PI / 6) * Main.rand.NextFloat(6f, 10f),
                                                     ModContent.ProjectileType <CelestialRuneFireball>(), (int)(50f * player.meleeDamage), 9f, player.whoAmI);
                        }
                    }
                    if (item.ranged) //lightning
                    {
                        float   ai1 = Main.rand.Next(100);
                        Vector2 vel = Vector2.Normalize(velocity.RotatedByRandom(Math.PI / 4)) * 7f;
                        Projectile.NewProjectile(position, vel, ModContent.ProjectileType <CelestialRuneLightningArc>(),
                                                 (int)(50f * player.rangedDamage), 1f, player.whoAmI, velocity.ToRotation(), ai1);
                    }
                    if (item.magic) //ice mist
                    {
                        Projectile.NewProjectile(position, velocity * 4.25f, ModContent.ProjectileType <CelestialRuneIceMist>(), (int)(50f * player.magicDamage), 4f, player.whoAmI);
                    }
                    if (item.thrown) //ancient vision
                    {
                        Projectile.NewProjectile(position, velocity * 16f, ModContent.ProjectileType <CelestialRuneAncientVision>(), (int)(50f * player.magicDamage), 0, player.whoAmI);
                    }
                }

                if (modPlayer.PumpkingsCape && player.GetToggleValue("MasoPump"))
                {
                    if (item.melee && item.pick == 0 && item.axe == 0 && item.hammer == 0) //flaming jack
                    {
                        float distance = 2000f;
                        int   target   = -1;
                        for (int i = 0; i < 200; i++)
                        {
                            if (Main.npc[i].active && Main.npc[i].CanBeChasedBy())
                            {
                                float newDist = Main.npc[i].Distance(player.Center);
                                if (newDist < distance)
                                {
                                    distance = newDist;
                                    target   = i;
                                }
                            }
                        }
                        if (target != -1)
                        {
                            Projectile.NewProjectile(position, velocity * 8f, ProjectileID.FlamingJack, (int)(75f * player.meleeDamage), 7.5f, player.whoAmI, target, 0f);
                        }
                    }
                    if (item.ranged) //jack o lantern
                    {
                        Projectile.NewProjectile(position, velocity * 11f, ProjectileID.JackOLantern, (int)(95f * player.rangedDamage), 8f, player.whoAmI);
                    }
                    if (item.magic) //bat scepter
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            Vector2 newVel = velocity * 10f;
                            newVel.X += Main.rand.Next(-35, 36) * 0.02f;
                            newVel.Y += Main.rand.Next(-35, 36) * 0.02f;
                            Projectile.NewProjectile(position, newVel, ProjectileID.Bat, (int)(45f * player.magicDamage), 3f, player.whoAmI);
                        }
                    }
                }
            }

            //critter attack timer
            if (modPlayer.WoodEnchant && player.altFunctionUse == ItemAlternativeFunctionID.ActivatedAndUsed && item.makeNPC > 0)
            {
                if (modPlayer.CritterAttackTimer == 0)
                {
                    Vector2 vel = Vector2.Normalize(Main.MouseWorld - player.Center);
                    float   damageMultiplier = player.minionDamage;

                    int type           = -1;
                    int damage         = 0;
                    int attackCooldown = 0;

                    switch (item.type)
                    {
                    //case ItemID.Bunny:
                    //    type = ProjectileID.ExplosiveBunny;
                    //    damage = 10;
                    //    attackCooldown = 10;
                    //    break;

                    case ItemID.Bird:
                        type           = ModContent.ProjectileType <BirdProj>();
                        damage         = 15;
                        attackCooldown = 15;
                        break;

                    case ItemID.BlueJay:
                        type           = ModContent.ProjectileType <BlueJayProj>();
                        damage         = 10;
                        attackCooldown = 10;
                        break;

                    case ItemID.Cardinal:
                        type           = ModContent.ProjectileType <CardinalProj>();
                        damage         = 20;
                        attackCooldown = 20;
                        break;
                    }

                    if (type != -1)
                    {
                        Projectile.NewProjectile(player.Center, vel * 2f, type, damage, 2, player.whoAmI);
                        modPlayer.CritterAttackTimer = attackCooldown;
                    }
                }



                return(false);
            }

            if (item.type == ItemID.RodofDiscord)
            {
                if (FargoSoulsWorld.MasochistMode && EModeGlobalNPC.AnyBossAlive())
                {
                    player.AddBuff(ModContent.BuffType <Buffs.Masomode.ChaosLife>(), 30);
                    modPlayer.MaxLifeReduction += 100;

                    /*player.statLife -= player.statLifeMax2 / 5;
                     * PlayerDeathReason damageSource = PlayerDeathReason.ByOther(13);
                     * if (Main.rand.Next(2) == 0)
                     *  damageSource = PlayerDeathReason.ByOther(player.Male ? 14 : 15);
                     * if (player.statLife <= 0 && !player.chaosState) //since chaos state will check and kill anyway, avoid doublekill
                     *  player.KillMe(damageSource, 1, 0);
                     * player.lifeRegenCount = 0;
                     * player.lifeRegenTime = 0;*/
                }
            }

            return(true);
        }