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

◆ NaturalAttempt()

static void Terraria.GameContent.Events.BirthdayParty.NaturalAttempt ( )
inlinestaticprivate

Definition at line 73 of file BirthdayParty.cs.

74 {
75 if (Main.netMode == 1 || !NPC.AnyNPCs(208))
76 {
77 return;
78 }
79 if (PartyDaysOnCooldown > 0)
80 {
82 return;
83 }
84 int maxValue = 10;
85 if (Main.tenthAnniversaryWorld)
86 {
87 maxValue = 7;
88 }
89 if (Main.rand.Next(maxValue) != 0)
90 {
91 return;
92 }
93 List<NPC> list = new List<NPC>();
94 for (int j = 0; j < 200; j++)
95 {
96 NPC nPC = Main.npc[j];
97 if (CanNPCParty(nPC))
98 {
99 list.Add(nPC);
100 }
101 }
102 if (list.Count >= 5)
103 {
104 GenuineParty = true;
105 PartyDaysOnCooldown = Main.rand.Next(5, 11);
106 NPC.freeCake = true;
107 CelebratingNPCs.Clear();
108 List<int> list2 = new List<int>();
109 int num = 1;
110 if (Main.rand.Next(5) == 0 && list.Count > 12)
111 {
112 num = 3;
113 }
114 else if (Main.rand.Next(3) == 0)
115 {
116 num = 2;
117 }
118 list = list.OrderBy((NPC i) => Main.rand.Next()).ToList();
119 for (int k = 0; k < num; k++)
120 {
121 list2.Add(k);
122 }
123 for (int l = 0; l < list2.Count; l++)
124 {
125 CelebratingNPCs.Add(list[list2[l]].whoAmI);
126 }
127 Color color = new Color(255, 0, 160);
128 if (CelebratingNPCs.Count == 3)
129 {
130 WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_3", Main.npc[CelebratingNPCs[0]].GetGivenOrTypeNetName(), Main.npc[CelebratingNPCs[1]].GetGivenOrTypeNetName(), Main.npc[CelebratingNPCs[2]].GetGivenOrTypeNetName()), color);
131 }
132 else if (CelebratingNPCs.Count == 2)
133 {
134 WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_2", Main.npc[CelebratingNPCs[0]].GetGivenOrTypeNetName(), Main.npc[CelebratingNPCs[1]].GetGivenOrTypeNetName()), color);
135 }
136 else
137 {
138 WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_1", Main.npc[CelebratingNPCs[0]].GetGivenOrTypeNetName()), color);
139 }
140 NetMessage.SendData(7);
142 }
143 }
void Add(TKey key, TValue value)
static NetworkText FromKey(string key, params object[] substitutions)

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), Terraria.NPC.AnyNPCs(), Terraria.WorldGen.BroadcastText(), Terraria.GameContent.Events.BirthdayParty.CanNPCParty(), Terraria.GameContent.Events.BirthdayParty.CelebratingNPCs, Terraria.GameContent.Events.BirthdayParty.CheckForAchievement(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, Terraria.Localization.NetworkText.FromKey(), Terraria.GameContent.Events.BirthdayParty.GenuineParty, Terraria.Main.netMode, Terraria.Main.npc, Terraria.GameContent.Events.BirthdayParty.PartyDaysOnCooldown, Terraria.Main.rand, Terraria.NetMessage.SendData(), and Terraria.Main.tenthAnniversaryWorld.

Referenced by Terraria.GameContent.Events.BirthdayParty.CheckMorning().