Example #1
0
        public override int ChoosePrefix(UnifiedRandom rand)
        {
            /*
             * I changed this so it would be impossible to get a non-melee prefix
             */

            int  roll = rand.Next(41);
            byte pfix;

            if (roll <= 15)
            {
                pfix = (byte)rand.Next(1, 15);
            }
            else if (roll <= 31)
            {
                pfix = (byte)rand.Next(36, 51);
            }
            else if (roll <= 36)
            {
                pfix = (byte)rand.Next(53, 57);
            }
            else if (roll <= 39)
            {
                pfix = (byte)rand.Next(59, 61);
            }
            else
            {
                pfix      = (byte)81;
                item.rare = 10;                 //This is to have the reforged moonstone show up bright purple if Legendary so it will contrast the other colors
            }

            return(pfix);
        }
        ////

        private static ChestImplanterDefinition GetRandomImplanterFromSet(ChestImplanterSetDefinition setDef)
        {
            if (setDef.Value.Count == 0)
            {
                return(null);
            }

            UnifiedRandom rand           = TmlHelpers.SafelyGetRand();
            float         totalWeight    = setDef.TotalWeight();
            float         randPick       = rand.NextFloat() * totalWeight;
            float         countedWeights = 0;

            for (int i = 0; i < setDef.Value.Count; i++)
            {
                countedWeights += setDef.Value[i].Value.Weight;

                if (countedWeights > randPick)
                {
                    return(setDef.Value[i].Value);
                }
            }

            LogHelpers.Warn("Could not randomly pick from implanter set. Total weight " + countedWeights + " of " + setDef.Value.Count + " implanters.");
            return(null);
        }
        public override int ChoosePrefix(Item item, UnifiedRandom rand)
        {
            int randValue = rand.Next(4);

            if (item.accessory && rand.Next(15) == 0)
            {
                switch (randValue)
                {
                case 0:
                    return(mod.PrefixType("Natural"));

                case 1:
                    return(mod.PrefixType("Spiritual"));

                case 2:
                    return(mod.PrefixType("Brewing"));

                case 3:
                    return(mod.PrefixType("Loaded"));

                case 4:
                    return(mod.PrefixType("Crooked"));

                default:
                    break;
                }
            }
            return(-1);
        }
        public static void ThrowPieces(Vector2 MoonlordCoreCenter, int DramaSeed)
        {
            var r         = new UnifiedRandom(DramaSeed);
            var vector2_1 = Vector2.UnitY.RotatedBy(
                (double)r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257, new Vector2());

            MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(
                                               TextureManager.Load("Images/Misc/MoonExplosion/Spine"), new Vector2(64f, 150f),
                                               MoonlordCoreCenter + new Vector2(0.0f, 50f), vector2_1 * 6f, 0.0f,
                                               (float)((double)r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
            var vector2_2 = Vector2.UnitY.RotatedBy(
                (double)r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257, new Vector2());

            MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(
                                               TextureManager.Load("Images/Misc/MoonExplosion/Shoulder"), new Vector2(40f, 120f),
                                               MoonlordCoreCenter + new Vector2(50f, -120f), vector2_2 * 10f, 0.0f,
                                               (float)((double)r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
            var vector2_3 = Vector2.UnitY.RotatedBy(
                (double)r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257, new Vector2());

            MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(
                                               TextureManager.Load("Images/Misc/MoonExplosion/Torso"), new Vector2(192f, 252f), MoonlordCoreCenter,
                                               vector2_3 * 8f, 0.0f, (float)((double)r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
            var vector2_4 = Vector2.UnitY.RotatedBy(
                (double)r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257, new Vector2());

            MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(
                                               TextureManager.Load("Images/Misc/MoonExplosion/Head"), new Vector2(138f, 185f),
                                               MoonlordCoreCenter - new Vector2(0.0f, 200f), vector2_4 * 12f, 0.0f,
                                               (float)((double)r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
        }
Example #5
0
 public static void DropItemForEachInteractingPlayerOnThePlayer(
     NPC npc,
     int itemId,
     UnifiedRandom rng,
     int dropsAtXOutOfY_TheX,
     int dropsAtXOutOfY_TheY,
     int stack = 1,
     bool interactionRequired = true)
 {
     if (itemId <= 0 || itemId >= 5043)
     {
         return;
     }
     if (Main.netMode == 2)
     {
         for (int index = 0; index < (int)byte.MaxValue; ++index)
         {
             Player player = Main.player[index];
             if (player.active && (npc.playerInteraction[index] || !interactionRequired) && rng.Next(dropsAtXOutOfY_TheY) < dropsAtXOutOfY_TheX)
             {
                 int itemIndex = Item.NewItem(player.position, player.Size, itemId, stack, false, -1, false, false);
                 CommonCode.ModifyItemDropFromNPC(npc, itemIndex);
             }
         }
     }
     else if (rng.Next(dropsAtXOutOfY_TheY) < dropsAtXOutOfY_TheX)
     {
         CommonCode.DropItemFromNPC(npc, itemId, stack, false);
     }
     npc.value = 0.0f;
 }
        public override int ChoosePrefix(Item item, UnifiedRandom rand)
        {
            if (item.accessory && item.stack == 1 && rand.NextBool(40))
            {
                string pref = "Yeeting";
                switch (rand.Next(4))
                {
                case 0:
                    pref = "Swift";
                    break;

                case 1:
                    pref = "Speedy";
                    break;

                case 2:
                    pref = "Zippy";
                    break;

                default:
                    pref = "Yeeting";
                    break;
                }
                return(mod.PrefixType(pref));
            }
            return(-1);
        }
        ////

        private bool RunBloom()
        {
            if (this.Cooldown++ > 20)
            {
                this.Cooldown = 0;
            }
            else
            {
                return(false);
            }

            int           nearby;
            UnifiedRandom rand = TmlHelpers.SafelyGetRand();

            foreach (BrambleBloomTendril tendril in this.Tendrils.ToArray())
            {
                if (tendril.IsSplit())
                {
                    this.Tendrils.Add(tendril.CloneAsSplit());
                }

                (int x, int y)growAt = tendril.Grow();
                nearby = this.CountBramblesNear(growAt.x, growAt.y) + 1;

                if (nearby <= 1 || rand.NextFloat() < (1f - ((float)nearby / 10f)))
                {
                    CursedBrambleTile.CreateBrambleAt(growAt.x, growAt.y);
                }
            }

            return(true);
        }
Example #8
0
		public override int ChoosePrefix(UnifiedRandom rand)
		{
		
			/*
			I changed this so it would be impossible to get a non-ranged prefix
			*/
		
			int roll = rand.Next(37);
			byte pfix;
			
			if (roll <= 10)
			{
				pfix = (byte)rand.Next(16, 25);
			}
			else if (roll <= 26)
			{
				pfix = (byte)rand.Next(36, 51);
			}
			else if (roll <= 35)
			{
				pfix = (byte)rand.Next(53, 61);
			}
			else
			{
				pfix = (byte)82;
				item.rare = 10;//This is to have the reforged moonstone show up bright purple if Unreal so it will contrast the other colors

			}
			
			return pfix;//This is to have the reforged moonstone show up bright purple if Legendary so it will contrast the other colors
			}
        public static ElementDefinition PickDefinitionForNPC(float chanceForAny)
        {
            UnifiedRandom rand = TmlHelpers.SafelyGetRand();

            if (rand.NextFloat() > chanceForAny)
            {
                return(null);
            }

            var   elements    = ElementsConfig.Instance.Elements;
            float totalWeight = ElementDefinition.GetTotalElementNPCAutoAssignWeight();
            float weight      = rand.NextFloat() * totalWeight;

            float countedWeights = 0f;

            for (int i = 0; i < elements.Count; i++)
            {
                countedWeights += elements[i].AutoAssignNPCWeight;
                if (weight < countedWeights)
                {
                    return(elements[i]);
                }
            }

            return(null);
        }
Example #10
0
        //Don't want Vanilla Prefixes, will have Prefixes of our own that are more like Borderlands' Prefixes
        public override bool?PrefixChance(int pre, UnifiedRandom rand)
        {
            if (pre == -1)
            {
                GetAvailablePrefixes();
                if (itemPrefix == TLPrefixList.Default)
                {
                    itemPrefix = availablePrefixes.Get();
                    item.SetNameOverride(GetAdjustedName());
                }
                if (itemSuffix == TLSuffixList.Default)
                {
                    itemSuffix = TLSuffixList.GetRandomSuffix();
                    item.SetNameOverride(GetAdjustedName());
                }
                GetAvailableElements();
                if (itemElement == ElementType.Default)
                {
                    itemElement = availableElements.Get();
                }
                return(false);
            }

            else if (pre == -3)
            {
                return(false);
            }

            return(null);
        }
Example #11
0
        internal IList <Projectile> GetProjPool()
        {
            if (this.ProjPool != null)
            {
                return(this.ProjPool);
            }

            var list = new Projectile[ProjectileLoader.ProjectileCount];

            list[0] = null;

            UnifiedRandom oldRand = Main.rand;

            Main.rand = new UnifiedRandom();

            for (int i = 1; i < ProjectileLoader.ProjectileCount; i++)
            {
                list[i] = new Projectile();

                try {
                    list[i].SetDefaults(i);
                } catch (Exception e) {
                    LogHelpers.Log("GetProjPool " + i + " - " + e.ToString());
                }
            }

            Main.rand = oldRand;

            this.ProjPool = new List <Projectile>(list);
            return(this.ProjPool);
        }
Example #12
0
 public override int ChoosePrefix(Item item, UnifiedRandom rand)
 {
     if (item.damage > 0 && item.maxStack == 1)
     {
         if (rand.NextBool(30) && DRGNModWorld.MentalMode)
         {
             return(mod.PrefixType("Mental"));
         }
     }
     else if (item.accessory && item.maxStack == 1)
     {
         if (rand.NextBool(30))
         {
             return(mod.PrefixType("Wrathful"));
         }
         if (rand.NextBool(30))
         {
             return(mod.PrefixType("Shielding"));
         }
         if (rand.NextBool(30))
         {
             return(mod.PrefixType("Weighted"));
         }
         if (rand.NextBool(30))
         {
             return(mod.PrefixType("Rapid"));
         }
         if (rand.NextBool(30))
         {
             return(mod.PrefixType("Beserk"));
         }
     }
     return(-1);
 }
Example #13
0
        public override int ChoosePrefix(UnifiedRandom rand)
        {
            int  roll = rand.Next(37);
            byte pfix;

            if (roll <= 10)
            {
                pfix = (byte)rand.Next(16, 26);
            }
            else if (roll <= 26)
            {
                pfix = (byte)rand.Next(36, 52);
            }
            else if (roll <= 35)
            {
                pfix = (byte)rand.Next(53, 62);
            }
            else
            {
                pfix      = (byte)82;
                item.rare = 10;
            }

            return(pfix);
        }
 public override int ChoosePrefix(Item item, UnifiedRandom rand)
 {
     if (item.damage > 1 && !item.accessory && item.notAmmo == true && GetInstance <AzercadmiumConfig>().azercadmiumPrefixes)
     {
         if (Main.rand.Next(25) == 0)
         {
             return(ModContent.PrefixType <Rough>());
         }
         if (Main.rand.Next(30) == 0)
         {
             return(ModContent.PrefixType <Blessed>());
         }
         if (Main.rand.Next(30) == 0)
         {
             return(ModContent.PrefixType <Cursed>());
         }
         if (item.knockBack > 0)
         {
             if (Main.rand.Next(30) == 0)
             {
                 return(ModContent.PrefixType <Epic>());
             }
             if (Main.rand.Next(30) == 0)
             {
                 return(ModContent.PrefixType <Odd>());
             }
             if (Main.rand.Next(30) == 0)
             {
                 return(ModContent.PrefixType <Egotistical>());
             }
             if (Main.rand.Next(75) == 0)
             {
                 return(ModContent.PrefixType <Exotic>());
             }
         }
         if (item.melee)
         {
             if (Main.rand.Next(30) == 0)
             {
                 return(ModContent.PrefixType <Tremendous>());
             }
             if (Main.rand.Next(30) == 0)
             {
                 return(ModContent.PrefixType <Atomic>());
             }
         }
         if (item.ranged)
         {
             if (Main.rand.Next(30) == 0)
             {
                 return(ModContent.PrefixType <Wasted>());
             }
             if (Main.rand.Next(30) == 0)
             {
                 return(ModContent.PrefixType <Empowered>());
             }
         }
     }
     return(-1);
 }
        private static Ambush CreateRandomWorldAmbush(int maxAttempts)
        {
            int           attempts = 0;
            int           randTileX, randTileY;
            UnifiedRandom rand = TmlHelpers.SafelyGetRand();

            do
            {
                randTileX = rand.Next(64, Main.maxTilesX - 64);
                randTileY = rand.Next((int)Main.worldSurface, Main.maxTilesY - 220);

                if (Ambush.CheckForAmbushElegibility(randTileX, randTileY))
                {
                    break;
                }
            } while(attempts++ < maxAttempts);

            if (attempts >= maxAttempts)
            {
                return(null);
            }

            Ambush.AdjustAmbushTileCenter(randTileX, ref randTileY);
            return(Ambush.CreateRandomType(randTileX, randTileY));
        }
Example #16
0
        public override int ChoosePrefix(Item item, UnifiedRandom rand)
        {
            //resetting for custom prefix stuff
            prefixLine = "";

            return(-1);
        }
        protected CustomParticle(
            bool isInWorld,
            Vector2 pos,
            int tickDuration,
            Color color,
            float scale,
            float sprayAmt,
            bool hasGravity)
        {
            this.IsInWorld    = isInWorld;
            this.Position     = pos;
            this.TickDuration = tickDuration;
            this.Color        = color;
            this.Scale        = scale;
            this.SprayAmt     = sprayAmt;
            this.HasGravity   = hasGravity;

            UnifiedRandom rand = TmlLibraries.SafelyGetRand();

            this.Velocity = new Vector2(
                (rand.NextFloat() - 0.5f) * this.SprayAmt,
                (rand.NextFloat() - 0.5f) * this.SprayAmt
                );
            this.RotVelocity = rand.NextFloat() - 0.5f;
        }
Example #18
0
        public static Vector2 NextVec2CircularEven(this UnifiedRandom rand, float halfWidth, float halfHeight)
        {
            double x = rand.NextDouble();
            double y = rand.NextDouble();

            if (x + y > 1)
            {
                x = 1 - x;
                y = 1 - y;
            }

            double s = 1 / (x + y);

            if (double.IsNaN(s))
            {
                return(Vector2.Zero);
            }

            s *= s;
            s  = Math.Sqrt(x * x * s + y * y * s);
            s  = 1 / s;

            x *= s;
            y *= s;

            double angle = rand.NextDouble() * (2 * Math.PI);
            double cos   = Math.Cos(angle);
            double sin   = Math.Sin(angle);

            return(new Vector2((float)(x * cos - y * sin) * halfWidth, (float)(x * sin + y * cos) * halfHeight));
        }
Example #19
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);
        }
Example #20
0
        public override int ChoosePrefix(UnifiedRandom rand)
        {
            /*
             * I changed this so it would be impossible to get a non-arcane prefix
             */

            int  roll = rand.Next(37);
            byte pfix;

            if (roll <= 32)
            {
                pfix = (byte)rand.Next(26, 57);
            }
            else if (roll <= 35)
            {
                pfix = (byte)rand.Next(59, 61);
            }
            else
            {
                pfix      = (byte)83;
                item.rare = 10;                 //This is to have the reforged moonstone show up bright purple if Mythical so it will contrast the other colors
            }

            return(pfix);
        }
Example #21
0
        public override int ChoosePrefix(UnifiedRandom rand)
        {
            int  roll = rand.Next(41);
            byte pfix;

            if (roll <= 15)
            {
                pfix = (byte)rand.Next(1, 16);
            }
            else if (roll <= 31)
            {
                pfix = (byte)rand.Next(36, 52);
            }
            else if (roll <= 36)
            {
                pfix = (byte)rand.Next(53, 58);
            }
            else if (roll <= 39)
            {
                pfix = (byte)rand.Next(59, 62);
            }
            else
            {
                pfix      = (byte)81;
                item.rare = 10;
            }

            return(pfix);
        }
 public override int ChoosePrefix(Item item, UnifiedRandom rand)
 {
     if ((item.accessory || item.damage > 0) && item.maxStack == 1 && rand.NextBool(30))
     {
         //return mod.PrefixType(rand.Next(2) == 0 ? "Terrifying" : "Truly Terrifying");
     }
     return(-1);
 }
        public static float ComputeAimShakeRadiansOffsetWithinCone()
        {
            var           config   = TMRConfig.Instance;
            UnifiedRandom rand     = TmlLibraries.SafelyGetRand();
            float         radRange = MathHelper.ToRadians(config.Get <float>(nameof(TMRConfig.UnaimedConeDegreesRange)));

            return((rand.NextFloat() * radRange) - (radRange * 0.5f));
        }
Example #24
0
 public override bool?PrefixChance(int pre, UnifiedRandom rand)
 {
     if (pre == -1)
     {
         return(true);
     }
     return(base.PrefixChance(pre, rand));
 }
        public override int ChoosePrefix(UnifiedRandom rand)
        {
            byte roll = (byte)rand.Next(1, 65);

            // Legendary = 81; Unreal = 82; Mythical = 83;
            // Therefore those are mapped to 62, 63, 64 (thus the + 19 in the following line)
            return(roll <= 61 ? roll : roll + 19);
        }
Example #26
0
 public override bool?PrefixChance(int pre, UnifiedRandom rand)
 {
     if (pre == -3 || pre == -1)
     {
         return(false);
     }
     return(base.AllowPrefix(pre));
 }
Example #27
0
 public override int ChoosePrefix(Item item, UnifiedRandom rand)
 {
     if (ClickerPrefix.DoConditionsApply(item))
     {
         return(rand.Next(ClickerPrefix.ClickerPrefixes));
     }
     return(base.ChoosePrefix(item, rand));
 }
Example #28
0
 public override int ChoosePrefix(Item item, UnifiedRandom rand)
 {
     if ((item.accessory || item.damage > 0) && item.maxStack == 1 && rand.NextBool(30))
     {
         return(mod.PrefixType(rand.Next(2) == 0 ? "Awesome" : "ReallyAwesome"));
     }
     return(-1);
 }
Example #29
0
        /// <summary> Returns true 1 out of X times. </summary>
        public static bool NextBool(this UnifiedRandom r, int consequent)
        {
            if (consequent < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(consequent), "consequent must be greater than or equal to 1.");
            }

            return(r.Next(consequent) == 0);
        }
Example #30
0
        /// <summary> Returns true X out of Y times. </summary>
        public static bool NextBool(this UnifiedRandom r, int antecedent, int consequent)
        {
            if (antecedent > consequent)
            {
                throw new ArgumentOutOfRangeException(nameof(antecedent), "antecedent must be less than or equal to consequent.");
            }

            return(r.Next(consequent) < antecedent);
        }