Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 89.95 KB | None | 0 0
  1. using Terraria;
  2. using Terraria.ID;
  3. using Terraria.ModLoader;
  4. using Terraria.GameContent.Generation;
  5. using Terraria.World.Generation;
  6. using System.Collections.Generic;
  7.  
  8. using System;
  9. using Terraria.ModLoader.IO;
  10. using System.IO;
  11. using Microsoft.Xna.Framework;
  12. using Terraria.Localization;
  13. using QwertysRandomContent.NPCs.FortressBoss;
  14.  
  15. namespace QwertysRandomContent
  16. {
  17. public class FortressBiome : ModPlayer
  18. {
  19. public bool TheFortress = false;
  20. public override void UpdateBiomes()
  21. {
  22. TheFortress = (SkyFortress.fortressBrick > 200) && ( ((Main.maxTilesX < 6000) && (player.Center.Y / 16) < 160) || ((Main.maxTilesX < 8000 && Main.maxTilesX > 6000) && (player.Center.Y / 16) < 250) || ((Main.maxTilesX >8000) &&(player.Center.Y/16)<350));
  23. }
  24. public override bool CustomBiomesMatch(Player other)
  25. {
  26. FortressBiome modOther = other.GetModPlayer<FortressBiome>(mod);
  27. return TheFortress == modOther.TheFortress;
  28. }
  29.  
  30. public override void CopyCustomBiomesTo(Player other)
  31. {
  32. FortressBiome modOther = other.GetModPlayer<FortressBiome>(mod);
  33. modOther.TheFortress = TheFortress;
  34. }
  35.  
  36. public override void SendCustomBiomes(BinaryWriter writer)
  37. {
  38. BitsByte flags = new BitsByte();
  39. flags[0] = TheFortress;
  40. writer.Write(flags);
  41. }
  42.  
  43. public override void ReceiveCustomBiomes(BinaryReader reader)
  44. {
  45. BitsByte flags = reader.ReadByte();
  46. TheFortress = flags[0];
  47. }
  48. }
  49. public class FortressSpawn : GlobalNPC
  50. {
  51. public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
  52. {
  53. if (player.GetModPlayer<FortressBiome>(mod).TheFortress)
  54. {
  55. if (NPC.AnyNPCs(mod.NPCType<FortressBoss>()))
  56. {
  57. spawnRate = 0;
  58. maxSpawns = 0;
  59. }
  60. else
  61. {
  62. if (Main.hardMode)
  63. {
  64. if (Main.dayTime)
  65. {
  66. spawnRate = 30;
  67. maxSpawns = 12;
  68. }
  69. else
  70. {
  71. spawnRate = 34;
  72. maxSpawns = 10;
  73. }
  74. }
  75. else
  76. {
  77. if (Main.dayTime)
  78. {
  79. spawnRate = 34;
  80. maxSpawns = 10;
  81. }
  82. else
  83. {
  84. spawnRate = 38;
  85. maxSpawns = 8;
  86. }
  87. }
  88. }
  89.  
  90.  
  91. }
  92. }
  93. public override void EditSpawnPool(IDictionary<int, float> pool, NPCSpawnInfo spawnInfo)
  94. {
  95.  
  96. if (spawnInfo.player.GetModPlayer<FortressBiome>(mod).TheFortress)
  97. {
  98. pool[0] = 0f;
  99. }
  100. //pool.Add(NPCID.Harpy, 0f);
  101. }
  102.  
  103. }
  104. public class SkyFortress : ModWorld
  105. {
  106. public static int fortressBrick;
  107. public override void ResetNearbyTileEffects()
  108. {
  109. QwertyPlayer modPlayer = Main.LocalPlayer.GetModPlayer<QwertyPlayer>(mod);
  110.  
  111. fortressBrick = 0;
  112. }
  113. public override void TileCountsAvailable(int[] tileCounts)
  114. {
  115. fortressBrick = tileCounts[mod.TileType("FortressBrick")];
  116. }
  117. #region
  118. private static int numIslandHouses = 0;
  119.  
  120. private static int houseCount = 0;
  121. private static bool[] skyLake = new bool[30];
  122. private static int[] fihX = new int[30];
  123.  
  124. private static int[] fihY = new int[30];
  125. #endregion
  126. int tile1;
  127. int plat1 = TileID.Platforms;
  128. int wall1 = WallID.CobaltBrick;
  129. int pillar;
  130.  
  131. public void Vertical(int i, int j, int type=0)
  132. {
  133. pillar = mod.TileType("FortressPillar");
  134. tile1 = mod.TileType("FortressBrick");
  135. if (type ==1) //basic vertical connection
  136. {
  137. int side = WorldGen.genRand.Next(2);
  138. for (int b = -1; b < 22; b++)
  139. {
  140. for (int a = 0; a < 25; a++)
  141. {
  142.  
  143. if (side == 0)
  144. {
  145. if (a < 8 && b == 8)
  146. {
  147. WorldGen.PlaceTile(i + a, j + b, tile1);
  148. if (a != 0 && a != 7)
  149. {
  150. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  151. }
  152. }
  153. else if (a > 16 && b == 12)
  154. {
  155.  
  156. WorldGen.PlaceTile(i + a, j + b, tile1);
  157. if (a != 17 && a != 24)
  158. {
  159. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  160. }
  161. }
  162. }
  163. else
  164. {
  165. if (a < 8 && b ==12)
  166. {
  167. WorldGen.PlaceTile(i + a, j + b , tile1);
  168. if (a != 0 && a != 7)
  169. {
  170. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  171. }
  172. }
  173. else if (a > 16 && b == 8)
  174. {
  175.  
  176. WorldGen.PlaceTile(i + a, j + b , tile1);
  177. if (a != 17 && a != 24)
  178. {
  179. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  180. }
  181. }
  182. }
  183.  
  184.  
  185. if((a ==23 || a==1 || a ==18 || a==6) && !Main.tile[i + a, j + b].active())
  186. {
  187. WorldGen.PlaceTile(i + a, j + b, pillar);
  188. }
  189. }
  190. }
  191. }
  192. }
  193. public void generateBridge(int i, int j, int type = 0)
  194. {
  195. tile1 = mod.TileType("FortressBrick");
  196. wall1 = mod.WallType("FortressWall");
  197. pillar = mod.TileType("FortressPillar");
  198. if (type ==0)
  199. {
  200. type = WorldGen.genRand.Next(1, 4);
  201. }
  202. if (type == 1) //basic bridge
  203. {
  204. for (int a = 0; a < 75; a++)
  205. {
  206. for (int b = 0; b < 25; b++)
  207. {
  208. int extension = 28;
  209. int upperExtension = 18;
  210. if (b == 20 && (a < extension || a > 74 - extension))
  211. {
  212. WorldGen.PlaceTile(i + a, j + b, tile1);
  213. }
  214. if (b == 21 && (a < extension - 1 || a > 74 - extension + 1))
  215. {
  216. WorldGen.PlaceTile(i + a, j + b, tile1);
  217. }
  218. if (b == 22 && (a < extension - 2 || a > 74 - extension + 2))
  219. {
  220. WorldGen.PlaceTile(i + a, j + b, tile1);
  221. }
  222. if (b == 4 && (a < upperExtension || a > 74 - upperExtension))
  223. {
  224. WorldGen.PlaceTile(i + a, j + b, tile1);
  225. }
  226. if (b == 3 && (a < upperExtension - 1 || a > 74 - upperExtension + 1))
  227. {
  228. WorldGen.PlaceTile(i + a, j + b, tile1);
  229. }
  230. if (b == 2 && (a < upperExtension - 2 || a > 74 - upperExtension + 2))
  231. {
  232. WorldGen.PlaceTile(i + a, j + b, tile1);
  233. }
  234. if (a%4 ==3 && !Main.tile[i + a, j + b].active() && (a < upperExtension - 1 || a > 74 - upperExtension + 1) && b>4 && b <20)
  235. {
  236. WorldGen.PlaceTile(i + a, j + b, pillar);
  237. }
  238. #region walls
  239. #endregion
  240. }
  241. }
  242.  
  243. }
  244. if (type == 2) //shorter bridge with island in center
  245. {
  246. for (int a = 0; a < 75; a++)
  247. {
  248. for (int b = 0; b < 25; b++)
  249. {
  250. int extension = 8;
  251. if (b == 20 && ((a < extension || a > 75 - extension) || (a > 25 && a < 49)))
  252. {
  253. WorldGen.PlaceTile(i + a, j + b, tile1);
  254. }
  255. if (b == 21 && ((a < extension - 1 || a > 75 - extension + 1) || (a > 26 && a < 48)))
  256. {
  257. WorldGen.PlaceTile(i + a, j + b, tile1);
  258. }
  259. if (b == 22 && ((a < extension - 2 || a > 75 - extension + 2) || (a > 27 && a < 47)))
  260. {
  261. WorldGen.PlaceTile(i + a, j + b, tile1);
  262. }
  263. if(b==12 && (a > 29 && a < 45))
  264. {
  265. WorldGen.PlaceTile(i + a, j + b, tile1);
  266. if(a !=30 && a != 44)
  267. {
  268. WorldGen.PlaceTile(i + a, j + b-1, tile1);
  269. }
  270. }
  271. if(b >12 && b <20 && (a == 31 || a == 43 || a == 35 || a == 39) && !Main.tile[i + a, j + b].active())
  272. {
  273. WorldGen.PlaceTile(i + a, j + b, pillar);
  274. }
  275. }
  276. }
  277. }
  278. if (type == 3)
  279. {
  280.  
  281. for (int b = 0; b < 25; b++)
  282. {
  283. if (b >2 && b<22)
  284. {
  285. WorldGen.PlaceTile(i, j + b, tile1);
  286. WorldGen.PlaceTile(i + 74, j + b, tile1);
  287. }
  288. }
  289.  
  290. }
  291.  
  292. }
  293. public void generateRoom(int i, int j, int type = 0)
  294. {
  295.  
  296. pillar = mod.TileType("FortressPillar");
  297. wall1 = mod.WallType("FortressWall");
  298. tile1 = mod.TileType("FortressBrick");
  299. plat1 = mod.TileType("FortressPlatform");
  300. if (type ==1) //Basic Room
  301. {
  302. #region tiles
  303. for(int b =0; b<25; b++)//Layers
  304. {
  305. if (b ==0 || b== 24)
  306. {
  307. for(int a =0; a<25; a++)
  308. {
  309. if (a >= 10 && a <= 14)
  310. {
  311.  
  312. WorldGen.PlaceTile(i + a, j + b, plat1);
  313. }
  314. else if( a >=2 && a <= 22)
  315. {
  316. WorldGen.PlaceTile(i + a, j + b, tile1);
  317. }
  318.  
  319. }
  320. }
  321. else if (b == 1 || b == 23)
  322. {
  323. for (int a = 0; a < 25; a++)
  324. {
  325. if (a >= 10 && a <= 14)
  326. {
  327.  
  328. }
  329. else if(a >= 1 && a <= 23)
  330. {
  331. WorldGen.PlaceTile(i + a, j + b, tile1);
  332. }
  333. }
  334. }
  335. else if (b < 5 || b > 19)
  336. {
  337. for (int a = 0; a < 25; a++)
  338. {
  339. if (a >= 10 && a <= 14)
  340. {
  341.  
  342. }
  343. else
  344. {
  345. WorldGen.PlaceTile(i + a, j + b, tile1);
  346. }
  347. }
  348. }
  349. else if (b == 11)
  350. {
  351. for (int a = 0; a < 25; a++)
  352. {
  353. if (a >= 10 && a <= 14)
  354. {
  355.  
  356. WorldGen.PlaceTile(i + a, j + b, tile1);
  357. }
  358. }
  359. }
  360. else if (b==12)
  361. {
  362. for (int a = 0; a < 25; a++)
  363. {
  364.  
  365. if (a >= 6 && a <= 18)
  366. {
  367.  
  368. WorldGen.PlaceTile(i + a, j + b, tile1);
  369. }
  370. }
  371. }
  372. else if (b == 13)
  373. {
  374. for (int a = 0; a < 25; a++)
  375. {
  376.  
  377. if (a >= 7 && a <= 17)
  378. {
  379.  
  380. WorldGen.PlaceTile(i + a, j + b, tile1);
  381. }
  382. }
  383. }
  384.  
  385.  
  386. }
  387. #endregion
  388. #region walls
  389. for (int b = 0; b < 25; b++)//Layers
  390. {
  391. for(int a= 0; a < 25; a++)
  392. {
  393. if(!Main.tile[i + a, j + b].active() && !(a ==0 && b==0) && !(a == 1 && b == 0) && !(a == 0 && b == 1) && !(a == 24 && b == 0) && !(a == 24 && b == 1) && !(a == 23 && b == 0) && !(a == 24 && b == 24) && !(a == 23 && b == 24) && !(a == 24 && b == 23) && !(a == 0 && b == 24) && !(a == 1 && b == 24) && !(a == 0 && b == 23))
  394. {
  395. WorldGen.PlaceWall(i + a, j + b, wall1);
  396. }
  397. }
  398.  
  399. }
  400. #endregion
  401. #region pillars
  402. for (int b = 0; b < 25; b++)//Layers
  403. {
  404. for (int a = 0; a < 25; a++)
  405. {
  406. if ((a == 8 || a == 16) && !Main.tile[i + a, j + b].active())
  407. {
  408. WorldGen.PlaceTile(i + a, j + b, pillar);
  409. }
  410. }
  411. }
  412. #endregion
  413. }
  414. if (type == -1) //altar room
  415. {
  416. #region tiles
  417. for (int b = 0; b < 25; b++)//Layers
  418. {
  419. if (b == 0 || b == 24)
  420. {
  421. for (int a = 0; a < 25; a++)
  422. {
  423. if (a >= 10 && a <= 14 && b==0)
  424. {
  425.  
  426. WorldGen.PlaceTile(i + a, j + b, plat1);
  427. }
  428. else if (a >= 2 && a <= 22)
  429. {
  430. WorldGen.PlaceTile(i + a, j + b, tile1);
  431. }
  432.  
  433. }
  434. }
  435. else if (b == 1 || b == 23)
  436. {
  437. for (int a = 0; a < 25; a++)
  438. {
  439. if (a >= 10 && a <= 14 && b == 1)
  440. {
  441.  
  442. }
  443. else if (a >= 1 && a <= 23)
  444. {
  445. WorldGen.PlaceTile(i + a, j + b, tile1);
  446. }
  447. }
  448. }
  449. else if (b < 5 || b > 19)
  450. {
  451. for (int a = 0; a < 25; a++)
  452. {
  453. if (a >= 10 && a <= 14 && b < 5)
  454. {
  455.  
  456. }
  457. else
  458. {
  459. WorldGen.PlaceTile(i + a, j + b, tile1);
  460. }
  461. }
  462. }
  463. if(b ==19)
  464. {
  465. for (int a = 0; a < 25; a++)
  466. {
  467. if (a >= 7 && a <= 17)
  468. {
  469. WorldGen.PlaceTile(i + a, j + b, tile1);
  470. }
  471. }
  472. }
  473. if (b == 18)
  474. {
  475. for (int a = 0; a < 25; a++)
  476. {
  477. if (a >= 9 && a <= 15)
  478. {
  479. WorldGen.PlaceTile(i + a, j + b, tile1);
  480. }
  481. }
  482. }
  483.  
  484.  
  485. }
  486. #endregion
  487. #region walls
  488. for (int b = 0; b < 25; b++)//Layers
  489. {
  490. for (int a = 0; a < 25; a++)
  491. {
  492. if (!Main.tile[i + a, j + b].active() && !(a == 0 && b == 0) && !(a == 1 && b == 0) && !(a == 0 && b == 1) && !(a == 24 && b == 0) && !(a == 24 && b == 1) && !(a == 23 && b == 0) && !(a == 24 && b == 24) && !(a == 23 && b == 24) && !(a == 24 && b == 23) && !(a == 0 && b == 24) && !(a == 1 && b == 24) && !(a == 0 && b == 23))
  493. {
  494. WorldGen.PlaceWall(i + a, j + b, wall1);
  495. }
  496. }
  497.  
  498. }
  499. #endregion
  500. WorldGen.PlaceTile(i +12, j +17, mod.TileType("FortressAltar"));
  501. WorldGen.PlaceTile(i + 12, j + 12, mod.TileType("FortressCarving1"));
  502. WorldGen.PlaceTile(i + 18, j + 14, mod.TileType("FortressCarving2"));
  503. WorldGen.PlaceTile(i + 6, j + 14, mod.TileType("FortressCarving3"));
  504. }
  505. if (type == -2) //treausre room
  506. {
  507. #region tiles
  508. for (int b = 0; b < 25; b++)//Layers
  509. {
  510. if (b == 0 || b == 24)
  511. {
  512. for (int a = 0; a < 25; a++)
  513. {
  514. if (a >= 10 && a <= 14 && b == 0)
  515. {
  516.  
  517. WorldGen.PlaceTile(i + a, j + b, plat1);
  518. }
  519. else if (a >= 2 && a <= 22)
  520. {
  521. WorldGen.PlaceTile(i + a, j + b, tile1);
  522. }
  523.  
  524. }
  525. }
  526. else if (b == 1 || b == 23)
  527. {
  528. for (int a = 0; a < 25; a++)
  529. {
  530. if (a >= 10 && a <= 14 && b == 1)
  531. {
  532.  
  533. }
  534. else if (a >= 1 && a <= 23)
  535. {
  536. WorldGen.PlaceTile(i + a, j + b, tile1);
  537. }
  538. }
  539. }
  540. else if (b < 5 || b > 19)
  541. {
  542. for (int a = 0; a < 25; a++)
  543. {
  544. if (a >= 10 && a <= 14 && b < 5)
  545. {
  546.  
  547. }
  548. else
  549. {
  550. WorldGen.PlaceTile(i + a, j + b, tile1);
  551. }
  552. }
  553. }
  554. else if(b >=5 && b<= 7)
  555. {
  556. for (int a = 0; a < 25; a++)
  557. {
  558. if(a ==0 || a ==24)
  559. {
  560. WorldGen.PlaceTile(i + a, j + b, tile1);
  561. }
  562. }
  563. }
  564. else if (b==8)
  565. {
  566. for (int a = 0; a < 25; a++)
  567. {
  568. if (a <= 5 || a >= 19)
  569. {
  570. WorldGen.PlaceTile(i + a, j + b, tile1);
  571. }
  572. }
  573. }
  574. else if (b == 11)
  575. {
  576. for (int a = 0; a < 25; a++)
  577. {
  578. if (a >= 10 && a <= 14)
  579. {
  580.  
  581. WorldGen.PlaceTile(i + a, j + b, tile1);
  582. }
  583. }
  584. }
  585. else if (b == 12)
  586. {
  587. for (int a = 0; a < 25; a++)
  588. {
  589.  
  590. if (a >= 6 && a <= 18)
  591. {
  592.  
  593. WorldGen.PlaceTile(i + a, j + b, tile1);
  594. }
  595. }
  596. }
  597. else if (b == 13)
  598. {
  599. for (int a = 0; a < 25; a++)
  600. {
  601.  
  602. if (a >= 7 && a <= 17)
  603. {
  604.  
  605. WorldGen.PlaceTile(i + a, j + b, tile1);
  606. }
  607. }
  608. }
  609.  
  610.  
  611. }
  612. #endregion
  613. #region walls
  614. for (int b = 0; b < 25; b++)//Layers
  615. {
  616. for (int a = 0; a < 25; a++)
  617. {
  618. if (!Main.tile[i + a, j + b].active() && !(a == 0 && b == 0) && !(a == 1 && b == 0) && !(a == 0 && b == 1) && !(a == 24 && b == 0) && !(a == 24 && b == 1) && !(a == 23 && b == 0) && !(a == 24 && b == 24) && !(a == 23 && b == 24) && !(a == 24 && b == 23) && !(a == 0 && b == 24) && !(a == 1 && b == 24) && !(a == 0 && b == 23))
  619. {
  620. if (a != 0 && a != 24)
  621. {
  622. WorldGen.PlaceWall(i + a, j + b, wall1);
  623. }
  624. }
  625. }
  626.  
  627. }
  628. #endregion
  629. WorldGen.PlaceTile(i + 12, j + 19, TileID.Anvils);
  630. #region pillars
  631. for (int b = 0; b < 25; b++)//Layers
  632. {
  633. for (int a = 0; a < 25; a++)
  634. {
  635. if ((a == 8 || a == 16) && !Main.tile[i + a, j + b].active())
  636. {
  637. WorldGen.PlaceTile(i + a, j + b, pillar);
  638. }
  639. }
  640. if (b >= 5 && b <= 7)
  641. {
  642. for (int a = 0; a < 25; a++)
  643. {
  644. if (a == 4 || a == 20)
  645. {
  646. WorldGen.PlaceTile(i + a, j + b, pillar);
  647. }
  648. }
  649. }
  650. if (b > 5 && b < 20)
  651. {
  652. for (int a = 0; a < 25; a++)
  653. {
  654. if((a ==0 || a ==24 ) && !Main.tile[i + a, j + b].active())
  655. {
  656. WorldGen.PlaceTile(i + a, j + b, pillar);
  657. }
  658. }
  659. }
  660. }
  661.  
  662. #endregion
  663. #region treasure
  664. int gap = WorldGen.genRand.Next(0, 3);
  665. int gap2 = WorldGen.genRand.Next(0, 3);
  666. bool secondPlace = false;
  667. bool secondPlace2 = false;
  668. bool hasntPlaced = true;
  669. bool hasntPlaced2 = true;
  670. for (int b = 0; b < 25; b++)
  671. {
  672. if (b == 7)
  673. {
  674. for (int a = 0; a < 25; a++)
  675. {
  676. if ((a >= 21 && a <= 23))
  677. {
  678. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  679. if(21 + gap != a)
  680. {
  681. WorldGen.PlaceTile(i + a, j + b - 1, mod.TileType("CaeliteBar"));
  682. if ((Main.rand.Next(1) == 0 || secondPlace) && hasntPlaced)
  683. {
  684. WorldGen.PlaceTile(i + a, j + b - 2, mod.TileType("CaeliteBar"));
  685. hasntPlaced = false;
  686. }
  687. else
  688. {
  689. secondPlace = true;
  690. }
  691. }
  692. }
  693. if ((a >= 1 && a <= 3) )
  694. {
  695. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  696. if (1 + gap2 != a)
  697. {
  698. WorldGen.PlaceTile(i + a, j + b - 1, mod.TileType("CaeliteBar"));
  699. if ((Main.rand.Next(1) == 0 || secondPlace2) && hasntPlaced2)
  700. {
  701. WorldGen.PlaceTile(i + a, j + b - 2, mod.TileType("CaeliteBar"));
  702. hasntPlaced2 = false;
  703. }
  704. else
  705. {
  706. secondPlace2 = true;
  707. }
  708. }
  709. }
  710. }
  711. }
  712. /*
  713. if (b == 6)
  714. {
  715.  
  716. for (int a = 0; a < 25; a++)
  717. {
  718. if ((a >= 1 && a <= 3 && 1+gap != a) )
  719. {
  720.  
  721. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  722.  
  723. if((Main.rand.Next(1) ==0|| secondPlace) && hasntPlaced)
  724. {
  725. WorldGen.PlaceTile(i + a, j + b-1, mod.TileType("CaeliteBar"));
  726. hasntPlaced = false;
  727. }
  728. else
  729. {
  730. secondPlace = true;
  731. }
  732.  
  733. }
  734. if((a >= 21 && a <= 23 && 21 + gap != a))
  735. {
  736. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  737.  
  738. if ((Main.rand.Next(1) == 0 || secondPlace2) && hasntPlaced2)
  739. {
  740. WorldGen.PlaceTile(i + a, j + b - 1, mod.TileType("CaeliteBar"));
  741. hasntPlaced2 = false;
  742. }
  743. else
  744. {
  745. secondPlace2 = true;
  746. }
  747.  
  748. }
  749. }
  750.  
  751. }
  752. */
  753. }
  754. #endregion
  755.  
  756. }
  757. }
  758. public int startingX;
  759.  
  760. public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
  761. {
  762. Mod Overrated = ModLoader.GetMod("CalamityMod");
  763. if (Overrated == null)
  764. {
  765. #region
  766. int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Islands"));
  767. if (ShiniesIndex != -1)
  768. {
  769. tasks.RemoveAt(ShiniesIndex);
  770. }
  771. ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Island Houses"));
  772. if (ShiniesIndex != -1)
  773. {
  774. tasks.RemoveAt(ShiniesIndex);
  775. }
  776. int skyLakes = 1;
  777. if (Main.maxTilesX > 8000)
  778. {
  779. int skyLakes2 = skyLakes;
  780. skyLakes = skyLakes2 + 1;
  781. }
  782. if (Main.maxTilesX > 6000)
  783. {
  784. int skyLakes2 = skyLakes;
  785. skyLakes = skyLakes2 + 1;
  786. }
  787. ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Full Desert"));
  788. if (ShiniesIndex != -1)
  789. {
  790.  
  791. tasks.Insert(ShiniesIndex + 1, new PassLegacy("Giving Sky Fortress space", delegate (GenerationProgress progress)
  792. {
  793.  
  794. numIslandHouses = 0;
  795. houseCount = 0;
  796. progress.Message = Lang.gen[12].Value;
  797. for (int k = 0; k < (int)((double)Main.maxTilesX * 0.0008) + skyLakes; k++)
  798. {
  799. int num = 1000;
  800. int num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
  801. if (WorldGen.dungeonX < Main.maxTilesX * .5f)
  802. {
  803. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
  804. }
  805. else
  806. {
  807. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
  808. }
  809.  
  810. while (--num > 0)
  811. {
  812. bool flag2 = true;
  813. while (num2 > Main.maxTilesX / 2 - 80 && num2 < Main.maxTilesX / 2 + 80)
  814. {
  815. if (WorldGen.dungeonX < Main.maxTilesX * .5f)
  816. {
  817. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
  818. }
  819. else
  820. {
  821. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
  822. }
  823. }
  824. for (int l = 0; l < numIslandHouses; l++)
  825. {
  826. if (num2 > fihX[l] - 180 && num2 < fihX[l] + 180)
  827. {
  828. flag2 = false;
  829. break;
  830. }
  831. }
  832. if (flag2)
  833. {
  834. flag2 = false;
  835. int num3 = 0;
  836. int num4 = 200;
  837. while ((double)num4 < Main.worldSurface)
  838. {
  839. if (Main.tile[num2, num4].active())
  840. {
  841. num3 = num4;
  842. flag2 = true;
  843. break;
  844. }
  845. num4++;
  846. }
  847. if (flag2)
  848. {
  849. int num5 = WorldGen.genRand.Next(90, num3 - 100);
  850. num5 = Math.Min(num5, (int)WorldGen.worldSurfaceLow - 50);
  851. if (k < skyLakes)
  852. {
  853. skyLake[numIslandHouses] = true;
  854. WorldGen.CloudLake(num2, num5);
  855. }
  856. else
  857. {
  858. WorldGen.CloudIsland(num2, num5);
  859. }
  860. fihX[numIslandHouses] = num2;
  861. fihY[numIslandHouses] = num5;
  862. numIslandHouses++;
  863. }
  864. }
  865. }
  866. }
  867. }));
  868. }
  869. #endregion
  870. ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Jungle Trees"));
  871. if (ShiniesIndex != -1)
  872. {
  873. #region
  874.  
  875. tasks.Insert(ShiniesIndex + 1, new PassLegacy("Giving Sky Fortress space", delegate (GenerationProgress progress)
  876. {
  877. for (int k = 0; k < numIslandHouses; k++)
  878. {
  879. if (!skyLake[k])
  880. {
  881. WorldGen.IslandHouse(fihX[k], fihY[k]);
  882. }
  883. }
  884. }));
  885.  
  886. #endregion
  887.  
  888. }
  889. ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Tile Cleanup"));
  890.  
  891. if (ShiniesIndex != -1)
  892. {
  893. tasks.Insert(ShiniesIndex + 1, new PassLegacy("Fortifying the Sky!!", delegate (GenerationProgress progress)
  894. {
  895.  
  896. if (WorldGen.dungeonX < Main.maxTilesX * .5f)
  897. {
  898. startingX = (int)((double)Main.maxTilesX * 0.8);
  899. }
  900. else
  901. {
  902. startingX = (int)((double)Main.maxTilesX * 0.2);
  903. }
  904. int roomsPerLayer = 7;
  905.  
  906. if (Main.maxTilesX > 8000)
  907. {
  908. roomsPerLayer += 4;
  909. }
  910. if (Main.maxTilesX > 6000)
  911. {
  912. roomsPerLayer += 4;
  913. }
  914. int roomHeight = 25;
  915. int roomWidth = 25;
  916. int bridgeHeight = 25;
  917. int bridgeWidth = 75;
  918. int verticalHeight = 21;
  919. int verticalWith = 25;
  920. int HeightOffset = (roomHeight - 1) / 2;
  921. int WidthOffset = (roomWidth - 1) / 2;
  922. int startingY = (((int)WorldGen.worldSurfaceLow - 50) + (90)) / 2;
  923. if (Main.maxTilesX > 8000)
  924. {
  925. startingY -= 25;
  926. }
  927. startingX -= WidthOffset + (((roomsPerLayer - 1) / 2) * (roomWidth + bridgeWidth));
  928. startingY -= HeightOffset;
  929. /*
  930. generateRoom(startingX, startingY, 1);
  931. generateBridge(startingX + roomWidth, startingY, 1);
  932. generateRoom(startingX + roomWidth + bridgeWidth, startingY, 1);
  933. */
  934. int treasure = Main.rand.Next(roomsPerLayer - 1);
  935. if (treasure >= (roomsPerLayer - 1) / 2)
  936. {
  937. treasure++;
  938. }
  939. for (int n = 0; n < roomsPerLayer; n++)
  940. {
  941. if (n == (roomsPerLayer - 1) / 2)
  942. {
  943. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, -1);
  944. }
  945. else
  946. {
  947. if (n == treasure)
  948. {
  949. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, -2);
  950. }
  951. else
  952. {
  953. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, 1);
  954. }
  955.  
  956. }
  957.  
  958. if (n != roomsPerLayer - 1)
  959. {
  960. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY, 0);
  961. }
  962.  
  963.  
  964. }
  965. treasure = Main.rand.Next(roomsPerLayer);
  966. for (int n = 0; n < roomsPerLayer; n++)
  967. {
  968. if (n == treasure)
  969. {
  970. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), -2);
  971. }
  972. else
  973. {
  974. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), 1);
  975. }
  976. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight) + roomHeight, 1);
  977. if (n != roomsPerLayer - 1)
  978. {
  979. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), 0);
  980. }
  981.  
  982.  
  983. }
  984. if (Main.maxTilesX > 6000)
  985. {
  986. treasure = Main.rand.Next(roomsPerLayer);
  987. for (int n = 0; n < roomsPerLayer; n++)
  988. {
  989. if (n == treasure)
  990. {
  991. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), -2);
  992. }
  993. else
  994. {
  995. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), 1);
  996. }
  997. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight) - verticalHeight, 1);
  998. if (n != roomsPerLayer - 1)
  999. {
  1000. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), 0);
  1001. }
  1002.  
  1003.  
  1004. }
  1005. treasure = Main.rand.Next(roomsPerLayer);
  1006. for (int n = 0; n < roomsPerLayer; n++)
  1007. {
  1008. if (n == treasure)
  1009. {
  1010. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), -2);
  1011. }
  1012. else
  1013. {
  1014. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), 1);
  1015. }
  1016. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight) + roomHeight, 1);
  1017. if (n != roomsPerLayer - 1)
  1018. {
  1019. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), 0);
  1020. }
  1021.  
  1022.  
  1023. }
  1024. }
  1025. if (Main.maxTilesX > 8000)
  1026. {
  1027. treasure = Main.rand.Next(roomsPerLayer);
  1028. for (int n = 0; n < roomsPerLayer; n++)
  1029. {
  1030. if (n == treasure)
  1031. {
  1032. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), -2);
  1033. }
  1034. else
  1035. {
  1036. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), 1);
  1037. }
  1038. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight) - verticalHeight, 1);
  1039. if (n != roomsPerLayer - 1)
  1040. {
  1041. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), 0);
  1042. }
  1043.  
  1044.  
  1045. }
  1046.  
  1047. }
  1048.  
  1049. }));
  1050. }
  1051. }
  1052. }
  1053. public override void PostWorldGen()
  1054. {
  1055.  
  1056. Mod Overrated = ModLoader.GetMod("CalamityMod");
  1057. if(Overrated != null)
  1058. {
  1059. int startingX;
  1060. float upperLimit = 60;
  1061. float lowerLimit;
  1062. int Center;
  1063. int maxDistanceFromCenter;
  1064. if (Main.dungeonX < Main.maxTilesX * .5f)
  1065. {
  1066. Center = (int)((double)Main.maxTilesX * 0.8);
  1067. }
  1068. else
  1069. {
  1070. Center = (int)((double)Main.maxTilesX * 0.2);
  1071. }
  1072. if (Main.maxTilesX > 8000)
  1073. {
  1074. lowerLimit = 320;
  1075. maxDistanceFromCenter = 750;
  1076. }
  1077. else if (Main.maxTilesX > 6000)
  1078. {
  1079. lowerLimit = 230;
  1080. maxDistanceFromCenter = 550;
  1081. }
  1082. else
  1083. {
  1084. lowerLimit = 130;
  1085. maxDistanceFromCenter = 320;
  1086. }
  1087. QwertyMethods.BreakTiles(Center - maxDistanceFromCenter, 0, maxDistanceFromCenter * 2, (int)(lowerLimit));
  1088. //Main.NewText(maxDistanceFromCenter);
  1089.  
  1090. //Main.NewText(Main.maxTilesX);
  1091. if (Main.dungeonX < Main.maxTilesX * .5f)
  1092. {
  1093. startingX = (int)((double)Main.maxTilesX * 0.8);
  1094. }
  1095. else
  1096. {
  1097. startingX = (int)((double)Main.maxTilesX * 0.2);
  1098. }
  1099. //Main.NewText(startingX);
  1100. int roomsPerLayer = 7;
  1101.  
  1102. if (Main.maxTilesX > 8000)
  1103. {
  1104. roomsPerLayer += 4;
  1105.  
  1106. }
  1107. if (Main.maxTilesX > 6000)
  1108. {
  1109. roomsPerLayer += 4;
  1110. }
  1111. else
  1112. {
  1113.  
  1114. }
  1115. int roomHeight = 25;
  1116. int roomWidth = 25;
  1117. int bridgeHeight = 25;
  1118. int bridgeWidth = 75;
  1119. int verticalHeight = 21;
  1120. int verticalWith = 25;
  1121. int HeightOffset = (roomHeight - 1) / 2;
  1122. int WidthOffset = (roomWidth - 1) / 2;
  1123. int startingY = 110;
  1124. if (Main.maxTilesX > 8000)
  1125. {
  1126. startingY = 195;
  1127. }
  1128. else if (Main.maxTilesX > 6000)
  1129. {
  1130. startingY = 145;
  1131. }
  1132. else
  1133. {
  1134. startingY = 110;
  1135.  
  1136. }
  1137. if (Main.maxTilesX > 8000)
  1138. {
  1139. startingY -= 25;
  1140. }
  1141. startingX -= WidthOffset + (((roomsPerLayer - 1) / 2) * (roomWidth + bridgeWidth));
  1142. startingY -= HeightOffset;
  1143.  
  1144.  
  1145.  
  1146. int treasure = Main.rand.Next(roomsPerLayer - 1);
  1147. if (treasure >= (roomsPerLayer - 1) / 2)
  1148. {
  1149. treasure++;
  1150. }
  1151. for (int n = 0; n < roomsPerLayer; n++)
  1152. {
  1153. if (n == (roomsPerLayer - 1) / 2)
  1154. {
  1155. //Main.NewText(n + ", " + startingX + (n * (roomWidth + bridgeWidth)) + ", " + startingY);
  1156. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, -1);
  1157. }
  1158. else
  1159. {
  1160. if (n == treasure)
  1161. {
  1162. //Main.NewText(n + ", " + startingX + (n * (roomWidth + bridgeWidth)) + ", " + startingY);
  1163. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, -2);
  1164. }
  1165. else
  1166. {
  1167. //Main.NewText(n + ", " + startingX + (n * (roomWidth + bridgeWidth)) + ", " + startingY);
  1168. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, 1);
  1169. }
  1170.  
  1171. }
  1172.  
  1173. if (n != roomsPerLayer - 1)
  1174. {
  1175. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY, 0);
  1176. }
  1177.  
  1178.  
  1179. }
  1180. treasure = Main.rand.Next(roomsPerLayer);
  1181. for (int n = 0; n < roomsPerLayer; n++)
  1182. {
  1183. if (n == treasure)
  1184. {
  1185. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), -2);
  1186. }
  1187. else
  1188. {
  1189. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), 1);
  1190. }
  1191. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight) + roomHeight, 1);
  1192. if (n != roomsPerLayer - 1)
  1193. {
  1194. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), 0);
  1195. }
  1196.  
  1197.  
  1198. }
  1199. if (Main.maxTilesX > 6000)
  1200. {
  1201. treasure = Main.rand.Next(roomsPerLayer);
  1202. for (int n = 0; n < roomsPerLayer; n++)
  1203. {
  1204. if (n == treasure)
  1205. {
  1206. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), -2);
  1207. }
  1208. else
  1209. {
  1210. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), 1);
  1211. }
  1212. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight) - verticalHeight, 1);
  1213. if (n != roomsPerLayer - 1)
  1214. {
  1215. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), 0);
  1216. }
  1217.  
  1218.  
  1219. }
  1220. treasure = Main.rand.Next(roomsPerLayer);
  1221. for (int n = 0; n < roomsPerLayer; n++)
  1222. {
  1223. if (n == treasure)
  1224. {
  1225. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), -2);
  1226. }
  1227. else
  1228. {
  1229. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), 1);
  1230. }
  1231. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight) + roomHeight, 1);
  1232. if (n != roomsPerLayer - 1)
  1233. {
  1234. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), 0);
  1235. }
  1236.  
  1237.  
  1238. }
  1239. }
  1240. if (Main.maxTilesX > 8000)
  1241. {
  1242. treasure = Main.rand.Next(roomsPerLayer);
  1243. for (int n = 0; n < roomsPerLayer; n++)
  1244. {
  1245. if (n == treasure)
  1246. {
  1247. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), -2);
  1248. }
  1249. else
  1250. {
  1251. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), 1);
  1252. }
  1253. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight) - verticalHeight, 1);
  1254. if (n != roomsPerLayer - 1)
  1255. {
  1256. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), 0);
  1257. }
  1258.  
  1259.  
  1260. }
  1261.  
  1262. }
  1263. }
  1264. }
  1265.  
  1266. }
  1267.  
  1268. public class RegenFortress : ModCommand
  1269. {
  1270. public override CommandType Type
  1271. {
  1272. get { return CommandType.Chat; }
  1273. }
  1274.  
  1275. public override string Command
  1276. {
  1277. get { return "RegenFortress"; }
  1278. }
  1279.  
  1280. public override string Description
  1281. {
  1282. get { return "Regenerates the sky fortress"; }
  1283. }
  1284.  
  1285. public void Vertical(int i, int j, int type = 0)
  1286. {
  1287. int pillar = mod.TileType("FortressPillar");
  1288. int tile1 = mod.TileType("FortressBrick");
  1289. if (type == 1) //basic vertical connection
  1290. {
  1291. int side = WorldGen.genRand.Next(2);
  1292. for (int b = -1; b < 22; b++)
  1293. {
  1294. for (int a = 0; a < 25; a++)
  1295. {
  1296.  
  1297. if (side == 0)
  1298. {
  1299. if (a < 8 && b == 8)
  1300. {
  1301. WorldGen.PlaceTile(i + a, j + b, tile1);
  1302. if (a != 0 && a != 7)
  1303. {
  1304. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  1305. }
  1306. }
  1307. else if (a > 16 && b == 12)
  1308. {
  1309.  
  1310. WorldGen.PlaceTile(i + a, j + b, tile1);
  1311. if (a != 17 && a != 24)
  1312. {
  1313. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  1314. }
  1315. }
  1316. }
  1317. else
  1318. {
  1319. if (a < 8 && b == 12)
  1320. {
  1321. WorldGen.PlaceTile(i + a, j + b, tile1);
  1322. if (a != 0 && a != 7)
  1323. {
  1324. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  1325. }
  1326. }
  1327. else if (a > 16 && b == 8)
  1328. {
  1329.  
  1330. WorldGen.PlaceTile(i + a, j + b, tile1);
  1331. if (a != 17 && a != 24)
  1332. {
  1333. WorldGen.PlaceTile(i + a, j + b + 1, tile1);
  1334. }
  1335. }
  1336. }
  1337.  
  1338.  
  1339. if ((a == 23 || a == 1 || a == 18 || a == 6) && !Main.tile[i + a, j + b].active())
  1340. {
  1341. WorldGen.PlaceTile(i + a, j + b, pillar);
  1342. }
  1343. }
  1344. }
  1345. }
  1346. }
  1347. public void generateBridge(int i, int j, int type = 0)
  1348. {
  1349. int tile1 = mod.TileType("FortressBrick");
  1350. int wall1 = mod.WallType("FortressWall");
  1351. int pillar = mod.TileType("FortressPillar");
  1352. if (type == 0)
  1353. {
  1354. type = WorldGen.genRand.Next(1, 4);
  1355. }
  1356. if (type == 1) //basic bridge
  1357. {
  1358. for (int a = 0; a < 75; a++)
  1359. {
  1360. for (int b = 0; b < 25; b++)
  1361. {
  1362. int extension = 28;
  1363. int upperExtension = 18;
  1364. if (b == 20 && (a < extension || a > 74 - extension))
  1365. {
  1366. WorldGen.PlaceTile(i + a, j + b, tile1);
  1367. }
  1368. if (b == 21 && (a < extension - 1 || a > 74 - extension + 1))
  1369. {
  1370. WorldGen.PlaceTile(i + a, j + b, tile1);
  1371. }
  1372. if (b == 22 && (a < extension - 2 || a > 74 - extension + 2))
  1373. {
  1374. WorldGen.PlaceTile(i + a, j + b, tile1);
  1375. }
  1376. if (b == 4 && (a < upperExtension || a > 74 - upperExtension))
  1377. {
  1378. WorldGen.PlaceTile(i + a, j + b, tile1);
  1379. }
  1380. if (b == 3 && (a < upperExtension - 1 || a > 74 - upperExtension + 1))
  1381. {
  1382. WorldGen.PlaceTile(i + a, j + b, tile1);
  1383. }
  1384. if (b == 2 && (a < upperExtension - 2 || a > 74 - upperExtension + 2))
  1385. {
  1386. WorldGen.PlaceTile(i + a, j + b, tile1);
  1387. }
  1388. if (a % 4 == 3 && !Main.tile[i + a, j + b].active() && (a < upperExtension - 1 || a > 74 - upperExtension + 1) && b > 4 && b < 20)
  1389. {
  1390. WorldGen.PlaceTile(i + a, j + b, pillar);
  1391. }
  1392. #region walls
  1393. #endregion
  1394. }
  1395. }
  1396.  
  1397. }
  1398. if (type == 2) //shorter bridge with island in center
  1399. {
  1400. for (int a = 0; a < 75; a++)
  1401. {
  1402. for (int b = 0; b < 25; b++)
  1403. {
  1404. int extension = 8;
  1405. if (b == 20 && ((a < extension || a > 75 - extension) || (a > 25 && a < 49)))
  1406. {
  1407. WorldGen.PlaceTile(i + a, j + b, tile1);
  1408. }
  1409. if (b == 21 && ((a < extension - 1 || a > 75 - extension + 1) || (a > 26 && a < 48)))
  1410. {
  1411. WorldGen.PlaceTile(i + a, j + b, tile1);
  1412. }
  1413. if (b == 22 && ((a < extension - 2 || a > 75 - extension + 2) || (a > 27 && a < 47)))
  1414. {
  1415. WorldGen.PlaceTile(i + a, j + b, tile1);
  1416. }
  1417. if (b == 12 && (a > 29 && a < 45))
  1418. {
  1419. WorldGen.PlaceTile(i + a, j + b, tile1);
  1420. if (a != 30 && a != 44)
  1421. {
  1422. WorldGen.PlaceTile(i + a, j + b - 1, tile1);
  1423. }
  1424. }
  1425. if (b > 12 && b < 20 && (a == 31 || a == 43 || a == 35 || a == 39) && !Main.tile[i + a, j + b].active())
  1426. {
  1427. WorldGen.PlaceTile(i + a, j + b, pillar);
  1428. }
  1429. }
  1430. }
  1431. }
  1432. if (type == 3)
  1433. {
  1434.  
  1435. for (int b = 0; b < 25; b++)
  1436. {
  1437. if (b > 2 && b < 22)
  1438. {
  1439. WorldGen.PlaceTile(i, j + b, tile1);
  1440. WorldGen.PlaceTile(i + 74, j + b, tile1);
  1441. }
  1442. }
  1443.  
  1444. }
  1445.  
  1446. }
  1447. public void generateRoom(int i, int j, int type = 0)
  1448. {
  1449.  
  1450. int pillar = mod.TileType("FortressPillar");
  1451. int wall1 = mod.WallType("FortressWall");
  1452. int tile1 = mod.TileType("FortressBrick");
  1453. int plat1 = mod.TileType("FortressPlatform");
  1454. if (type == 1) //Basic Room
  1455. {
  1456. #region tiles
  1457. for (int b = 0; b < 25; b++)//Layers
  1458. {
  1459. if (b == 0 || b == 24)
  1460. {
  1461. for (int a = 0; a < 25; a++)
  1462. {
  1463. if (a >= 10 && a <= 14)
  1464. {
  1465.  
  1466. WorldGen.PlaceTile(i + a, j + b, plat1);
  1467. }
  1468. else if (a >= 2 && a <= 22)
  1469. {
  1470. WorldGen.PlaceTile(i + a, j + b, tile1);
  1471. }
  1472.  
  1473. }
  1474. }
  1475. else if (b == 1 || b == 23)
  1476. {
  1477. for (int a = 0; a < 25; a++)
  1478. {
  1479. if (a >= 10 && a <= 14)
  1480. {
  1481.  
  1482. }
  1483. else if (a >= 1 && a <= 23)
  1484. {
  1485. WorldGen.PlaceTile(i + a, j + b, tile1);
  1486. }
  1487. }
  1488. }
  1489. else if (b < 5 || b > 19)
  1490. {
  1491. for (int a = 0; a < 25; a++)
  1492. {
  1493. if (a >= 10 && a <= 14)
  1494. {
  1495.  
  1496. }
  1497. else
  1498. {
  1499. WorldGen.PlaceTile(i + a, j + b, tile1);
  1500. }
  1501. }
  1502. }
  1503. else if (b == 11)
  1504. {
  1505. for (int a = 0; a < 25; a++)
  1506. {
  1507. if (a >= 10 && a <= 14)
  1508. {
  1509.  
  1510. WorldGen.PlaceTile(i + a, j + b, tile1);
  1511. }
  1512. }
  1513. }
  1514. else if (b == 12)
  1515. {
  1516. for (int a = 0; a < 25; a++)
  1517. {
  1518.  
  1519. if (a >= 6 && a <= 18)
  1520. {
  1521.  
  1522. WorldGen.PlaceTile(i + a, j + b, tile1);
  1523. }
  1524. }
  1525. }
  1526. else if (b == 13)
  1527. {
  1528. for (int a = 0; a < 25; a++)
  1529. {
  1530.  
  1531. if (a >= 7 && a <= 17)
  1532. {
  1533.  
  1534. WorldGen.PlaceTile(i + a, j + b, tile1);
  1535. }
  1536. }
  1537. }
  1538.  
  1539.  
  1540. }
  1541. #endregion
  1542. #region walls
  1543. for (int b = 0; b < 25; b++)//Layers
  1544. {
  1545. for (int a = 0; a < 25; a++)
  1546. {
  1547. if (!Main.tile[i + a, j + b].active() && !(a == 0 && b == 0) && !(a == 1 && b == 0) && !(a == 0 && b == 1) && !(a == 24 && b == 0) && !(a == 24 && b == 1) && !(a == 23 && b == 0) && !(a == 24 && b == 24) && !(a == 23 && b == 24) && !(a == 24 && b == 23) && !(a == 0 && b == 24) && !(a == 1 && b == 24) && !(a == 0 && b == 23))
  1548. {
  1549. WorldGen.PlaceWall(i + a, j + b, wall1);
  1550. }
  1551. }
  1552.  
  1553. }
  1554. #endregion
  1555. #region pillars
  1556. for (int b = 0; b < 25; b++)//Layers
  1557. {
  1558. for (int a = 0; a < 25; a++)
  1559. {
  1560. if ((a == 8 || a == 16) && !Main.tile[i + a, j + b].active())
  1561. {
  1562. WorldGen.PlaceTile(i + a, j + b, pillar);
  1563. }
  1564. }
  1565. }
  1566. #endregion
  1567. }
  1568. if (type == -1) //altar room
  1569. {
  1570. #region tiles
  1571. for (int b = 0; b < 25; b++)//Layers
  1572. {
  1573. if (b == 0 || b == 24)
  1574. {
  1575. for (int a = 0; a < 25; a++)
  1576. {
  1577. if (a >= 10 && a <= 14 && b == 0)
  1578. {
  1579.  
  1580. WorldGen.PlaceTile(i + a, j + b, plat1);
  1581. }
  1582. else if (a >= 2 && a <= 22)
  1583. {
  1584. WorldGen.PlaceTile(i + a, j + b, tile1);
  1585. }
  1586.  
  1587. }
  1588. }
  1589. else if (b == 1 || b == 23)
  1590. {
  1591. for (int a = 0; a < 25; a++)
  1592. {
  1593. if (a >= 10 && a <= 14 && b == 1)
  1594. {
  1595.  
  1596. }
  1597. else if (a >= 1 && a <= 23)
  1598. {
  1599. WorldGen.PlaceTile(i + a, j + b, tile1);
  1600. }
  1601. }
  1602. }
  1603. else if (b < 5 || b > 19)
  1604. {
  1605. for (int a = 0; a < 25; a++)
  1606. {
  1607. if (a >= 10 && a <= 14 && b < 5)
  1608. {
  1609.  
  1610. }
  1611. else
  1612. {
  1613. WorldGen.PlaceTile(i + a, j + b, tile1);
  1614. }
  1615. }
  1616. }
  1617. if (b == 19)
  1618. {
  1619. for (int a = 0; a < 25; a++)
  1620. {
  1621. if (a >= 7 && a <= 17)
  1622. {
  1623. WorldGen.PlaceTile(i + a, j + b, tile1);
  1624. }
  1625. }
  1626. }
  1627. if (b == 18)
  1628. {
  1629. for (int a = 0; a < 25; a++)
  1630. {
  1631. if (a >= 9 && a <= 15)
  1632. {
  1633. WorldGen.PlaceTile(i + a, j + b, tile1);
  1634. }
  1635. }
  1636. }
  1637.  
  1638.  
  1639. }
  1640. #endregion
  1641. #region walls
  1642. for (int b = 0; b < 25; b++)//Layers
  1643. {
  1644. for (int a = 0; a < 25; a++)
  1645. {
  1646. if (!Main.tile[i + a, j + b].active() && !(a == 0 && b == 0) && !(a == 1 && b == 0) && !(a == 0 && b == 1) && !(a == 24 && b == 0) && !(a == 24 && b == 1) && !(a == 23 && b == 0) && !(a == 24 && b == 24) && !(a == 23 && b == 24) && !(a == 24 && b == 23) && !(a == 0 && b == 24) && !(a == 1 && b == 24) && !(a == 0 && b == 23))
  1647. {
  1648. WorldGen.PlaceWall(i + a, j + b, wall1);
  1649. }
  1650. }
  1651.  
  1652. }
  1653. #endregion
  1654. WorldGen.PlaceTile(i + 12, j + 17, mod.TileType("FortressAltar"));
  1655. WorldGen.PlaceTile(i + 12, j + 12, mod.TileType("FortressCarving1"));
  1656. WorldGen.PlaceTile(i + 18, j + 14, mod.TileType("FortressCarving2"));
  1657. WorldGen.PlaceTile(i + 6, j + 14, mod.TileType("FortressCarving3"));
  1658. }
  1659. if (type == -2) //treausre room
  1660. {
  1661. #region tiles
  1662. for (int b = 0; b < 25; b++)//Layers
  1663. {
  1664. if (b == 0 || b == 24)
  1665. {
  1666. for (int a = 0; a < 25; a++)
  1667. {
  1668. if (a >= 10 && a <= 14 && b == 0)
  1669. {
  1670.  
  1671. WorldGen.PlaceTile(i + a, j + b, plat1);
  1672. }
  1673. else if (a >= 2 && a <= 22)
  1674. {
  1675. WorldGen.PlaceTile(i + a, j + b, tile1);
  1676. }
  1677.  
  1678. }
  1679. }
  1680. else if (b == 1 || b == 23)
  1681. {
  1682. for (int a = 0; a < 25; a++)
  1683. {
  1684. if (a >= 10 && a <= 14 && b == 1)
  1685. {
  1686.  
  1687. }
  1688. else if (a >= 1 && a <= 23)
  1689. {
  1690. WorldGen.PlaceTile(i + a, j + b, tile1);
  1691. }
  1692. }
  1693. }
  1694. else if (b < 5 || b > 19)
  1695. {
  1696. for (int a = 0; a < 25; a++)
  1697. {
  1698. if (a >= 10 && a <= 14 && b < 5)
  1699. {
  1700.  
  1701. }
  1702. else
  1703. {
  1704. WorldGen.PlaceTile(i + a, j + b, tile1);
  1705. }
  1706. }
  1707. }
  1708. else if (b >= 5 && b <= 7)
  1709. {
  1710. for (int a = 0; a < 25; a++)
  1711. {
  1712. if (a == 0 || a == 24)
  1713. {
  1714. WorldGen.PlaceTile(i + a, j + b, tile1);
  1715. }
  1716. }
  1717. }
  1718. else if (b == 8)
  1719. {
  1720. for (int a = 0; a < 25; a++)
  1721. {
  1722. if (a <= 5 || a >= 19)
  1723. {
  1724. WorldGen.PlaceTile(i + a, j + b, tile1);
  1725. }
  1726. }
  1727. }
  1728. else if (b == 11)
  1729. {
  1730. for (int a = 0; a < 25; a++)
  1731. {
  1732. if (a >= 10 && a <= 14)
  1733. {
  1734.  
  1735. WorldGen.PlaceTile(i + a, j + b, tile1);
  1736. }
  1737. }
  1738. }
  1739. else if (b == 12)
  1740. {
  1741. for (int a = 0; a < 25; a++)
  1742. {
  1743.  
  1744. if (a >= 6 && a <= 18)
  1745. {
  1746.  
  1747. WorldGen.PlaceTile(i + a, j + b, tile1);
  1748. }
  1749. }
  1750. }
  1751. else if (b == 13)
  1752. {
  1753. for (int a = 0; a < 25; a++)
  1754. {
  1755.  
  1756. if (a >= 7 && a <= 17)
  1757. {
  1758.  
  1759. WorldGen.PlaceTile(i + a, j + b, tile1);
  1760. }
  1761. }
  1762. }
  1763.  
  1764.  
  1765. }
  1766. #endregion
  1767. #region walls
  1768. for (int b = 0; b < 25; b++)//Layers
  1769. {
  1770. for (int a = 0; a < 25; a++)
  1771. {
  1772. if (!Main.tile[i + a, j + b].active() && !(a == 0 && b == 0) && !(a == 1 && b == 0) && !(a == 0 && b == 1) && !(a == 24 && b == 0) && !(a == 24 && b == 1) && !(a == 23 && b == 0) && !(a == 24 && b == 24) && !(a == 23 && b == 24) && !(a == 24 && b == 23) && !(a == 0 && b == 24) && !(a == 1 && b == 24) && !(a == 0 && b == 23))
  1773. {
  1774. if (a != 0 && a != 24)
  1775. {
  1776. WorldGen.PlaceWall(i + a, j + b, wall1);
  1777. }
  1778. }
  1779. }
  1780.  
  1781. }
  1782. #endregion
  1783. WorldGen.PlaceTile(i + 12, j + 19, TileID.Anvils);
  1784. #region pillars
  1785. for (int b = 0; b < 25; b++)//Layers
  1786. {
  1787. for (int a = 0; a < 25; a++)
  1788. {
  1789. if ((a == 8 || a == 16) && !Main.tile[i + a, j + b].active())
  1790. {
  1791. WorldGen.PlaceTile(i + a, j + b, pillar);
  1792. }
  1793. }
  1794. if (b >= 5 && b <= 7)
  1795. {
  1796. for (int a = 0; a < 25; a++)
  1797. {
  1798. if (a == 4 || a == 20)
  1799. {
  1800. WorldGen.PlaceTile(i + a, j + b, pillar);
  1801. }
  1802. }
  1803. }
  1804. if (b > 5 && b < 20)
  1805. {
  1806. for (int a = 0; a < 25; a++)
  1807. {
  1808. if ((a == 0 || a == 24) && !Main.tile[i + a, j + b].active())
  1809. {
  1810. WorldGen.PlaceTile(i + a, j + b, pillar);
  1811. }
  1812. }
  1813. }
  1814. }
  1815.  
  1816. #endregion
  1817. #region treasure
  1818. int gap = WorldGen.genRand.Next(0, 3);
  1819. int gap2 = WorldGen.genRand.Next(0, 3);
  1820. bool secondPlace = false;
  1821. bool secondPlace2 = false;
  1822. bool hasntPlaced = true;
  1823. bool hasntPlaced2 = true;
  1824. for (int b = 0; b < 25; b++)
  1825. {
  1826. if (b == 7)
  1827. {
  1828. for (int a = 0; a < 25; a++)
  1829. {
  1830. if ((a >= 21 && a <= 23))
  1831. {
  1832. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  1833. if (21 + gap != a)
  1834. {
  1835. WorldGen.PlaceTile(i + a, j + b - 1, mod.TileType("CaeliteBar"));
  1836. if ((Main.rand.Next(1) == 0 || secondPlace) && hasntPlaced)
  1837. {
  1838. WorldGen.PlaceTile(i + a, j + b - 2, mod.TileType("CaeliteBar"));
  1839. hasntPlaced = false;
  1840. }
  1841. else
  1842. {
  1843. secondPlace = true;
  1844. }
  1845. }
  1846. }
  1847. if ((a >= 1 && a <= 3))
  1848. {
  1849. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  1850. if (1 + gap2 != a)
  1851. {
  1852. WorldGen.PlaceTile(i + a, j + b - 1, mod.TileType("CaeliteBar"));
  1853. if ((Main.rand.Next(1) == 0 || secondPlace2) && hasntPlaced2)
  1854. {
  1855. WorldGen.PlaceTile(i + a, j + b - 2, mod.TileType("CaeliteBar"));
  1856. hasntPlaced2 = false;
  1857. }
  1858. else
  1859. {
  1860. secondPlace2 = true;
  1861. }
  1862. }
  1863. }
  1864. }
  1865. }
  1866. /*
  1867. if (b == 6)
  1868. {
  1869.  
  1870. for (int a = 0; a < 25; a++)
  1871. {
  1872. if ((a >= 1 && a <= 3 && 1+gap != a) )
  1873. {
  1874.  
  1875. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  1876.  
  1877. if((Main.rand.Next(1) ==0|| secondPlace) && hasntPlaced)
  1878. {
  1879. WorldGen.PlaceTile(i + a, j + b-1, mod.TileType("CaeliteBar"));
  1880. hasntPlaced = false;
  1881. }
  1882. else
  1883. {
  1884. secondPlace = true;
  1885. }
  1886.  
  1887. }
  1888. if((a >= 21 && a <= 23 && 21 + gap != a))
  1889. {
  1890. WorldGen.PlaceTile(i + a, j + b, mod.TileType("CaeliteBar"));
  1891.  
  1892. if ((Main.rand.Next(1) == 0 || secondPlace2) && hasntPlaced2)
  1893. {
  1894. WorldGen.PlaceTile(i + a, j + b - 1, mod.TileType("CaeliteBar"));
  1895. hasntPlaced2 = false;
  1896. }
  1897. else
  1898. {
  1899. secondPlace2 = true;
  1900. }
  1901.  
  1902. }
  1903. }
  1904.  
  1905. }
  1906. */
  1907. }
  1908. #endregion
  1909.  
  1910. }
  1911. }
  1912. public int startingX;
  1913. float upperLimit = 60;
  1914. float lowerLimit;
  1915. int Center;
  1916. int maxDistanceFromCenter;
  1917. public override void Action(CommandCaller caller, string input, string[] args)
  1918. {
  1919. Main.NewText("The sky has been Fortified!");
  1920.  
  1921. if (Main.dungeonX < Main.maxTilesX * .5f)
  1922. {
  1923. Center = (int)((double)Main.maxTilesX * 0.8);
  1924. }
  1925. else
  1926. {
  1927. Center = (int)((double)Main.maxTilesX * 0.2);
  1928. }
  1929. if (Main.maxTilesX > 8000)
  1930. {
  1931. lowerLimit = 320 ;
  1932. maxDistanceFromCenter = 750;
  1933. }
  1934. else if (Main.maxTilesX > 6000)
  1935. {
  1936. lowerLimit = 230 ;
  1937. maxDistanceFromCenter = 550;
  1938. }
  1939. else
  1940. {
  1941. lowerLimit = 130 ;
  1942. maxDistanceFromCenter = 320 ;
  1943. }
  1944. QwertyMethods.BreakTiles(Center- maxDistanceFromCenter, 0, maxDistanceFromCenter*2, (int)(lowerLimit));
  1945. //Main.NewText(maxDistanceFromCenter);
  1946.  
  1947. //Main.NewText(Main.maxTilesX);
  1948. if (Main.dungeonX < Main.maxTilesX * .5f)
  1949. {
  1950. startingX = (int)((double)Main.maxTilesX * 0.8);
  1951. }
  1952. else
  1953. {
  1954. startingX = (int)((double)Main.maxTilesX * 0.2);
  1955. }
  1956. //Main.NewText(startingX);
  1957. int roomsPerLayer = 7;
  1958.  
  1959. if (Main.maxTilesX > 8000)
  1960. {
  1961. roomsPerLayer += 4;
  1962.  
  1963. }
  1964. if (Main.maxTilesX > 6000)
  1965. {
  1966. roomsPerLayer += 4;
  1967. }
  1968. else
  1969. {
  1970.  
  1971. }
  1972. int roomHeight = 25;
  1973. int roomWidth = 25;
  1974. int bridgeHeight = 25;
  1975. int bridgeWidth = 75;
  1976. int verticalHeight = 21;
  1977. int verticalWith = 25;
  1978. int HeightOffset = (roomHeight - 1) / 2;
  1979. int WidthOffset = (roomWidth - 1) / 2;
  1980. int startingY = 110;
  1981. if (Main.maxTilesX > 8000)
  1982. {
  1983. startingY =195;
  1984. }
  1985. else if(Main.maxTilesX > 6000)
  1986. {
  1987. startingY = 145;
  1988. }
  1989. else
  1990. {
  1991. startingY = 110;
  1992.  
  1993. }
  1994. if (Main.maxTilesX > 8000)
  1995. {
  1996. startingY -= 25;
  1997. }
  1998. startingX -= WidthOffset + (((roomsPerLayer - 1) / 2) * (roomWidth + bridgeWidth));
  1999. startingY -= HeightOffset;
  2000.  
  2001.  
  2002.  
  2003. int treasure = Main.rand.Next(roomsPerLayer - 1);
  2004. if (treasure >= (roomsPerLayer - 1) / 2)
  2005. {
  2006. treasure++;
  2007. }
  2008. for (int n = 0; n < roomsPerLayer; n++)
  2009. {
  2010. if (n == (roomsPerLayer - 1) / 2)
  2011. {
  2012. //Main.NewText(n + ", " + startingX + (n * (roomWidth + bridgeWidth)) + ", " + startingY);
  2013. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, -1);
  2014. }
  2015. else
  2016. {
  2017. if (n == treasure)
  2018. {
  2019. //Main.NewText(n + ", " + startingX + (n * (roomWidth + bridgeWidth)) + ", " + startingY);
  2020. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, -2);
  2021. }
  2022. else
  2023. {
  2024. //Main.NewText(n + ", " + startingX + (n * (roomWidth + bridgeWidth)) + ", " + startingY);
  2025. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY, 1);
  2026. }
  2027.  
  2028. }
  2029.  
  2030. if (n != roomsPerLayer - 1)
  2031. {
  2032. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY, 0);
  2033. }
  2034.  
  2035.  
  2036. }
  2037. treasure = Main.rand.Next(roomsPerLayer);
  2038. for (int n = 0; n < roomsPerLayer; n++)
  2039. {
  2040. if (n == treasure)
  2041. {
  2042. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), -2);
  2043. }
  2044. else
  2045. {
  2046. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), 1);
  2047. }
  2048. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight) + roomHeight, 1);
  2049. if (n != roomsPerLayer - 1)
  2050. {
  2051. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY - 1 * (roomHeight + verticalHeight), 0);
  2052. }
  2053.  
  2054.  
  2055. }
  2056. if (Main.maxTilesX > 6000)
  2057. {
  2058. treasure = Main.rand.Next(roomsPerLayer);
  2059. for (int n = 0; n < roomsPerLayer; n++)
  2060. {
  2061. if (n == treasure)
  2062. {
  2063. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), -2);
  2064. }
  2065. else
  2066. {
  2067. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), 1);
  2068. }
  2069. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight) - verticalHeight, 1);
  2070. if (n != roomsPerLayer - 1)
  2071. {
  2072. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY + 1 * (roomHeight + verticalHeight), 0);
  2073. }
  2074.  
  2075.  
  2076. }
  2077. treasure = Main.rand.Next(roomsPerLayer);
  2078. for (int n = 0; n < roomsPerLayer; n++)
  2079. {
  2080. if (n == treasure)
  2081. {
  2082. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), -2);
  2083. }
  2084. else
  2085. {
  2086. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), 1);
  2087. }
  2088. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight) + roomHeight, 1);
  2089. if (n != roomsPerLayer - 1)
  2090. {
  2091. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY - 2 * (roomHeight + verticalHeight), 0);
  2092. }
  2093.  
  2094.  
  2095. }
  2096. }
  2097. if (Main.maxTilesX > 8000)
  2098. {
  2099. treasure = Main.rand.Next(roomsPerLayer);
  2100. for (int n = 0; n < roomsPerLayer; n++)
  2101. {
  2102. if (n == treasure)
  2103. {
  2104. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), -2);
  2105. }
  2106. else
  2107. {
  2108. generateRoom(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), 1);
  2109. }
  2110. Vertical(startingX + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight) - verticalHeight, 1);
  2111. if (n != roomsPerLayer - 1)
  2112. {
  2113. generateBridge(startingX + roomWidth + (n * (roomWidth + bridgeWidth)), startingY + 2 * (roomHeight + verticalHeight), 0);
  2114. }
  2115.  
  2116.  
  2117. }
  2118.  
  2119. }
  2120.  
  2121. }
  2122. }
  2123. public class SkyRNG : ModCommand
  2124. {
  2125. private static int numIslandHouses = 0;
  2126.  
  2127. private static int houseCount = 0;
  2128. private static bool[] skyLake = new bool[30];
  2129. private static int[] fihX = new int[30];
  2130.  
  2131. private static int[] fihY = new int[30];
  2132. public override CommandType Type
  2133. {
  2134. get { return CommandType.Chat; }
  2135. }
  2136.  
  2137. public override string Command
  2138. {
  2139. get { return "skyrng"; }
  2140. }
  2141.  
  2142. public override string Description
  2143. {
  2144. get { return "Stimulates sky island generation and give the coordinates"; }
  2145. }
  2146.  
  2147. public override void Action(CommandCaller caller, string input, string[] args)
  2148. {
  2149. Main.NewText("player: " + Main.player[Main.myPlayer].Center.ToPoint16());
  2150. numIslandHouses = 0;
  2151. houseCount = 0;
  2152. int skyLakes = 1;
  2153. if (Main.maxTilesX > 8000)
  2154. {
  2155. int skyLakes2 = skyLakes;
  2156. skyLakes = skyLakes2 + 1;
  2157. }
  2158. if (Main.maxTilesX > 6000)
  2159. {
  2160. int skyLakes2 = skyLakes;
  2161. skyLakes = skyLakes2 + 1;
  2162. }
  2163. for (int k = 0; k < (int)((double)Main.maxTilesX * 0.0008) + skyLakes; k++)
  2164. {
  2165. int num = 1000;
  2166. int num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.1), (int)((double)Main.maxTilesX * 0.9));
  2167. if (WorldGen.dungeonX < Main.maxTilesX * .5f)
  2168. {
  2169. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.1), (int)((double)Main.maxTilesX * 0.7));
  2170. }
  2171. else
  2172. {
  2173. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.9));
  2174. }
  2175.  
  2176. while (--num > 0)
  2177. {
  2178. bool flag2 = true;
  2179. while (num2 > Main.maxTilesX / 2 - 80 && num2 < Main.maxTilesX / 2 + 80)
  2180. {
  2181. if (WorldGen.dungeonX < Main.maxTilesX * .5f)
  2182. {
  2183. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.1), (int)((double)Main.maxTilesX * 0.7));
  2184. }
  2185. else
  2186. {
  2187. num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.9));
  2188. }
  2189. }
  2190. for (int l = 0; l < numIslandHouses; l++)
  2191. {
  2192. if (num2 > fihX[l] - 180 && num2 < fihX[l] + 180)
  2193. {
  2194. flag2 = false;
  2195. break;
  2196. }
  2197. }
  2198. if (flag2)
  2199. {
  2200. flag2 = false;
  2201. int num3 = 0;
  2202. int num4 = 200;
  2203. while ((double)num4 < Main.worldSurface)
  2204. {
  2205. if (Main.tile[num2, num4].active())
  2206. {
  2207. num3 = num4;
  2208. flag2 = true;
  2209. break;
  2210. }
  2211. num4++;
  2212. }
  2213. if (flag2)
  2214. {
  2215. int num5 = WorldGen.genRand.Next(90, num3 - 100);
  2216. num5 = Math.Min(num5, (int)WorldGen.worldSurfaceLow - 50);
  2217. if (k < skyLakes)
  2218. {
  2219. skyLake[numIslandHouses] = true;
  2220. WorldGen.CloudLake(num2, num5);
  2221. Main.NewText("Lake: " + new Vector2(num2, num5));
  2222. }
  2223. else
  2224. {
  2225. WorldGen.CloudIsland(num2, num5);
  2226. //Main.NewText(new Vector2(num2, num5));
  2227. Main.NewText("Island: " + new Vector2(num2, num5));
  2228. }
  2229. fihX[numIslandHouses] = num2;
  2230. fihY[numIslandHouses] = num5;
  2231. numIslandHouses++;
  2232. }
  2233. }
  2234. }
  2235. }
  2236.  
  2237. }
  2238. }
  2239.  
  2240.  
  2241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement