////

        private void UpdateDebugInfo()
        {
            var config = PDYBConfig.Instance;

            if (!config.DebugModeInfo)
            {
                return;
            }

            var logic = PirateLogic.Instance;

            DebugHelpers.Print("pirate_negotiator_info",
                               "Patience: " + logic.Patience
                               + ", base demand: " + logic.PirateDemand
                               + ", +demand%: " + logic.PirateDemandVariancePercent
                               + ", computed demand: " + logic.ComputedDemand
                               + ", TicksWhileNegotiatorAway: " + logic.TicksWhileNegotiatorAway
                               + ", TicksUntilNextArrival: " + logic.TicksUntilNextArrival
                               );
            if (logic.IsRaiding)
            {
                DebugHelpers.Print("pirate_raid_info",
                                   "Elapsed ticks: " + logic.RaidElapsedTicks
                                   + ", percent done: " + ((float)logic.RaidElapsedTicks / (float)config.RaidDurationTicks).ToString()
                                   );
                DebugHelpers.Print("pirate_raid_deaths",
                                   string.Join(", ", logic.KillsNearTownNPC.Select(kv => kv.Key + ": " + kv.Value))
                                   );
            }
        }
Пример #2
0
        internal void Update_Internal()
        {
            // Cleanup unclaimed cutscenes
            foreach (int plrWho in this._CutscenePerPlayer.Keys.ToArray())
            {
                if (Main.netMode != NetmodeID.Server && CutsceneLibConfig.Instance.DebugModeInfo)
                {
                    Cutscene cutscene = this._CutscenePerPlayer[plrWho];
                    DebugHelpers.Print(
                        "cutscene_" + plrWho,
                        cutscene.UniqueId.ToString() + ", " + cutscene?.CurrentScene.UniqueId.ToString()
                        );
                }

                if (Main.player[plrWho]?.active != true)
                {
                    this.EndCutscene(this._CutscenePerPlayer[plrWho].UniqueId, plrWho, false);
                }
            }

            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                Cutscene cutscene = this.GetCurrentCutscene_Player(Main.LocalPlayer);
                cutscene?.UpdateCutscene_Internal();
            }
            else
            {
                this.UpdateActivations_Host_Internal();

                foreach (Cutscene cutscene in this._CutscenePerPlayer.Values.ToArray())
                {
                    cutscene.UpdateCutscene_Internal();
                }
            }
        }
Пример #3
0
        public Color GetTintColor()
        {
            var   mymod     = TheLunaticMod.Instance;
            Color color     = Color.Black;
            float tintScale = MathHelper.Clamp(this.TintScale, 0f, 1f);
            float daySpike  = (float)Math.Abs(WorldStateHelpers.GetDayOrNightPercentDone() - 0.5d);

            if (Main.dayTime)
            {
                tintScale *= 1f - daySpike;
            }
            else
            {
                tintScale *= (daySpike * 0.6f) + 0.2f;
            }

            color.R = (byte)(255f * tintScale);
            color.G = (byte)(128f * tintScale);
            color.A = (byte)(255f * tintScale);

            if (mymod.Config.DebugModeInfo)
            {
                DebugHelpers.Print("Sky", color.ToString(), 20);
            }
            return(color);
        }
