Ejemplo n.º 1
0
 public override bool OnPickup(Item item, Player player)
 {
     if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI)
     {
         // Loot and Collections Updating
         List <BossInfo> BossList  = BossChecklist.bossTracker.SortedBosses;
         PlayerAssist    modplayer = player.GetModPlayer <PlayerAssist>();
         for (int i = 0; i < BossList.Count; i++)
         {
             int BossIndex = modplayer.BossTrophies.FindIndex(boss => boss.bossName == BossList[i].Key);
             if (BossIndex == -1)
             {
                 continue;
             }
             // Loot Collections
             if (BossList[i].loot.Contains(item.type))
             {
                 if (modplayer.BossTrophies[i].loot.All(x => x.Type != item.type))
                 {
                     modplayer.BossTrophies[i].loot.Add(new ItemDefinition(item.type));
                 }
             }
             // Boss Collections
             if (BossList[i].collection.Contains(item.type))
             {
                 if (modplayer.BossTrophies[i].collectibles.All(x => x.Type != item.type))
                 {
                     modplayer.BossTrophies[i].collectibles.Add(new ItemDefinition(item.type));
                 }
             }
         }
     }
     return(base.OnPickup(item, player));
 }
Ejemplo n.º 2
0
        public override bool PreAI(NPC npc)
        {
            if (npc.realLife != -1 && npc.realLife != npc.whoAmI)
            {
                return(true);                                                              // Checks for multi-segmented bosses?
            }
            int listNum = ListedBossNum(npc);

            if (listNum != -1)
            {
                if (!WorldAssist.ActiveBossesList[listNum])
                {
                    for (int j = 0; j < Main.maxPlayers; j++)
                    {
                        if (!Main.player[j].active)
                        {
                            continue;
                        }
                        PlayerAssist modPlayer = Main.player[j].GetModPlayer <PlayerAssist>();
                        modPlayer.MaxHealth[listNum]    = Main.player[j].statLifeMax;
                        modPlayer.RecordTimers[listNum] = 0;
                        modPlayer.BrinkChecker[listNum] = 0;
                        modPlayer.DodgeTimer[listNum]   = 0;
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public bool CheckWorldRecords(int recordIndex)           // Returns whether or not to stop the New Record! text from appearing to show World Record! instead
        {
            Player       player       = Main.LocalPlayer;
            PlayerAssist modPlayer    = player.GetModPlayer <PlayerAssist>();
            BossStats    playerRecord = modPlayer.AllBossRecords[recordIndex].stat;
            WorldStats   worldRecord  = WorldAssist.worldRecords[recordIndex].stat;
            bool         newRecord    = false;

            if (playerRecord.durationBest < worldRecord.durationWorld || worldRecord.durationWorld <= 0)
            {
                worldRecord.durationWorld  = playerRecord.durationBest;
                worldRecord.durationHolder = player.name;
                newRecord = true;
            }
            if (playerRecord.hitsTakenBest < worldRecord.hitsTakenWorld || worldRecord.hitsTakenWorld < 0)
            {
                worldRecord.hitsTakenWorld  = playerRecord.hitsTakenBest;
                worldRecord.dodgeTimeWorld  = playerRecord.dodgeTimeBest;
                worldRecord.hitsTakenHolder = player.name;
                newRecord = true;
            }
            if (playerRecord.healthLossBest < worldRecord.healthLossWorld || worldRecord.healthLossWorld <= 0)
            {
                worldRecord.healthLossWorld    = playerRecord.healthLossBest;
                worldRecord.healthAtStartWorld = playerRecord.healthAtStart;
                worldRecord.healthLossHolder   = player.name;
                newRecord = true;
            }
            return(newRecord);
        }
Ejemplo n.º 4
0
        public bool CheckWorldRecords(int recordIndex)           // Returns whether or not to stop the New Record! text from appearing to show World Record! instead
        {
            Player       player       = Main.LocalPlayer;
            PlayerAssist modPlayer    = player.GetModPlayer <PlayerAssist>();
            BossStats    playerRecord = modPlayer.AllBossRecords[recordIndex].stat;
            WorldStats   worldRecord  = WorldAssist.worldRecords[recordIndex].stat;
            bool         newRecord    = false;

            if (playerRecord.durationBest < worldRecord.durationWorld || worldRecord.durationWorld <= 0)
            {
                // only say World Record if you the player is on a server OR if the player wasn't holding the previoes record
                newRecord = (worldRecord.durationHolder != player.name && worldRecord.durationHolder != "") || Main.netMode == NetmodeID.MultiplayerClient;
                worldRecord.durationWorld  = playerRecord.durationBest;
                worldRecord.durationHolder = player.name;
            }
            if (playerRecord.hitsTakenBest < worldRecord.hitsTakenWorld || worldRecord.hitsTakenWorld < 0)
            {
                newRecord = (worldRecord.hitsTakenHolder != player.name && worldRecord.hitsTakenHolder != "") || Main.netMode == NetmodeID.MultiplayerClient;
                worldRecord.hitsTakenWorld  = playerRecord.hitsTakenBest;
                worldRecord.dodgeTimeWorld  = playerRecord.dodgeTimeBest;
                worldRecord.hitsTakenHolder = player.name;
            }
            if (playerRecord.healthLossBest < worldRecord.healthLossWorld || worldRecord.healthLossWorld <= 0)
            {
                newRecord = (worldRecord.healthLossHolder != player.name && worldRecord.healthLossHolder != "") || Main.netMode == NetmodeID.MultiplayerClient;
                worldRecord.healthLossWorld    = playerRecord.healthLossBest;
                worldRecord.healthAtStartWorld = playerRecord.healthAtStart;
                worldRecord.healthLossHolder   = player.name;
            }
            return(newRecord);
        }
Ejemplo n.º 5
0
        public override bool PreAI(NPC npc)
        {
            if (npc.realLife != -1 && npc.realLife != npc.whoAmI)
            {
                return(true);                                                              // Checks for multi-segmented bosses?
            }
            int listNum = ListedBossNum(npc);

            if (listNum != -1)
            {
                if (!WorldAssist.ActiveBossesList[listNum])
                {
                    for (int j = 0; j < Main.maxPlayers; j++)
                    {
                        if (!Main.player[j].active)
                        {
                            continue;
                        }
                        PlayerAssist modPlayer = Main.player[j].GetModPlayer <PlayerAssist>();
                        modPlayer.MaxHealth[listNum]    = Main.player[j].statLifeMax;
                        modPlayer.RecordTimers[listNum] = 0;
                        modPlayer.BrinkChecker[listNum] = 0;                         // starts at 0 to prevent less health at start cheese, only updates when hit (if no-hitter, change to max health)
                        modPlayer.DodgeTimer[listNum]   = 0;
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 6
0
 public override void OnCraft(Item item, Recipe recipe)
 {
     if (Main.netMode != NetmodeID.Server)
     {
         Player player = Main.LocalPlayer;
         // Loot and Collections Updating
         List <BossInfo> BossList  = BossChecklist.bossTracker.SortedBosses;
         PlayerAssist    modplayer = player.GetModPlayer <PlayerAssist>();
         for (int i = 0; i < BossList.Count; i++)
         {
             int BossIndex = modplayer.BossTrophies.FindIndex(boss => boss.bossName == BossList[i].Key);
             if (BossIndex == -1)
             {
                 continue;
             }
             // Loot Collections
             if (BossList[i].loot.Contains(item.type))
             {
                 if (modplayer.BossTrophies[i].loot.All(x => x.Type != item.type))
                 {
                     modplayer.BossTrophies[i].loot.Add(new ItemDefinition(item.type));
                 }
             }
             // Boss Collections
             if (BossList[i].collection.Contains(item.type))
             {
                 if (modplayer.BossTrophies[i].collectibles.All(x => x.Type != item.type))
                 {
                     modplayer.BossTrophies[i].collectibles.Add(new ItemDefinition(item.type));
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
        public override void clientClone(ModPlayer clientClone)
        {
            PlayerAssist clone = clientClone as PlayerAssist;

            clone.hasOpenedTheBossLog = hasOpenedTheBossLog;
            clone.BossTrophies        = BossTrophies;
            clone.AllBossRecords      = AllBossRecords;
        }
Ejemplo n.º 8
0
        public void CheckRecordsMultiplayer(NPC npc, int recordIndex)
        {
            string[] newRecordHolders = new string[] { "", "", "" };
            int[]    newWorldRecords  = new int[] {
                WorldAssist.worldRecords[recordIndex].stat.durationWorld,
                WorldAssist.worldRecords[recordIndex].stat.hitsTakenWorld,
                WorldAssist.worldRecords[recordIndex].stat.dodgeTimeWorld,
                WorldAssist.worldRecords[recordIndex].stat.healthLossWorld,
                WorldAssist.worldRecords[recordIndex].stat.healthAtStartWorld,
            };
            for (int i = 0; i < 255; i++)
            {
                Player player = Main.player[i];

                // Players must be active AND have interacted with the boss AND cannot have recordingstats disabled
                if (!player.active || !npc.playerInteraction[i])
                {
                    continue;
                }
                PlayerAssist     modPlayer = player.GetModPlayer <PlayerAssist>();
                List <BossStats> list      = BossChecklist.ServerCollectedRecords[i];
                BossStats        oldRecord = list[recordIndex];

                // Establish the new records for comparing
                BossStats newRecord = new BossStats()
                {
                    durationPrev      = modPlayer.RecordTimers[recordIndex],
                    hitsTakenPrev     = modPlayer.AttackCounter[recordIndex],
                    dodgeTimePrev     = modPlayer.DodgeTimer[recordIndex],
                    healthLossPrev    = modPlayer.BrinkChecker[recordIndex],
                    healthAtStartPrev = modPlayer.MaxHealth[recordIndex]
                };

                // Setup player's last fight attempt numbers
                modPlayer.durationLastFight   = newRecord.durationPrev;
                modPlayer.hitsTakenLastFight  = newRecord.hitsTakenPrev;
                modPlayer.healthLossLastFight = newRecord.healthLossPrev;

                RecordID specificRecord = RecordID.None;
                // For each record type we check if its beats the current record or if it is not set already
                // If it is beaten, we add a flag to specificRecord to allow newRecord's numbers to override the current record
                if (newRecord.durationPrev < oldRecord.durationBest || oldRecord.durationBest <= 0)
                {
                    Console.WriteLine($"{player.name} set a new record for DURATION: {newRecord.durationPrev} (Previous Record: {oldRecord.durationBest})");
                    specificRecord        |= RecordID.ShortestFightTime;
                    oldRecord.durationPrev = oldRecord.durationBest;
                    oldRecord.durationBest = newRecord.durationPrev;
                }
                else
                {
                    oldRecord.durationPrev = newRecord.durationPrev;
                }

                if (newRecord.hitsTakenPrev < oldRecord.hitsTakenBest || oldRecord.hitsTakenBest < 0)
                {
                    Console.WriteLine($"{player.name} set a new record for HITS TAKEN: {newRecord.hitsTakenPrev} (Previous Record: {oldRecord.hitsTakenBest})");
                    specificRecord         |= RecordID.LeastHits;
                    oldRecord.hitsTakenPrev = oldRecord.hitsTakenBest;
                    oldRecord.hitsTakenBest = newRecord.hitsTakenPrev;
                }
                else
                {
                    oldRecord.hitsTakenPrev = newRecord.hitsTakenPrev;
                }

                if (newRecord.dodgeTimePrev > oldRecord.dodgeTimeBest || oldRecord.dodgeTimeBest <= 0)
                {
                    Console.WriteLine($"{player.name} set a new record for BEST DODGE TIME: {newRecord.dodgeTimePrev} (Previous Record: {oldRecord.dodgeTimeBest})");
                    specificRecord         |= RecordID.DodgeTime;
                    oldRecord.dodgeTimeBest = newRecord.dodgeTimePrev;
                }

                if (newRecord.healthLossPrev > oldRecord.healthLossBest || oldRecord.healthLossBest <= 0)
                {
                    Console.WriteLine($"{player.name} set a new record for BEST HEALTH: {newRecord.healthLossPrev} (Previous Record: {oldRecord.healthLossBest})");
                    specificRecord          |= RecordID.BestBrink;
                    oldRecord.healthLossPrev = oldRecord.healthLossBest;
                    oldRecord.healthLossBest = newRecord.healthLossPrev;
                }
                else
                {
                    oldRecord.healthLossPrev = newRecord.healthLossPrev;
                }

                // Make and send the packet
                ModPacket packet = mod.GetPacket();
                packet.Write((byte)PacketMessageType.RecordUpdate);
                packet.Write((int)recordIndex);            // Which boss record are we changing?
                newRecord.NetSend(packet, specificRecord); // Writes all the variables needed
                packet.Send(toClient: i);                  // We send to the player. Only they need to see their own records
            }
            if (newRecordHolders.Any(x => x != ""))
            {
                WorldStats worldStats     = WorldAssist.worldRecords[recordIndex].stat;
                RecordID   specificRecord = RecordID.None;
                if (newRecordHolders[0] != "")
                {
                    specificRecord           |= RecordID.ShortestFightTime;
                    worldStats.durationHolder = newRecordHolders[0];
                    worldStats.durationWorld  = newWorldRecords[0];
                }
                if (newRecordHolders[1] != "")
                {
                    specificRecord            |= RecordID.LeastHits;
                    worldStats.hitsTakenHolder = newRecordHolders[1];
                    worldStats.hitsTakenWorld  = newWorldRecords[1];
                    worldStats.dodgeTimeWorld  = newWorldRecords[2];
                }
                if (newRecordHolders[2] != "")
                {
                    specificRecord |= RecordID.BestBrink;
                    worldStats.healthLossHolder   = newRecordHolders[2];
                    worldStats.healthLossWorld    = newWorldRecords[3];
                    worldStats.healthAtStartWorld = newWorldRecords[4];
                }

                ModPacket packet = mod.GetPacket();
                packet.Write((byte)PacketMessageType.WorldRecordUpdate);
                packet.Write((int)recordIndex); // Which boss record are we changing?
                worldStats.NetSend(packet, specificRecord);
                packet.Send();                  // To server (world data for everyone)
            }
        }
Ejemplo n.º 9
0
        public void CheckRecords(NPC npc, int recordIndex)
        {
            Player       player    = Main.LocalPlayer;
            PlayerAssist modPlayer = player.GetModPlayer <PlayerAssist>();

            if (!npc.playerInteraction[Main.myPlayer])
            {
                return;                                                    // Player must have contributed to the boss fight
            }
            bool      newRecordSet = false;
            BossStats bossStats    = modPlayer.AllBossRecords[recordIndex].stat;

            int durationAttempt     = modPlayer.RecordTimers[recordIndex];
            int currentBestDuration = bossStats.durationBest;

            int hitsTakenAttempt     = modPlayer.AttackCounter[recordIndex];
            int currentBestHitsTaken = bossStats.hitsTakenBest;

            int dodgeTimeAttempt     = modPlayer.DodgeTimer[recordIndex];
            int currentBestDodgeTime = bossStats.dodgeTimeBest;

            int brinkAttempt       = modPlayer.BrinkChecker[recordIndex];
            int maxLifeAttempt     = modPlayer.MaxHealth[recordIndex];
            int currentBestBrink   = bossStats.healthLossBest;
            int currentBestMaxLife = bossStats.healthAtStart;

            // Setup player's last fight attempt numbers
            modPlayer.durationLastFight   = durationAttempt;
            modPlayer.hitsTakenLastFight  = hitsTakenAttempt;
            modPlayer.healthLossLastFight = brinkAttempt;

            bossStats.kills++;             // Kills always go up, since comparing only occurs if boss was defeated

            // If the player has beaten their best record, we change BEST to PREV and make the current attempt the new BEST
            // Otherwise, just overwrite PREV with the current attempt
            if (durationAttempt < currentBestDuration || currentBestDuration <= 0)
            {
                bossStats.durationPrev = currentBestDuration;
                bossStats.durationBest = durationAttempt;
                newRecordSet           = true;
            }
            else
            {
                bossStats.durationPrev = durationAttempt;
            }

            // Empty check should be less than 0 because 0 is achievable (No Hit)
            if (hitsTakenAttempt < currentBestHitsTaken || currentBestHitsTaken < 0)
            {
                bossStats.hitsTakenPrev = currentBestHitsTaken;
                bossStats.hitsTakenBest = hitsTakenAttempt;
                newRecordSet            = true;
            }
            else
            {
                bossStats.hitsTakenPrev = hitsTakenAttempt;
            }

            // This is an extra record based on Hits Taken. Only overwrite if time is higher than previous.
            if (dodgeTimeAttempt > currentBestDodgeTime || currentBestDodgeTime <= 0)
            {
                bossStats.dodgeTimeBest = dodgeTimeAttempt;
            }

            if (brinkAttempt < currentBestBrink || currentBestBrink <= 0)
            {
                bossStats.healthLossPrev    = currentBestBrink;
                bossStats.healthLossBest    = brinkAttempt;
                bossStats.healthAtStartPrev = currentBestMaxLife;
                bossStats.healthAtStart     = maxLifeAttempt;
                newRecordSet = true;
            }
            else
            {
                bossStats.healthLossPrev    = brinkAttempt;
                bossStats.healthAtStartPrev = maxLifeAttempt;
            }

            // If a new record was made, notify the player
            if (newRecordSet)
            {
                modPlayer.hasNewRecord[recordIndex] = true;
                // Compare records to World Records. Logically, you can only beat the world records if you have beaten your own record
                // TODO: Move World Record texts to Multiplayer exclusively. Check should still happen.
                string message = CheckWorldRecords(recordIndex) ? "World Record!" : "New Record!";
                CombatText.NewText(player.getRect(), Color.LightYellow, message, true);
            }
        }
Ejemplo n.º 10
0
        //int lastSeenScreenWidth;
        //int lastSeenScreenHeight;
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            //if (BossChecklistUI.visible)
            //{
            //	layers.RemoveAll(x => x.Name == "Vanilla: Resource Bars" || x.Name == "Vanilla: Map / Minimap");
            //}

            int MouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (MouseTextIndex != -1)
            {
                layers.Insert(MouseTextIndex, new LegacyGameInterfaceLayer(
                                  "BossChecklist: Boss Checklist",
                                  delegate {
                    if (BossChecklistUI.Visible)
                    {
                        bossChecklistInterface?.Draw(Main.spriteBatch, new GameTime());

                        if (BossChecklistUI.hoverText != "")
                        {
                            float x        = Main.fontMouseText.MeasureString(BossChecklistUI.hoverText).X;
                            Vector2 vector = new Vector2((float)Main.mouseX, (float)Main.mouseY) + new Vector2(16f, 16f);
                            if (vector.Y > (float)(Main.screenHeight - 30))
                            {
                                vector.Y = (float)(Main.screenHeight - 30);
                            }
                            if (vector.X > (float)(Main.screenWidth - x - 30))
                            {
                                vector.X = (float)(Main.screenWidth - x - 30);
                            }
                            //Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, BossChecklistUI.hoverText,
                            //	vector.X, vector.Y, new Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor), Color.Black, Vector2.Zero, 1f);
                            //	Utils.draw

                            //ItemTagHandler.GenerateTag(item)
                            int hoveredSnippet  = -1;
                            TextSnippet[] array = ChatManager.ParseMessage(BossChecklistUI.hoverText, Color.White).ToArray();
                            ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, array,
                                                                       vector, 0f, Vector2.Zero, Vector2.One, out hoveredSnippet /*, -1f, 2f*/);

                            if (hoveredSnippet > -1)
                            {
                                array[hoveredSnippet].OnHover();
                                //if (Main.mouseLeft && Main.mouseLeftRelease)
                                //{
                                //	array[hoveredSnippet].OnClick();
                                //}
                            }
                        }
                    }
                    return(true);
                },
                                  InterfaceScaleType.UI)
                              );
            }
            // This doesn't work perfectly.
            //if (BossChecklistUI.Visible) {
            //	layers.RemoveAll(x => LayersToHideWhenChecklistVisible.Contains(x.Name));
            //}
            if (MouseTextIndex != -1)
            {
                layers.Insert(MouseTextIndex, new LegacyGameInterfaceLayer("BossChecklist: Boss Log",
                                                                           delegate {
                    BossLogInterface.Draw(Main.spriteBatch, new GameTime());
                    return(true);
                },
                                                                           InterfaceScaleType.UI)
                              );
                layers.Insert(++MouseTextIndex, new LegacyGameInterfaceLayer("BossChecklist: Boss Radar",
                                                                             delegate {
                    BossRadarUIInterface.Draw(Main.spriteBatch, new GameTime());
                    return(true);
                },
                                                                             InterfaceScaleType.UI)
                              );
            }
            if (ClientConfig.RespawnTimerEnabled)
            {
                int InventoryIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Death Text"));
                if (InventoryIndex != -1)
                {
                    layers.Insert(InventoryIndex, new LegacyGameInterfaceLayer("BossChecklist: Respawn Timer",
                                                                               delegate {
                        if (Main.LocalPlayer.dead && Main.LocalPlayer.difficulty != 2)
                        {
                            if (ClientConfig.TimerSounds)
                            {
                                if (Main.LocalPlayer.respawnTimer % 60 == 0 && Main.LocalPlayer.respawnTimer / 60 <= 3)
                                {
                                    Main.PlaySound(25);
                                }
                            }
                            string timer      = (Main.LocalPlayer.respawnTimer / 60 + 1).ToString();
                            Vector2 screenPos = new Vector2(Main.screenWidth / 2, Main.screenHeight / 2 - 75);
                            Color deathColor  = Main.player[Main.myPlayer].GetDeathAlpha(Color.Transparent);
                            DynamicSpriteFontExtensionMethods.DrawString(Main.spriteBatch, Main.fontDeathText, timer, screenPos, deathColor);
                        }
                        return(true);
                    },
                                                                               InterfaceScaleType.UI)
                                  );
                }
            }
            #region DEBUG
            int PlayerChatIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Player Chat"));
            if (PlayerChatIndex != -1)
            {
                layers.Insert(PlayerChatIndex, new LegacyGameInterfaceLayer("BossChecklist: Debug Timers and Counters",
                                                                            delegate {
                    PlayerAssist playerAssist = Main.LocalPlayer.GetModPlayer <PlayerAssist>();
                    int ConfigIndex           = NPCAssist.ListedBossNum(DebugConfig.ShowTimerOrCounter.Type, DebugConfig.ShowTimerOrCounter.mod);
                    if (ConfigIndex != -1)
                    {
                        string textKingSlime = $"{bossTracker.SortedBosses[ConfigIndex].name} (#{ConfigIndex + 1})" +
                                               $"\nTime: {playerAssist.RecordTimers[ConfigIndex]}" +
                                               $"\nDodge Timer: {playerAssist.DodgeTimer[ConfigIndex]}" +
                                               $"\nTimes Hit: {playerAssist.AttackCounter[ConfigIndex]}" +
                                               $"\nLowest Health: {playerAssist.BrinkChecker[ConfigIndex]} / {playerAssist.MaxHealth[ConfigIndex]}" +
                                               $"\nDeaths: {playerAssist.DeathTracker[ConfigIndex]}";
                        DynamicSpriteFontExtensionMethods.DrawString(Main.spriteBatch, Main.fontMouseText, textKingSlime, new Vector2(20, Main.screenHeight - 175), new Color(1f, 0.388f, 0.278f), 0f, default(Vector2), 1, SpriteEffects.None, 0f);
                    }
                    return(true);
                },
                                                                            InterfaceScaleType.UI)
                              );
            }
            #endregion
        }