Exemple #1
0
        public virtual void addBuffToPlayer(Player player, int slot)
        {
            FishPlayer pl     = player.GetModPlayer <FishPlayer>();
            int        pbtype = mod.BuffType <PoweredBaitBuff>();

            for (int j = 0; j < 22; j++)
            {
                if (player.buffType[j] == pbtype)
                {
                    player.buffTime[j] = buffTime;
                    pl.baitTimer       = buffTime;
                    pl.addBaitBuffs(buffTime, slot, buffID);
                    pl.addBaitDebuffs(buffTime, slot, debuffID);
                    return;
                }
            }
            for (int i = 0; i < 22; i++)
            {
                if (player.buffType[i] <= 0)
                {
                    player.buffType[i] = pbtype;
                    player.buffTime[i] = buffTime;
                    pl.baitTimer       = buffTime;
                    pl.addBaitBuffs(buffTime, slot, buffID);
                    pl.addBaitDebuffs(buffTime, slot, debuffID);
                    return;
                }
            }
        }
Exemple #2
0
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            FishPlayer p     = player.GetModPlayer <FishPlayer>(mod);
            int        lures = noOfBobs + p.multilineFishing;

            Vector2 speedVector = new Vector2(speedX, speedY);
            float   trueSpeed   = speedVector.Length() * p.bobberShootSpeed;

            if (p.aimBobber && player.whoAmI == Main.myPlayer)
            {
                speedVector = Main.MouseWorld - position;
                speedVector.Normalize();
                speedX = speedVector.X;
                speedY = speedVector.Y;
            }
            else
            {
                speedVector.Normalize();
                speedX = speedVector.X;
                speedY = speedVector.Y;
            }
            speedX        *= trueSpeed;
            speedY        *= trueSpeed;
            speedVector.X *= trueSpeed;
            speedVector.Y *= trueSpeed;
            int trueDamage = 0;

            if (damage > 0)
            {
                trueDamage = (damage / lures < 1 ? 1 : damage / lures);
            }
            if (lures > 1)
            {
                if (p.aimBobber)
                {
                    for (int i = 0; i < lures - 1; i++)
                    {
                        Projectile.NewProjectile(position.X + Main.rand.Next(5), position.Y + Main.rand.Next(5), speedVector.X, speedVector.Y, type, trueDamage, knockBack, player.whoAmI);
                    }
                }
                else
                {
                    for (int i = 1; i < lures; i++)
                    {
                        Projectile.NewProjectile(position.X + Main.rand.Next(5), position.Y + Main.rand.Next(5), speedX + Main.rand.Next(lures) - lures / 2, speedY + Main.rand.Next(lures) - lures / 2, type, trueDamage, knockBack, player.whoAmI);
                    }
                }
                if (trueDamage * lures < damage)
                {
                    damage = damage - (trueDamage * (lures - 1));
                }
            }
            int baitTotal     = getNoOfBaits(p);
            int totalBuffs    = getNoOfBuffs(p.player);
            int usedBaitCount = p.getNumberOfBaitDebuffs() + p.getNumberOfBaitBuffs();
            int useableBaits  = p.getNumberOfUseableBaits();

            //if rod can use powered bait && less than ten seconds in bait timer && the total number of bait the rod can use is bigger than the current applied bait count
            if (baitTotal > 0 &&
                (p.baitTimer < 600 || (usedBaitCount != useableBaits && baitTotal != usedBaitCount)) &&
                totalBuffs < player.buffType.Length)
            {
                int slot = 0;
                for (int i = 54; i < 58; i++)
                {
                    BasePoweredBait b = player.inventory[i].modItem as BasePoweredBait;
                    if (b != null)
                    {
                        b.addBuffToPlayer(player, slot);
                        player.inventory[i].stack--;
                        slot++;
                        if (slot >= baitTotal)
                        {
                            for (; slot < p.baitBuff.Length; slot++)
                            {
                                p.addBaitBuffs(0, slot, -1);
                                p.addBaitDebuffs(0, slot, -1);
                            }
                            if (Main.netMode != 0)
                            {
                                p.updateBaits(player.whoAmI);
                            }

                            return(base.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack));
                        }
                    }
                }
                if (slot > 0)
                {
                    for (; slot < p.baitBuff.Length; slot++)
                    {
                        p.addBaitBuffs(0, slot, -1);
                        p.addBaitDebuffs(0, slot, -1);
                    }
                    if (Main.netMode != 0)
                    {
                        p.updateBaits(player.whoAmI);
                    }
                }
            }
            return(base.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack));
        }