Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ NPCLoot_DropMoney()

void Terraria.NPC.NPCLoot_DropMoney ( Player closestPlayer)
inlineprivate

Definition at line 71825 of file NPC.cs.

71826 {
71827 float num = 0f;
71828 float luck = closestPlayer.luck;
71829 int num2 = 1;
71830 if (Main.rand.NextFloat() < Math.Abs(luck))
71831 {
71832 num2 = 2;
71833 }
71834 for (int i = 0; i < num2; i++)
71835 {
71836 float num3 = value;
71837 if (midas)
71838 {
71839 num3 *= 1f + (float)Main.rand.Next(10, 51) * 0.01f;
71840 }
71841 num3 *= 1f + (float)Main.rand.Next(-20, 76) * 0.01f;
71842 if (Main.rand.Next(2) == 0)
71843 {
71844 num3 *= 1f + (float)Main.rand.Next(5, 11) * 0.01f;
71845 }
71846 if (Main.rand.Next(4) == 0)
71847 {
71848 num3 *= 1f + (float)Main.rand.Next(10, 21) * 0.01f;
71849 }
71850 if (Main.rand.Next(8) == 0)
71851 {
71852 num3 *= 1f + (float)Main.rand.Next(15, 31) * 0.01f;
71853 }
71854 if (Main.rand.Next(16) == 0)
71855 {
71856 num3 *= 1f + (float)Main.rand.Next(20, 41) * 0.01f;
71857 }
71858 if (Main.rand.Next(32) == 0)
71859 {
71860 num3 *= 1f + (float)Main.rand.Next(25, 51) * 0.01f;
71861 }
71862 if (Main.rand.Next(64) == 0)
71863 {
71864 num3 *= 1f + (float)Main.rand.Next(50, 101) * 0.01f;
71865 }
71866 if (Main.bloodMoon)
71867 {
71868 num3 *= 1f + (float)Main.rand.Next(101) * 0.01f;
71869 }
71870 if (i == 0)
71871 {
71872 num = num3;
71873 }
71874 else if (luck < 0f)
71875 {
71876 if (num3 < num)
71877 {
71878 num = num3;
71879 }
71880 }
71881 else if (num3 > num)
71882 {
71883 num = num3;
71884 }
71885 }
71886 num += (float)extraValue;
71887 while ((int)num > 0)
71888 {
71889 if (num > 1000000f)
71890 {
71891 int num4 = (int)(num / 1000000f);
71892 if (num4 > 50 && Main.rand.Next(5) == 0)
71893 {
71894 num4 /= Main.rand.Next(3) + 1;
71895 }
71896 if (Main.rand.Next(5) == 0)
71897 {
71898 num4 /= Main.rand.Next(3) + 1;
71899 }
71900 int num5 = num4;
71901 while (num5 > 999)
71902 {
71903 num5 -= 999;
71904 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 74, 999);
71905 }
71906 num -= (float)(1000000 * num4);
71907 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 74, num5);
71908 }
71909 else if (num > 10000f)
71910 {
71911 int num6 = (int)(num / 10000f);
71912 if (num6 > 50 && Main.rand.Next(5) == 0)
71913 {
71914 num6 /= Main.rand.Next(3) + 1;
71915 }
71916 if (Main.rand.Next(5) == 0)
71917 {
71918 num6 /= Main.rand.Next(3) + 1;
71919 }
71920 num -= (float)(10000 * num6);
71921 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 73, num6);
71922 }
71923 else if (num > 100f)
71924 {
71925 int num7 = (int)(num / 100f);
71926 if (num7 > 50 && Main.rand.Next(5) == 0)
71927 {
71928 num7 /= Main.rand.Next(3) + 1;
71929 }
71930 if (Main.rand.Next(5) == 0)
71931 {
71932 num7 /= Main.rand.Next(3) + 1;
71933 }
71934 num -= (float)(100 * num7);
71935 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 72, num7);
71936 }
71937 else
71938 {
71939 int num8 = (int)num;
71940 if (num8 > 50 && Main.rand.Next(5) == 0)
71941 {
71942 num8 /= Main.rand.Next(3) + 1;
71943 }
71944 if (Main.rand.Next(5) == 0)
71945 {
71946 num8 /= Main.rand.Next(4) + 1;
71947 }
71948 if (num8 < 1)
71949 {
71950 num8 = 1;
71951 }
71952 num -= (float)num8;
71953 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 71, num8);
71954 }
71955 }
71956 }
static double Abs(double value)
Vector2 position
Definition Entity.cs:14
int extraValue
Definition NPC.cs:525
bool midas
Definition NPC.cs:221
float value
Definition NPC.cs:523
IEntitySource GetItemSource_Loot()
Definition NPC.cs:87551

References System.Math.Abs(), Terraria.Main.bloodMoon, Terraria.Item.NewItem(), Terraria.Main.rand, and System.value.

Referenced by Terraria.NPC.NPCLoot().