Beispiel #1
0
        ////

        /// <summary>
        /// Handles aim state changes when a shot successfully hits any target.
        /// </summary>
        /// <param name="plr"></param>
        public void ApplySuccessfulHit(Player plr)
        {
            var config         = TMRConfig.Instance;
            int aimDuration    = config.Get <int>(nameof(TMRConfig.AimModeActivationTickDuration));
            int aimDurationAdd = config.Get <int>(nameof(TMRConfig.AimModeActivationTickDurationAddedBuffer));
            int max            = aimDuration + aimDurationAdd;

            // Switch to full aim mode
            if (this.IsQuickDrawActive)
            {
                this.QuickDrawDuration = 0;
                this.AimElapsed        = max;
            }
            // Otherwise, increase buildup to aim mode
            else
            {
                this.AimElapsed += config.Get <float>(nameof(TMRConfig.AimModeOnHitBuildupAmount));
                if (this.AimElapsed > max)
                {
                    this.AimElapsed = max;
                }

                if (TMRConfig.Instance.DebugModeInfo)
                {
                    DebugLibraries.Print("aim_hit", "aim%: "
                                         + (this.AimPercent * 100f).ToString("N0")
                                         + " (" + this.AimElapsed.ToString("N1") + "), "
                                         + max);
                }
            }
        }
        /// <summary></summary>
        /// <returns>`true` on mouse movement.</returns>
        private bool UpdateEquippedAimStateValueForMouseMovement()
        {
            var   config         = TMRConfig.Instance;
            var   mousePos       = new Vector2(Main.mouseX, Main.mouseY);
            float mouseThreshSqr = config.Get <float>(nameof(config.AimModeMouseMoveThreshold));

            mouseThreshSqr *= mouseThreshSqr;

            // Mouse is not moving?
            if ((this.LastAimMousePosition - mousePos).LengthSquared() <= mouseThreshSqr)
            {
                return(false);
            }

            float aimBuildupAmt = config.Get <float>(nameof(config.AimModeOnMouseMoveBuildupAmount));

            if (config.DebugModeInfo)
            {
                DebugLibraries.Print("aim_mouse", "aim%: "
                                     + (this.AimPercent * 100f).ToString("N0")
                                     + " (" + this.AimElapsed.ToString("N1") + "), "
                                     + aimBuildupAmt);
            }

            this.AimElapsed = Math.Max(this.AimElapsed + aimBuildupAmt, 0f);

            this.LastAimMousePosition = mousePos;

            return(true);
        }
        ////////////////

        public override void UpdateInventory(Player player)
        {
            if (!Main.gamePaused && !player.dead)
            {
                this.ElapsedTimeSinceLastShotAttempt++;
            }

            if (TMRConfig.Instance.DebugModeInfo)
            {
                DebugLibraries.Print("cylinder", this.CurrentCylinderSlot + " = " + string.Join(", ", this.Cylinder));
            }
        }
Beispiel #4
0
        public override void Update(NPC npc, ref int buffIndex)
        {
            var config = EnragedConfig.Instance;

            if (config.DebugModeInfo)
            {
                DebugLibraries.Print("BossEnrageDuration_" + npc.whoAmI, "" + npc.buffTime[buffIndex]);
            }

            /*Timers.RunNow( () => {
             *      int times = config.Get<int>( nameof(config.TimesToRunAIPerTickWhileEnraged) );
             *
             *      for( int i = 0; i < times; i++ ) {
             *              npc.AI();
             *      }
             * } );*/
        }
        ////////////////

        private void ReduceAnimaPerContext(float percent, string context)
        {
            var    config = NecrotisConfig.Instance;
            Player plr    = this.player;

            bool isTown     = plr.townNPCs > 1f;
            bool isUnsafe   = Main.bloodMoon || Main.eclipse;
            bool isElixired = player.HasBuff(ModContent.BuffType <RespiritedBuff>());

            if (percent > 0f)                   // is drain
            // Town
            {
                if (isTown && !isUnsafe)
                {
                    percent = 0f;
                }

                // Elixer
                if (isElixired)
                {
                    percent *= config.Get <float>(nameof(config.ElixirAnimaDrainMultiplier));
                }
            }

            this.SubtractAnimaPercent(percent, false, false);

            if (config.DebugModeInfo)
            {
                if (isTown)
                {
                    context += "_Town";
                    if (isUnsafe)
                    {
                        context += "Unsafe";
                    }
                }
                string amtStr = percent.ToString("F6");
                if (isElixired)
                {
                    amtStr += "e";
                }

                DebugLibraries.Print(context, amtStr);
            }
        }
