コード例 #1
0
        public override bool UseItem(Player player)
        {
            DBTPlayer dbtPlayer = player.GetModPlayer <DBTPlayer>();

            dbtPlayer.ModifyKi(-dbtPlayer.Ki);
            return(true);
        }
コード例 #2
0
ファイル: BlackDiamondShell.cs プロジェクト: kinggrinyov/DBT
        public bool OnPlayerPreHurt(DBTPlayer dbtPlayer, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
        {
            int i = Main.rand.Next(10, 100);

            dbtPlayer.ModifyKi(i);

            CombatText.NewText(new Rectangle((int)dbtPlayer.player.position.X, (int)dbtPlayer.player.position.Y, dbtPlayer.player.width, dbtPlayer.player.height), new Color(51, 204, 255), i, false, false);
            return(true);
        }
コード例 #3
0
        public override bool CanUseItem(Player player)
        {
            DBTPlayer dbtPlayer = player.GetModPlayer <DBTPlayer>();
            // TODO Add check for skill unlocked.

            bool hasKi = dbtPlayer.Ki >= Definition.Characteristics.ChargeCharacteristics.GetCastKiDrain(dbtPlayer);

            if (hasKi)
            {
                dbtPlayer.ModifyKi(-Definition.Characteristics.ChargeCharacteristics.GetCastKiDrain(dbtPlayer), Definition.Characteristics.ChargeCharacteristics.GetBaseKiRegenerationHaltedForDuration(dbtPlayer));
            }

            return(base.CanUseItem(player) && hasKi);
        }
コード例 #4
0
ファイル: SenzuBean.cs プロジェクト: kinggrinyov/DBT
        public override bool UseItem(Player player)
        {
            bool      baseResult = base.UseItem(player);
            DBTPlayer dbtPlayer  = player.GetModPlayer <DBTPlayer>();

            List <IAffectSenzuBeanCooldown> items = player.GetItemsByType <IAffectSenzuBeanCooldown>(armor: true, accessories: true);

            float cooldown = 18000;

            for (int i = 0; i < items.Count; i++)
            {
                items[i].AffectSenzuBeanCooldown(dbtPlayer, this, ref cooldown);
            }

            dbtPlayer.ModifyKi(dbtPlayer.MaxKi - dbtPlayer.Ki);
            return(baseResult);
        }
コード例 #5
0
        public override void Update(Player player, ref int buffIndex)
        {
            DBTPlayer dbtPlayer = player.GetModPlayer <DBTPlayer>();

            if (dbtPlayer == null)
            {
                return;
            }

            if (!dbtPlayer.IsTransformed(this) && dbtPlayer.player.HasBuff(Type))
            {
                player.ClearBuff(Type);
                return;
            }

            TransformationTimer++;
            bool isFormMastered = dbtPlayer.HasMastered(Definition);

            float kiDrain          = -(isFormMastered ? Definition.GetMasteredKiDrain(dbtPlayer) : Definition.GetUnmasteredKiDrain(dbtPlayer));
            float healthDrain      = -(isFormMastered ? Definition.GetMasteredHealthDrain(dbtPlayer) : Definition.GetUnmasteredHealthDrain(dbtPlayer));
            float overloadIncrease = (isFormMastered ? Definition.GetMasteredOverloadGrowthRate(dbtPlayer) : Definition.GetUnmasteredOverloadGrowthRate(dbtPlayer));

            if (kiDrain != 0f)
            {
                if (!isFormMastered)
                {
                    kiDrain *= KiDrainMultiplier;
                }

                kiDrain *= dbtPlayer.KiDrainMultiplier;
                dbtPlayer.ModifyKi(kiDrain);

                if (TransformationTimer % Definition.Drain.transformationStepDelay == 0 && KiDrainMultiplier < Definition.Drain.maxTransformationKiDrainMultiplier)
                {
                    KiDrainMultiplier += Definition.Drain.kiMultiplierPerStep;
                }
            }

            if (healthDrain != 0f)
            {
                if (!isFormMastered)
                {
                    healthDrain *= HealthDrainMultiplier;
                }

                healthDrain *= dbtPlayer.HealthDrainMultiplier;

                dbtPlayer.player.statLife     -= (int)healthDrain;
                dbtPlayer.player.lifeRegenTime = 0;

                if (TransformationTimer % Definition.Drain.transformationStepDelay == 0 && HealthDrainMultiplier < Definition.Drain.maxTransformationHealthDrainMultiplier)
                {
                    HealthDrainMultiplier += Definition.Drain.healthMultiplierPerStep;
                }
            }

            if (overloadIncrease != 0f)
            {
                overloadIncrease   *= dbtPlayer.OverloadIncreaseMultiplier;
                dbtPlayer.Overload += overloadIncrease;
            }

            float
                damageMultiplier       = Definition.GetDamageMultiplier(dbtPlayer),
                halvedDamageMultiplier = damageMultiplier / 2;

            player.allDamage            *= damageMultiplier;
            dbtPlayer.KiDamageMultiplier = damageMultiplier;

            player.statDefense += Definition.GetDefenseAdditive(dbtPlayer);

            float speedMultiplier = Definition.GetSpeedMultiplier(dbtPlayer);

            player.moveSpeed       *= speedMultiplier;
            player.maxRunSpeed     *= speedMultiplier;
            player.runAcceleration *= speedMultiplier;

            if (player.jumpSpeedBoost < 1f)
            {
                player.jumpSpeedBoost = 1f;
            }

            player.jumpSpeedBoost *= speedMultiplier;
        }
コード例 #6
0
        public static void Update(DBTPlayer dbtPlayer)
        {
            if (Main.netMode == NetmodeID.Server) // Servers can't fly.
            {
                return;
            }

            if (!dbtPlayer.Flying) // Imagine wanting to run code without flying.
            {
                return;
            }

            Player player = dbtPlayer.player;

            if (player.dead || player.mount.Type != -1 || player.ropeCount != 0 || (dbtPlayer.StopFlightOnNoKi && dbtPlayer.Ki <= FLIGHT_KI_DRAIN))
            {
                dbtPlayer.Flying = false;
                AddKatchinFeetBuff(dbtPlayer);
                dbtPlayer.player.fallStart = (int)(dbtPlayer.player.position.Y / 16f);

                return;
            }

            player.DryCollision(true, true);
            player.fullRotationOrigin = new Vector2(11, 22);

            Vector2 rotationDirection = Vector2.Zero;

            float
                boostSpeed = BURST_SPEED * (dbtPlayer.Charging ? 1 : 0),

                flightCostMultiplier = (dbtPlayer.FlightT3 ? 0.25f : dbtPlayer.FlightDampenedFall ? 0.5f : 1f),
                totalFlightUsage     = Math.Max(1f, FLIGHT_KI_DRAIN * dbtPlayer.FlightKiUsageModifier) * flightCostMultiplier,

                flightSpeedMultiplier = (1f + boostSpeed) * (dbtPlayer.FlightT3 ? 1.25f : dbtPlayer.FlightDampenedFall ? 1f : 0.75f),
                flightSpeed           = FLIGHT_SPEED * flightSpeedMultiplier,

                totalHorizontalFlightSpeed = flightSpeed + player.moveSpeed + dbtPlayer.FlightSpeedModifier,
                totalVerticalFlightSpeed   = flightSpeed + Player.jumpHeight / 5 + dbtPlayer.FlightSpeedModifier;

            dbtPlayer.ModifyKi(-totalFlightUsage * (1f + boostSpeed));

            if (dbtPlayer.UpHeld)
            {
                player.velocity.Y -= totalVerticalFlightSpeed / 3.8f; //3.8 original
                rotationDirection  = Vector2.UnitY;
            }
            else if (dbtPlayer.DownHeld)
            {
                player.maxFallSpeed = 20f;
                player.velocity.Y  += totalVerticalFlightSpeed / 3.8f; //3.6 original
                rotationDirection   = -Vector2.UnitY;
            }

            if (dbtPlayer.RightHeld)
            {
                player.velocity.X += totalHorizontalFlightSpeed;
                rotationDirection += Vector2.UnitX;
            }
            else if (dbtPlayer.LeftHeld)

            {
                player.velocity.X -= totalHorizontalFlightSpeed;
                rotationDirection -= Vector2.UnitX;
            }

            player.velocity.X = MathHelper.Lerp(player.velocity.X, 0, 0.1f);
            player.velocity.Y = MathHelper.Lerp(player.velocity.Y, 0, 0.1f);

            player.velocity -= player.gravity * Vector2.UnitY;

            if (player.velocity.X > 0)
            {
                player.legFrameCounter = -player.velocity.X;
            }
            else
            {
                player.legFrameCounter = player.velocity.X;
            }

            player.fullRotation = MathHelper.Lerp(player.fullRotation, GetPlayerFlightRotation(rotationDirection, player), 0.1f);
        }
コード例 #7
0
ファイル: FlightSystem.cs プロジェクト: Fructure/DBT
        public static void Update(Player player)
        {
            // this might seem weird but the server isn't allowed to control the flight system.
            if (Main.netMode == NetmodeID.Server)
            {
                return;
            }

            DBTPlayer modPlayer = player.GetModPlayer <DBTPlayer>();

            //check for ki or death lol
            if ((modPlayer.Ki <= 0 || player.dead || player.mount.Type != -1 || player.ropeCount != 0) && modPlayer.Flying)
            {
                modPlayer.Flying = false;
                AddKatchinFeetBuff(player);
            }

            if (modPlayer.Flying)
            {
                // cancel platform collision
                player.DryCollision(true, true);

                //prepare vals
                player.fullRotationOrigin = new Vector2(11, 22);
                Vector2 mRotationDir = Vector2.Zero;

                //Input checks
                float boostSpeed = (BURST_SPEED)*(modPlayer.IsCharging ? 1 : 0);

                // handle ki drain
                float totalFlightUsage = Math.Max(1f, FLIGHT_KI_DRAIN * modPlayer.FlightKiUsageModifier);
                float flightCostMult   = modPlayer.FlightT3 ? 0.25f : (modPlayer.FlightDampenedFall ? 0.5f : 1f);
                totalFlightUsage *= flightCostMult;
                modPlayer.ModifyKi(totalFlightUsage * (1f + boostSpeed) * -1);
                float flightSpeedMult = (1f + boostSpeed);
                flightSpeedMult *= modPlayer.FlightT3 ? 1.25f : (modPlayer.FlightDampenedFall ? 1f : 0.75f);
                float flightSpeed = FLIGHT_SPEED * flightSpeedMult;

                float totalHorizontalFlightSpeed = flightSpeed + (player.moveSpeed / 3) + modPlayer.FlightSpeedModifier;
                float totalVerticalFlightSpeed   = flightSpeed + (Player.jumpSpeed / 2) + modPlayer.FlightSpeedModifier;

                if (modPlayer.UpHeld)
                {
                    // for some reason flying up is way, way faster than flying down.
                    player.velocity.Y -= (totalVerticalFlightSpeed / 3.8f);
                    mRotationDir       = Vector2.UnitY;
                }
                else if (modPlayer.DownHeld)
                {
                    player.maxFallSpeed = 20f;
                    player.velocity.Y  += totalVerticalFlightSpeed / 3.6f;
                    mRotationDir        = -Vector2.UnitY;
                }

                if (modPlayer.RightHeld)
                {
                    player.velocity.X += totalHorizontalFlightSpeed;
                    mRotationDir      += Vector2.UnitX;
                }
                else if (modPlayer.LeftHeld)
                {
                    player.velocity.X -= totalHorizontalFlightSpeed;
                    mRotationDir      -= Vector2.UnitX;
                }

                //calculate velocity
                player.velocity.X = MathHelper.Lerp(player.velocity.X, 0, 0.1f);
                player.velocity.Y = MathHelper.Lerp(player.velocity.Y, 0, 0.1f);
                // keep the player suspended at worst.
                player.velocity = player.velocity - (player.gravity * Vector2.UnitY);

                // handles keeping legs from moving when the player is in flight/moving fast/channeling.
                if (player.velocity.X > 0)
                {
                    player.legFrameCounter = -player.velocity.X;
                }
                else
                {
                    player.legFrameCounter = player.velocity.X;
                }

                //calculate rotation
                float radRot = GetPlayerFlightRotation(mRotationDir, player);

                player.fullRotation = MathHelper.Lerp(player.fullRotation, radRot, 0.1f);
            }

            // altered to only fire once, the moment you exit flight, to avoid overburden of sync packets when moving normally.
            if (!modPlayer.Flying)
            {
                player.fullRotation = MathHelper.Lerp(player.fullRotation, 0, 0.1f);
            }
        }