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

◆ AI_084_LunaticCultist()

void Terraria.NPC.AI_084_LunaticCultist ( )
inlineprivate

Definition at line 56687 of file NPC.cs.

56688 {
56689 if (this.ai[0] != -1f && Main.rand.Next(1000) == 0)
56690 {
56691 SoundEngine.PlaySound(29, (int)position.X, (int)position.Y, Main.rand.Next(88, 92));
56692 }
56693 bool expertMode = Main.expertMode;
56694 bool flag = life <= lifeMax / 2;
56695 int num = 120;
56697 if (expertMode)
56698 {
56699 num = 90;
56700 }
56701 if (Main.getGoodWorld)
56702 {
56703 num -= 30;
56704 }
56705 int num2 = 18;
56706 int num3 = 3;
56708 if (expertMode)
56709 {
56710 num2 = 12;
56711 num3 = 4;
56712 }
56713 if (Main.getGoodWorld)
56714 {
56715 num2 = 10;
56716 num3 = 5;
56717 }
56718 int num4 = 80;
56720 if (expertMode)
56721 {
56722 num4 = 40;
56723 }
56724 if (Main.getGoodWorld)
56725 {
56726 num4 -= 20;
56727 }
56728 int num5 = 20;
56729 int num6 = 2;
56730 if (expertMode)
56731 {
56732 num5 = 30;
56733 num6 = 2;
56734 }
56735 int num7 = 20;
56736 int num8 = 3;
56737 bool flag2 = type == 439;
56738 bool flag3 = false;
56739 bool flag4 = false;
56740 if (flag)
56741 {
56742 defense = (int)((float)defDefense * 0.65f);
56743 }
56744 if (!flag2)
56745 {
56746 if (this.ai[3] < 0f || !Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 439)
56747 {
56748 life = 0;
56749 HitEffect();
56750 active = false;
56751 return;
56752 }
56753 this.ai[0] = Main.npc[(int)this.ai[3]].ai[0];
56754 this.ai[1] = Main.npc[(int)this.ai[3]].ai[1];
56755 if (this.ai[0] == 5f)
56756 {
56757 if (justHit)
56758 {
56759 life = 0;
56760 HitEffect();
56761 active = false;
56762 if (Main.netMode != 1)
56763 {
56764 NetMessage.SendData(23, -1, -1, null, whoAmI);
56765 }
56766 NPC obj = Main.npc[(int)this.ai[3]];
56767 obj.ai[0] = 6f;
56768 obj.ai[1] = 0f;
56769 obj.netUpdate = true;
56770 }
56771 }
56772 else
56773 {
56774 flag3 = true;
56775 flag4 = true;
56776 }
56777 }
56778 else if (this.ai[0] == 5f && this.ai[1] >= 120f && this.ai[1] < 420f && justHit)
56779 {
56780 this.ai[0] = 0f;
56781 this.ai[1] = 0f;
56782 this.ai[3] += 1f;
56784 netUpdate = true;
56785 List<int> list = new List<int>();
56786 for (int i = 0; i < 200; i++)
56787 {
56788 if (Main.npc[i].active && Main.npc[i].type == 440 && Main.npc[i].ai[3] == (float)whoAmI)
56789 {
56790 list.Add(i);
56791 }
56792 }
56793 int num9 = 10;
56794 if (Main.expertMode)
56795 {
56796 num9 = 3;
56797 }
56798 foreach (int item in list)
56799 {
56800 NPC nPC = Main.npc[item];
56801 if (nPC.localAI[1] == localAI[1] && num9 > 0)
56802 {
56803 num9--;
56804 nPC.life = 0;
56805 nPC.HitEffect();
56806 nPC.active = false;
56807 if (Main.netMode != 1)
56808 {
56809 NetMessage.SendData(23, -1, -1, null, item);
56810 }
56811 }
56812 else if (num9 > 0)
56813 {
56814 num9--;
56815 nPC.life = 0;
56816 nPC.HitEffect();
56817 nPC.active = false;
56818 }
56819 }
56820 Main.projectile[(int)this.ai[2]].ai[1] = -1f;
56821 Main.projectile[(int)this.ai[2]].netUpdate = true;
56822 }
56823 Vector2 center = base.Center;
56824 Player player = Main.player[target];
56825 float num10 = 5600f;
56826 if (target < 0 || target == 255 || player.dead || !player.active || Vector2.Distance(player.Center, center) > num10)
56827 {
56829 player = Main.player[target];
56830 netUpdate = true;
56831 }
56832 if (player.dead || !player.active || Vector2.Distance(player.Center, center) > num10)
56833 {
56834 life = 0;
56835 HitEffect();
56836 active = false;
56837 if (Main.netMode != 1)
56838 {
56839 NetMessage.SendData(28, -1, -1, null, whoAmI, -1f);
56840 }
56841 new List<int>().Add(whoAmI);
56842 for (int j = 0; j < 200; j++)
56843 {
56844 if (Main.npc[j].active && Main.npc[j].type == 440 && Main.npc[j].ai[3] == (float)whoAmI)
56845 {
56846 Main.npc[j].life = 0;
56847 Main.npc[j].HitEffect();
56848 Main.npc[j].active = false;
56849 if (Main.netMode != 1)
56850 {
56851 NetMessage.SendData(28, -1, -1, null, whoAmI, -1f);
56852 }
56853 }
56854 }
56855 }
56856 float num11 = this.ai[3];
56857 if (localAI[0] == 0f)
56858 {
56859 SoundEngine.PlaySound(29, (int)position.X, (int)position.Y, 89);
56860 localAI[0] = 1f;
56861 alpha = 255;
56862 rotation = 0f;
56863 if (Main.netMode != 1)
56864 {
56865 this.ai[0] = -1f;
56866 netUpdate = true;
56867 }
56868 }
56869 if (this.ai[0] == -1f)
56870 {
56871 alpha -= 5;
56872 if (alpha < 0)
56873 {
56874 alpha = 0;
56875 }
56876 this.ai[1] += 1f;
56877 if (this.ai[1] >= 420f)
56878 {
56879 this.ai[0] = 0f;
56880 this.ai[1] = 0f;
56881 netUpdate = true;
56882 }
56883 else if (this.ai[1] > 360f)
56884 {
56885 velocity *= 0.95f;
56886 if (localAI[2] != 13f)
56887 {
56888 SoundEngine.PlaySound(29, (int)position.X, (int)position.Y, 105);
56889 }
56890 localAI[2] = 13f;
56891 }
56892 else if (this.ai[1] > 300f)
56893 {
56895 localAI[2] = 10f;
56896 }
56897 else if (this.ai[1] > 120f)
56898 {
56899 localAI[2] = 1f;
56900 }
56901 else
56902 {
56903 localAI[2] = 0f;
56904 }
56905 flag3 = true;
56906 flag4 = true;
56907 }
56908 if (this.ai[0] == 0f)
56909 {
56910 if (this.ai[1] == 0f)
56911 {
56913 }
56914 localAI[2] = 10f;
56915 int num12 = Math.Sign(player.Center.X - center.X);
56916 if (num12 != 0)
56917 {
56919 }
56920 this.ai[1] += 1f;
56921 if (this.ai[1] >= 40f && flag2)
56922 {
56923 int num13 = 0;
56924 if (flag)
56925 {
56926 switch ((int)this.ai[3])
56927 {
56928 case 0:
56929 num13 = 0;
56930 break;
56931 case 1:
56932 num13 = 1;
56933 break;
56934 case 2:
56935 num13 = 0;
56936 break;
56937 case 3:
56938 num13 = 5;
56939 break;
56940 case 4:
56941 num13 = 0;
56942 break;
56943 case 5:
56944 num13 = 3;
56945 break;
56946 case 6:
56947 num13 = 0;
56948 break;
56949 case 7:
56950 num13 = 5;
56951 break;
56952 case 8:
56953 num13 = 0;
56954 break;
56955 case 9:
56956 num13 = 2;
56957 break;
56958 case 10:
56959 num13 = 0;
56960 break;
56961 case 11:
56962 num13 = 3;
56963 break;
56964 case 12:
56965 num13 = 0;
56966 break;
56967 case 13:
56968 num13 = 4;
56969 this.ai[3] = -1f;
56970 break;
56971 default:
56972 this.ai[3] = -1f;
56973 break;
56974 }
56975 }
56976 else
56977 {
56978 switch ((int)this.ai[3])
56979 {
56980 case 0:
56981 num13 = 0;
56982 break;
56983 case 1:
56984 num13 = 1;
56985 break;
56986 case 2:
56987 num13 = 0;
56988 break;
56989 case 3:
56990 num13 = 2;
56991 break;
56992 case 4:
56993 num13 = 0;
56994 break;
56995 case 5:
56996 num13 = 3;
56997 break;
56998 case 6:
56999 num13 = 0;
57000 break;
57001 case 7:
57002 num13 = 1;
57003 break;
57004 case 8:
57005 num13 = 0;
57006 break;
57007 case 9:
57008 num13 = 2;
57009 break;
57010 case 10:
57011 num13 = 0;
57012 break;
57013 case 11:
57014 num13 = 4;
57015 this.ai[3] = -1f;
57016 break;
57017 default:
57018 this.ai[3] = -1f;
57019 break;
57020 }
57021 }
57022 int maxValue = 6;
57023 if (life < lifeMax / 3)
57024 {
57025 maxValue = 4;
57026 }
57027 if (life < lifeMax / 4)
57028 {
57029 maxValue = 3;
57030 }
57031 if (expertMode && flag && Main.rand.Next(maxValue) == 0 && num13 != 0 && num13 != 4 && num13 != 5 && CountNPCS(523) < 10)
57032 {
57033 num13 = 6;
57034 }
57035 if (num13 == 0)
57036 {
57037 float num14 = (float)Math.Ceiling((player.Center + new Vector2(0f, -100f) - center).Length() / 50f);
57038 if (num14 == 0f)
57039 {
57040 num14 = 1f;
57041 }
57042 List<int> list2 = new List<int>();
57043 int num15 = 0;
57044 list2.Add(whoAmI);
57045 for (int k = 0; k < 200; k++)
57046 {
57047 if (Main.npc[k].active && Main.npc[k].type == 440 && Main.npc[k].ai[3] == (float)whoAmI)
57048 {
57049 list2.Add(k);
57050 }
57051 }
57052 bool flag5 = list2.Count % 2 == 0;
57053 foreach (int item2 in list2)
57054 {
57055 NPC nPC2 = Main.npc[item2];
57056 Vector2 center2 = nPC2.Center;
57057 float num16 = (float)((num15 + flag5.ToInt() + 1) / 2) * ((float)Math.PI * 2f) * 0.4f / (float)list2.Count;
57058 if (num15 % 2 == 1)
57059 {
57060 num16 *= -1f;
57061 }
57062 if (list2.Count == 1)
57063 {
57064 num16 = 0f;
57065 }
57066 Vector2 vector = new Vector2(0f, -1f).RotatedBy(num16) * new Vector2(300f, 200f);
57067 Vector2 vector2 = player.Center + vector - center2;
57068 nPC2.ai[0] = 1f;
57069 nPC2.ai[1] = num14 * 2f;
57070 nPC2.velocity = vector2 / num14;
57071 if (whoAmI >= nPC2.whoAmI)
57072 {
57073 nPC2.position -= nPC2.velocity;
57074 }
57075 nPC2.netUpdate = true;
57076 num15++;
57077 }
57078 }
57079 switch (num13)
57080 {
57081 case 1:
57082 this.ai[0] = 3f;
57083 this.ai[1] = 0f;
57084 break;
57085 case 2:
57086 this.ai[0] = 2f;
57087 this.ai[1] = 0f;
57088 break;
57089 case 3:
57090 this.ai[0] = 4f;
57091 this.ai[1] = 0f;
57092 break;
57093 case 4:
57094 this.ai[0] = 5f;
57095 this.ai[1] = 0f;
57096 break;
57097 }
57098 if (num13 == 5)
57099 {
57100 this.ai[0] = 7f;
57101 this.ai[1] = 0f;
57102 }
57103 if (num13 == 6)
57104 {
57105 this.ai[0] = 8f;
57106 this.ai[1] = 0f;
57107 }
57108 netUpdate = true;
57109 }
57110 }
57111 else if (this.ai[0] == 1f)
57112 {
57113 flag3 = true;
57114 localAI[2] = 10f;
57115 if ((float)(int)this.ai[1] % 2f != 0f && this.ai[1] != 1f)
57116 {
57117 position -= velocity;
57118 }
57119 this.ai[1] -= 1f;
57120 if (this.ai[1] <= 0f)
57121 {
57122 this.ai[0] = 0f;
57123 this.ai[1] = 0f;
57124 this.ai[3] += 1f;
57126 netUpdate = true;
57127 }
57128 }
57129 else if (this.ai[0] == 2f)
57130 {
57131 localAI[2] = 11f;
57132 Vector2 vec = Vector2.Normalize(player.Center - center);
57133 if (vec.HasNaNs())
57134 {
57135 vec = new Vector2(direction, 0f);
57136 }
57137 if (this.ai[1] >= 4f && flag2 && (int)(this.ai[1] - 4f) % num == 0)
57138 {
57139 if (Main.netMode != 1)
57140 {
57141 List<int> list3 = new List<int>();
57142 for (int l = 0; l < 200; l++)
57143 {
57144 if (Main.npc[l].active && Main.npc[l].type == 440 && Main.npc[l].ai[3] == (float)whoAmI)
57145 {
57146 list3.Add(l);
57147 }
57148 }
57149 foreach (int item3 in list3)
57150 {
57151 NPC nPC3 = Main.npc[item3];
57152 Vector2 center3 = nPC3.Center;
57153 int num17 = Math.Sign(player.Center.X - center3.X);
57154 if (num17 != 0)
57155 {
57156 nPC3.direction = (nPC3.spriteDirection = num17);
57157 }
57158 if (Main.netMode != 1)
57159 {
57160 vec = Vector2.Normalize(player.Center - center3 + player.velocity * 20f);
57161 if (vec.HasNaNs())
57162 {
57163 vec = new Vector2(direction, 0f);
57164 }
57165 Vector2 vector3 = center3 + new Vector2(direction * 30, 12f);
57166 for (int m = 0; m < 1; m++)
57167 {
57168 Vector2 spinninpoint = vec * (6f + (float)Main.rand.NextDouble() * 4f);
57169 spinninpoint = spinninpoint.RotatedByRandom(0.5235987901687622);
57170 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector3.X, vector3.Y, spinninpoint.X, spinninpoint.Y, 468, 18, 0f, Main.myPlayer);
57171 }
57172 }
57173 }
57174 }
57175 if (Main.netMode != 1)
57176 {
57177 vec = Vector2.Normalize(player.Center - center + player.velocity * 20f);
57178 if (vec.HasNaNs())
57179 {
57180 vec = new Vector2(direction, 0f);
57181 }
57182 Vector2 vector4 = base.Center + new Vector2(direction * 30, 12f);
57183 for (int n = 0; n < 1; n++)
57184 {
57185 Vector2 vector5 = vec * 4f;
57186 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector4.X, vector4.Y, vector5.X, vector5.Y, 464, attackDamage_ForProjectiles, 0f, Main.myPlayer, 0f, 1f);
57187 }
57188 }
57189 }
57190 this.ai[1] += 1f;
57191 if (this.ai[1] >= (float)(4 + num))
57192 {
57193 this.ai[0] = 0f;
57194 this.ai[1] = 0f;
57195 this.ai[3] += 1f;
57197 netUpdate = true;
57198 }
57199 }
57200 else if (this.ai[0] == 3f)
57201 {
57202 localAI[2] = 11f;
57203 Vector2 vec2 = Vector2.Normalize(player.Center - center);
57204 if (vec2.HasNaNs())
57205 {
57206 vec2 = new Vector2(direction, 0f);
57207 }
57208 if (this.ai[1] >= 4f && flag2 && (int)(this.ai[1] - 4f) % num2 == 0)
57209 {
57210 if ((int)(this.ai[1] - 4f) / num2 == 2)
57211 {
57212 List<int> list4 = new List<int>();
57213 for (int num18 = 0; num18 < 200; num18++)
57214 {
57215 if (Main.npc[num18].active && Main.npc[num18].type == 440 && Main.npc[num18].ai[3] == (float)whoAmI)
57216 {
57217 list4.Add(num18);
57218 }
57219 }
57220 if (Main.netMode != 1)
57221 {
57222 foreach (int item4 in list4)
57223 {
57224 NPC nPC4 = Main.npc[item4];
57225 Vector2 center4 = nPC4.Center;
57226 int num19 = Math.Sign(player.Center.X - center4.X);
57227 if (num19 != 0)
57228 {
57229 nPC4.direction = (nPC4.spriteDirection = num19);
57230 }
57231 if (Main.netMode != 1)
57232 {
57233 vec2 = Vector2.Normalize(player.Center - center4 + player.velocity * 20f);
57234 if (vec2.HasNaNs())
57235 {
57236 vec2 = new Vector2(direction, 0f);
57237 }
57238 Vector2 vector6 = center4 + new Vector2(direction * 30, 12f);
57239 for (int num20 = 0; num20 < 1; num20++)
57240 {
57241 Vector2 spinninpoint2 = vec2 * (6f + (float)Main.rand.NextDouble() * 4f);
57242 spinninpoint2 = spinninpoint2.RotatedByRandom(0.5235987901687622);
57243 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector6.X, vector6.Y, spinninpoint2.X, spinninpoint2.Y, 468, 18, 0f, Main.myPlayer);
57244 }
57245 }
57246 }
57247 }
57248 }
57249 int num21 = Math.Sign(player.Center.X - center.X);
57250 if (num21 != 0)
57251 {
57253 }
57254 if (Main.netMode != 1)
57255 {
57256 vec2 = Vector2.Normalize(player.Center - center + player.velocity * 20f);
57257 if (vec2.HasNaNs())
57258 {
57259 vec2 = new Vector2(direction, 0f);
57260 }
57261 Vector2 vector7 = base.Center + new Vector2(direction * 30, 12f);
57262 for (int num22 = 0; num22 < 1; num22++)
57263 {
57264 Vector2 spinninpoint3 = vec2 * (6f + (float)Main.rand.NextDouble() * 4f);
57265 spinninpoint3 = spinninpoint3.RotatedByRandom(0.5235987901687622);
57266 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector7.X, vector7.Y, spinninpoint3.X, spinninpoint3.Y, 467, attackDamage_ForProjectiles2, 0f, Main.myPlayer);
57267 }
57268 }
57269 }
57270 this.ai[1] += 1f;
57271 if (this.ai[1] >= (float)(4 + num2 * num3))
57272 {
57273 this.ai[0] = 0f;
57274 this.ai[1] = 0f;
57275 this.ai[3] += 1f;
57277 netUpdate = true;
57278 }
57279 }
57280 else if (this.ai[0] == 4f)
57281 {
57282 if (flag2)
57283 {
57284 localAI[2] = 12f;
57285 }
57286 else
57287 {
57288 localAI[2] = 11f;
57289 }
57290 if (this.ai[1] == 20f && flag2 && Main.netMode != 1)
57291 {
57292 List<int> list5 = new List<int>();
57293 for (int num23 = 0; num23 < 200; num23++)
57294 {
57295 if (Main.npc[num23].active && Main.npc[num23].type == 440 && Main.npc[num23].ai[3] == (float)whoAmI)
57296 {
57297 list5.Add(num23);
57298 }
57299 }
57300 foreach (int item5 in list5)
57301 {
57302 NPC nPC5 = Main.npc[item5];
57303 Vector2 center5 = nPC5.Center;
57304 int num24 = Math.Sign(player.Center.X - center5.X);
57305 if (num24 != 0)
57306 {
57307 nPC5.direction = (nPC5.spriteDirection = num24);
57308 }
57309 if (Main.netMode != 1)
57310 {
57311 Vector2 vector8 = Vector2.Normalize(player.Center - center5 + player.velocity * 20f);
57312 if (vector8.HasNaNs())
57313 {
57314 vector8 = new Vector2(direction, 0f);
57315 }
57316 Vector2 vector9 = center5 + new Vector2(direction * 30, 12f);
57317 for (int num25 = 0; num25 < 1; num25++)
57318 {
57319 Vector2 spinninpoint4 = vector8 * (6f + (float)Main.rand.NextDouble() * 4f);
57320 spinninpoint4 = spinninpoint4.RotatedByRandom(0.5235987901687622);
57321 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector9.X, vector9.Y, spinninpoint4.X, spinninpoint4.Y, 468, 18, 0f, Main.myPlayer);
57322 }
57323 }
57324 }
57325 if ((int)(this.ai[1] - 20f) % num4 == 0)
57326 {
57327 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X, base.Center.Y - 100f, 0f, 0f, 465, attackDamage_ForProjectiles3, 0f, Main.myPlayer);
57328 }
57329 }
57330 this.ai[1] += 1f;
57331 if (this.ai[1] >= (float)(20 + num4))
57332 {
57333 this.ai[0] = 0f;
57334 this.ai[1] = 0f;
57335 this.ai[3] += 1f;
57337 netUpdate = true;
57338 }
57339 }
57340 else if (this.ai[0] == 5f)
57341 {
57342 localAI[2] = 10f;
57343 if (Vector2.Normalize(player.Center - center).HasNaNs())
57344 {
57345 new Vector2(direction, 0f);
57346 }
57347 if (this.ai[1] >= 0f && this.ai[1] < 30f)
57348 {
57349 flag3 = true;
57350 flag4 = true;
57351 float num26 = (this.ai[1] - 0f) / 30f;
57352 alpha = (int)(num26 * 255f);
57353 }
57354 else if (this.ai[1] >= 30f && this.ai[1] < 90f)
57355 {
57356 if (this.ai[1] == 30f && Main.netMode != 1 && flag2)
57357 {
57358 localAI[1] += 1f;
57359 Vector2 spinningpoint = new Vector2(180f, 0f);
57360 List<int> list6 = new List<int>();
57361 for (int num27 = 0; num27 < 200; num27++)
57362 {
57363 if (Main.npc[num27].active && Main.npc[num27].type == 440 && Main.npc[num27].ai[3] == (float)whoAmI)
57364 {
57365 list6.Add(num27);
57366 }
57367 }
57368 int num28 = 6 - list6.Count;
57369 if (num28 > 2)
57370 {
57371 num28 = 2;
57372 }
57373 int num29 = list6.Count + num28 + 1;
57374 float[] array = new float[num29];
57375 for (int num30 = 0; num30 < array.Length; num30++)
57376 {
57377 array[num30] = Vector2.Distance(base.Center + spinningpoint.RotatedBy((float)num30 * ((float)Math.PI * 2f) / (float)num29 - (float)Math.PI / 2f), player.Center);
57378 }
57379 int num31 = 0;
57380 for (int num32 = 1; num32 < array.Length; num32++)
57381 {
57382 if (array[num31] > array[num32])
57383 {
57384 num31 = num32;
57385 }
57386 }
57387 num31 = ((num31 >= num29 / 2) ? (num31 - num29 / 2) : (num31 + num29 / 2));
57388 int num33 = num28;
57389 for (int num34 = 0; num34 < array.Length; num34++)
57390 {
57391 if (num31 != num34)
57392 {
57393 Vector2 center6 = base.Center + spinningpoint.RotatedBy((float)num34 * ((float)Math.PI * 2f) / (float)num29 - (float)Math.PI / 2f);
57394 if (num33-- > 0)
57395 {
57396 int num35 = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)center6.X, (int)center6.Y + height / 2, 440, whoAmI);
57397 Main.npc[num35].ai[3] = whoAmI;
57398 Main.npc[num35].netUpdate = true;
57399 Main.npc[num35].localAI[1] = localAI[1];
57400 }
57401 else
57402 {
57403 int num36 = list6[-num33 - 1];
57404 Main.npc[num36].Center = center6;
57405 NetMessage.SendData(23, -1, -1, null, num36);
57406 }
57407 }
57408 }
57409 this.ai[2] = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X, base.Center.Y, 0f, 0f, 490, 0, 0f, Main.myPlayer, 0f, whoAmI);
57410 base.Center += spinningpoint.RotatedBy((float)num31 * ((float)Math.PI * 2f) / (float)num29 - (float)Math.PI / 2f);
57411 netUpdate = true;
57412 list6.Clear();
57413 }
57414 flag3 = true;
57415 flag4 = true;
57416 alpha = 255;
57417 if (flag2)
57418 {
57419 Vector2 vector10 = Main.projectile[(int)this.ai[2]].Center;
57420 vector10 -= base.Center;
57421 if (vector10 == Vector2.Zero)
57422 {
57424 }
57425 vector10.Normalize();
57426 if (Math.Abs(vector10.Y) < 0.77f)
57427 {
57428 localAI[2] = 11f;
57429 }
57430 else if (vector10.Y < 0f)
57431 {
57432 localAI[2] = 12f;
57433 }
57434 else
57435 {
57436 localAI[2] = 10f;
57437 }
57438 int num37 = Math.Sign(vector10.X);
57439 if (num37 != 0)
57440 {
57442 }
57443 }
57444 else
57445 {
57446 Vector2 vector11 = Main.projectile[(int)Main.npc[(int)this.ai[3]].ai[2]].Center;
57447 vector11 -= base.Center;
57448 if (vector11 == Vector2.Zero)
57449 {
57451 }
57452 vector11.Normalize();
57453 if (Math.Abs(vector11.Y) < 0.77f)
57454 {
57455 localAI[2] = 11f;
57456 }
57457 else if (vector11.Y < 0f)
57458 {
57459 localAI[2] = 12f;
57460 }
57461 else
57462 {
57463 localAI[2] = 10f;
57464 }
57465 int num38 = Math.Sign(vector11.X);
57466 if (num38 != 0)
57467 {
57469 }
57470 }
57471 }
57472 else if (this.ai[1] >= 90f && this.ai[1] < 120f)
57473 {
57474 flag3 = true;
57475 flag4 = true;
57476 float num39 = (this.ai[1] - 90f) / 30f;
57477 alpha = 255 - (int)(num39 * 255f);
57478 }
57479 else if (this.ai[1] >= 120f && this.ai[1] < 420f)
57480 {
57481 flag4 = true;
57482 alpha = 0;
57483 if (flag2)
57484 {
57485 Vector2 vector12 = Main.projectile[(int)this.ai[2]].Center;
57486 vector12 -= base.Center;
57487 if (vector12 == Vector2.Zero)
57488 {
57490 }
57491 vector12.Normalize();
57492 if (Math.Abs(vector12.Y) < 0.77f)
57493 {
57494 localAI[2] = 11f;
57495 }
57496 else if (vector12.Y < 0f)
57497 {
57498 localAI[2] = 12f;
57499 }
57500 else
57501 {
57502 localAI[2] = 10f;
57503 }
57504 int num40 = Math.Sign(vector12.X);
57505 if (num40 != 0)
57506 {
57508 }
57509 }
57510 else
57511 {
57512 Vector2 vector13 = Main.projectile[(int)Main.npc[(int)this.ai[3]].ai[2]].Center;
57513 vector13 -= base.Center;
57514 if (vector13 == Vector2.Zero)
57515 {
57517 }
57518 vector13.Normalize();
57519 if (Math.Abs(vector13.Y) < 0.77f)
57520 {
57521 localAI[2] = 11f;
57522 }
57523 else if (vector13.Y < 0f)
57524 {
57525 localAI[2] = 12f;
57526 }
57527 else
57528 {
57529 localAI[2] = 10f;
57530 }
57531 int num41 = Math.Sign(vector13.X);
57532 if (num41 != 0)
57533 {
57535 }
57536 }
57537 }
57538 this.ai[1] += 1f;
57539 if (this.ai[1] >= 420f)
57540 {
57541 flag4 = true;
57542 this.ai[0] = 0f;
57543 this.ai[1] = 0f;
57544 this.ai[3] += 1f;
57546 netUpdate = true;
57547 }
57548 }
57549 else if (this.ai[0] == 6f)
57550 {
57551 localAI[2] = 13f;
57552 this.ai[1] += 1f;
57553 if (this.ai[1] >= 120f)
57554 {
57555 this.ai[0] = 0f;
57556 this.ai[1] = 0f;
57557 this.ai[3] += 1f;
57559 netUpdate = true;
57560 }
57561 }
57562 else if (this.ai[0] == 7f)
57563 {
57564 localAI[2] = 11f;
57565 Vector2 vec3 = Vector2.Normalize(player.Center - center);
57566 if (vec3.HasNaNs())
57567 {
57568 vec3 = new Vector2(direction, 0f);
57569 }
57570 if (this.ai[1] >= 4f && flag2 && (int)(this.ai[1] - 4f) % num5 == 0)
57571 {
57572 if ((int)(this.ai[1] - 4f) / num5 == 2)
57573 {
57574 List<int> list7 = new List<int>();
57575 for (int num42 = 0; num42 < 200; num42++)
57576 {
57577 if (Main.npc[num42].active && Main.npc[num42].type == 440 && Main.npc[num42].ai[3] == (float)whoAmI)
57578 {
57579 list7.Add(num42);
57580 }
57581 }
57582 foreach (int item6 in list7)
57583 {
57584 NPC nPC6 = Main.npc[item6];
57585 Vector2 center7 = nPC6.Center;
57586 int num43 = Math.Sign(player.Center.X - center7.X);
57587 if (num43 != 0)
57588 {
57589 nPC6.direction = (nPC6.spriteDirection = num43);
57590 }
57591 if (Main.netMode != 1)
57592 {
57593 vec3 = Vector2.Normalize(player.Center - center7 + player.velocity * 20f);
57594 if (vec3.HasNaNs())
57595 {
57596 vec3 = new Vector2(direction, 0f);
57597 }
57598 Vector2 vector14 = center7 + new Vector2(direction * 30, 12f);
57599 for (int num44 = 0; (float)num44 < 5f; num44++)
57600 {
57601 Vector2 spinninpoint5 = vec3 * (6f + (float)Main.rand.NextDouble() * 4f);
57602 spinninpoint5 = spinninpoint5.RotatedByRandom(1.2566370964050293);
57603 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector14.X, vector14.Y, spinninpoint5.X, spinninpoint5.Y, 468, 18, 0f, Main.myPlayer);
57604 }
57605 }
57606 }
57607 }
57608 int num45 = Math.Sign(player.Center.X - center.X);
57609 if (num45 != 0)
57610 {
57612 }
57613 if (Main.netMode != 1)
57614 {
57615 vec3 = Vector2.Normalize(player.Center - center + player.velocity * 20f);
57616 if (vec3.HasNaNs())
57617 {
57618 vec3 = new Vector2(direction, 0f);
57619 }
57620 Vector2 vector15 = base.Center + new Vector2(direction * 30, 12f);
57621 float num46 = 8f;
57622 float num47 = (float)Math.PI * 2f / 25f;
57623 for (int num48 = 0; (float)num48 < 5f; num48++)
57624 {
57626 spinningpoint2 = spinningpoint2.RotatedBy(num47 * (float)num48 - ((float)Math.PI * 2f / 5f - num47) / 2f);
57627 float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * ((float)Math.PI * 2f) / 60f;
57628 int num49 = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)vector15.X, (int)vector15.Y + 7, 522, 0, 0f, ai, spinningpoint2.X, spinningpoint2.Y);
57629 Main.npc[num49].velocity = spinningpoint2;
57630 Main.npc[num49].netUpdate = true;
57631 }
57632 }
57633 }
57634 this.ai[1] += 1f;
57635 if (this.ai[1] >= (float)(4 + num5 * num6))
57636 {
57637 this.ai[0] = 0f;
57638 this.ai[1] = 0f;
57639 this.ai[3] += 1f;
57641 netUpdate = true;
57642 }
57643 }
57644 else if (this.ai[0] == 8f)
57645 {
57646 localAI[2] = 13f;
57647 if (this.ai[1] >= 4f && flag2 && (int)(this.ai[1] - 4f) % num7 == 0)
57648 {
57649 List<int> list8 = new List<int>();
57650 for (int num50 = 0; num50 < 200; num50++)
57651 {
57652 if (Main.npc[num50].active && Main.npc[num50].type == 440 && Main.npc[num50].ai[3] == (float)whoAmI)
57653 {
57654 list8.Add(num50);
57655 }
57656 }
57657 int num51 = list8.Count + 1;
57658 if (num51 > 3)
57659 {
57660 num51 = 3;
57661 }
57662 int num52 = Math.Sign(player.Center.X - center.X);
57663 if (num52 != 0)
57664 {
57666 }
57667 if (Main.netMode != 1)
57668 {
57669 for (int num53 = 0; num53 < num51; num53++)
57670 {
57671 Point point = base.Center.ToTileCoordinates();
57672 Point point2 = Main.player[target].Center.ToTileCoordinates();
57673 Vector2 vector16 = Main.player[target].Center - base.Center;
57674 int num54 = 20;
57675 int num55 = 3;
57676 int num56 = 7;
57677 int num57 = 2;
57678 int num58 = 0;
57679 bool flag6 = false;
57680 if (vector16.Length() > 2000f)
57681 {
57682 flag6 = true;
57683 }
57684 while (!flag6 && num58 < 100)
57685 {
57686 num58++;
57687 int num59 = Main.rand.Next(point2.X - num54, point2.X + num54 + 1);
57688 int num60 = Main.rand.Next(point2.Y - num54, point2.Y + num54 + 1);
57689 if ((num60 < point2.Y - num56 || num60 > point2.Y + num56 || num59 < point2.X - num56 || num59 > point2.X + num56) && (num60 < point.Y - num55 || num60 > point.Y + num55 || num59 < point.X - num55 || num59 > point.X + num55) && !Main.tile[num59, num60].nactive())
57690 {
57691 bool flag7 = true;
57692 if (flag7 && Collision.SolidTiles(num59 - num57, num59 + num57, num60 - num57, num60 + num57))
57693 {
57694 flag7 = false;
57695 }
57696 if (flag7)
57697 {
57698 NewNPC(GetSpawnSourceForNPCFromNPCAI(), num59 * 16 + 8, num60 * 16 + 8, 523, 0, whoAmI);
57699 flag6 = true;
57700 break;
57701 }
57702 }
57703 }
57704 }
57705 }
57706 }
57707 this.ai[1] += 1f;
57708 if (this.ai[1] >= (float)(4 + num7 * num8))
57709 {
57710 this.ai[0] = 0f;
57711 this.ai[1] = 0f;
57712 this.ai[3] += 1f;
57714 netUpdate = true;
57715 }
57716 }
57717 if (!flag2)
57718 {
57719 this.ai[3] = num11;
57720 }
57722 chaseable = !flag4;
57723 }
void Add(TKey key, TValue value)
static double Ceiling(double a)
static double Abs(double value)
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 Center
Definition Entity.cs:43
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
int defense
Definition NPC.cs:463
static int CountNPCS(int Type)
Definition NPC.cs:86664
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
bool chaseable
Definition NPC.cs:263
int lifeMax
Definition NPC.cs:479
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
int defDefense
Definition NPC.cs:467
float[] ai
Definition NPC.cs:447
bool dontTakeDamage
Definition NPC.cs:527
int type
Definition NPC.cs:445
int alpha
Definition NPC.cs:489
float rotation
Definition NPC.cs:501
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:87546
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
int GetAttackDamage_ForProjectiles(float normalDamage, float expertDamage)
Definition NPC.cs:1082
void HitEffect(int hitDirection=0, double dmg=10.0)
Definition NPC.cs:78386
bool justHit
Definition NPC.cs:455
int life
Definition NPC.cs:477
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
bool netUpdate
Definition NPC.cs:507
int target
Definition NPC.cs:459
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References System.Math.Abs(), Terraria.Entity.active, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), Terraria.NPC.ai, Terraria.NPC.alpha, System.array, System.Math.Ceiling(), Terraria.Entity.Center, Terraria.NPC.chaseable, System.Collections.Generic.Dictionary< TKey, TValue >.Clear(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, Terraria.NPC.CountNPCS(), Terraria.Player.dead, Terraria.NPC.defDefense, Terraria.NPC.defense, Terraria.Entity.direction, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.NPC.dontTakeDamage, Terraria.Main.expertMode, Terraria.NPC.GetAttackDamage_ForProjectiles(), Terraria.Main.getGoodWorld, Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetSpawnSourceForNPCFromNPCAI(), Terraria.Entity.height, Terraria.NPC.HitEffect(), System.item, Terraria.NPC.justHit, Terraria.NPC.life, Terraria.NPC.lifeMax, System.list, Terraria.NPC.localAI, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.NPC.NewNPC(), Terraria.Projectile.NewProjectile(), Microsoft.Xna.Framework.Vector2.Normalize(), Terraria.Main.npc, System.obj, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.projectile, Terraria.Main.rand, Terraria.NPC.rotation, Terraria.NetMessage.SendData(), System.Math.Sign(), Terraria.Collision.SolidTiles(), Terraria.NPC.spriteDirection, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.Main.tile, Terraria.NPC.type, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, Terraria.Entity.whoAmI, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().