Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DD2Event.cs
Go to the documentation of this file.
2using System.IO;
5using Terraria.Chat;
9using Terraria.ID;
12
14
15public class DD2Event
16{
17 private static readonly Color INFO_NEW_WAVE_COLOR = new Color(175, 55, 255);
18
19 private static readonly Color INFO_START_INVASION_COLOR = new Color(50, 255, 130);
20
21 private static readonly Color INFO_FAILURE_INVASION_COLOR = new Color(255, 0, 0);
22
23 private const int INVASION_ID = 3;
24
25 public static bool DownedInvasionT1;
26
27 public static bool DownedInvasionT2;
28
29 public static bool DownedInvasionT3;
30
31 public static bool LostThisRun;
32
33 public static bool WonThisRun;
34
35 public static int LaneSpawnRate = 60;
36
37 private static bool _downedDarkMageT1;
38
39 private static bool _downedOgreT2;
40
41 private static bool _spawnedBetsyT3;
42
43 public static bool Ongoing;
44
45 public static Rectangle ArenaHitbox;
46
47 private static int _arenaHitboxingCooldown;
48
49 public static int OngoingDifficulty;
50
52
53 private static int _crystalsDropping_lastWave;
54
55 private static int _crystalsDropping_toDrop;
56
58
59 private static int _timeLeftUntilSpawningBegins;
60
61 public static bool ReadyToFindBartender => NPC.downedBoss2;
62
63 public static bool DownedInvasionAnyDifficulty
64 {
65 get
66 {
68 {
69 return DownedInvasionT3;
70 }
71 return true;
72 }
73 }
74
75 public static int TimeLeftBetweenWaves
76 {
77 get
78 {
80 }
81 set
82 {
84 }
85 }
86
88
89 public static bool EnemiesShouldChasePlayers
90 {
91 get
92 {
93 if (!Ongoing)
94 {
95 return true;
96 }
97 return true;
98 }
99 }
100
101 public static bool ReadyForTier2
102 {
103 get
104 {
105 if (Main.hardMode)
106 {
107 return NPC.downedMechBossAny;
108 }
109 return false;
110 }
111 }
112
113 public static bool ReadyForTier3
114 {
115 get
116 {
117 if (Main.hardMode)
118 {
119 return NPC.downedGolemBoss;
120 }
121 return false;
122 }
123 }
124
125 public static void Save(BinaryWriter writer)
126 {
127 writer.Write(DownedInvasionT1);
128 writer.Write(DownedInvasionT2);
129 writer.Write(DownedInvasionT3);
130 }
131
132 public static void Load(BinaryReader reader, int gameVersionNumber)
133 {
134 if (gameVersionNumber < 178)
135 {
136 NPC.savedBartender = false;
138 return;
139 }
140 NPC.savedBartender = reader.ReadBoolean();
141 DownedInvasionT1 = reader.ReadBoolean();
142 DownedInvasionT2 = reader.ReadBoolean();
143 DownedInvasionT3 = reader.ReadBoolean();
144 }
145
146 public static void ResetProgressEntirely()
147 {
149 Ongoing = false;
150 ArenaHitbox = default(Rectangle);
153 }
154
160
166
167 public static void SpawnNPC(ref int newNPC)
168 {
169 }
170
171 public static void UpdateTime()
172 {
173 if (!Ongoing && !Main.dedServ)
174 {
175 Filters.Scene.Deactivate("CrystalDestructionVortex");
176 Filters.Scene.Deactivate("CrystalDestructionColor");
177 Filters.Scene.Deactivate("CrystalWin");
178 return;
179 }
180 if (Main.netMode != 1 && !NPC.AnyNPCs(548))
181 {
182 StopInvasion();
183 }
184 if (Main.netMode == 1)
185 {
187 {
189 }
191 {
193 }
194 return;
195 }
197 {
200 {
202 if (!LostThisRun)
203 {
205 if (currentWave == 7 && OngoingDifficulty == 3)
206 {
207 SummonBetsy();
208 }
209 }
210 else
211 {
213 }
214 if (Main.netMode != 1)
215 {
217 }
218 if (Main.netMode == 2)
219 {
221 }
222 }
223 }
225 {
227 }
228 }
229
230 public static void StartInvasion(int difficultyOverride = -1)
231 {
232 if (Main.netMode != 1)
233 {
238 Ongoing = true;
240 if (difficultyOverride != -1)
241 {
243 }
244 _deadGoblinSpots.Clear();
245 _downedDarkMageT1 = false;
246 _downedOgreT2 = false;
247 _spawnedBetsyT3 = false;
248 LostThisRun = false;
249 WonThisRun = false;
250 NPC.totalInvasionPoints = 0f;
251 NPC.waveKills = 0f;
252 NPC.waveNumber = 1;
254 WorldGen.BroadcastText(NetworkText.FromKey("DungeonDefenders2.InvasionStart"), INFO_START_INVASION_COLOR);
256 if (Main.netMode != 1)
257 {
258 Main.ReportInvasionProgress(0, 1, 3, 1);
259 }
260 if (Main.netMode == 2)
261 {
262 NetMessage.SendData(78, -1, -1, null, 0, 1f, 3f, 1f);
263 }
265 WipeEntities();
266 }
267 }
268
269 public static void StopInvasion(bool win = false)
270 {
271 if (Ongoing)
272 {
273 if (win)
274 {
276 }
277 Ongoing = false;
278 _deadGoblinSpots.Clear();
279 if (Main.netMode != 1)
280 {
281 NPC.totalInvasionPoints = 0f;
282 NPC.waveKills = 0f;
283 NPC.waveNumber = 0;
284 WipeEntities();
286 }
287 }
288 }
289
290 private static void WinInvasionInternal()
291 {
292 if (OngoingDifficulty >= 1)
293 {
294 DownedInvasionT1 = true;
295 }
296 if (OngoingDifficulty >= 2)
297 {
298 DownedInvasionT2 = true;
299 }
300 if (OngoingDifficulty >= 3)
301 {
302 DownedInvasionT3 = true;
303 }
304 if (OngoingDifficulty == 1)
305 {
306 DropMedals(3);
307 }
308 if (OngoingDifficulty == 2)
309 {
310 DropMedals(15);
311 }
312 if (OngoingDifficulty == 3)
313 {
315 DropMedals(60);
316 }
317 WorldGen.BroadcastText(NetworkText.FromKey("DungeonDefenders2.InvasionWin"), INFO_START_INVASION_COLOR);
318 }
319
320 public static void LoseInvasionMessage()
321 {
322 WorldGen.BroadcastText(NetworkText.FromKey("DungeonDefenders2.InvasionLose"), INFO_FAILURE_INVASION_COLOR);
323 }
324
325 private static void FindProperDifficulty()
326 {
328 if (ReadyForTier2)
329 {
331 }
332 if (ReadyForTier3)
333 {
335 }
336 }
337
338 public static void CheckProgress(int slainMonsterID)
339 {
341 {
342 return;
343 }
346 float waveKills = NPC.waveKills;
347 NPC.waveKills += num;
348 NPC.totalInvasionPoints += num;
349 currentKillCount += (int)num;
350 bool flag = false;
351 int num2 = currentWave;
352 if (NPC.waveKills >= (float)requiredKillCount && requiredKillCount != 0)
353 {
354 NPC.waveKills = 0f;
355 NPC.waveNumber++;
356 flag = true;
358 if (WonThisRun)
359 {
360 if ((float)currentKillCount != waveKills && num != 0f)
361 {
362 if (Main.netMode != 1)
363 {
365 }
366 if (Main.netMode == 2)
367 {
369 }
370 }
371 return;
372 }
373 int num3 = currentWave;
374 string key = "DungeonDefenders2.WaveComplete";
375 if (num3 == 2)
376 {
377 key = "DungeonDefenders2.WaveCompleteFirst";
378 }
381 if (OngoingDifficulty == 1)
382 {
383 if (num3 == 5)
384 {
385 DropMedals(1);
386 }
387 if (num3 == 4)
388 {
389 DropMedals(1);
390 }
391 }
392 if (OngoingDifficulty == 2)
393 {
394 if (num3 == 7)
395 {
396 DropMedals(6);
397 }
398 if (num3 == 6)
399 {
400 DropMedals(3);
401 }
402 if (num3 == 5)
403 {
404 DropMedals(1);
405 }
406 }
407 if (OngoingDifficulty == 3)
408 {
409 if (num3 == 7)
410 {
411 DropMedals(25);
412 }
413 if (num3 == 6)
414 {
415 DropMedals(11);
416 }
417 if (num3 == 5)
418 {
419 DropMedals(3);
420 }
421 if (num3 == 4)
422 {
423 DropMedals(1);
424 }
425 }
426 }
427 if ((float)currentKillCount == waveKills)
428 {
429 return;
430 }
431 if (flag)
432 {
433 int num4 = 1;
434 int num5 = 1;
435 if (Main.netMode != 1)
436 {
438 }
439 if (Main.netMode == 2)
440 {
441 NetMessage.SendData(78, -1, -1, null, num4, num5, 3f, num2);
442 }
443 }
444 else
445 {
446 if (Main.netMode != 1)
447 {
449 }
450 if (Main.netMode == 2)
451 {
453 }
454 }
455 }
456
457 public static void StartVictoryScene()
458 {
459 WonThisRun = true;
460 int num = NPC.FindFirstNPC(548);
461 if (num == -1)
462 {
463 return;
464 }
465 Main.npc[num].ai[1] = 2f;
466 Main.npc[num].ai[0] = 2f;
467 Main.npc[num].netUpdate = true;
468 for (int i = 0; i < 200; i++)
469 {
470 if (Main.npc[i] != null && Main.npc[i].active && Main.npc[i].type == 549)
471 {
472 Main.npc[i].ai[0] = 0f;
473 Main.npc[i].ai[1] = 1f;
474 Main.npc[i].netUpdate = true;
475 }
476 }
477 }
478
479 public static void ReportLoss()
480 {
481 LostThisRun = true;
483 }
484
503
504 private static short[] GetEnemiesForWave(int wave)
505 {
506 return OngoingDifficulty switch
507 {
511 };
512 }
513
523
525 {
526 switch (OngoingDifficulty)
527 {
528 case 3:
530 break;
531 case 2:
533 break;
534 default:
536 break;
537 }
538 }
539
540 public static void SummonCrystal(int x, int y, int whoAsks)
541 {
542 if (Main.netMode == 1)
543 {
544 NetMessage.SendData(113, -1, -1, null, x, y);
545 }
546 else
547 {
549 }
550 }
551
552 public static void SummonCrystalDirect(int x, int y, int whoAsks)
553 {
554 if (!NPC.AnyNPCs(548))
555 {
557 if (tileSafely.active() && tileSafely.type == 466)
558 {
559 Point point = new Point(x * 16, y * 16);
560 point.X -= tileSafely.frameX / 18 * 16;
561 point.Y -= tileSafely.frameY / 18 * 16;
562 point.X += 40;
563 point.Y += 64;
565 NPC.NewNPC(Main.player[whoAsks].GetNPCSource_TileInteraction(x, y), point.X, point.Y, 548);
567 }
568 }
569 }
570
571 public static bool WouldFailSpawningHere(int x, int y)
572 {
573 StrayMethods.CheckArenaScore(new Point(x, y).ToWorldCoordinates(), out var xLeftEnd, out var xRightEnd);
574 int num = xRightEnd.X - x;
575 int num2 = x - xLeftEnd.X;
576 if (num < 60 || num2 < 60)
577 {
578 return true;
579 }
580 return false;
581 }
582
583 public static void FailureMessage(int client)
584 {
585 LocalizedText text = Language.GetText("DungeonDefenders2.BartenderWarning");
586 Color color = new Color(255, 255, 0);
587 if (Main.netMode == 2)
588 {
590 }
591 else
592 {
593 Main.NewText(text.Value, color.R, color.G, color.B);
594 }
595 }
596
597 public static void WipeEntities()
598 {
602 if (Main.netMode == 2)
603 {
604 NetMessage.SendData(114);
605 }
606 }
607
608 public static void ClearAllTowersInGame()
609 {
610 for (int i = 0; i < 1000; i++)
611 {
612 if (Main.projectile[i].active && ProjectileID.Sets.IsADD2Turret[Main.projectile[i].type])
613 {
614 Main.projectile[i].Kill();
615 }
616 }
617 }
618
619 public static void ClearAllDD2HostilesInGame()
620 {
621 for (int i = 0; i < 200; i++)
622 {
623 if (Main.npc[i].active && NPCID.Sets.BelongsToInvasionOldOnesArmy[Main.npc[i].type])
624 {
625 Main.npc[i].active = false;
626 if (Main.netMode == 2)
627 {
628 NetMessage.SendData(23, -1, -1, null, i);
629 }
630 }
631 }
632 }
633
635 {
636 for (int i = 0; i < 400; i++)
637 {
638 Item item = Main.item[i];
639 if (item.active && item.type == 3822)
640 {
641 item.active = false;
642 if (Main.netMode == 2)
643 {
644 NetMessage.SendData(21, -1, -1, null, i);
645 }
646 }
647 }
648 }
649
651 {
652 if (Main.netMode == 1)
653 {
654 return;
655 }
657 for (int i = 0; i < 8000; i++)
658 {
659 Chest chest = Main.chest[i];
660 if (chest == null || !currentlyOpenChests.Contains(i))
661 {
662 continue;
663 }
664 for (int j = 0; j < 40; j++)
665 {
666 if (chest.item[j].type == 3822 && chest.item[j].stack > 0)
667 {
668 chest.item[j].TurnToAir();
669 if (Main.netMode != 0)
670 {
671 NetMessage.SendData(32, -1, -1, null, i, j);
672 }
673 }
674 }
675 }
676 }
677
678 public static void AnnounceGoblinDeath(NPC n)
679 {
680 _deadGoblinSpots.Add(n.Bottom);
681 }
682
683 public static bool CanRaiseGoblinsHere(Vector2 spot)
684 {
685 int num = 0;
687 {
689 {
690 num++;
691 if (num >= 3)
692 {
693 return true;
694 }
695 }
696 }
697 return false;
698 }
699
700 public static void RaiseGoblins(NPC caller, Vector2 spot)
701 {
702 List<Vector2> list = new List<Vector2>();
704 {
706 {
707 list.Add(deadGoblinSpot);
708 }
709 }
710 foreach (Vector2 item in list)
711 {
712 _deadGoblinSpots.Remove(item);
713 }
714 int num = 0;
715 foreach (Vector2 item2 in list)
716 {
717 Point origin = item2.ToTileCoordinates();
718 origin.X += Main.rand.Next(-15, 16);
719 if (WorldUtils.Find(origin, Searches.Chain(new Searches.Down(50), new Conditions.IsSolid()), out var result))
720 {
721 if (OngoingDifficulty == 3)
722 {
723 NPC.NewNPC(caller.GetSpawnSourceForNPCFromNPCAI(), result.X * 16 + 8, result.Y * 16, 567);
724 }
725 else
726 {
727 NPC.NewNPC(caller.GetSpawnSourceForNPCFromNPCAI(), result.X * 16 + 8, result.Y * 16, 566);
728 }
729 if (++num >= 8)
730 {
731 break;
732 }
733 }
734 }
735 }
736
737 public static void FindArenaHitbox()
738 {
740 {
742 return;
743 }
745 Vector2 vector = new Vector2(float.MaxValue, float.MaxValue);
746 Vector2 vector2 = new Vector2(0f, 0f);
747 for (int i = 0; i < 200; i++)
748 {
749 NPC nPC = Main.npc[i];
750 if (nPC.active && (nPC.type == 549 || nPC.type == 548))
751 {
752 Vector2 topLeft = nPC.TopLeft;
753 if (vector.X > topLeft.X)
754 {
755 vector.X = topLeft.X;
756 }
757 if (vector.Y > topLeft.Y)
758 {
759 vector.Y = topLeft.Y;
760 }
761 topLeft = nPC.BottomRight;
762 if (vector2.X < topLeft.X)
763 {
764 vector2.X = topLeft.X;
765 }
766 if (vector2.Y < topLeft.Y)
767 {
768 vector2.Y = topLeft.Y;
769 }
770 }
771 }
772 Vector2 vector3 = new Vector2(16f, 16f) * 50f;
773 vector -= vector3;
774 vector2 += vector3;
776 ArenaHitbox.X = (int)vector.X;
777 ArenaHitbox.Y = (int)vector.Y;
778 ArenaHitbox.Width = (int)vector4.X;
779 ArenaHitbox.Height = (int)vector4.Y;
780 }
781
783 {
784 return ArenaHitbox.Contains(worldPosition.ToPoint());
785 }
786
787 public static void DropMedals(int numberOfMedals)
788 {
789 for (int i = 0; i < 200; i++)
790 {
791 if (Main.npc[i].active && Main.npc[i].type == 548)
792 {
793 Main.npc[i].DropItemInstanced(Main.npc[i].position, Main.npc[i].Size, 3817, numberOfMedals, interactionRequired: false);
794 }
795 }
796 }
797
798 public static bool ShouldDropCrystals()
799 {
802 {
805 {
807 }
808 if (OngoingDifficulty == 1)
809 {
810 switch (currentWave)
811 {
812 case 1:
814 break;
815 case 2:
817 break;
818 case 3:
820 break;
821 case 4:
823 break;
824 case 5:
826 break;
827 }
828 }
829 else if (OngoingDifficulty == 2)
830 {
831 switch (currentWave)
832 {
833 case 1:
835 break;
836 case 2:
838 break;
839 case 3:
841 break;
842 case 4:
844 break;
845 case 5:
847 break;
848 case 6:
850 break;
851 case 7:
853 break;
854 }
855 }
856 else if (OngoingDifficulty == 3)
857 {
858 switch (currentWave)
859 {
860 case 1:
862 break;
863 case 2:
865 break;
866 case 3:
868 break;
869 case 4:
871 break;
872 case 5:
874 break;
875 case 6:
877 break;
878 case 7:
880 break;
881 }
882 }
883 }
884 if (Main.netMode != 0 && Main.expertMode)
885 {
887 }
888 float num = (float)currentKillCount / (float)requiredKillCount;
890 {
892 return true;
893 }
894 return false;
895 }
896
897 private static void SummonBetsy()
898 {
899 if (!_spawnedBetsyT3 && !NPC.AnyNPCs(551))
900 {
901 Vector2 position = new Vector2(1f, 1f);
902 int num = NPC.FindFirstNPC(548);
903 if (num != -1)
904 {
905 position = Main.npc[num].Center;
906 }
907 NPC.SpawnOnPlayer(Player.FindClosest(position, 1, 1), 551);
908 _spawnedBetsyT3 = true;
909 }
910 }
911
912 private static void DropStarterCrystals()
913 {
914 for (int i = 0; i < 200; i++)
915 {
916 if (Main.npc[i].active && Main.npc[i].type == 548)
917 {
918 for (int j = 0; j < 5; j++)
919 {
920 Item.NewItem(new EntitySource_WorldEvent(), Main.npc[i].position, Main.npc[i].width, Main.npc[i].height, 3822, 2);
921 }
922 break;
923 }
924 }
925 }
926
927 private static void SetEnemySpawningOnHold(int forHowLong)
928 {
930 if (Main.netMode == 2)
931 {
933 }
934 }
935
936 private static short[] Difficulty_1_GetEnemiesForWave(int wave)
937 {
938 LaneSpawnRate = 60;
939 switch (wave)
940 {
941 case 1:
942 LaneSpawnRate = 90;
943 return new short[1] { 552 };
944 case 2:
945 return new short[2] { 552, 555 };
946 case 3:
947 LaneSpawnRate = 55;
948 return new short[3] { 552, 555, 561 };
949 case 4:
950 LaneSpawnRate = 50;
951 return new short[4] { 552, 555, 561, 558 };
952 case 5:
953 LaneSpawnRate = 40;
954 return new short[5] { 552, 555, 561, 558, 564 };
955 default:
956 return new short[1] { 552 };
957 }
958 }
959
961 {
962 switch (waveNumber)
963 {
964 case -1:
965 return 0;
966 case 1:
967 return 60;
968 case 2:
969 return 80;
970 case 3:
971 return 100;
972 case 4:
973 _deadGoblinSpots.Clear();
974 return 120;
975 case 5:
977 {
978 currentKillCount = 139;
979 }
980 return 140;
981 case 6:
982 waveNumber = 5;
985 {
987 }
988 return 1;
989 default:
990 return 10;
991 }
992 }
993
995 {
996 int x = (int)gateBottom.X;
997 int y = (int)gateBottom.Y;
998 int num = 50;
999 int num2 = 6;
1000 if (NPC.waveNumber > 4)
1001 {
1002 num2 = 12;
1003 }
1004 else if (NPC.waveNumber > 3)
1005 {
1006 num2 = 8;
1007 }
1008 int num3 = 6;
1009 if (NPC.waveNumber > 4)
1010 {
1011 num3 = 8;
1012 }
1013 for (int i = 1; i < Main.CurrentFrameFlags.ActivePlayersCount; i++)
1014 {
1015 num = (int)((double)num * 1.3);
1016 num2 = (int)((double)num2 * 1.3);
1017 num3 = (int)((double)num3 * 1.3);
1018 }
1019 int num4 = 200;
1020 switch (NPC.waveNumber)
1021 {
1022 case 1:
1023 if (NPC.CountNPCS(552) + NPC.CountNPCS(555) < num)
1024 {
1025 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 552);
1026 }
1027 break;
1028 case 2:
1029 if (NPC.CountNPCS(552) + NPC.CountNPCS(555) < num)
1030 {
1031 num4 = ((Main.rand.Next(7) != 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 552) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 555));
1032 }
1033 break;
1034 case 3:
1035 if (Main.rand.Next(6) == 0 && NPC.CountNPCS(561) < num2)
1036 {
1037 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 561);
1038 }
1039 else if (NPC.CountNPCS(552) + NPC.CountNPCS(555) < num)
1040 {
1041 num4 = ((Main.rand.Next(5) != 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 552) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 555));
1042 }
1043 break;
1044 case 4:
1045 if (Main.rand.Next(12) == 0 && NPC.CountNPCS(558) < num3)
1046 {
1047 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 558);
1048 }
1049 else if (Main.rand.Next(5) == 0 && NPC.CountNPCS(561) < num2)
1050 {
1051 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 561);
1052 }
1053 else if (NPC.CountNPCS(552) + NPC.CountNPCS(555) < num)
1054 {
1055 num4 = ((Main.rand.Next(5) != 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 552) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 555));
1056 }
1057 break;
1058 case 5:
1059 {
1061 if ((float)currentKillCount > (float)requiredKillCount * 0.5f && !NPC.AnyNPCs(564))
1062 {
1063 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 564);
1064 }
1065 if (Main.rand.Next(10) == 0 && NPC.CountNPCS(558) < num3)
1066 {
1067 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 558);
1068 }
1069 else if (Main.rand.Next(4) == 0 && NPC.CountNPCS(561) < num2)
1070 {
1071 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 561);
1072 }
1073 else if (NPC.CountNPCS(552) + NPC.CountNPCS(555) < num)
1074 {
1075 num4 = ((Main.rand.Next(4) != 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 552) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 555));
1076 }
1077 break;
1078 }
1079 default:
1080 num4 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 552);
1081 break;
1082 }
1083 if (Main.netMode == 2 && num4 < 200)
1084 {
1085 NetMessage.SendData(23, -1, -1, null, num4);
1086 }
1087 }
1088
1090 {
1091 if (NPC.waveNumber == 5 && NPC.waveKills >= 139f)
1092 {
1093 if (slainMonsterID == 564 || slainMonsterID == 565)
1094 {
1095 _downedDarkMageT1 = true;
1096 return 1;
1097 }
1098 return 0;
1099 }
1100 if ((uint)(slainMonsterID - 551) <= 14u || (uint)(slainMonsterID - 568) <= 10u)
1101 {
1102 if (NPC.waveNumber == 5 && NPC.waveKills == 138f)
1103 {
1104 return 1;
1105 }
1106 if (!Main.expertMode)
1107 {
1108 return 1;
1109 }
1110 return 2;
1111 }
1112 return 0;
1113 }
1114
1115 private static short[] Difficulty_2_GetEnemiesForWave(int wave)
1116 {
1117 LaneSpawnRate = 60;
1118 switch (wave)
1119 {
1120 case 1:
1121 LaneSpawnRate = 90;
1122 return new short[2] { 553, 562 };
1123 case 2:
1124 LaneSpawnRate = 70;
1125 return new short[3] { 553, 562, 572 };
1126 case 3:
1127 return new short[5] { 553, 556, 562, 559, 572 };
1128 case 4:
1129 LaneSpawnRate = 55;
1130 return new short[5] { 553, 559, 570, 572, 562 };
1131 case 5:
1132 LaneSpawnRate = 50;
1133 return new short[6] { 553, 556, 559, 572, 574, 570 };
1134 case 6:
1135 LaneSpawnRate = 45;
1136 return new short[8] { 553, 556, 562, 559, 568, 570, 572, 574 };
1137 case 7:
1138 LaneSpawnRate = 42;
1139 return new short[8] { 553, 556, 572, 559, 568, 574, 570, 576 };
1140 default:
1141 return new short[1] { 553 };
1142 }
1143 }
1144
1146 {
1147 switch (waveNumber)
1148 {
1149 case -1:
1150 return 0;
1151 case 1:
1152 return 60;
1153 case 2:
1154 return 80;
1155 case 3:
1156 return 100;
1157 case 4:
1158 return 120;
1159 case 5:
1160 return 140;
1161 case 6:
1162 return 180;
1163 case 7:
1164 if (!_downedOgreT2 && currentKillCount > 219)
1165 {
1166 currentKillCount = 219;
1167 }
1168 return 220;
1169 case 8:
1170 waveNumber = 7;
1171 currentKillCount = 1;
1173 {
1175 }
1176 return 1;
1177 default:
1178 return 10;
1179 }
1180 }
1181
1183 {
1184 if (NPC.waveNumber == 7 && NPC.waveKills >= 219f)
1185 {
1186 if (slainMonsterID == 576 || slainMonsterID == 577)
1187 {
1188 _downedOgreT2 = true;
1189 return 1;
1190 }
1191 return 0;
1192 }
1193 if ((uint)(slainMonsterID - 551) <= 14u || (uint)(slainMonsterID - 568) <= 10u)
1194 {
1195 if (NPC.waveNumber == 7 && NPC.waveKills == 218f)
1196 {
1197 return 1;
1198 }
1199 if (!Main.expertMode)
1200 {
1201 return 1;
1202 }
1203 return 2;
1204 }
1205 return 0;
1206 }
1207
1209 {
1210 int x = (int)gateBottom.X;
1211 int y = (int)gateBottom.Y;
1212 int num = 50;
1213 int num2 = 5;
1214 if (NPC.waveNumber > 1)
1215 {
1216 num2 = 8;
1217 }
1218 if (NPC.waveNumber > 3)
1219 {
1220 num2 = 10;
1221 }
1222 if (NPC.waveNumber > 5)
1223 {
1224 num2 = 12;
1225 }
1226 int num3 = 5;
1227 if (NPC.waveNumber > 4)
1228 {
1229 num3 = 7;
1230 }
1231 int num4 = 2;
1232 int num5 = 8;
1233 if (NPC.waveNumber > 3)
1234 {
1235 num5 = 12;
1236 }
1237 int num6 = 3;
1238 if (NPC.waveNumber > 5)
1239 {
1240 num6 = 5;
1241 }
1242 for (int i = 1; i < Main.CurrentFrameFlags.ActivePlayersCount; i++)
1243 {
1244 num = (int)((double)num * 1.3);
1245 num2 = (int)((double)num2 * 1.3);
1246 num5 = (int)((double)num * 1.3);
1247 num6 = (int)((double)num * 1.35);
1248 }
1249 int num7 = 200;
1250 int num8 = 200;
1251 switch (NPC.waveNumber)
1252 {
1253 case 1:
1254 if (Main.rand.Next(20) == 0 && NPC.CountNPCS(562) < num2)
1255 {
1256 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 562);
1257 }
1258 else if (NPC.CountNPCS(553) < num)
1259 {
1260 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1261 }
1262 break;
1263 case 2:
1264 if (Main.rand.Next(3) == 0 && NPC.CountNPCS(572) < num5)
1265 {
1266 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 572);
1267 }
1268 else if (Main.rand.Next(8) == 0 && NPC.CountNPCS(562) < num2)
1269 {
1270 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 562);
1271 }
1272 else if (NPC.CountNPCS(553) < num)
1273 {
1274 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1275 }
1276 break;
1277 case 3:
1278 if (Main.rand.Next(7) == 0 && NPC.CountNPCS(572) < num5)
1279 {
1280 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 572);
1281 }
1282 else if (Main.rand.Next(10) == 0 && NPC.CountNPCS(559) < num3)
1283 {
1284 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 559);
1285 }
1286 else if (Main.rand.Next(8) == 0 && NPC.CountNPCS(562) < num2)
1287 {
1288 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 562);
1289 }
1290 else if (NPC.CountNPCS(553) + NPC.CountNPCS(556) < num)
1291 {
1292 if (Main.rand.Next(4) == 0)
1293 {
1294 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 556);
1295 }
1296 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1297 }
1298 break;
1299 case 4:
1300 if (Main.rand.Next(10) == 0 && NPC.CountNPCS(570) < num6)
1301 {
1302 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 570);
1303 }
1304 else if (Main.rand.Next(12) == 0 && NPC.CountNPCS(559) < num3)
1305 {
1306 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 559);
1307 }
1308 else if (Main.rand.Next(6) == 0 && NPC.CountNPCS(562) < num2)
1309 {
1310 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 562);
1311 }
1312 else if (Main.rand.Next(3) == 0 && NPC.CountNPCS(572) < num5)
1313 {
1314 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 572);
1315 }
1316 else if (NPC.CountNPCS(553) < num)
1317 {
1318 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1319 }
1320 break;
1321 case 5:
1322 if (Main.rand.Next(7) == 0 && NPC.CountNPCS(570) < num6)
1323 {
1324 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 570);
1325 }
1326 else if (Main.rand.Next(10) == 0 && NPC.CountNPCS(559) < num3)
1327 {
1328 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 559);
1329 }
1330 else if (Main.rand.Next(4) == 0 && NPC.CountNPCS(572) + NPC.CountNPCS(574) < num5)
1331 {
1332 num7 = ((Main.rand.Next(2) != 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 574) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 572));
1333 }
1334 else if (NPC.CountNPCS(553) + NPC.CountNPCS(556) < num)
1335 {
1336 if (Main.rand.Next(3) == 0)
1337 {
1338 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 556);
1339 }
1340 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1341 }
1342 break;
1343 case 6:
1344 if (Main.rand.Next(7) == 0 && NPC.CountNPCS(570) < num6)
1345 {
1346 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 570);
1347 }
1348 else if (Main.rand.Next(17) == 0 && NPC.CountNPCS(568) < num4)
1349 {
1350 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 568);
1351 }
1352 else if (Main.rand.Next(5) == 0 && NPC.CountNPCS(572) + NPC.CountNPCS(574) < num5)
1353 {
1354 num7 = ((Main.rand.Next(2) == 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 574) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 572));
1355 }
1356 else if (Main.rand.Next(9) == 0 && NPC.CountNPCS(559) < num3)
1357 {
1358 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 559);
1359 }
1360 else if (Main.rand.Next(3) == 0 && NPC.CountNPCS(562) < num2)
1361 {
1362 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 562);
1363 }
1364 else if (NPC.CountNPCS(553) + NPC.CountNPCS(556) < num)
1365 {
1366 if (Main.rand.Next(3) != 0)
1367 {
1368 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 556);
1369 }
1370 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1371 }
1372 break;
1373 case 7:
1374 {
1376 if ((float)currentKillCount > (float)requiredKillCount * 0.1f && !NPC.AnyNPCs(576))
1377 {
1378 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 576);
1379 }
1380 else if (Main.rand.Next(7) == 0 && NPC.CountNPCS(570) < num6)
1381 {
1382 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 570);
1383 }
1384 else if (Main.rand.Next(17) == 0 && NPC.CountNPCS(568) < num4)
1385 {
1386 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 568);
1387 }
1388 else if (Main.rand.Next(7) == 0 && NPC.CountNPCS(572) + NPC.CountNPCS(574) < num5)
1389 {
1390 num7 = ((Main.rand.Next(3) == 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 574) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 572));
1391 }
1392 else if (Main.rand.Next(11) == 0 && NPC.CountNPCS(559) < num3)
1393 {
1394 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 559);
1395 }
1396 else if (NPC.CountNPCS(553) + NPC.CountNPCS(556) < num)
1397 {
1398 if (Main.rand.Next(2) == 0)
1399 {
1400 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 556);
1401 }
1402 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1403 }
1404 break;
1405 }
1406 default:
1407 num7 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 553);
1408 break;
1409 }
1410 if (Main.netMode == 2 && num7 < 200)
1411 {
1412 NetMessage.SendData(23, -1, -1, null, num7);
1413 }
1414 if (Main.netMode == 2 && num8 < 200)
1415 {
1416 NetMessage.SendData(23, -1, -1, null, num8);
1417 }
1418 }
1419
1420 private static short[] Difficulty_3_GetEnemiesForWave(int wave)
1421 {
1422 LaneSpawnRate = 60;
1423 switch (wave)
1424 {
1425 case 1:
1426 LaneSpawnRate = 85;
1427 return new short[3] { 554, 557, 563 };
1428 case 2:
1429 LaneSpawnRate = 75;
1430 return new short[5] { 554, 557, 563, 573, 578 };
1431 case 3:
1432 LaneSpawnRate = 60;
1433 return new short[5] { 554, 563, 560, 573, 571 };
1434 case 4:
1435 LaneSpawnRate = 60;
1436 return new short[7] { 554, 560, 571, 573, 563, 575, 565 };
1437 case 5:
1438 LaneSpawnRate = 55;
1439 return new short[7] { 554, 557, 573, 575, 571, 569, 577 };
1440 case 6:
1441 LaneSpawnRate = 60;
1442 return new short[8] { 554, 557, 563, 578, 569, 571, 577, 565 };
1443 case 7:
1444 LaneSpawnRate = 90;
1445 return new short[6] { 554, 557, 563, 569, 571, 551 };
1446 default:
1447 return new short[1] { 554 };
1448 }
1449 }
1450
1452 {
1453 switch (waveNumber)
1454 {
1455 case -1:
1456 return 0;
1457 case 1:
1458 return 60;
1459 case 2:
1460 return 80;
1461 case 3:
1462 return 100;
1463 case 4:
1464 return 120;
1465 case 5:
1466 return 140;
1467 case 6:
1468 return 180;
1469 case 7:
1470 {
1471 int num = NPC.FindFirstNPC(551);
1472 if (num == -1)
1473 {
1474 return 1;
1475 }
1476 currentKillCount = 100 - (int)((float)Main.npc[num].life / (float)Main.npc[num].lifeMax * 100f);
1477 return 100;
1478 }
1479 case 8:
1480 waveNumber = 7;
1481 currentKillCount = 1;
1483 {
1485 }
1486 return 1;
1487 default:
1488 return 10;
1489 }
1490 }
1491
1493 {
1494 if (NPC.waveNumber == 7)
1495 {
1496 if (slainMonsterID == 551)
1497 {
1498 return 1;
1499 }
1500 return 0;
1501 }
1502 if ((uint)(slainMonsterID - 551) <= 14u || (uint)(slainMonsterID - 568) <= 10u)
1503 {
1504 if (!Main.expertMode)
1505 {
1506 return 1;
1507 }
1508 return 2;
1509 }
1510 return 0;
1511 }
1512
1514 {
1515 int x = (int)gateBottom.X;
1516 int y = (int)gateBottom.Y;
1517 int num = 60;
1518 int num2 = 7;
1519 if (NPC.waveNumber > 1)
1520 {
1521 num2 = 9;
1522 }
1523 if (NPC.waveNumber > 3)
1524 {
1525 num2 = 12;
1526 }
1527 if (NPC.waveNumber > 5)
1528 {
1529 num2 = 15;
1530 }
1531 int num3 = 7;
1532 if (NPC.waveNumber > 4)
1533 {
1534 num3 = 10;
1535 }
1536 int num4 = 2;
1537 if (NPC.waveNumber > 5)
1538 {
1539 num4 = 3;
1540 }
1541 int num5 = 12;
1542 if (NPC.waveNumber > 3)
1543 {
1544 num5 = 18;
1545 }
1546 int num6 = 4;
1547 if (NPC.waveNumber > 5)
1548 {
1549 num6 = 6;
1550 }
1551 int num7 = 4;
1552 for (int i = 1; i < Main.CurrentFrameFlags.ActivePlayersCount; i++)
1553 {
1554 num = (int)((double)num * 1.3);
1555 num2 = (int)((double)num2 * 1.3);
1556 num5 = (int)((double)num * 1.3);
1557 num6 = (int)((double)num * 1.35);
1558 num7 = (int)((double)num7 * 1.3);
1559 }
1560 int num8 = 200;
1561 int num9 = 200;
1562 switch (NPC.waveNumber)
1563 {
1564 case 1:
1565 if (Main.rand.Next(18) == 0 && NPC.CountNPCS(563) < num2)
1566 {
1567 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 563);
1568 }
1569 else if (NPC.CountNPCS(554) < num)
1570 {
1571 if (Main.rand.Next(7) == 0)
1572 {
1573 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 557);
1574 }
1575 num9 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1576 }
1577 break;
1578 case 2:
1579 if (Main.rand.Next(3) == 0 && NPC.CountNPCS(578) < num7)
1580 {
1581 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 578);
1582 }
1583 else if (Main.rand.Next(7) == 0 && NPC.CountNPCS(563) < num2)
1584 {
1585 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 563);
1586 }
1587 else if (Main.rand.Next(3) == 0 && NPC.CountNPCS(573) < num5)
1588 {
1589 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 573);
1590 }
1591 else if (NPC.CountNPCS(554) < num)
1592 {
1593 if (Main.rand.Next(4) == 0)
1594 {
1595 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 557);
1596 }
1597 num9 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1598 }
1599 break;
1600 case 3:
1601 if (Main.rand.Next(13) == 0 && NPC.CountNPCS(571) < num6)
1602 {
1603 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 571);
1604 }
1605 else if (Main.rand.Next(7) == 0 && NPC.CountNPCS(573) < num5)
1606 {
1607 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 573);
1608 }
1609 else if (Main.rand.Next(10) == 0 && NPC.CountNPCS(560) < num3)
1610 {
1611 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 560);
1612 }
1613 else if (Main.rand.Next(8) == 0 && NPC.CountNPCS(563) < num2)
1614 {
1615 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 563);
1616 }
1617 else if (NPC.CountNPCS(554) + NPC.CountNPCS(557) < num)
1618 {
1619 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1620 }
1621 break;
1622 case 4:
1623 if (Main.rand.Next(24) == 0 && !NPC.AnyNPCs(565))
1624 {
1625 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 565);
1626 }
1627 else if (Main.rand.Next(12) == 0 && NPC.CountNPCS(571) < num6)
1628 {
1629 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 571);
1630 }
1631 else if (Main.rand.Next(15) == 0 && NPC.CountNPCS(560) < num3)
1632 {
1633 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 560);
1634 }
1635 else if (Main.rand.Next(7) == 0 && NPC.CountNPCS(563) < num2)
1636 {
1637 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 563);
1638 }
1639 else if (Main.rand.Next(5) == 0 && NPC.CountNPCS(573) + NPC.CountNPCS(575) < num5)
1640 {
1641 num8 = ((Main.rand.Next(3) == 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 575) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 573));
1642 }
1643 else if (NPC.CountNPCS(554) < num)
1644 {
1645 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1646 }
1647 break;
1648 case 5:
1649 if (Main.rand.Next(20) == 0 && !NPC.AnyNPCs(577))
1650 {
1651 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 577);
1652 }
1653 else if (Main.rand.Next(17) == 0 && NPC.CountNPCS(569) < num4)
1654 {
1655 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 569);
1656 }
1657 else if (Main.rand.Next(8) == 0 && NPC.CountNPCS(571) < num6)
1658 {
1659 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 571);
1660 }
1661 else if (Main.rand.Next(7) == 0 && NPC.CountNPCS(573) + NPC.CountNPCS(575) < num5)
1662 {
1663 num8 = ((Main.rand.Next(4) == 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 575) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 573));
1664 }
1665 else if (NPC.CountNPCS(554) + NPC.CountNPCS(557) < num)
1666 {
1667 if (Main.rand.Next(3) == 0)
1668 {
1669 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 557);
1670 }
1671 num9 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1672 }
1673 break;
1674 case 6:
1675 if (Main.rand.Next(20) == 0 && !NPC.AnyNPCs(577))
1676 {
1677 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 577);
1678 }
1679 else if (Main.rand.Next(20) == 0 && !NPC.AnyNPCs(565))
1680 {
1681 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 565);
1682 }
1683 else if (Main.rand.Next(12) == 0 && NPC.CountNPCS(571) < num6)
1684 {
1685 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 571);
1686 }
1687 else if (Main.rand.Next(25) == 0 && NPC.CountNPCS(569) < num4)
1688 {
1689 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 569);
1690 }
1691 if (Main.rand.Next(7) == 0 && NPC.CountNPCS(578) < num7)
1692 {
1693 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 578);
1694 }
1695 else if (Main.rand.Next(7) == 0 && NPC.CountNPCS(573) + NPC.CountNPCS(575) < num5)
1696 {
1697 num8 = ((Main.rand.Next(3) == 0) ? NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 575) : NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 573));
1698 }
1699 else if (Main.rand.Next(5) == 0 && NPC.CountNPCS(563) < num2)
1700 {
1701 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 563);
1702 }
1703 else if (NPC.CountNPCS(554) + NPC.CountNPCS(557) < num)
1704 {
1705 if (Main.rand.Next(3) == 0)
1706 {
1707 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 557);
1708 }
1709 num9 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1710 }
1711 break;
1712 case 7:
1713 if (Main.rand.Next(20) == 0 && NPC.CountNPCS(571) < num6)
1714 {
1715 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 571);
1716 }
1717 else if (Main.rand.Next(17) == 0 && NPC.CountNPCS(569) < num4)
1718 {
1719 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 569);
1720 }
1721 else if (Main.rand.Next(10) == 0 && NPC.CountNPCS(563) < num2)
1722 {
1723 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 563);
1724 }
1725 else if (NPC.CountNPCS(554) + NPC.CountNPCS(557) < num)
1726 {
1727 if (Main.rand.Next(5) == 0)
1728 {
1729 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 557);
1730 }
1731 num9 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1732 }
1733 break;
1734 default:
1735 num8 = NPC.NewNPC(GetSpawnSource_OldOnesArmy(), x, y, 554);
1736 break;
1737 }
1738 if (Main.netMode == 2 && num8 < 200)
1739 {
1740 NetMessage.SendData(23, -1, -1, null, num8);
1741 }
1742 if (Main.netMode == 2 && num9 < 200)
1743 {
1744 NetMessage.SendData(23, -1, -1, null, num9);
1745 }
1746 }
1747
1748 public static bool IsStandActive(int x, int y)
1749 {
1750 Vector2 target = new Vector2(x * 16 + 8, y * 16 + 8);
1751 for (int i = 0; i < 200; i++)
1752 {
1753 NPC nPC = Main.npc[i];
1754 if (nPC != null && nPC.active && nPC.type == 548)
1755 {
1756 return nPC.Bottom.Distance(target) < 36f;
1757 }
1758 }
1759 return false;
1760 }
1761
1762 public static void RequestToSkipWaitTime(int x, int y)
1763 {
1764 if (TimeLeftBetweenWaves > 60 && IsStandActive(x, y))
1765 {
1766 SoundEngine.PlaySound(SoundID.NPCDeath7, x * 16 + 8, y * 16 + 8);
1767 if (Main.netMode == 0)
1768 {
1770 }
1771 else if (Main.netMode != 2)
1772 {
1773 NetMessage.SendData(143);
1774 }
1775 }
1776 }
1777
1778 public static void AttemptToSkipWaitTime()
1779 {
1780 if (Main.netMode != 1 && TimeLeftBetweenWaves > 60)
1781 {
1783 }
1784 }
1785
1787 {
1788 return new EntitySource_OldOnesArmy();
1789 }
1790}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
virtual bool ReadBoolean()
static void PlaySound(int type, Vector2 position, int style=1)
static void SendChatMessageToClient(NetworkText text, Color color, int playerId)
Definition ChatHelper.cs:28
Item[] item
Definition Chest.cs:41
static List< int > GetCurrentlyOpenChests()
Definition Chest.cs:222
static Tile GetTileSafely(Vector2 position)
Definition Framing.cs:419
static readonly Color INFO_FAILURE_INVASION_COLOR
Definition DD2Event.cs:21
static short[] Difficulty_2_GetEnemiesForWave(int wave)
Definition DD2Event.cs:1115
static readonly Color INFO_NEW_WAVE_COLOR
Definition DD2Event.cs:17
static int Difficulty_2_GetMonsterPointsWorth(int slainMonsterID)
Definition DD2Event.cs:1182
static void GetInvasionStatus(out int currentWave, out int requiredKillCount, out int currentKillCount, bool currentlyInCheckProgress=false)
Definition DD2Event.cs:485
static bool WouldFailSpawningHere(int x, int y)
Definition DD2Event.cs:571
static void SetEnemySpawningOnHold(int forHowLong)
Definition DD2Event.cs:927
static void ClearAllDD2EnergyCrystalsInGame()
Definition DD2Event.cs:634
static short[] Difficulty_1_GetEnemiesForWave(int wave)
Definition DD2Event.cs:936
static void SpawnMonsterFromGate(Vector2 gateBottom)
Definition DD2Event.cs:524
static bool ShouldBlockBuilding(Vector2 worldPosition)
Definition DD2Event.cs:782
static void SummonCrystal(int x, int y, int whoAsks)
Definition DD2Event.cs:540
static void CheckProgress(int slainMonsterID)
Definition DD2Event.cs:338
static void ClearAllDD2EnergyCrystalsInChests()
Definition DD2Event.cs:650
static int Difficulty_1_GetRequiredWaveKills(ref int waveNumber, ref int currentKillCount, bool currentlyInCheckProgress)
Definition DD2Event.cs:960
static bool CanRaiseGoblinsHere(Vector2 spot)
Definition DD2Event.cs:683
static void SyncInvasionProgress(int toWho)
Definition DD2Event.cs:161
static void Load(BinaryReader reader, int gameVersionNumber)
Definition DD2Event.cs:132
static int GetMonsterPointsWorth(int slainMonsterID)
Definition DD2Event.cs:514
static IEntitySource GetSpawnSource_OldOnesArmy()
Definition DD2Event.cs:1786
static bool IsStandActive(int x, int y)
Definition DD2Event.cs:1748
static readonly Color INFO_START_INVASION_COLOR
Definition DD2Event.cs:19
static void Save(BinaryWriter writer)
Definition DD2Event.cs:125
static void RaiseGoblins(NPC caller, Vector2 spot)
Definition DD2Event.cs:700
static void DropMedals(int numberOfMedals)
Definition DD2Event.cs:787
static void SummonCrystalDirect(int x, int y, int whoAsks)
Definition DD2Event.cs:552
static List< Vector2 > _deadGoblinSpots
Definition DD2Event.cs:51
static void RequestToSkipWaitTime(int x, int y)
Definition DD2Event.cs:1762
static int Difficulty_2_GetRequiredWaveKills(ref int waveNumber, ref int currentKillCount, bool currentlyInCheckProgress)
Definition DD2Event.cs:1145
static void Difficulty_1_SpawnMonsterFromGate(Vector2 gateBottom)
Definition DD2Event.cs:994
static short[] GetEnemiesForWave(int wave)
Definition DD2Event.cs:504
static void StopInvasion(bool win=false)
Definition DD2Event.cs:269
static void Difficulty_3_SpawnMonsterFromGate(Vector2 gateBottom)
Definition DD2Event.cs:1513
static short[] Difficulty_3_GetEnemiesForWave(int wave)
Definition DD2Event.cs:1420
static void FailureMessage(int client)
Definition DD2Event.cs:583
static void SpawnNPC(ref int newNPC)
Definition DD2Event.cs:167
static void StartInvasion(int difficultyOverride=-1)
Definition DD2Event.cs:230
static int Difficulty_1_GetMonsterPointsWorth(int slainMonsterID)
Definition DD2Event.cs:1089
static int Difficulty_3_GetMonsterPointsWorth(int slainMonsterID)
Definition DD2Event.cs:1492
static void AnnounceGoblinDeath(NPC n)
Definition DD2Event.cs:678
static int Difficulty_3_GetRequiredWaveKills(ref int waveNumber, ref int currentKillCount, bool currentlyInCheckProgress)
Definition DD2Event.cs:1451
static void Difficulty_2_SpawnMonsterFromGate(Vector2 gateBottom)
Definition DD2Event.cs:1208
static FilterManager Scene
Definition Filters.cs:5
static bool[] BelongsToInvasionOldOnesArmy
Definition NPCID.cs:4166
static readonly LegacySoundStyle NPCDeath7
Definition SoundID.cs:294
int stack
Definition Item.cs:149
void TurnToAir(bool fullReset=false)
Definition Item.cs:49954
static int NewItem(IEntitySource source, Vector2 pos, Vector2 randomBox, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
Definition Item.cs:49697
static NetworkText GetInvasionWaveText(int wave, params short[] npcIds)
Definition Lang.cs:1112
static LocalizedText GetText(string key)
Definition Language.cs:10
static NetworkText FromKey(string key, params object[] substitutions)
static int ActivePlayersCount
Definition Main.cs:89
static Chest[] chest
Definition Main.cs:1699
static Item[] item
Definition Main.cs:1681
static int netMode
Definition Main.cs:2095
static void ReportInvasionProgress(int progress, int progressMax, int icon, int progressWave)
Definition Main.cs:44714
static bool expertMode
Definition Main.cs:2737
static bool dedServ
Definition Main.cs:1226
static void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
Definition Main.cs:61429
static Projectile[] projectile
Definition Main.cs:1691
static UnifiedRandom rand
Definition Main.cs:1387
static NPC[] npc
Definition Main.cs:1685
static int invasionProgress
Definition Main.cs:1988
static int invasionProgressMax
Definition Main.cs:1990
static bool hardMode
Definition Main.cs:1022
static Player[] player
Definition Main.cs:1803
static int CountNPCS(int Type)
Definition NPC.cs:86664
static bool downedBoss2
Definition NPC.cs:347
static int waveNumber
Definition NPC.cs:77
static int FindFirstNPC(int Type)
Definition NPC.cs:86701
static bool downedMechBossAny
Definition NPC.cs:421
static float GetBalance()
Definition NPC.cs:12256
static bool AnyNPCs(int Type)
Definition NPC.cs:86689
static float waveKills
Definition NPC.cs:75
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
static void SpawnOnPlayer(int plr, int Type)
Definition NPC.cs:77311
static bool downedGolemBoss
Definition NPC.cs:365
static void SendData(int msgType, int remoteClient=-1, int ignoreClient=-1, NetworkText text=null, int number=0, float number2=0f, float number3=0f, float number4=0f, int number5=0, int number6=0, int number7=0)
Definition NetMessage.cs:88
static byte FindClosest(Vector2 Position, int Width, int Height)
Definition Player.cs:4011
static void CheckArenaScore(Vector2 arenaCenter, out Point xLeftEnd, out Point xRightEnd, int walkerWidthInTiles=5, int walkerHeightInTiles=10)
static GenSearch Chain(GenSearch search, params GenCondition[] conditions)
Definition Searches.cs:123
static bool Find(Point origin, GenSearch search, out Point result)
Definition WorldUtils.cs:27
static void BroadcastText(NetworkText text, Vector4 color)
static float DistanceSquared(Vector2 value1, Vector2 value2)
Definition Vector2.cs:107