Ejemplo n.º 1
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            int Truffle = NPC.FindFirstNPC(NPCID.Truffle);

            if (Truffle >= 0 && Main.rand.Next(4) == 0)
            {
                chat.Add("Those glowing truffles are all just such downers.");
            }
            int WitchDoctor = NPC.FindFirstNPC(NPCID.WitchDoctor);

            if (WitchDoctor >= 0 && Main.rand.Next(4) == 0)
            {
                return(Main.npc[WitchDoctor].GivenName + "offered to let me get in his hot tub one time. I denied because I had better things to do");
            }
            chat.Add("The Mushroom Monarch isn't all he seems, you know.");
            chat.Add("Don't ask where I get the mushrooms for my potions.");
            chat.Add("I got potions, you got money. Wanna trade?");
            int Clothier = NPC.FindFirstNPC(NPCID.Clothier);

            if (WitchDoctor >= 0 && Main.rand.Next(4) == 0)
            {
                return(Main.npc[WitchDoctor].GivenName + "Asked me one time if red truffles tasted as good as blue ones. Obviously not. Blue truffles are way saltier.");
            }
            return(chat); // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
        }
Ejemplo n.º 2
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            //#region contract uncompleted
            //chat.Add("Hey, Pauling here. Could use some help with these.");
            //chat.Add("Hi, I need a task done, you up for it?");
            //chat.Add("I could use a hand, wanna have at this contract?");
            //chat.Add("Take a look at this job.");
            //chat.Add("I need a task done. Want the details?");
            //chat.Add("You wanted dialogue? I'm too busy for that, but I can give you a contract.");
            //#endregion

            //#region contract turned in
            //chat.Add("Nice work! Thanks for your help.");
            //chat.Add("Great work on this contract.");
            //chat.Add("You did it! I appreciate it.");
            //chat.Add("I owe you one for this contract.");
            //chat.Add("Knew I could count on you, solid work.");
            //chat.Add("That'll do, thank you!");
            //chat.Add("Your results prove well, thanks for the help.");
            //chat.Add("Well done, I'll stay in touch with you.");
            //chat.Add("Your contract has been fulfilled!");
            //#endregion

            //#region contract already done
            //chat.Add("Sorry, these aren't for fun.");
            //chat.Add("I'd give you more if I could, no dice.");
            //chat.Add("I'm busy, but you can come back for more soon.");
            //chat.Add("Good news, you're set for today.");
            //chat.Add("Beeeep. You have reached Ms. Pauling. She is probably killing someone.");
            //chat.Add("I've got a phone call due. Come back in some time.");
            //#endregion

            #region normal conversation
            chat.Add("I prefer doing jobs in the third dimension.");
            chat.Add("My first name? Can't remember after ending up in Terraria.");
            chat.Add("Have you seen my mo-ped?");
            chat.Add("If you see a handsome guy sporting red and a cap, don't tell him I'm here!");
            chat.Add("I'm no good at jokes, last time I tried them I contract-ed an illness.");
            #endregion

            if (!Main.dayTime)
            {
                chat.Add("It's never too late to do a contract, you know.");
                chat.Add("Monsters? Fighting? Sounds fitting for this job I got you.");
            }

            if (Main.bloodMoon)
            {
                chat.Add("Back where I'm from, we have blood money, not blood moons.");
                chat.Add("I'm already too cranky over contracts to care about some hemopossesion.");
            }

            if (Main.eclipse)
            {
                chat.Add("Maybe Scream Fortress doesn't come to an end.");
            }
            return(chat);
        }
Ejemplo n.º 3
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            /*chat.Add("The birds. They are coming.");
             * chat.Add("Ravens. Robins. Gulls.");
             * chat.Add("They are calling for you.");
             * chat.Add("The flock guides us all");*///Shifting from Emissary if the flock
            int guide = NPC.FindFirstNPC(NPCID.Guide);

            if (guide > -1)
            {
                chat.Add("You know I honestly feel bad for the guide: voodoo dolls that are being tossed into the fire, I mean come on those are perfect for shop displays, i could see signs saying, \"New fashionable doll in stores today\", you know?");
            }
            int nurse = NPC.FindFirstNPC(NPCID.Nurse);

            if (nurse > -1)
            {
                chat.Add("you know I don’t need the nurse to help because I have my . . . uh, well \"ways\"");
                if (Vector2.Distance(Main.npc[nurse].Center, this.npc.Center) < 30 * 16) //*16 to convert from 30 tile coordinates to 480 world coordinates
                {
                    chat.Add($"Hey {Main.npc[nurse].GivenName}, how much for the healing potions. Not for sale? Well, what about I give you 5 platinum coins then.");
                }
            }
            int merchant = NPC.FindFirstNPC(NPCID.Merchant);

            if (merchant > -1)
            {
                chat.Add("Hey did you know I heard that the reason the merchant can sell infinite piggy banks is that he has a vortex in his pockets, but don’t ask me how I know this, because a collector never tells his secrets, unless for a really high price.");
            }
            return(chat);            // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
        }
Ejemplo n.º 4
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            int Truffle = NPC.FindFirstNPC(NPCID.Truffle);

            if (Truffle >= 0 && Main.rand.Next(4) == 0)
            {
                chat.Add(Lang.TownNPCMushman("MushmanChat1"));
            }
            int WitchDoctor = NPC.FindFirstNPC(NPCID.WitchDoctor);

            if (WitchDoctor >= 0 && Main.rand.Next(4) == 0)
            {
                return(Main.npc[WitchDoctor].GivenName + Lang.TownNPCMushman("MushmanChat2"));
            }
            chat.Add(Lang.TownNPCMushman("MushmanChat3"));
            chat.Add(Lang.TownNPCMushman("MushmanChat4"));
            chat.Add(Lang.TownNPCMushman("MushmanChat5"));
            int Clothier = NPC.FindFirstNPC(NPCID.Clothier);

            if (Clothier >= 0 && Main.rand.Next(4) == 0)
            {
                return(Main.npc[Clothier].GivenName + Lang.TownNPCMushman("MushmanChat6"));
            }
            return(chat);
        }
Ejemplo n.º 5
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            int Truffle = NPC.FindFirstNPC(NPCID.Truffle);

            if (Truffle >= 0 && Main.rand.Next(4) == 0)
            {
                chat.Add(Lang.TownNPCMushman("MushmanChat1"));
            }
            int WitchDoctor = NPC.FindFirstNPC(NPCID.WitchDoctor);

            if (WitchDoctor >= 0 && Main.rand.Next(4) == 0)
            {
                return(Main.npc[WitchDoctor].GivenName + Lang.TownNPCMushman("MushmanChat2"));
            }
            chat.Add(Lang.TownNPCMushman("MushmanChat3"));
            chat.Add(Lang.TownNPCMushman("MushmanChat4"));
            chat.Add(Lang.TownNPCMushman("MushmanChat5"));
            int Clothier = NPC.FindFirstNPC(NPCID.Clothier);

            if (Clothier >= 0 && Main.rand.Next(4) == 0)
            {
                return(Main.npc[Clothier].GivenName + Lang.TownNPCMushman("MushmanChat6"));
            }
            return(chat); // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
        }
Ejemplo n.º 6
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
			if (firstButton)
			{
				if (shopNum == 1)
				shop = true;
				else if (shopNum == 2) {
					WeightedRandom<string> challenge = new WeightedRandom<string>();
					challenge.Add("You are clearly not ready.");
					challenge.Add("I don't care if you slayed several cosmic beings!");
					challenge.Add("Come back later.");
					challenge.Add("Nah.");
					challenge.Add("Go wait for V1.0 to release.");
					challenge.Add("Nope.");
					challenge.Add("Convince me to bring back the harp subclass first.");
					challenge.Add("Go away.");
					challenge.Add("Are you kidding me?");
					challenge.Add("Make developing Azercadmium fun again.");
					Main.npcChatText = challenge;
				}
			}
			else {
				shopNum += 1;
				if (shopNum > 2)
					shopNum = 1;
			}
		}
Ejemplo n.º 7
0
        //   Miner ammo helper function
        internal static bool processMinerOreDrop(NPC target, int oneInX = 100)
        {
            if (WorldGen.genRand.Next(oneInX) != 0)
            {
                return(false);
            }
            if (target.type == NPCID.TargetDummy)
            {
                return(false);
            }
            if (target.SpawnedFromStatue)
            {
                return(false);
            }

            //  Load drop table
            var dropTable = new WeightedRandom <int>();

            if (!Main.hardMode)
            {
                foreach (int a in AmmoboxPlus.AmmoboxOreVanillaPHM)
                {
                    dropTable.Add(a);
                }
            }
            else if (Main.hardMode)
            {
                //  Include both phm and hm ores
                foreach (int a in AmmoboxPlus.AmmoboxOreVanillaPHM)
                {
                    dropTable.Add(a);
                }
                if (AmmoboxPlus.AmmoboxOreVanillaHM.Count > 0)
                {
                    foreach (int a in AmmoboxPlus.AmmoboxOreVanillaHM)
                    {
                        dropTable.Add(a);
                    }
                }
            }

            //  Add mod-supplied ores to the drop table (if any exist)
            if (AmmoboxPlus.AmmoboxOreModded.Count > 0)
            {
                foreach (int a in AmmoboxPlus.AmmoboxOreModded)
                {
                    dropTable.Add(a);
                }
            }

            //  Spawn the item
            int index = Item.NewItem(target.position, dropTable, WorldGen.genRand.Next(10, 30));

            if (Main.netMode == 1)
            {
                NetMessage.SendData(21, -1, -1, Terraria.Localization.NetworkText.Empty, index, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            }
            return(true);
        }
Ejemplo n.º 8
0
        protected override void OnEnd()
        {
            TwitchChat.Instance.Irc.ChannelMessage -= CountVote;

            if (VoteMode != VoteMode.EndAction || Main.netMode == NetmodeID.MultiplayerClient)
            {
                return;
            }

            var votesCount = new SortedDictionary <string, int>();

            foreach (KeyValuePair <string, string> it in Votes)
            {
                if (votesCount.ContainsKey(it.Value))
                {
                    votesCount[it.Value]++;
                }
                else
                {
                    votesCount.Add(it.Value, 1);
                }
            }

            var    bigger = 0;
            string index = "", draftIndex = "";

            foreach (KeyValuePair <string, int> it in votesCount)
            {
                if (it.Value > bigger)
                {
                    bigger     = it.Value;
                    index      = it.Key;
                    draftIndex = "";
                }
                else if (it.Value == bigger)
                {
                    draftIndex = it.Key;
                }
            }


            if (index == draftIndex && index != "")
            {
                var rand = new WeightedRandom <string>();
                rand.Add(index);
                rand.Add(draftIndex);

                index = rand.Get();
            }

            if (index != string.Empty)
            {
                VoteSuggestion[index].Invoke(null);
            }
            else
            {
                TwitchChat.Send("No votes...");
            }
        }
Ejemplo n.º 9
0
 //Fun part :p, Control what goes into the loot box! This is per item
 protected virtual void FillLootBox(WeightedRandom <LootBoxContents> WR)
 {
     WR.Add(new LootBoxContents(ItemID.TwilightDye, 5), 1);
     WR.Add(new LootBoxContents(ItemID.CoinGun, 1), 0.1);
     WR.Add(new LootBoxContents(ItemID.AleThrowingGlove, 1), 0.01);
     WR.Add(new LootBoxContents(ItemID.Handgun, 1), 4);
     loots.Add(WR.Get());
 }
Ejemplo n.º 10
0
        public string MushroomChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            chat.Add(Lang.TownNPCMushman("MushroomChat1"));
            chat.Add(Lang.TownNPCMushman("MushroomChat2"));
            chat.Add(Lang.TownNPCMushman("MushroomChat3"));
            return(chat);
        }