Beispiel #6
0
        public float AddRageIf(string context, NPC npc, float addedPercent)
        {
            var config = EnragedConfig.Instance;

            var   rageScale = config.Get <Dictionary <NPCDefinition, ConfigFloat> >(nameof(EnragedConfig.RageRateScales));
            float scale     = rageScale.GetOrDefault(new NPCDefinition(npc.type))?.Value
                              ?? 1f;

            if (scale == 0f || addedPercent == 0f)
            {
                return(0f);
            }
            if (npc.HasBuff(ModContent.BuffType <EnragedBuff>()))
            {
                return(0f);
            }

            addedPercent *= scale;

            //

            this.RagePercent += addedPercent;

            if (this.RagePercent < 0)
            {
                this.RagePercent = 0;
            }
            else if (this.RagePercent >= 1f)
            {
                this.RagePercent = 1f;
                this.BeginEnragedState(npc);
            }

            //

            if (config.DebugModeInfo)
            {
                DebugLibraries.Print(
                    context + npc.whoAmI,
                    "Boss " + npc.FullName + " enraged from " + context + " by " + addedPercent + "; is now " + this.RagePercent
                    );
            }

            return(addedPercent);
        }
        private void UpdateEquippedAimStateValueForPlayerIdle()
        {
            var   config = TMRConfig.Instance;
            int   activationThreshold = config.Get <int>(nameof(config.AimModeActivationTickDuration)) + 2;              // Added buffer for slight aim tweaks
            float aimIdleBuildup      = config.Get <float>(nameof(config.AimModeOnIdleBuildupAmount));

            if (this.AimElapsed < activationThreshold)
            {
                if (config.DebugModeInfo)
                {
                    DebugLibraries.Print("aim_idle", "aim%: "
                                         + (this.AimPercent * 100f).ToString("N0")
                                         + " (" + this.AimElapsed.ToString("N1") + "), "
                                         + aimIdleBuildup);
                }

                this.AimElapsed += aimIdleBuildup;
            }
        }
        ////////////////

        /// <summary></summary>
        /// <returns>`true` on player movement.</returns>
        private bool UpdateEquippedAimStateValueForPlayerMovement(Player plr)
        {
            if (plr.velocity.LengthSquared() <= 1f)
            {
                return(false);
            }

            var   config         = TMRConfig.Instance;
            float aimMoveBuildup = config.Get <float>(nameof(config.AimModeOnPlayerMoveBuildupAmount));

            // Player is moving
            if (config.DebugModeInfo)
            {
                DebugLibraries.Print("aim_move", "aim%: "
                                     + (this.AimPercent * 100f).ToString("N0")
                                     + " (" + this.AimElapsed.ToString("N1") + "), "
                                     + aimMoveBuildup);
            }

            this.AimElapsed = Math.Max(this.AimElapsed + aimMoveBuildup, 0f);
            return(true);
        }
Beispiel #9
0
        /// <summary>
        /// Handles aim state changes when a shot hits no target.
        /// </summary>
        /// <param name="plr"></param>
        public void ApplyUnsuccessfulHit(Player plr)
        {
            if (this.IsModeActive)
            {
                return;
            }

            var   config         = TMRConfig.Instance;
            float aimMissBuildup = config.Get <float>(nameof(TMRConfig.AimModeOnMissBuildupAmount));

            this.AimElapsed += aimMissBuildup;
            if (this.AimElapsed < 0f)
            {
                this.AimElapsed = 0f;
            }

            if (config.DebugModeInfo)
            {
                DebugLibraries.Print("aim_miss", "aim%: "
                                     + (this.AimPercent * 100f).ToString("N0")
                                     + " (" + this.AimElapsed.ToString("N1") + "), "
                                     + aimMissBuildup);
            }
        }
        public void AnimateManaCrystalShardHint()
        {
            if (Timers.GetTimerTickDuration("ManaCrystalShardHint") > 0)
            {
                return;
            }

            float percent;

            if (this.MeasureClosestOnScreenManaCrystalShardTileDistance(out percent) == null)
            {
                return;
            }

            var config = FMCConfig.Instance;

            int beginTicks = config.Get <int>(nameof(FMCConfig.BinocularsHintBeginDurationTicks));

            Timers.SetTimer("ManaCrystalShardHint", beginTicks, false, () => {
                Item heldItem = Main.LocalPlayer.HeldItem;
                if (heldItem == null || heldItem.IsAir || heldItem.type != ItemID.Binoculars)
                {
                    return(0);
                }

                float?newTileProximityIf = this.MeasureClosestOnScreenManaCrystalShardTileDistance(out percent);
                if (!newTileProximityIf.HasValue)
                {
                    return(0);
                }

                float rateScaleOfSparks = config.Get <float>(nameof(FMCConfig.BinocularsHintIntensity));
                rateScaleOfSparks       = 1f - rateScaleOfSparks;
                float rateOfSparks      = newTileProximityIf.Value * rateScaleOfSparks;
                UnifiedRandom rand      = TmlLibraries.SafelyGetRand();

                int dustIdx = Dust.NewDust(
                    Position: Main.screenPosition,
                    Width: Main.screenWidth,
                    Height: Main.screenHeight,
                    Type: 59,
                    SpeedX: (4f * rand.NextFloat() * percent * percent) - 2f,
                    SpeedY: (4f * rand.NextFloat() * percent * percent) - 2f,
                    Alpha: 128 - (int)(percent * 128f),
                    newColor: new Color(255, 255, 255),
                    Scale: 1.25f + (2f * percent * percent)
                    );
                Dust dust      = Main.dust[dustIdx];
                dust.noGravity = true;
                dust.noLight   = true;

                if (config.DebugModeInfo)
                {
                    DebugLibraries.Print(
                        "FindableManaCrystals",
                        "rateOfSparks: " + rateScaleOfSparks.ToString("N2")
                        + ", proximity: " + newTileProximityIf.Value.ToString("N2")
                        + ", rate: " + rateOfSparks.ToString("N2")
                        );
                }

                return((int)Math.Max(5, rateOfSparks));
            });
        }