示例#1
0
        ////////////////

        public override void Initialize()
        {
            var mymod = (TheLunaticMod)this.mod;

            this.ID           = Guid.NewGuid().ToString("D");
            this.HasCorrectID = false;              // 'Load()' decides if no pre-existing one is found

            this.GameLogic = new GameLogic();
            this.MaskLogic = new MaskLogic();

            if (mymod.Config.DebugModeInfo)
            {
                LogHelpers.Log("DEBUG World created; logics (re)created.");
            }
        }
        ////////////////

        public override void Load(TagCompound tag)
        {
            if (tag.ContainsKey("boss_npc_type"))
            {
                int    npcType     = tag.GetInt("boss_npc_type");
                int    bossHeadIdx = tag.GetInt("boss_head_index");
                string bossUid     = tag.GetString("boss_uid");
                string bossName    = tag.GetString("boss_display_name");

                if (this.CustomLoad(npcType, bossHeadIdx, bossUid, bossName))
                {
                    string maskName = MaskLogic.GetMaskDisplayName(this.item);
                    if (maskName != null)
                    {
                        this.DisplayName.SetDefault(maskName);
                    }
                }
            }
        }
        ////////////////

        private string onGiveMaskButtonClick()
        {
            var mymod   = (TheLunaticMod)this.mod;
            var myworld = ModContent.GetInstance <TheLunaticWorld>();

            if (myworld.MaskLogic == null)
            {
                throw new ModHelpersException("Mask logic not initialized.");
            }

            Player player         = Main.player[Main.myPlayer];
            var    remainingMasks = myworld.MaskLogic.GetRemainingVanillaMasks();

            if (remainingMasks.Count == 0)
            {
                return("I need no more masks.");
            }

            bool isCustom = false;
            bool isGiven  = false;

            Item mask = PlayerItemFinderHelpers.FindFirstOfPossessedItemFor(player, remainingMasks, false);

            if (mask == null)
            {
                mask = PlayerItemFinderHelpers.FindFirstOfPossessedItemFor(player, new HashSet <int> {
                    ModContent.ItemType <CustomBossMaskItem>()
                }, false);
                isCustom = mask != null;
                isGiven  = isCustom && myworld.MaskLogic.DoesLoonyHaveThisMask(mask);
            }

            if (mask == null || isGiven)
            {
                if (mask == null)
                {
                    mask = PlayerItemFinderHelpers.FindFirstOfPossessedItemFor(player, MaskLogic.AllVanillaMasks, false);
                }
                string msg, hint = this.GetHint();

                if (mask == null)
                {
                    msg = "Ehehe, good one! But seriously, you DO have a mask... don't you? ...please?\n" + hint;
                }
                else
                {
                    msg = "Very nice, but I've already got a " + MaskLogic.GetMaskDisplayName(mask) + ".\n" + hint;
                }

                if (!myworld.GameLogic.HasGameEnded && mymod.Config.LoonyIndicatesDaysRemaining)
                {
                    int daysLeft = mymod.Config.DaysUntil - (myworld.GameLogic.HalfDaysElapsed / 2);
                    msg += "\n \nDays remaining: " + daysLeft;
                }
                return(msg);
            }

            if (myworld.MaskLogic.IsValidMask(mask))
            {
                int    remaining = remainingMasks.Count() - (isCustom?0:1);
                string status, msg;

                if (mymod.Config.MoonLordMaskWins)
                {
                    if (mask.type == ItemID.BossMaskMoonlord)
                    {
                        status = "At last! Seems this world gets to live a little bit longer. I won't need this anymore. Enjoy!";
                        UmbralCowlItem.Give(player);
                    }
                    else
                    {
                        status = "I require more masks!";
                    }
                }
                else
                {
                    if (remaining >= 2)
                    {
                        status = "I require " + remaining + " more masks.";
                    }
                    else if (remaining == 1)
                    {
                        status = "I require one final mask.";
                    }
                    else
                    {
                        if (mymod.Config.LoonyGivesCompletionReward)
                        {
                            status = "At last! Seems this world gets to live a little bit longer. I won't need this anymore. Enjoy!";
                            UmbralCowlItem.Give(player);
                        }
                        else
                        {
                            status = "At last! Seems this world gets to live a little bit longer. Be sure to celebrate by buying some of my delicious treats!";
                        }
                    }
                }

                msg = this.GiveMaskReply(mask);

                myworld.MaskLogic.GiveMaskToLoony(player, mask);

                return(msg + "\n\n" + status);
            }
            else
            {
                // 1: Display info, 2: Fast time, 4: Reset, 8: Reset win, 16: Skip to signs, 32: Display net info
                if (mymod.Config.DebugModeInfo)
                {
                    LogHelpers.Log("DEBUG cheater detected. " + mask.Name);
                }

                if (mymod.Config.LoonyShunsCheaters)
                {
                    player.GetModPlayer <TheLunaticPlayer>().SetCheater();
                    return("You... you aren't supposed to even have this. Bye.");
                }
                else
                {
                    return("I don't know how you got this, but I'm not ready for it yet.");
                }
            }
        }
示例#4
0
        public override void NPCLoot(NPC npc)
        {
            if (npc == null)
            {
                return;
            }

            var mymod = (TheLunaticMod)this.mod;

            if (!mymod.Config.Enabled)
            {
                return;
            }

            if (!npc.boss && npc.type != 551 && npc.type != 398)
            {
                return;
            }                                                                                   // Betsy isn't a boss?
            var myworld = ModContent.GetInstance <TheLunaticWorld>();

            if (!myworld.GameLogic.HaveWeHopeToWin())
            {
                return;
            }

            Item item     = null;
            int  maskType = MaskLogic.GetMaskTypeOfNpc(npc.type);

            if (maskType == -1)
            {
                return;
            }

            // Already given this mask?
            bool isVanilla = MaskLogic.AllVanillaMasks.Contains(maskType);

            if (!myworld.MaskLogic.GivenVanillaMasksByType.Contains(maskType))
            {
                if (!isVanilla && myworld.MaskLogic.GivenCustomMasksByBossUid.Contains(NPCID.GetUniqueKey(npc)))
                {
                    return;
                }
            }

            // No modded masks allowed?
            if (!isVanilla && mymod.Config.OnlyVanillaBossesDropMasks)
            {
                return;
            }

            int which = ItemHelpers.CreateItem(npc.position, maskType, 1, 15, 15);

            item = Main.item[which];

            if (item != null && !item.IsAir)
            {
                if (maskType == ModContent.ItemType <CustomBossMaskItem>())
                {
                    var moditem = (CustomBossMaskItem)item.modItem;
                    if (!moditem.SetBoss(npc.type))
                    {
                        ItemHelpers.DestroyWorldItem(which);
                    }
                }
                else
                {
                    /*if( !modworld.MaskLogic.GivenVanillaMasks.Contains( mask_type ) ) {
                     *      // Does this mask already exist in the world?
                     *      for( int i = 0; i < Main.item.Length; i++ ) {
                     *              if( Main.item[i] != null && Main.item[i].active && Main.item[i].type == mask_type ) {
                     *                      item = Main.item[i];
                     *                      break;
                     *              }
                     *      }
                     * }*/
                }
            }
            else
            {
                LogHelpers.Log("Could not spawn a mask of type " + maskType);
            }
        }
        ////////////////

        public string GiveMaskReply(Item mask)
        {
            string msg;

            switch (mask.type)
            {
            case ItemID.EyeMask:             // Eye of Cthulhu Mask
                msg = "A genuine Eye of Cthulhu mask. Much thanks!\nThat wasn't really Cthulhu's eye, by the way. We tried getting a real one, but it saw right through us. Right THROUGH us.";
                break;

            case ItemID.KingSlimeMask:             // King Slime Mask
                msg = "A genuine King Slime mask. Much thanks!\nA bit sticky to the touch, though.";
                break;

            case ItemID.BeeMask:             // Queen Bee Mask
                msg = "A genuine Queen Bee mask. Much thanks!\nI'll take it. Not one of ours, but having it gone helps us cut back on the bug spray.";
                break;

            case ItemID.BrainMask:             // Brain of Cthulhu Mask
                msg = "A genuine Brain of Cthulhu mask. Much thanks!\nDon't be confused: It's a brain OF Cthulhu. Not Cthulhu's brain. Dang newbies.";
                break;

            case ItemID.EaterMask:             // Eater of Worlds Mask
                msg = "A genuine Eater of Worlds mask. Much thanks!\nSuch an ominous name. It really only nibbles them a bit...";
                break;

            case ItemID.SkeletronMask:             // Skeletron Mask
                msg = "A genuine Skeletron mask. Much thanks!\nYou don't even want to know what it took to stuff that thing inside the old geezer. Took it like a champ, he did.";
                break;

            case ItemID.FleshMask:             // Wall of Flesh Mask
                msg = "A genuine Wall of Flesh mask. Much thanks!\nAh, you cleared up that fleshy blockage yourself. I wonder what happened to the plumber we called...";
                break;

            case ItemID.DestroyerMask:             // Destroyer Mask
                msg = "A genuine Destroyer Mask mask. Much thanks!\nDo you have any idea how much assembly these req... er, thanks for the mask!";
                break;

            case ItemID.TwinMask:             // Twin Mask
                msg = "A genuine Twins mask. Much thanks!\nI wonder what became of the larger thing these were supposed to be part of...";
                break;

            case ItemID.SkeletronPrimeMask:             // Skeletron Prime Mask
                msg = "A genuine Skeletron Prime mask. Much thanks!\nA favorite for terrorizing small children! Uh, I mean the mask, of course! That's right!";
                break;

            case ItemID.PlanteraMask:             // Plantera Mask
                msg = "A genuine Plantera mask. Much thanks!\nI have a strange urge to listen to heavy metal for some reason...";
                break;

            case ItemID.GolemMask:             // Golem Mask
                msg = "A genuine Golem mask. Much thanks!\nServes those damn reptiles right for going rogue.";
                break;

            case ItemID.DukeFishronMask:             // Duke Fishron Mask
                //msg = "A genuine Duke Fishron mask. Much thanks!\nThese are quite the delicacy. A heck of a fishing trip to catch, though.";
                msg = "A genuine Duke Fishron mask. Much thanks!\nHere's what you get for breeding a shark, a pig, and a dragon. Just a little leftover from someone's previous party.";
                break;

            case ItemID.BossMaskCultist:             // Ancient Cultist Mask
                msg = "A genuine Ancient Cultist mask. Much thanks!\nFairwell, boss. The summoning ritual is now halted. Seems we're still getting a party of sorts, though...";
                break;

            case ItemID.BossMaskMoonlord:             // Moon Lord Mask
                msg = "PRAISE BE TO YOG-er, thank you very much!";
                break;

            default:
                string maskName = MaskLogic.GetMaskDisplayName(mask);
                msg = "A genuine " + maskName + ". Much thanks!\nA bit non-standard, but it should work...";
                break;
            }

            return(msg);
        }