Ejemplo n.º 11
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            chat.Add("We don't have much resources here in our village, please reframe from any harvesting.");
            chat.Add("Is it as dangerous as they say it is outside the village?");
            chat.Add("you want a shop? What do i look like to you, a flocking minecraft villager? Oh, wait.");
            return(chat);
        }
Ejemplo n.º 12
0
 //Fun part :p, Control what goes into the loot box! This is per item
 protected override void FillLootBox(WeightedRandom <LootBoxContents> WR)
 {
     WR.Add(new LootBoxContents(ModContent.ItemType <DreadfulChalice>(), 1), 1);
     WR.Add(new LootBoxContents(ModContent.ItemType <DireKunai>(), 1), 1);
     WR.Add(new LootBoxContents(ModContent.ItemType <Nystagmus>(), 1), 1);
     WR.Add(new LootBoxContents(ModContent.ItemType <SentientTetherRemote>(), 1), 1);
     WR.Add(new LootBoxContents(ModContent.ItemType <HorizonStriderAegis>(), 1), 1);
     loots.Add(WR.Get());
 }
Ejemplo n.º 13
0
        // Consider using this alternate approach to choosing a random thing. Very useful for a variety of use cases.
        // The WeightedRandom class needs "using Terraria.Utilities;" to use
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            chat.Add("The birds. They are coming.");
            chat.Add("Ravens. Robins. Gulls.");
            chat.Add("They are calling for you.");
            chat.Add("The flock guides us all");
            return(chat);            // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
        }
Ejemplo n.º 14
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            int Goblin = NPC.FindFirstNPC(NPCID.GoblinTinkerer);

            if (Goblin >= 0 && Main.rand.Next(4) == 0)
            {
                chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat1") + Main.npc[Goblin].GivenName + Lang.TownNPCGoblinSlayer("GoblinSlayerChat2"));
            }
            int DD2Bartender = NPC.FindFirstNPC(NPCID.DD2Bartender);

            if (DD2Bartender >= 0 && Main.rand.Next(4) == 0)
            {
                return(Main.npc[DD2Bartender].GivenName + Lang.TownNPCGoblinSlayer("GoblinSlayerChat3"));
            }
            chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat4"));
            chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat5"));
            chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat6"));
            chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat7"));
            chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat8"));
            chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat9"));
            chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat10"));
            if (NPC.downedPirates || NPC.downedMartians || DownedBools.downedOgre)
            {
                chat.Add(Lang.TownNPCGoblinSlayer("GoblinSlayerChat11"));
            }
            return(chat);
        }
Ejemplo n.º 15
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            chat.Add(Lang.TownNPCAlpha("AlphaChat1"));
            chat.Add(Lang.TownNPCAlpha("AlphaChat2"));
            chat.Add(Lang.TownNPCAlpha("AlphaChat3"));
            chat.Add(Lang.TownNPCAlpha("AlphaChat4"));

            return(chat);
        }
Ejemplo n.º 16
0
        public override bool PreNPCLoot(VNPC npc)         // @TODO weighted money rates
        {
            WeightedRandom <double> wr = new WeightedRandom <double>();

            wr.Add(0.5, 30f);
            wr.Add(1, 50f);
            wr.Add(1.5, 15f);
            wr.Add(2, 5f);
            npc.npc.value = (int)(npc.npc.value * wr.Get());
            return(base.PreNPCLoot(npc));
        }
