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

◆ NPCLoot_DropMoney()

void Terraria.NPC.NPCLoot_DropMoney ( Player closestPlayer)
inlineprivate

Definition at line 85239 of file NPC.cs.

85240 {
85241 float num = 0f;
85242 float luck = closestPlayer.luck;
85243 int num2 = 1;
85244 if (Main.rand.NextFloat() < Math.Abs(luck))
85245 {
85246 num2 = 2;
85247 }
85248 for (int i = 0; i < num2; i++)
85249 {
85250 float num3 = value;
85251 if (midas)
85252 {
85253 num3 *= 1f + (float)Main.rand.Next(10, 51) * 0.01f;
85254 }
85255 num3 *= 1f + (float)Main.rand.Next(-20, 76) * 0.01f;
85256 if (Main.rand.Next(2) == 0)
85257 {
85258 num3 *= 1f + (float)Main.rand.Next(5, 11) * 0.01f;
85259 }
85260 if (Main.rand.Next(4) == 0)
85261 {
85262 num3 *= 1f + (float)Main.rand.Next(10, 21) * 0.01f;
85263 }
85264 if (Main.rand.Next(8) == 0)
85265 {
85266 num3 *= 1f + (float)Main.rand.Next(15, 31) * 0.01f;
85267 }
85268 if (Main.rand.Next(16) == 0)
85269 {
85270 num3 *= 1f + (float)Main.rand.Next(20, 41) * 0.01f;
85271 }
85272 if (Main.rand.Next(32) == 0)
85273 {
85274 num3 *= 1f + (float)Main.rand.Next(25, 51) * 0.01f;
85275 }
85276 if (Main.rand.Next(64) == 0)
85277 {
85278 num3 *= 1f + (float)Main.rand.Next(50, 101) * 0.01f;
85279 }
85280 if (Main.bloodMoon)
85281 {
85282 num3 *= 1f + (float)Main.rand.Next(101) * 0.01f;
85283 }
85284 if (i == 0)
85285 {
85286 num = num3;
85287 }
85288 else if (luck < 0f)
85289 {
85290 if (num3 < num)
85291 {
85292 num = num3;
85293 }
85294 }
85295 else if (num3 > num)
85296 {
85297 num = num3;
85298 }
85299 }
85300 num += (float)extraValue;
85301 while ((int)num > 0)
85302 {
85303 if (num > 1000000f)
85304 {
85305 int num4 = (int)(num / 1000000f);
85306 if (num4 > 50 && Main.rand.Next(5) == 0)
85307 {
85308 num4 /= Main.rand.Next(3) + 1;
85309 }
85310 if (Main.rand.Next(5) == 0)
85311 {
85312 num4 /= Main.rand.Next(3) + 1;
85313 }
85314 int num5 = num4;
85315 while (num5 > 999)
85316 {
85317 num5 -= 999;
85318 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 74, 999);
85319 }
85320 num -= (float)(1000000 * num4);
85321 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 74, num5);
85322 }
85323 else if (num > 10000f)
85324 {
85325 int num6 = (int)(num / 10000f);
85326 if (num6 > 50 && Main.rand.Next(5) == 0)
85327 {
85328 num6 /= Main.rand.Next(3) + 1;
85329 }
85330 if (Main.rand.Next(5) == 0)
85331 {
85332 num6 /= Main.rand.Next(3) + 1;
85333 }
85334 num -= (float)(10000 * num6);
85335 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 73, num6);
85336 }
85337 else if (num > 100f)
85338 {
85339 int num7 = (int)(num / 100f);
85340 if (num7 > 50 && Main.rand.Next(5) == 0)
85341 {
85342 num7 /= Main.rand.Next(3) + 1;
85343 }
85344 if (Main.rand.Next(5) == 0)
85345 {
85346 num7 /= Main.rand.Next(3) + 1;
85347 }
85348 num -= (float)(100 * num7);
85349 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 72, num7);
85350 }
85351 else
85352 {
85353 int num8 = (int)num;
85354 if (num8 > 50 && Main.rand.Next(5) == 0)
85355 {
85356 num8 /= Main.rand.Next(3) + 1;
85357 }
85358 if (Main.rand.Next(5) == 0)
85359 {
85360 num8 /= Main.rand.Next(4) + 1;
85361 }
85362 if (num8 < 1)
85363 {
85364 num8 = 1;
85365 }
85366 num -= (float)num8;
85367 Item.NewItem(GetItemSource_Loot(), (int)position.X, (int)position.Y, width, height, 71, num8);
85368 }
85369 }
85370 }
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
int extraValue
Definition NPC.cs:1158
bool midas
Definition NPC.cs:660
float value
How many copper coins the NPC will drop when killed (100 copper coins = 1 silver coin etc....
Definition NPC.cs:1156
IEntitySource GetItemSource_Loot()
Definition NPC.cs:107573

References Terraria.Main.bloodMoon, Terraria.Item.NewItem(), and Terraria.Main.rand.

Referenced by Terraria.NPC.NPCLoot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: