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

◆ SpawnStardustMark_StardustWorm()

void Terraria.NPC.SpawnStardustMark_StardustWorm ( )
inlineprivate

Definition at line 37033 of file NPC.cs.

37034 {
37035 List<int> list = new List<int>();
37036 if (CountNPCS(405) + CountNPCS(406) < 2)
37037 {
37038 list.Add(405);
37039 }
37040 if (CountNPCS(402) < 3)
37041 {
37042 list.Add(402);
37043 }
37044 if (CountNPCS(407) < 1)
37045 {
37046 list.Add(407);
37047 }
37048 if (list.Count <= 0)
37049 {
37050 return;
37051 }
37052 int num = Utils.SelectRandom(Main.rand, list.ToArray());
37053 int num2 = Main.rand.Next(3, 6);
37054 int num3 = Main.rand.Next(0, 4);
37055 int num4 = 0;
37058 list2.Add(Tuple.Create(base.Center, num2, 0));
37059 int num5 = 0;
37060 int num6 = list2.Count;
37061 while (list2.Count > 0)
37062 {
37063 Vector2 item = list2[0].Item1;
37064 int num7 = 1;
37065 int num8 = 1;
37066 if (num5 > 0 && num3 > 0 && (Main.rand.Next(3) != 0 || num5 == 1))
37067 {
37068 num8 = Main.rand.Next(Math.Max(1, list2[0].Item2));
37069 num7++;
37070 num3--;
37071 }
37072 for (int i = 0; i < num7; i++)
37073 {
37074 int num9 = list2[0].Item3;
37075 if (num5 == 0)
37076 {
37077 num9 = Utils.SelectRandom<int>(Main.rand, -1, 1);
37078 }
37079 else if (i == 1)
37080 {
37081 num9 *= -1;
37082 }
37083 float num10 = ((num5 % 2 == 0) ? 0f : ((float)Math.PI)) + (0.5f - Main.rand.NextFloat()) * ((float)Math.PI / 4f) + (float)num9 * ((float)Math.PI / 4f) * (float)(num5 % 2 == 0).ToDirectionInt();
37084 float num11 = 100f + 50f * Main.rand.NextFloat();
37085 int num12 = list2[0].Item2;
37086 if (i != 0)
37087 {
37088 num12 = num8;
37089 }
37090 if (num5 == 0)
37091 {
37092 num10 = (0.5f - Main.rand.NextFloat()) * ((float)Math.PI / 4f);
37093 num11 = 100f + 100f * Main.rand.NextFloat();
37094 }
37095 Vector2 vector = (-Vector2.UnitY).RotatedBy(num10) * num11;
37096 if (num12 - 1 < 0)
37097 {
37099 }
37100 num4 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), item.X, item.Y, vector.X, vector.Y, 540, 0, 0f, Main.myPlayer, (float)(-num5) * 10f, 0.5f + Main.rand.NextFloat() * 0.5f);
37101 list3.Add(item + vector);
37102 if (num5 < num2 && list2[0].Item2 > 0)
37103 {
37104 list2.Add(Tuple.Create(item + vector, num12 - 1, num9));
37105 }
37106 }
37107 list2.Remove(list2[0]);
37108 if (--num6 == 0)
37109 {
37110 num6 = list2.Count;
37111 num5++;
37112 }
37113 }
37114 Main.projectile[num4].localAI[0] = num;
37115 }
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static int CountNPCS(int Type)
Definition NPC.cs:86664
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, Terraria.NPC.CountNPCS(), Terraria.NPC.GetSpawnSource_ForProjectile(), System.item, System.list, System.Math.Max(), Terraria.Main.myPlayer, Terraria.Projectile.NewProjectile(), System.Math.PI, Terraria.Main.projectile, Terraria.Main.rand, System.Collections.Generic.Dictionary< TKey, TValue >.Remove(), Microsoft.Xna.Framework.Vector2.UnitY, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI_006_Worms().