Ejemplo n.º 17
0
        // Consider using this alternate approach to choosing a random thing. Very useful for a variety of use cases.
        // The WeightedRandom class needs "using Terraria.Utilities;" to use
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            int npc = NPC.FindFirstNPC(NPCID.ArmsDealer);

            if (npc >= 0 && Main.rand.Next(2) == 0)
            {
                chat.Add(Main.npc[npc].GivenName + " thinks he's got the rare stuff, take a look at what I got.");
            }
            if (ModLoader.GetMod("CalamityMod") != null)
            {
                npc = NPC.FindFirstNPC(ModLoader.GetMod("CalamityMod").NPCType("FAP"));
                if (npc >= 0 && Main.rand.Next(2) == 0)
                {
                    chat.Add("I coulda swore I saw " + Main.npc[npc].GivenName + " riding some pastel pony, it might have just been those Unicorns around here, but that one had wings too!");
                }
            }
            if (ModLoader.GetMod("StartWithBase") != null)
            {
                chat.Add("I'm not going to make fun of your auto-generated base; if you are anything like me, I hate base building too.");
            }


            chat.Add("Pretty interesting little settlement you got here.");
            chat.Add("Your pretty brave to be talking to me.");
            chat.Add("Prove your mettle, and I might make it worth your time.");
            chat.Add("I hope you have... Deep pockets.");
            chat.Add("Why yes am I profiting off you, because you can't escape the middleman here.");
            chat.Add("Wrong? Pfff, when that one guy is standing in the way you kill them with rotten eggs! And you think what I do is wrong...");
            chat.Add("Me a fence? With what proof, it's not like guards instantly know where I am when I steal a sweetroll.");
            chat.Add("Sure I may be a recolor but atleast I don't use my vanity slots as storage.");
            chat.Add("No, I don't know about this 'Epic Store', stop asking me to sell stuff from it.");
            chat.Add("I'd like to see you try getting what I sell on your own.");
            chat.Add("I like to live on the edge, and part of that includes not living in your crude dwellings.");
            chat.Add("Only I would sell dragon bones, because I know 'he' would protect those creatures.");
            chat.Add("I don't magically get my wares without leaving, if your wondering why I'm not selling anything new after giving me requested items...", 2.0);
            chat.Add("After you have defeated powerful foes, Check back with me the next time I return as I may have something for you.", 2.0);
            chat.Add("If I require items, hold 'Shift' to give them to me, if I could fit a 4th dialog option in, I would.", 3.0);
            //chat.Add("This message has a weight of 5, meaning it appears 5 times more often.", 5.0);
            //chat.Add("This message has a weight of 0.1, meaning it appears 10 times as rare.", 0.1);

            if (Main.dayTime)
            {
                chat = new WeightedRandom <string>();
                chat.Add("Nothing for sale while the sun shines, it's blistering bright glow...");
                chat.Add("If you'll excuse me, I need to pack up and leave.");
                chat.Add("I'll be back another night, but my time is up for now.");
                chat.Add("Your a bit late arn't ya?");
            }

            return(chat);            // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
        }
Ejemplo n.º 18
0
        public override void NPCLoot()
        {
            var dropChooser = new WeightedRandom <int>();

            dropChooser.Add(ModContent.ItemType <Items.Weapons.Eligos.Attarax>());
            dropChooser.Add(ModContent.ItemType <Items.Weapons.Eligos.Vorax>());
            dropChooser.Add(ModContent.ItemType <Items.Weapons.Eligos.Rubico>());
            Item.NewItem(npc.getRect(), mod.ItemType("Veerium"), Main.rand.Next(8, 15));
            int choice = dropChooser;

            Item.NewItem(npc.getRect(), choice);
        }
Ejemplo n.º 19
0
        public override void OpenBossBag(Player player)
        {
            player.TryGettingDevArmor();
            if (Main.rand.NextBool(7))
            {
                // Mask
                //player.QuickSpawnItem(mod.ItemType(" "));
            }

            int[] drops =
            {
                mod.ItemType("GoldenGun"),
                mod.ItemType("SunPowerSeed"),
                mod.ItemType("BeskarBar")
            };
            var dropChooser = new WeightedRandom <int>();

            for (int i = 0; i < drops.Length; ++i)
            {
                dropChooser.Add(drops[i], 1);
            }
            int choice = dropChooser;

            if (choice == mod.ItemType("BeskarBar"))
            {
                player.QuickSpawnItem(choice, Main.rand.Next(5, 10));
            }
            else
            {
                player.QuickSpawnItem(choice);
            }
            dropChooser.Clear();
            for (int i = 0; i < drops.Length; ++i)
            {
                if (drops[i] != choice)
                {
                    dropChooser.Add(drops[i], 1);
                }
            }
            int choice2 = dropChooser;

            player.QuickSpawnItem(choice2);

            // Guaranteed drops
            player.QuickSpawnItem(ItemID.GoldCoin, Main.rand.Next(30, 50));
            player.QuickSpawnItem(mod.ItemType("BeskarOre"), Main.rand.Next(15, 20));
            // Expert
            //player.QuickSpawnItem(mod.ItemType("SunPowerSeed"));
            //if (player.GetModPlayer<EGGPlayer>().serums < EGGPlayer.maxSerums) {
            player.QuickSpawnItem(mod.ItemType("SerumResearch"));
            //}
        }
Ejemplo n.º 20
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();
            int wizard = NPC.FindFirstNPC(NPCID.Wizard);

            if (wizard >= 0)
            {
                chat.Add("I'm glad to see " + Main.npc[wizard].GivenName + " back");
            }
            chat.Add("Potions? Yes, I have some");
            chat.Add("Did you know that if you mix mushrooms with blinkroot, you can see the future!");
            chat.Add("You won't see potions better than mine");
            return(chat);
        }
Ejemplo n.º 21
0
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            if (NPC.FindFirstNPC(NPCID.DyeTrader) != -1)
            {
                chat.Add(Language.GetTextValue("Mods.EvanModpack.NPCDialog.AudioEngineer0", Main.npc[NPC.FindFirstNPC(NPCID.DyeTrader)].GivenName));
            }
            for (int i = 1; i < 7; ++i)
            {
                chat.Add(Language.GetText(string.Format("Mods.EvanModpack.NPCDialog.AudioEngineer{0}", i)).Value);
            }
            return(chat);
        }
Ejemplo n.º 22
0
        public static void BuildWeightedBuffsFor(Item item)
        {
            WeightedBuffs.Clear();
            foreach (string name in VitriumBuffs.Keys)
            {
                VitriBuff buff = TranslateVitri(name);

                if (buff.IApplicableTo(item))
                {
                    WeightedBuffs.Add(buff, buff.Weight);
                    WeightedBuffs.Add(null, buff.Weight * 0.25d);
                }
            }
        }
Ejemplo n.º 23
0
        /*public override void FindFrame(int frameHeight)
         * {
         *  npc.frameCounter += 1;
         *  npc.frameCounter %= 20;
         *  int frame = (int)(npc.frameCounter / 2.0);
         *  if(frame >= Main.npcFrameCount[npc.type])
         *  {
         *      frame = 0;
         *  }
         *  npc.frame.Y = frame * frameHeight;
         * }*/

        public override void NPCLoot()
        {
            if (Main.expertMode)
            {
                npc.DropBossBags();
            }
            else
            {
                if (Main.rand.NextBool(7))
                {
                    // Mask
                    //player.QuickSpawnItem(mod.ItemType(" "));
                }

                int[] drops =
                {
                    mod.ItemType("GoldenGun"),
                    mod.ItemType("SunPowerSeed"),
                    mod.ItemType("BeskarBar")
                };
                var dropChooser = new WeightedRandom <int>();
                for (int i = 0; i < drops.Length; ++i)
                {
                    dropChooser.Add(drops[i], 1);
                }
                int choice = dropChooser;
                player.QuickSpawnItem(choice);
                dropChooser.Clear();
                for (int i = 0; i < drops.Length; ++i)
                {
                    if (drops[i] != choice)
                    {
                        dropChooser.Add(drops[i], 1);
                    }
                }
                int choice2 = dropChooser;
                player.QuickSpawnItem(choice2);
                player.QuickSpawnItem(ItemID.GoldCoin, Main.rand.Next(15, 20));
                player.QuickSpawnItem(mod.ItemType("BeskarOre"), Main.rand.Next(15, 20));
            }
            SpawnOre();
            if (!EGGWorld.downedSunGod)
            {
                EGGWorld.downedSunGod = true;
                if (Main.netMode == NetmodeID.Server)
                {
                    NetMessage.SendData(MessageID.WorldData); // Immediately inform clients of new world state.
                }
            }
        }