Пример #4
0
        protected bool CastRareNpcDowse(Player player, Vector2 aiming_at, int tile_range)
        {
            var  mymod              = (DowsingMod)this.mod;
            var  modplayer          = player.GetModPlayer <DowsingPlayer>();
            bool dowsed             = false;
            var  npc_poses          = this.GetNpcPositions();
            NPC  npc                = null;
            var  rare_npc_type_list = WitchingTargetData.GetCurrentRareNpcTypes();

            if (rare_npc_type_list.Count == 0)
            {
                return(false);
            }
            var rare_npc_type_set = new HashSet <int>(rare_npc_type_list);
            int traveled          = 0;

            this.CurrentBeamTravelDistance = 0;

            this.CastDowseBeamWithinCone(player, aiming_at, new Utils.PerLinePoint(delegate(int tile_x, int tile_y) {
                if (!TileWorldHelpers.IsWithinMap(tile_x, tile_y) || traveled >= tile_range)
                {
                    return(false);
                }

                if (npc_poses.ContainsKey(tile_x) && npc_poses[tile_x].ContainsKey(tile_y))
                {
                    npc = Main.npc[npc_poses[tile_x][tile_y]];
                    if (rare_npc_type_set.Contains(npc.type))
                    {
                        dowsed = true;
                    }
                }

                if (dowsed)
                {
                    this.RenderRodHitFX(player, tile_x, tile_y);
                }
                else
                {
                    traveled++;
                    if (TileHelpers.IsSolid(Framing.GetTileSafely(tile_x, tile_y), false, false))
                    {
                        traveled++;
                    }
                }
                this.CurrentBeamTravelDistance = traveled;

                if ((mymod.DEBUGFLAGS & 1) != 0)
                {
                    DebugHelpers.Print("current rare npcs", (this.III++) + " " + string.Join(",", rare_npc_type_set.ToArray()), 20);
                    //var dust = Dust.NewDustPerfect( new Vector2( tile_x * 16, tile_y * 16 ), 259, Vector2.Zero, 0, Color.Red, 0.75f );
                    //dust.noGravity = true;
                }
                return(!dowsed);
            }));

            return(dowsed);
        }
Пример #5
0
        public override void PreUpdate()
        {
            if (this.player.dead)
            {
                return;
            }

            var   mymod       = (EncumbranceMod)this.mod;
            float encumbrance = this.GaugeEncumbrance();

            if (mymod.Config.DebugInfoMode)
            {
                DebugHelpers.Print("Encumbrance", "Capacity: " + this.GetCurrentCapacity() + ", Encumbrance: " + encumbrance, 20);
            }

            if (encumbrance > 0f)
            {
                this.player.AddBuff(ModContent.BuffType <EncumberedDebuff>(), 3);
            }

            if (this.ItemDropCooldown > 0)
            {
                this.ItemDropCooldown--;
            }
            if (this.ItemUseCooldown > 0)
            {
                this.ItemUseCooldown--;
            }

            switch (this.player.mount.Type)
            {
            case MountID.MineCart:
            case MountID.MineCartWood:
            case MountID.MineCartMech:
                break;

            default:
                if (this.player.mount.Active)
                {
                    if (!this.IsMounted)
                    {
                        this.IsMounted = true;
                        this.RunMountEffect();
                    }
                }
                else
                {
                    this.IsMounted = false;
                }
                break;
            }

            if (this.QueuedDropAmount != 0)
            {
                this.DropCarriedItems(this.QueuedDropAmount);
                this.QueuedDropAmount = 0;
            }
        }
Пример #6
0
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            var myworld = ModContent.GetInstance <AmbushesWorld>();

            myworld.AmbushMngr.EditSpawnData(player, ref spawnRate, ref maxSpawns);

            if (AmbushesMod.Config.DebugModeInfoSpawns)
            {
                DebugHelpers.Print(
                    "SpawnsRates_" + player.whoAmI + " (" + player.name + ")",
                    "Rate: " + spawnRate + ", max: " + maxSpawns,
                    20);
            }
        }
Пример #7
0
        ////////////////

        public override void EditSpawnPool(IDictionary <int, float> pool, NPCSpawnInfo spawnInfo)
        {
            var myworld = ModContent.GetInstance <AmbushesWorld>();

            myworld.AmbushMngr.EditSpawnPool(pool, spawnInfo);

            if (AmbushesMod.Config.DebugModeInfoSpawns)
            {
                DebugHelpers.Print(
                    "SpawnsInfo_" + spawnInfo.player.whoAmI + " (" + spawnInfo.player.name + ")",
                    string.Join(", ", pool.Select(kv => kv.Key + ": " + kv.Value.ToString("N3"))),
                    20);
            }
        }
Пример #8
0
        internal void InternalUpdateNPCForAmbush(NPC npc)
        {
            if (!this.ClaimedNpcWhos.Contains(npc.whoAmI) && this.AttemptClaimNPC(npc))
            {
                this.OnClaimNPC(npc);
            }
            if (this.ClaimedNpcWhos.Contains(npc.whoAmI))
            {
                this.UpdateNPCForAmbush(npc);
            }

            if (AmbushesMod.Config.DebugModeInfoSpawns)
            {
                DebugHelpers.Print(this.GetType() + "_claimed_npcs", this.ClaimedNpcWhos.Count + "", 20);
            }
        }
