Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ AddBuriedChest() [1/2]

static bool Terraria.WorldGen.AddBuriedChest ( int i,
int j,
int contain = 0,
bool notNearOtherChests = false,
int Style = -1,
bool trySlope = false,
ushort chestTileType = 0 )
inlinestatic

Definition at line 30940 of file WorldGen.cs.

30941 {
30942 if (chestTileType == 0)
30943 {
30944 chestTileType = 21;
30945 }
30946 bool flag = false;
30947 bool flag2 = false;
30948 bool flag3 = false;
30949 bool flag4 = false;
30950 bool flag5 = false;
30951 bool flag6 = false;
30952 bool flag7 = false;
30953 bool flag8 = false;
30954 bool flag9 = false;
30955 bool flag10 = false;
30956 int num = 15;
30958 {
30959 num *= 3;
30960 }
30961 for (int k = j; k < Main.maxTilesY - 10; k++)
30962 {
30963 int num2 = -1;
30964 int num3 = -1;
30965 if (Main.tile[i, k].shimmer())
30966 {
30967 return false;
30968 }
30969 if (trySlope && Main.tile[i, k].active() && Main.tileSolid[Main.tile[i, k].type] && !Main.tileSolidTop[Main.tile[i, k].type])
30970 {
30971 if (Style == 17)
30972 {
30973 int num4 = 30;
30974 for (int l = i - num4; l <= i + num4; l++)
30975 {
30976 for (int m = k - num4; m <= k + num4; m++)
30977 {
30978 if (!InWorld(l, m, 5))
30979 {
30980 return false;
30981 }
30982 if (Main.tile[l, m].active() && (Main.tile[l, m].type == 21 || Main.tile[l, m].type == 467))
30983 {
30984 return false;
30985 }
30986 }
30987 }
30988 }
30989 if (Main.tile[i - 1, k].topSlope())
30990 {
30991 num2 = Main.tile[i - 1, k].slope();
30992 Main.tile[i - 1, k].slope(0);
30993 }
30994 if (Main.tile[i, k].topSlope())
30995 {
30996 num3 = Main.tile[i, k].slope();
30997 Main.tile[i, k].slope(0);
30998 }
30999 }
31000 if (remixWorldGen && (double)i > (double)Main.maxTilesX * 0.37 && (double)i < (double)Main.maxTilesX * 0.63 && k > Main.maxTilesY - 250)
31001 {
31002 return false;
31003 }
31004 int num5 = 2;
31005 for (int n = i - num5; n <= i + num5; n++)
31006 {
31007 for (int num6 = k - num5; num6 <= k + num5; num6++)
31008 {
31009 if (Main.tile[n, num6].active() && (TileID.Sets.Boulders[Main.tile[n, num6].type] || Main.tile[n, num6].type == 26 || Main.tile[n, num6].type == 237))
31010 {
31011 return false;
31012 }
31013 }
31014 }
31015 if (!SolidTile(i, k))
31016 {
31017 continue;
31018 }
31019 bool flag11 = false;
31020 int num7 = k;
31021 int num8 = -1;
31022 int num9 = 0;
31023 bool flag12 = (double)num7 >= Main.worldSurface + 25.0;
31024 if (remixWorldGen)
31025 {
31026 flag12 = num7 < Main.maxTilesY - 400;
31027 }
31028 if (flag12 || contain > 0)
31029 {
31030 num9 = 1;
31031 }
31032 if (Style >= 0)
31033 {
31034 num9 = Style;
31035 }
31036 if ((chestTileType == 467 && num9 == 10) || (contain == 0 && num7 <= Main.maxTilesY - 205 && IsUndergroundDesert(i, k)))
31037 {
31038 flag2 = true;
31039 num9 = 10;
31040 chestTileType = 467;
31041 contain = ((num7 <= (GenVars.desertHiveHigh * 3 + GenVars.desertHiveLow * 4) / 7) ? Utils.SelectRandom(genRand, new short[4] { 4056, 4055, 4262, 4263 }) : Utils.SelectRandom(genRand, new short[3] { 4061, 4062, 4276 }));
31042 if (getGoodWorldGen && genRand.Next(num) == 0)
31043 {
31044 contain = 52;
31045 }
31046 }
31047 if (chestTileType == 21 && (num9 == 11 || (contain == 0 && (double)num7 >= Main.worldSurface + 25.0 && num7 <= Main.maxTilesY - 205 && (Main.tile[i, k].type == 147 || Main.tile[i, k].type == 161 || Main.tile[i, k].type == 162))))
31048 {
31049 flag = true;
31050 num9 = 11;
31051 contain = genRand.Next(6) switch
31052 {
31053 0 => 670,
31054 1 => 724,
31055 2 => 950,
31056 3 => (!remixWorldGen) ? 1319 : 725,
31057 4 => 987,
31058 _ => 1579,
31059 };
31060 if (genRand.Next(20) == 0)
31061 {
31062 contain = 997;
31063 }
31064 if (genRand.Next(50) == 0)
31065 {
31066 contain = 669;
31067 }
31068 if (getGoodWorldGen && genRand.Next(num) == 0)
31069 {
31070 contain = 52;
31071 }
31072 }
31073 if (chestTileType == 21 && (Style == 10 || contain == 211 || contain == 212 || contain == 213 || contain == 753))
31074 {
31075 flag3 = true;
31076 num9 = 10;
31077 if (getGoodWorldGen && genRand.Next(num) == 0)
31078 {
31079 contain = 52;
31080 }
31081 }
31082 if (chestTileType == 21 && num7 > Main.maxTilesY - 205 && contain == 0)
31083 {
31084 flag7 = true;
31086 num9 = 4;
31087 flag11 = true;
31088 if (getGoodWorldGen && genRand.Next(num) == 0)
31089 {
31090 contain = 52;
31091 }
31092 }
31093 if (chestTileType == 21 && num9 == 17)
31094 {
31095 flag4 = true;
31096 if (getGoodWorldGen && genRand.Next(num) == 0)
31097 {
31098 contain = 52;
31099 }
31100 }
31101 if (chestTileType == 21 && num9 == 12)
31102 {
31103 flag5 = true;
31104 if (getGoodWorldGen && genRand.Next(num) == 0)
31105 {
31106 contain = 52;
31107 }
31108 }
31109 if (chestTileType == 21 && num9 == 32)
31110 {
31111 flag6 = true;
31112 if (getGoodWorldGen && genRand.Next(num) == 0)
31113 {
31114 contain = 52;
31115 }
31116 }
31117 if (chestTileType == 21 && num9 != 0 && IsDungeon(i, k))
31118 {
31119 flag8 = true;
31120 }
31121 if (chestTileType == 21 && num9 != 0 && (contain == 848 || contain == 857 || contain == 934))
31122 {
31123 flag9 = true;
31124 }
31125 if (chestTileType == 21 && (num9 == 13 || contain == 159 || contain == 65 || contain == 158 || contain == 2219))
31126 {
31127 flag10 = true;
31129 {
31130 if (crimson)
31131 {
31132 num9 = 43;
31133 }
31134 else
31135 {
31136 chestTileType = 467;
31137 num9 = 3;
31138 }
31139 }
31140 }
31141 if (noTrapsWorldGen && num9 == 1 && chestTileType == 21 && (!remixWorldGen || genRand.Next(3) == 0))
31142 {
31143 num9 = 4;
31144 chestTileType = 467;
31145 }
31147 if (num8 >= 0)
31148 {
31149 if (flag11)
31150 {
31152 if (GenVars.hellChest >= GenVars.hellChestItem.Length)
31153 {
31154 GenVars.hellChest = 0;
31155 }
31156 }
31157 Chest chest = Main.chest[num8];
31158 int num10 = 0;
31159 while (num10 == 0)
31160 {
31161 bool flag13 = (double)num7 < Main.worldSurface + 25.0;
31162 if (remixWorldGen)
31163 {
31164 flag13 = (double)num7 >= (Main.rockLayer + (double)((Main.maxTilesY - 350) * 2)) / 3.0;
31165 }
31166 if ((num9 == 0 && flag13) || flag9)
31167 {
31168 if (contain > 0)
31169 {
31170 chest.item[num10].SetDefaults(contain);
31171 chest.item[num10].Prefix(-1);
31172 num10++;
31173 switch (contain)
31174 {
31175 case 848:
31176 chest.item[num10].SetDefaults(866);
31177 num10++;
31178 break;
31179 case 832:
31180 chest.item[num10].SetDefaults(933);
31181 num10++;
31182 if (genRand.Next(6) == 0)
31183 {
31184 int num11 = genRand.Next(2);
31185 switch (num11)
31186 {
31187 case 0:
31188 num11 = 4429;
31189 break;
31190 case 1:
31191 num11 = 4427;
31192 break;
31193 }
31194 chest.item[num10].SetDefaults(num11);
31195 num10++;
31196 }
31197 break;
31198 }
31199 if (Main.tenthAnniversaryWorld && flag9)
31200 {
31201 chest.item[num10++].SetDefaults(848);
31202 chest.item[num10++].SetDefaults(866);
31203 }
31204 }
31205 else
31206 {
31207 int num12 = genRand.Next(10);
31208 if (num12 == 0)
31209 {
31210 chest.item[num10].SetDefaults(280);
31211 chest.item[num10].Prefix(-1);
31212 }
31213 if (num12 == 1)
31214 {
31215 chest.item[num10].SetDefaults(281);
31216 chest.item[num10].Prefix(-1);
31217 }
31218 if (num12 == 2)
31219 {
31220 chest.item[num10].SetDefaults(284);
31221 chest.item[num10].Prefix(-1);
31222 }
31223 if (num12 == 3)
31224 {
31225 chest.item[num10].SetDefaults(285);
31226 chest.item[num10].Prefix(-1);
31227 }
31228 if (num12 == 4)
31229 {
31230 chest.item[num10].SetDefaults(953);
31231 chest.item[num10].Prefix(-1);
31232 }
31233 if (num12 == 5)
31234 {
31235 chest.item[num10].SetDefaults(946);
31236 chest.item[num10].Prefix(-1);
31237 }
31238 if (num12 == 6)
31239 {
31240 chest.item[num10].SetDefaults(3068);
31241 chest.item[num10].Prefix(-1);
31242 }
31243 if (num12 == 7)
31244 {
31245 if (remixWorldGen)
31246 {
31247 chest.item[num10].SetDefaults(517);
31248 chest.item[num10].Prefix(-1);
31249 }
31250 else
31251 {
31252 chest.item[num10].SetDefaults(3069);
31253 chest.item[num10].Prefix(-1);
31254 }
31255 }
31256 if (num12 == 8)
31257 {
31258 chest.item[num10].SetDefaults(3084);
31259 chest.item[num10].Prefix(-1);
31260 }
31261 if (num12 == 9)
31262 {
31263 chest.item[num10].SetDefaults(4341);
31264 chest.item[num10].Prefix(-1);
31265 }
31266 num10++;
31267 }
31268 if (genRand.Next(6) == 0)
31269 {
31270 int stack = genRand.Next(40, 76);
31271 chest.item[num10].SetDefaults(282);
31272 chest.item[num10].stack = stack;
31273 num10++;
31274 }
31275 if (genRand.Next(6) == 0)
31276 {
31277 int stack2 = genRand.Next(150, 301);
31278 chest.item[num10].SetDefaults(279);
31279 chest.item[num10].stack = stack2;
31280 num10++;
31281 }
31282 if (genRand.Next(6) == 0)
31283 {
31284 chest.item[num10].SetDefaults(3093);
31285 chest.item[num10].stack = 1;
31286 if (genRand.Next(5) == 0)
31287 {
31288 chest.item[num10].stack += genRand.Next(2);
31289 }
31290 if (genRand.Next(10) == 0)
31291 {
31292 chest.item[num10].stack += genRand.Next(3);
31293 }
31294 num10++;
31295 }
31296 if (genRand.Next(6) == 0)
31297 {
31298 chest.item[num10].SetDefaults(4345);
31299 chest.item[num10].stack = 1;
31300 if (genRand.Next(5) == 0)
31301 {
31302 chest.item[num10].stack += genRand.Next(2);
31303 }
31304 if (genRand.Next(10) == 0)
31305 {
31306 chest.item[num10].stack += genRand.Next(3);
31307 }
31308 num10++;
31309 }
31310 if (genRand.Next(3) == 0)
31311 {
31312 chest.item[num10].SetDefaults(168);
31313 chest.item[num10].stack = genRand.Next(3, 6);
31314 num10++;
31315 }
31316 if (genRand.Next(2) == 0)
31317 {
31318 int num13 = genRand.Next(2);
31319 int stack3 = genRand.Next(8) + 3;
31320 if (num13 == 0)
31321 {
31322 chest.item[num10].SetDefaults(GenVars.copperBar);
31323 }
31324 if (num13 == 1)
31325 {
31326 chest.item[num10].SetDefaults(GenVars.ironBar);
31327 }
31328 chest.item[num10].stack = stack3;
31329 num10++;
31330 }
31331 if (genRand.Next(2) == 0)
31332 {
31333 int stack4 = genRand.Next(50, 101);
31334 chest.item[num10].SetDefaults(965);
31335 chest.item[num10].stack = stack4;
31336 num10++;
31337 }
31338 if (genRand.Next(3) != 0)
31339 {
31340 int num14 = genRand.Next(2);
31341 int stack5 = genRand.Next(26) + 25;
31342 if (num14 == 0)
31343 {
31344 chest.item[num10].SetDefaults(40);
31345 }
31346 if (num14 == 1)
31347 {
31348 chest.item[num10].SetDefaults(42);
31349 }
31350 chest.item[num10].stack = stack5;
31351 num10++;
31352 }
31353 if (genRand.Next(2) == 0)
31354 {
31355 int stack6 = genRand.Next(3) + 3;
31356 chest.item[num10].SetDefaults(28);
31357 chest.item[num10].stack = stack6;
31358 num10++;
31359 }
31360 if (genRand.Next(3) != 0)
31361 {
31362 chest.item[num10].SetDefaults(2350);
31363 chest.item[num10].stack = genRand.Next(3, 6);
31364 num10++;
31365 }
31366 if (genRand.Next(3) > 0)
31367 {
31368 int num15 = genRand.Next(6);
31369 int stack7 = genRand.Next(1, 3);
31370 if (num15 == 0)
31371 {
31372 chest.item[num10].SetDefaults(292);
31373 }
31374 if (num15 == 1)
31375 {
31376 chest.item[num10].SetDefaults(298);
31377 }
31378 if (num15 == 2)
31379 {
31380 chest.item[num10].SetDefaults(299);
31381 }
31382 if (num15 == 3)
31383 {
31384 chest.item[num10].SetDefaults(290);
31385 }
31386 if (num15 == 4)
31387 {
31388 chest.item[num10].SetDefaults(2322);
31389 }
31390 if (num15 == 5)
31391 {
31392 chest.item[num10].SetDefaults(2325);
31393 }
31394 chest.item[num10].stack = stack7;
31395 num10++;
31396 }
31397 if (genRand.Next(2) == 0)
31398 {
31399 int num16 = genRand.Next(2);
31400 int stack8 = genRand.Next(11) + 10;
31401 if (num16 == 0)
31402 {
31403 chest.item[num10].SetDefaults(8);
31404 }
31405 if (num16 == 1)
31406 {
31407 chest.item[num10].SetDefaults(31);
31408 }
31409 chest.item[num10].stack = stack8;
31410 num10++;
31411 }
31412 if (genRand.Next(2) == 0)
31413 {
31414 chest.item[num10].SetDefaults(72);
31415 chest.item[num10].stack = genRand.Next(10, 30);
31416 num10++;
31417 }
31418 if (genRand.Next(2) == 0)
31419 {
31420 chest.item[num10].SetDefaults(9);
31421 chest.item[num10].stack = genRand.Next(50, 100);
31422 num10++;
31423 }
31424 }
31425 else if ((!remixWorldGen && (double)num7 < Main.rockLayer) || (remixWorldGen && (double)num7 > Main.rockLayer && num7 < Main.maxTilesY - 250))
31426 {
31427 if (contain > 0)
31428 {
31429 if (contain == 832)
31430 {
31431 chest.item[num10].SetDefaults(933);
31432 num10++;
31433 }
31434 chest.item[num10].SetDefaults(contain);
31435 chest.item[num10].Prefix(-1);
31436 num10++;
31437 if (flag4)
31438 {
31439 if (genRand.Next(2) == 0)
31440 {
31441 chest.item[num10++].SetDefaults(4425);
31442 }
31443 if (genRand.Next(2) == 0)
31444 {
31445 chest.item[num10++].SetDefaults(4460);
31446 }
31447 }
31448 if (flag10 && genRand.Next(40) == 0)
31449 {
31450 chest.item[num10++].SetDefaults(4978);
31451 }
31452 if (flag5 && genRand.Next(10) == 0)
31453 {
31454 int num17 = genRand.Next(2);
31455 switch (num17)
31456 {
31457 case 0:
31458 num17 = 4429;
31459 break;
31460 case 1:
31461 num17 = 4427;
31462 break;
31463 }
31464 chest.item[num10].SetDefaults(num17);
31465 num10++;
31466 }
31467 if (flag8 && (!GenVars.generatedShadowKey || genRand.Next(3) == 0))
31468 {
31469 GenVars.generatedShadowKey = true;
31470 chest.item[num10].SetDefaults(329);
31471 num10++;
31472 }
31473 }
31474 else
31475 {
31476 switch (genRand.Next(6))
31477 {
31478 case 0:
31479 chest.item[num10].SetDefaults(49);
31480 chest.item[num10].Prefix(-1);
31481 break;
31482 case 1:
31483 chest.item[num10].SetDefaults(50);
31484 chest.item[num10].Prefix(-1);
31485 break;
31486 case 2:
31487 chest.item[num10].SetDefaults(53);
31488 chest.item[num10].Prefix(-1);
31489 break;
31490 case 3:
31491 chest.item[num10].SetDefaults(54);
31492 chest.item[num10].Prefix(-1);
31493 break;
31494 case 4:
31495 chest.item[num10].SetDefaults(5011);
31496 chest.item[num10].Prefix(-1);
31497 break;
31498 default:
31499 chest.item[num10].SetDefaults(975);
31500 chest.item[num10].Prefix(-1);
31501 break;
31502 }
31503 num10++;
31504 if (genRand.Next(20) == 0)
31505 {
31506 chest.item[num10].SetDefaults(997);
31507 chest.item[num10].Prefix(-1);
31508 num10++;
31509 }
31510 else if (genRand.Next(20) == 0)
31511 {
31512 chest.item[num10].SetDefaults(930);
31513 chest.item[num10].Prefix(-1);
31514 num10++;
31515 chest.item[num10].SetDefaults(931);
31516 chest.item[num10].stack = genRand.Next(26) + 25;
31517 num10++;
31518 }
31519 if (flag6 && genRand.Next(2) == 0)
31520 {
31521 chest.item[num10].SetDefaults(4450);
31522 num10++;
31523 }
31524 if (flag6 && genRand.Next(3) == 0)
31525 {
31526 chest.item[num10].SetDefaults(4779);
31527 num10++;
31528 chest.item[num10].SetDefaults(4780);
31529 num10++;
31530 chest.item[num10].SetDefaults(4781);
31531 num10++;
31532 }
31533 }
31534 if (flag2)
31535 {
31536 if (genRand.Next(3) == 0)
31537 {
31538 chest.item[num10].SetDefaults(4423);
31539 chest.item[num10].stack = genRand.Next(10, 20);
31540 num10++;
31541 }
31542 }
31543 else if (genRand.Next(3) == 0)
31544 {
31545 chest.item[num10].SetDefaults(166);
31546 chest.item[num10].stack = genRand.Next(10, 20);
31547 num10++;
31548 }
31549 if (genRand.Next(5) == 0)
31550 {
31551 chest.item[num10].SetDefaults(52);
31552 num10++;
31553 }
31554 if (genRand.Next(3) == 0)
31555 {
31556 int stack9 = genRand.Next(50, 101);
31557 chest.item[num10].SetDefaults(965);
31558 chest.item[num10].stack = stack9;
31559 num10++;
31560 }
31561 if (genRand.Next(2) == 0)
31562 {
31563 int num18 = genRand.Next(2);
31564 int stack10 = genRand.Next(10) + 5;
31565 if (num18 == 0)
31566 {
31567 chest.item[num10].SetDefaults(GenVars.ironBar);
31568 }
31569 if (num18 == 1)
31570 {
31571 chest.item[num10].SetDefaults(GenVars.silverBar);
31572 }
31573 chest.item[num10].stack = stack10;
31574 num10++;
31575 }
31576 if (genRand.Next(2) == 0)
31577 {
31578 int num19 = genRand.Next(2);
31579 int stack11 = genRand.Next(25) + 25;
31580 if (num19 == 0)
31581 {
31582 chest.item[num10].SetDefaults(40);
31583 }
31584 if (num19 == 1)
31585 {
31586 chest.item[num10].SetDefaults(42);
31587 }
31588 chest.item[num10].stack = stack11;
31589 num10++;
31590 }
31591 if (genRand.Next(2) == 0)
31592 {
31593 int stack12 = genRand.Next(3) + 3;
31594 chest.item[num10].SetDefaults(28);
31595 chest.item[num10].stack = stack12;
31596 num10++;
31597 }
31598 if (genRand.Next(3) > 0)
31599 {
31600 int num20 = genRand.Next(9);
31601 int stack13 = genRand.Next(1, 3);
31602 if (num20 == 0)
31603 {
31604 chest.item[num10].SetDefaults(289);
31605 }
31606 if (num20 == 1)
31607 {
31608 chest.item[num10].SetDefaults(298);
31609 }
31610 if (num20 == 2)
31611 {
31612 chest.item[num10].SetDefaults(299);
31613 }
31614 if (num20 == 3)
31615 {
31616 chest.item[num10].SetDefaults(290);
31617 }
31618 if (num20 == 4)
31619 {
31620 chest.item[num10].SetDefaults(303);
31621 }
31622 if (num20 == 5)
31623 {
31624 chest.item[num10].SetDefaults(291);
31625 }
31626 if (num20 == 6)
31627 {
31628 chest.item[num10].SetDefaults(304);
31629 }
31630 if (num20 == 7)
31631 {
31632 chest.item[num10].SetDefaults(2322);
31633 }
31634 if (num20 == 8)
31635 {
31636 chest.item[num10].SetDefaults(2329);
31637 }
31638 chest.item[num10].stack = stack13;
31639 num10++;
31640 }
31641 if (genRand.Next(3) != 0)
31642 {
31643 int stack14 = genRand.Next(2, 5);
31644 chest.item[num10].SetDefaults(2350);
31645 chest.item[num10].stack = stack14;
31646 num10++;
31647 }
31648 if (genRand.Next(2) == 0)
31649 {
31650 int stack15 = genRand.Next(11) + 10;
31651 if (num9 == 11)
31652 {
31653 chest.item[num10].SetDefaults(974);
31654 }
31655 else
31656 {
31657 chest.item[num10].SetDefaults(8);
31658 }
31659 chest.item[num10].stack = stack15;
31660 num10++;
31661 }
31662 if (genRand.Next(2) == 0)
31663 {
31664 chest.item[num10].SetDefaults(72);
31665 chest.item[num10].stack = genRand.Next(50, 90);
31666 num10++;
31667 }
31668 }
31669 else if (num7 < Main.maxTilesY - 250 || (remixWorldGen && (Style == 7 || Style == 14)))
31670 {
31671 if (contain > 0)
31672 {
31673 chest.item[num10].SetDefaults(contain);
31674 chest.item[num10].Prefix(-1);
31675 num10++;
31676 if (flag && genRand.Next(5) == 0)
31677 {
31678 chest.item[num10].SetDefaults(3199);
31679 num10++;
31680 }
31681 if (flag2)
31682 {
31683 if (genRand.Next(7) == 0)
31684 {
31685 chest.item[num10].SetDefaults(4346);
31686 num10++;
31687 }
31688 if (genRand.Next(15) == 0)
31689 {
31690 chest.item[num10].SetDefaults(4066);
31691 num10++;
31692 }
31693 }
31694 if (flag3 && genRand.Next(6) == 0)
31695 {
31696 chest.item[num10++].SetDefaults(3360);
31697 chest.item[num10++].SetDefaults(3361);
31698 }
31699 if (flag3 && genRand.Next(10) == 0)
31700 {
31701 chest.item[num10++].SetDefaults(4426);
31702 }
31703 if (flag4)
31704 {
31705 if (genRand.Next(2) == 0)
31706 {
31707 chest.item[num10++].SetDefaults(4425);
31708 }
31709 if (genRand.Next(2) == 0)
31710 {
31711 chest.item[num10++].SetDefaults(4460);
31712 }
31713 }
31714 if (flag8 && (!GenVars.generatedShadowKey || genRand.Next(3) == 0))
31715 {
31716 GenVars.generatedShadowKey = true;
31717 chest.item[num10].SetDefaults(329);
31718 num10++;
31719 }
31720 }
31721 else
31722 {
31723 int num21 = genRand.Next(7);
31724 bool flag14 = num7 > GenVars.lavaLine;
31725 if (remixWorldGen)
31726 {
31727 flag14 = (double)num7 > Main.worldSurface && (double)num7 < Main.rockLayer;
31728 }
31729 int maxValue = 20;
31731 {
31732 maxValue = 15;
31733 }
31734 if (genRand.Next(maxValue) == 0 && flag14)
31735 {
31736 chest.item[num10].SetDefaults(906);
31737 chest.item[num10].Prefix(-1);
31738 }
31739 else if (genRand.Next(15) == 0)
31740 {
31741 chest.item[num10].SetDefaults(997);
31742 chest.item[num10].Prefix(-1);
31743 }
31744 else
31745 {
31746 if (num21 == 0)
31747 {
31748 chest.item[num10].SetDefaults(49);
31749 chest.item[num10].Prefix(-1);
31750 }
31751 if (num21 == 1)
31752 {
31753 chest.item[num10].SetDefaults(50);
31754 chest.item[num10].Prefix(-1);
31755 }
31756 if (num21 == 2)
31757 {
31758 chest.item[num10].SetDefaults(53);
31759 chest.item[num10].Prefix(-1);
31760 }
31761 if (num21 == 3)
31762 {
31763 chest.item[num10].SetDefaults(54);
31764 chest.item[num10].Prefix(-1);
31765 }
31766 if (num21 == 4)
31767 {
31768 chest.item[num10].SetDefaults(5011);
31769 chest.item[num10].Prefix(-1);
31770 }
31771 if (num21 == 5)
31772 {
31773 chest.item[num10].SetDefaults(975);
31774 chest.item[num10].Prefix(-1);
31775 }
31776 if (num21 == 6)
31777 {
31778 chest.item[num10].SetDefaults(930);
31779 chest.item[num10].Prefix(-1);
31780 num10++;
31781 chest.item[num10].SetDefaults(931);
31782 chest.item[num10].stack = genRand.Next(26) + 25;
31783 }
31784 }
31785 num10++;
31786 if (flag6)
31787 {
31788 if (genRand.Next(2) == 0)
31789 {
31790 chest.item[num10].SetDefaults(4450);
31791 num10++;
31792 }
31793 else
31794 {
31795 chest.item[num10].SetDefaults(4779);
31796 num10++;
31797 chest.item[num10].SetDefaults(4780);
31798 num10++;
31799 chest.item[num10].SetDefaults(4781);
31800 num10++;
31801 }
31802 }
31803 }
31804 if (genRand.Next(5) == 0)
31805 {
31806 chest.item[num10].SetDefaults(43);
31807 num10++;
31808 }
31809 if (genRand.Next(3) == 0)
31810 {
31811 chest.item[num10].SetDefaults(167);
31812 num10++;
31813 }
31814 if (genRand.Next(4) == 0)
31815 {
31816 chest.item[num10].SetDefaults(51);
31817 chest.item[num10].stack = genRand.Next(26) + 25;
31818 num10++;
31819 }
31820 if (genRand.Next(2) == 0)
31821 {
31822 int num22 = genRand.Next(2);
31823 int stack16 = genRand.Next(8) + 3;
31824 if (num22 == 0)
31825 {
31826 chest.item[num10].SetDefaults(GenVars.goldBar);
31827 }
31828 if (num22 == 1)
31829 {
31830 chest.item[num10].SetDefaults(GenVars.silverBar);
31831 }
31832 chest.item[num10].stack = stack16;
31833 num10++;
31834 }
31835 if (genRand.Next(2) == 0)
31836 {
31837 int num23 = genRand.Next(2);
31838 int stack17 = genRand.Next(26) + 25;
31839 if (num23 == 0)
31840 {
31841 chest.item[num10].SetDefaults(41);
31842 }
31843 if (num23 == 1)
31844 {
31845 chest.item[num10].SetDefaults(279);
31846 }
31847 chest.item[num10].stack = stack17;
31848 num10++;
31849 }
31850 if (genRand.Next(2) == 0)
31851 {
31852 int stack18 = genRand.Next(3) + 3;
31853 chest.item[num10].SetDefaults(188);
31854 chest.item[num10].stack = stack18;
31855 num10++;
31856 }
31857 if (genRand.Next(3) > 0)
31858 {
31859 int num24 = genRand.Next(6);
31860 int stack19 = genRand.Next(1, 3);
31861 if (num24 == 0)
31862 {
31863 chest.item[num10].SetDefaults(296);
31864 }
31865 if (num24 == 1)
31866 {
31867 chest.item[num10].SetDefaults(295);
31868 }
31869 if (num24 == 2)
31870 {
31871 chest.item[num10].SetDefaults(299);
31872 }
31873 if (num24 == 3)
31874 {
31875 chest.item[num10].SetDefaults(302);
31876 }
31877 if (num24 == 4)
31878 {
31879 chest.item[num10].SetDefaults(303);
31880 }
31881 if (num24 == 5)
31882 {
31883 chest.item[num10].SetDefaults(305);
31884 }
31885 chest.item[num10].stack = stack19;
31886 num10++;
31887 }
31888 if (genRand.Next(3) > 1)
31889 {
31890 int num25 = genRand.Next(6);
31891 int stack20 = genRand.Next(1, 3);
31892 if (num25 == 0)
31893 {
31894 chest.item[num10].SetDefaults(301);
31895 }
31896 if (num25 == 1)
31897 {
31898 chest.item[num10].SetDefaults(297);
31899 }
31900 if (num25 == 2)
31901 {
31902 chest.item[num10].SetDefaults(304);
31903 }
31904 if (num25 == 3)
31905 {
31906 chest.item[num10].SetDefaults(2329);
31907 }
31908 if (num25 == 4)
31909 {
31910 chest.item[num10].SetDefaults(2351);
31911 }
31912 if (num25 == 5)
31913 {
31914 chest.item[num10].SetDefaults(2326);
31915 }
31916 chest.item[num10].stack = stack20;
31917 num10++;
31918 }
31919 if (genRand.Next(2) == 0)
31920 {
31921 int stack21 = genRand.Next(2, 5);
31922 chest.item[num10].SetDefaults(2350);
31923 chest.item[num10].stack = stack21;
31924 num10++;
31925 }
31926 if (genRand.Next(2) == 0)
31927 {
31928 int num26 = genRand.Next(2);
31929 int stack22 = genRand.Next(15) + 15;
31930 if (num26 == 0)
31931 {
31932 if (num9 == 11)
31933 {
31934 chest.item[num10].SetDefaults(974);
31935 }
31936 else
31937 {
31938 chest.item[num10].SetDefaults(8);
31939 }
31940 }
31941 if (num26 == 1)
31942 {
31943 chest.item[num10].SetDefaults(282);
31944 }
31945 chest.item[num10].stack = stack22;
31946 num10++;
31947 }
31948 if (genRand.Next(2) == 0)
31949 {
31950 chest.item[num10].SetDefaults(73);
31951 chest.item[num10].stack = genRand.Next(1, 3);
31952 num10++;
31953 }
31954 }
31955 else
31956 {
31957 if (contain > 0)
31958 {
31959 chest.item[num10].SetDefaults(contain);
31960 chest.item[num10].Prefix(-1);
31961 num10++;
31962 if (flag7 && genRand.Next(5) == 0)
31963 {
31964 chest.item[num10].SetDefaults(5010);
31965 num10++;
31966 }
31967 if (flag7 && genRand.Next(10) == 0)
31968 {
31969 chest.item[num10].SetDefaults(4443);
31970 num10++;
31971 }
31972 if (flag7 && genRand.Next(10) == 0)
31973 {
31974 chest.item[num10].SetDefaults(4737);
31975 num10++;
31976 }
31977 if (flag7 && genRand.Next(10) == 0)
31978 {
31979 chest.item[num10].SetDefaults(4551);
31980 num10++;
31981 }
31982 }
31983 else
31984 {
31985 int num27 = genRand.Next(4);
31986 if (num27 == 0)
31987 {
31988 chest.item[num10].SetDefaults(49);
31989 chest.item[num10].Prefix(-1);
31990 }
31991 if (num27 == 1)
31992 {
31993 chest.item[num10].SetDefaults(50);
31994 chest.item[num10].Prefix(-1);
31995 }
31996 if (num27 == 2)
31997 {
31998 chest.item[num10].SetDefaults(53);
31999 chest.item[num10].Prefix(-1);
32000 }
32001 if (num27 == 3)
32002 {
32003 chest.item[num10].SetDefaults(54);
32004 chest.item[num10].Prefix(-1);
32005 }
32006 num10++;
32007 }
32008 if (genRand.Next(3) == 0)
32009 {
32010 chest.item[num10].SetDefaults(167);
32011 num10++;
32012 }
32013 if (genRand.Next(2) == 0)
32014 {
32015 int num28 = genRand.Next(2);
32016 int stack23 = genRand.Next(15) + 15;
32017 if (num28 == 0)
32018 {
32019 chest.item[num10].SetDefaults(117);
32020 }
32021 if (num28 == 1)
32022 {
32023 chest.item[num10].SetDefaults(GenVars.goldBar);
32024 }
32025 chest.item[num10].stack = stack23;
32026 num10++;
32027 }
32028 if (genRand.Next(2) == 0)
32029 {
32030 int num29 = genRand.Next(2);
32031 int stack24 = genRand.Next(25) + 50;
32032 if (num29 == 0)
32033 {
32034 chest.item[num10].SetDefaults(265);
32035 }
32036 if (num29 == 1)
32037 {
32038 if (SavedOreTiers.Silver == 168)
32039 {
32040 chest.item[num10].SetDefaults(4915);
32041 }
32042 else
32043 {
32044 chest.item[num10].SetDefaults(278);
32045 }
32046 }
32047 chest.item[num10].stack = stack24;
32048 num10++;
32049 }
32050 if (genRand.Next(2) == 0)
32051 {
32052 int stack25 = genRand.Next(6) + 15;
32053 chest.item[num10].SetDefaults(227);
32054 chest.item[num10].stack = stack25;
32055 num10++;
32056 }
32057 if (genRand.Next(4) > 0)
32058 {
32059 int num30 = genRand.Next(8);
32060 int stack26 = genRand.Next(1, 3);
32061 if (num30 == 0)
32062 {
32063 chest.item[num10].SetDefaults(296);
32064 }
32065 if (num30 == 1)
32066 {
32067 chest.item[num10].SetDefaults(295);
32068 }
32069 if (num30 == 2)
32070 {
32071 chest.item[num10].SetDefaults(293);
32072 }
32073 if (num30 == 3)
32074 {
32075 chest.item[num10].SetDefaults(288);
32076 }
32077 if (num30 == 4)
32078 {
32079 chest.item[num10].SetDefaults(294);
32080 }
32081 if (num30 == 5)
32082 {
32083 chest.item[num10].SetDefaults(297);
32084 }
32085 if (num30 == 6)
32086 {
32087 chest.item[num10].SetDefaults(304);
32088 }
32089 if (num30 == 7)
32090 {
32091 chest.item[num10].SetDefaults(2323);
32092 }
32093 chest.item[num10].stack = stack26;
32094 num10++;
32095 }
32096 if (genRand.Next(3) > 0)
32097 {
32098 int num31 = genRand.Next(8);
32099 int stack27 = genRand.Next(1, 3);
32100 if (num31 == 0)
32101 {
32102 chest.item[num10].SetDefaults(305);
32103 }
32104 if (num31 == 1)
32105 {
32106 chest.item[num10].SetDefaults(301);
32107 }
32108 if (num31 == 2)
32109 {
32110 chest.item[num10].SetDefaults(302);
32111 }
32112 if (num31 == 3)
32113 {
32114 chest.item[num10].SetDefaults(288);
32115 }
32116 if (num31 == 4)
32117 {
32118 chest.item[num10].SetDefaults(300);
32119 }
32120 if (num31 == 5)
32121 {
32122 chest.item[num10].SetDefaults(2351);
32123 }
32124 if (num31 == 6)
32125 {
32126 chest.item[num10].SetDefaults(2348);
32127 }
32128 if (num31 == 7)
32129 {
32130 chest.item[num10].SetDefaults(2345);
32131 }
32132 chest.item[num10].stack = stack27;
32133 num10++;
32134 }
32135 if (genRand.Next(3) == 0)
32136 {
32137 int stack28 = genRand.Next(1, 3);
32138 if (genRand.Next(2) == 0)
32139 {
32140 chest.item[num10].SetDefaults(2350);
32141 }
32142 else
32143 {
32144 chest.item[num10].SetDefaults(4870);
32145 }
32146 chest.item[num10].stack = stack28;
32147 num10++;
32148 }
32149 if (genRand.Next(2) == 0)
32150 {
32151 int num32 = genRand.Next(2);
32152 int stack29 = genRand.Next(15) + 15;
32153 if (num32 == 0)
32154 {
32155 chest.item[num10].SetDefaults(8);
32156 }
32157 if (num32 == 1)
32158 {
32159 chest.item[num10].SetDefaults(282);
32160 }
32161 chest.item[num10].stack = stack29;
32162 num10++;
32163 }
32164 if (genRand.Next(2) == 0)
32165 {
32166 chest.item[num10].SetDefaults(73);
32167 chest.item[num10].stack = genRand.Next(2, 5);
32168 num10++;
32169 }
32170 }
32171 if (num10 > 0 && chestTileType == 21)
32172 {
32173 if (num9 == 10 && genRand.Next(4) == 0)
32174 {
32175 chest.item[num10].SetDefaults(2204);
32176 num10++;
32177 }
32178 if (num9 == 11 && genRand.Next(7) == 0)
32179 {
32180 chest.item[num10].SetDefaults(2198);
32181 num10++;
32182 }
32183 if (flag10 && genRand.Next(3) == 0)
32184 {
32185 chest.item[num10].SetDefaults(2197);
32186 num10++;
32187 }
32188 if (flag10)
32189 {
32190 int num33 = genRand.Next(6);
32191 if (num33 == 0)
32192 {
32193 chest.item[num10].SetDefaults(5258);
32194 }
32195 if (num33 == 1)
32196 {
32197 chest.item[num10].SetDefaults(5226);
32198 }
32199 if (num33 == 2)
32200 {
32201 chest.item[num10].SetDefaults(5254);
32202 }
32203 if (num33 == 3)
32204 {
32205 chest.item[num10].SetDefaults(5238);
32206 }
32207 if (num33 == 4)
32208 {
32209 chest.item[num10].SetDefaults(5255);
32210 }
32211 if (num33 == 5)
32212 {
32213 chest.item[num10].SetDefaults(5388);
32214 }
32215 num10++;
32216 }
32217 if (flag10)
32218 {
32219 chest.item[num10].SetDefaults(751);
32220 chest.item[num10].stack = genRand.Next(50, 101);
32221 num10++;
32222 }
32223 if (num9 == 16)
32224 {
32225 chest.item[num10].SetDefaults(2195);
32226 num10++;
32227 }
32228 if (Main.wallDungeon[Main.tile[i, k].wall] && genRand.Next(8) == 0)
32229 {
32230 chest.item[num10].SetDefaults(2192);
32231 num10++;
32232 }
32233 if ((num9 == 23 || num9 == 24 || num9 == 25 || num9 == 26 || num9 == 27) && genRand.Next(2) == 0)
32234 {
32235 chest.item[num10].SetDefaults(5234);
32236 num10++;
32237 }
32238 if (num9 == 16)
32239 {
32240 if (genRand.Next(5) == 0)
32241 {
32242 chest.item[num10].SetDefaults(2767);
32243 num10++;
32244 }
32245 else
32246 {
32247 chest.item[num10].SetDefaults(2766);
32248 chest.item[num10].stack = genRand.Next(3, 8);
32249 num10++;
32250 }
32251 }
32252 }
32253 if (num10 <= 0 || chestTileType != 467)
32254 {
32255 continue;
32256 }
32257 if (flag10 && genRand.Next(3) == 0)
32258 {
32259 chest.item[num10].SetDefaults(2197);
32260 num10++;
32261 }
32262 if (flag10)
32263 {
32264 int num34 = genRand.Next(5);
32265 if (num34 == 0)
32266 {
32267 chest.item[num10].SetDefaults(5258);
32268 }
32269 if (num34 == 1)
32270 {
32271 chest.item[num10].SetDefaults(5226);
32272 }
32273 if (num34 == 2)
32274 {
32275 chest.item[num10].SetDefaults(5254);
32276 }
32277 if (num34 == 3)
32278 {
32279 chest.item[num10].SetDefaults(5238);
32280 }
32281 if (num34 == 4)
32282 {
32283 chest.item[num10].SetDefaults(5255);
32284 }
32285 num10++;
32286 }
32287 if (flag10)
32288 {
32289 chest.item[num10].SetDefaults(751);
32290 chest.item[num10].stack = genRand.Next(50, 101);
32291 num10++;
32292 }
32293 if (num9 == 13 && genRand.Next(2) == 0)
32294 {
32295 chest.item[num10].SetDefaults(5234);
32296 num10++;
32297 }
32298 }
32299 return true;
32300 }
32301 if (trySlope)
32302 {
32303 if (num2 > -1)
32304 {
32305 Main.tile[i - 1, k].slope((byte)num2);
32306 }
32307 if (num3 > -1)
32308 {
32309 Main.tile[i, k].slope((byte)num3);
32310 }
32311 }
32312 return false;
32313 }
32314 return false;
32315 }
static bool[] Boulders
Definition TileID.cs:123
static bool remixWorldGen
Definition WorldGen.cs:1148
static bool noTrapsWorldGen
Definition WorldGen.cs:1152
static bool tenthAnniversaryWorldGen
Definition WorldGen.cs:1160
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static bool crimson
Definition WorldGen.cs:932
static bool IsDungeon(int x, int y)
static bool IsUndergroundDesert(int x, int y)
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816
static bool getGoodWorldGen
Definition WorldGen.cs:1156
static int PlaceChest(int x, int y, ushort type=21, bool notNearOtherChests=false, int style=0)

References Terraria.ID.TileID.Sets.Boulders, Terraria.Main.chest, Terraria.WorldBuilding.GenVars.copperBar, Terraria.WorldBuilding.GenVars.generatedShadowKey, Terraria.WorldBuilding.GenVars.goldBar, Terraria.WorldBuilding.GenVars.hellChest, Terraria.WorldBuilding.GenVars.hellChestItem, Terraria.WorldBuilding.GenVars.ironBar, Terraria.Chest.item, Terraria.WorldBuilding.GenVars.lavaLine, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Item.Prefix(), Terraria.Main.rockLayer, Terraria.Item.SetDefaults(), Terraria.WorldGen.SavedOreTiers.Silver, Terraria.WorldBuilding.GenVars.silverBar, Terraria.Enums.SolidTile, Terraria.Item.stack, Terraria.Main.tenthAnniversaryWorld, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, Terraria.Main.wallDungeon, and Terraria.Main.worldSurface.