Ejemplo n.º 24
0
        public override void NPCLoot(NPC npc)
        {
            EventWorld world = ModContent.GetInstance <EventWorld>();

            if (useTuple)
            {
                if (InvasionList.ContainsKey(npc.type))
                {
                    world.CurrentEvent.TimeLeft -= InvasionList[npc.type].Item2;
                }
            }

            if (Main.netMode == 1)
            {
                return;
            }

            if (IsItemPoolOverrided && ItemPool != null)
            {
                var rand = new WeightedRandom <int>();
                foreach (KeyValuePair <int, float> it in ItemPool)
                {
                    rand.Add(it.Key, it.Value);
                }
                if (rand.random.NextFloat(100) > 55)
                {
                    Item.NewItem(npc.position, npc.Size, rand.Get());
                }
            }
        }
Ejemplo n.º 25
0
        // Consider using this alternate approach to choosing a random thing. Very useful for a variety of use cases.
        // The WeightedRandom class needs "using Terraria.Utilities;" to use
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            chat.Add("Your common currency won't do for what I have.");
            return(chat); // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Method used to determine what is said to the player based on the Village reputation upon pressing the Reputation button.
        /// </summary>
        /// <returns>Returns a value telling the player to contact a mod dev by default.</returns>
        public virtual WeightedRandom <string> GetReputationText()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            chat.Add("If someone saw this text... I'd be scared and tell a mod dev immediately!");
            return(chat);
        }
Ejemplo n.º 27
0
        public Trait GetRandomTrait()
        {
            float totalWeight = 0;

            WeightedRandom <Trait> traitChooser = new WeightedRandom <Trait>();

            for (int i = 0; i < byIndex.Count; i++)
            {
                if (byIndex[i].Percentage < 0)
                {
                    continue;
                }

                totalWeight += byIndex[i].Percentage;
                traitChooser.Add(byIndex[i], byIndex[i].Percentage);
            }

            UnifiedRandom rand = Main.rand;

            if (rand == null)
            {
                rand = new UnifiedRandom();
            }

            int roll = rand.Next(0, 100);

            if (roll <= totalWeight)
            {
                Trait trait = traitChooser;
                return(trait);
            }

            return(Default);
        }
Ejemplo n.º 28
0
        // Consider using this alternate approach to choosing a random thing. Very useful for a variety of use cases.
        // The WeightedRandom class needs "using Terraria.Utilities;" to use
        public override string GetChat()
        {
            WeightedRandom <string> chat = new WeightedRandom <string>();

            chat.Add("Offer bags with various loot once you have killed certain bossed. You can open each bag ONLY ONCE.");
            return(chat);
        }
Ejemplo n.º 29
0
 public static void ConditionalStringAdd <T>(this WeightedRandom <T> weightedRandom, T curType, bool boolean, double weight = 1)
 {
     if (boolean)
     {
         weightedRandom.Add(curType, weight);
     }
 }
Ejemplo n.º 30
0
 void prepare()
 {
     mGroupsHaveDepth = false;
     m_RepeatingGroups.MakePositive();
     m_RepeatingGroups.Clamp(0, GroupCount - 1);
     // Groups
     if (mGroupBag == null)
     {
         mGroupBag = new WeightedRandom <int>();
     }
     else
     {
         mGroupBag.Clear();
     }
     if (RepeatingOrder == CurvyRepeatingOrderEnum.Random)
     {
         for (int g = FirstRepeating; g <= LastRepeating; g++)
         {
             mGroupBag.Add(g, (int)(Groups[g].Weight * 10));
         }
     }
     // Prepare Groups & ItemBags
     for (int g = 0; g < Groups.Count; g++)
     {
         Groups[g].PrepareINTERNAL();
         mGroupsHaveDepth = mGroupsHaveDepth || (getMinGroupDepth(Groups[g]) > 0);
     }
 }