Пример #9
0
        public void RenderRodHitFX(Player player, int tile_x, int tile_y)
        {
            var mymod     = (DowsingMod)this.mod;
            var pos       = new Vector2(tile_x * 16, tile_y * 16);
            int dust_type = 259;

            for (int i = 0; i < 20; i++)
            {
                int dust_idx = Dust.NewDust(pos, 16, 16, dust_type, 0f, 0f, 0, Color.YellowGreen, 1f);
                Main.dust[dust_idx].noGravity = true;
            }

            if ((mymod.DEBUGFLAGS & 1) != 0)
            {
                DebugHelpers.Print("cast hit", "at: " + tile_x + ", " + tile_y, 20);
            }
        }
Пример #10
0
        ////////////////

        private void PrintStaminaDrainers(SpriteBatch sb, StaminaPlayer myplayer)
        {
            var dict = myplayer.Logic.CurrentDrainTypes;
            int i    = 0;

            foreach (var kv in dict.ToList())
            {
                if (kv.Value == 0f)
                {
                    continue;
                }

                //string msg = kv.Key.ToString() + ":  " + kv.Value;
                //sb.DrawString( Main.fontMouseText, msg, new Vector2( 8, (Main.screenHeight - 32) - (i * 24) ), Color.White );
                DebugHelpers.Print(kv.Key.ToString(), "" + kv.Value, 30);

                dict[kv.Key] = 0f;
                i++;
            }
        }
Пример #11
0
        ////////////////

        public void RenderRodCastFX(Player player)
        {
            var     mymod     = (DowsingMod)this.mod;
            Vector2 pos       = PlayerItemHelpers.TipOfHeldItem(player);
            int     particles = Math.Max(2, ((mymod.Config.Data.MaxDowsingRangeInTiles / 3) - this.CurrentBeamTravelDistance) / 2);
            int     dust_type = 264;

            for (int i = 0; i < particles; i++)
            {
                var dust = Dust.NewDustDirect(pos, 1, 1, dust_type, 0f, 0f, 0, Color.YellowGreen, 0.8f);
                dust.noGravity = true;
                dust.noLight   = true;
                dust.fadeIn    = 0.8f;
            }

            if ((mymod.DEBUGFLAGS & 1) != 0)
            {
                DebugHelpers.Print("cast from", "particles: " + particles + ", dist: " + this.CurrentBeamTravelDistance, 20);
            }
        }
Пример #12
0
        ////////////////

        public void Update()
        {
            if (DynamicInvasionsMod.Config.DebugModeInfo)
            {
                DebugHelpers.Print("DynamicInvasionInfo", "IsInvading: " + this.Data.IsInvading +
                                   ", : enroute: " + this.Data.InvasionEnrouteDuration +
                                   ", size: " + this.Data.InvasionSize +
                                   ", max: " + this.Data.InvasionSizeStart,
                                   20
                                   );
            }

            if (this.IsInvasionHappening())
            {
                Main.invasionDelay = 2;                 // Lightweight invasion

                if (this.Data.InvasionEnrouteDuration > 0)
                {
                    this.Data.InvasionEnrouteDuration--;
                    if (this.Data.InvasionEnrouteWarningDuration == 0)
                    {
                        this.Data.InvasionEnrouteWarningDuration = 12 * 60;
                        this.InvasionWarning("A dimensional breach is growing...");
                    }
                    else
                    {
                        this.Data.InvasionEnrouteWarningDuration--;
                    }
                }

                if (this.Data.InvasionEnrouteDuration == 1)
                {
                    this.Data.InvasionEnrouteDuration = 0;
                    this.InvasionWarning("A dimensional breach has arrived!");
                }
            }
            else
            {
                Main.invasionDelay = 0;
            }
        }
Пример #13
0
        public void RunTargetUpdate(DowsingMod mymod, Player player)
        {
            this.RunVirtualTargetUpdate(mymod, player);

            if (!this.HasNpcTarget())
            {
                this.ClearTargetNpc();
            }

            if ((mymod.DEBUGFLAGS & 1) != 0)
            {
                if (this.TargetNpcWho != -1)
                {
                    DebugHelpers.Print("targetting", "fakeouts: " + this.VirtualTargetFakeouts + ", npc: " + Main.npc[this.TargetNpcWho].TypeName + " (who:" + this.TargetNpcWho + ")", 20);
                }
                else
                {
                    DebugHelpers.Print("targetting", "fakeouts: " + this.VirtualTargetFakeouts, 20);
                }
            }
        }
Пример #14
0
        public int TestVirtualTargetMovement(DowsingMod mymod, Player player, out Vector2 newpos)
        {
            int max_range = mymod.Config.Data.MaxWitchingRangeInTiles * 16;
            int min_range = mymod.Config.Data.VirtualTargetApproachTriggerInTiles * 16;

            newpos = this.VirtualTargetPosition + (this.VirtualTargetHeading * 2);

            int dist   = (int)Vector2.Distance(newpos, player.Center);
            int tile_x = (int)newpos.X / 16;
            int tile_y = (int)newpos.Y / 16;

            if ((mymod.DEBUGFLAGS & 1) != 0)
            {
                DebugHelpers.Print("dist", min_range + "(" + (dist <= min_range) + ") <= " + dist + " >= " + max_range + "(" + (dist >= max_range) + ")", 20);
            }

            if (dist >= max_range)                  // Target out-of-range
            {
                return(-1);
            }
            if (dist <= min_range)                  // Target reached
            {
                return(1);
            }
            if (TileHelpers.IsSolid(Framing.GetTileSafely(tile_x, tile_y)))                   // Target collides with solid tile?
            {
                return(2);
            }
            if (!TileWorldHelpers.IsWithinMap(tile_x, tile_y))                   // Target outside map?
            {
                return(3);
            }
            if (!TileFinderHelpers.HasNearbySolid(tile_x, tile_y, 10))                    // Not near solids?
            {
                return(4);
            }
            return(0);
        }
        internal void Update()
        {
            var mymod = ResetModeMod.Instance;

            if (mymod.Config.DebugModeRealTimeInfo)
            {
                string worldId  = WorldHelpers.GetUniqueIdForCurrentWorld(true);
                var    myplayer = (ResetModePlayer)TmlHelpers.SafelyGetModPlayer(Main.LocalPlayer, mymod, "ResetModePlayer");

                DebugHelpers.Print("ResetModeSession",
                                   "Is running? " + this.Data.IsRunning
                                   + ", Exiting? " + this.IsExiting
                                   + ", Needs world? " + this.IsSessionNeedingWorld()
                                   + ", World id: " + worldId
                                   + ", Been played? " + this.HasWorldEverBeenPlayed(worldId), 20);
                DebugHelpers.Print("ResetModePlayer",
                                   "IsPromptingForResetOnLocal? " + myplayer.Logic.IsPromptingForResetOnLocal
                                   + ", IsSynced? " + myplayer.IsSynced
                                   + ", HasModSettings? " + myplayer.HasModSettings
                                   + ", HasSessionData? " + myplayer.HasSessionData, 20);
            }

            if (this.Data.IsRunning && !this.IsExiting)
            {
                if (Main.netMode == 0)
                {
                    this.UpdateSingle();
                }
                else if (Main.netMode == 1)
                {
                    this.UpdateClient();
                }
                else
                {
                    this.UpdateServer();
                }
            }
        }
Пример #16
0
        ////////////////

        public float ComputeFortifyScale(Player player)
        {
            var   mymod    = InjuryMod.Instance;
            float amt      = 1f;
            float add      = 0f;
            var   myplayer = player.GetModPlayer <InjuryPlayer>();

            if (player.FindBuffIndex(ModContent.BuffType <FortifiedBuff>()) != -1)
            {
                add += mymod.Config.FortitudePotionHarmAddedBufferMultiplier - 1f;
            }
            if (myplayer.LifeVestPresence > 0)
            {
                add += mymod.Config.LifeVestHarmAddedBufferMultiplier - 1f;
            }

            if (mymod.IsDebugInfoMode())
            {
                DebugHelpers.Print("fortify scale ", "" + (amt + add), 30);
            }

            return(amt + add);
        }
Пример #17
0
        ////////////////

        public void RenderPlayerChargeFX(Player player, int intensity)
        {
            if (this.FxTimer == 0)
            {
                this.FxTimer = (int)Math.Max(24d * (1f - (double)intensity / 30d), 0);

                var   mymod     = (DowsingMod)this.mod;
                var   pos       = new Vector2(player.position.X, player.position.Y - 12);
                float scale     = 0.7f + (0.01f * intensity);
                int   dust_type = 110;

                int puff_who = Dust.NewDust(player.position, player.width, player.height, dust_type, player.velocity.X, player.velocity.Y, 0, Color.YellowGreen, scale);
                Main.dust[puff_who].noGravity = true;

                if ((mymod.Config.Data.DEBUGFLAGS & 1) != 0)
                {
                    DebugHelpers.Print("player charge", "FxTimer " + this.FxTimer + ", scale " + scale + ", intensity " + intensity, 20);
                }
            }
            else
            {
                this.FxTimer--;
            }
        }
Пример #18
0
        public void Update()
        {
            var mymod = TheLunaticMod.Instance;

            // Simply idle (and keep track of day) until ready
            if (!this.IsReady())
            {
                this.IsDay = Main.dayTime;
                return;
            }

            if (mymod.Config.DebugModeInfo)
            {
                var modworld = ModContent.GetInstance <TheLunaticWorld>();
                DebugHelpers.Print("WorldID", "" + modworld.ID, 20);
                DebugHelpers.Print("IsApocalypse", "" + this.IsApocalypse, 20);
                DebugHelpers.Print("IsSafe", "" + this.IsSafe, 20);
                DebugHelpers.Print("HasLoonyArrived", "" + this.HasLoonyArrived, 20);
                DebugHelpers.Print("HasLoonyQuit", "" + this.HasLoonyQuit, 20);
                DebugHelpers.Print("HasGameEnded", "" + this.HasGameEnded, 20);
                DebugHelpers.Print("HalfDaysElapsed", "" + this.HalfDaysElapsed + " (" + (mymod.Config.DaysUntil * 2) + ")", 20);
                DebugHelpers.Print("HaveWeEndSigns", "" + this.HaveWeEndSigns(), 20);
                DebugHelpers.Print("HaveHope", "" + this.HaveWeHopeToWin(), 20);
                DebugHelpers.Print("TintScale", "" + mymod.Sky.TintScale, 20);
                DebugHelpers.Print("RemainingMasks", String.Join(",", modworld.MaskLogic.GetRemainingVanillaMasks()), 20);
                DebugHelpers.Print("GivenMasks", String.Join(",", modworld.MaskLogic.GivenVanillaMasksByType), 20);
            }
            if (mymod.Config.DebugModeFastTime)
            {
                Main.time += 24;
            }

            // Indicate when our loony is here to stay
            if (!this.HasLoonyArrived && TheLunaticTownNPC.AmHere)
            {
                this.HasLoonyArrived = true;
            }

            if (!this.IsSafe && !this.HasLoonyQuit)
            {
                if (!this.IsApocalypse && !NPC.LunarApocalypseIsUp)                     //!NPC.downedAncientCultist && NPC.MoonLordCountdown == 0 && !NPC.AnyNPCs(398)
                // Advance elapsed time until the end
                {
                    if (this.IsDay != Main.dayTime)
                    {
                        this.HalfDaysElapsed++;
                    }

                    this.UpdateEndSigns();
                }

                this.UpdateStateOfApocalypse();
            }

            this.IsDay = Main.dayTime;

            // Is loony gone for good?
            if (!this.HasLoonyQuit)
            {
                if (!this.HasLoonyArrived)
                {
                    if (!TheLunaticTownNPC.WantsToSpawnAnew())
                    {
                        this.Quit();
                    }
                }
                else if (!TheLunaticTownNPC.WantsToSpawn())
                {
                    this.Quit();
                }
            }

            // Have we won?
            if (!this.HasWon && this.HaveWeWon())
            {
                this.WinTheGame();
            }

            // Indicate final day
            if (!this.HasGameEnded)
            {
                if (!this.IsLastDay)
                {
                    if (this.HalfDaysElapsed >= (mymod.Config.DaysUntil - 1) * 2)
                    {
                        SimpleMessage.PostMessage("Final Day", "", 60 * 5);
                        this.IsLastDay = true;
                    }
                }
                else
                {
                    if (this.HalfDaysElapsed < (mymod.Config.DaysUntil - 1) * 2)
                    {
                        this.IsLastDay = false;
                    }
                }
            }
        }