Advertisement
Guest User

FBI

a guest
Jul 22nd, 2019
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 174.46 KB | None | 0 0
  1. using System;
  2. using Terraria;
  3. using Terraria.ID;
  4. using Terraria.ModLoader;
  5. using Microsoft.Xna.Framework;
  6. using System.Collections.Generic;
  7. using Terraria.Audio;
  8. using Terraria.DataStructures;
  9. using Terraria.Utilities;
  10.  
  11. namespace TheDonald.NPCs.HostileNPCs
  12. {
  13. class FBI : ModNPC
  14. {
  15. public override void SetStaticDefaults()
  16. {
  17. DisplayName.SetDefault("FBI Agent");
  18. Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.PirateCrossbower];
  19. }
  20. public override void SetDefaults()
  21. {
  22. npc.CloneDefaults(215);
  23. npc.aiStyle = 0;
  24. animationType = 215;
  25. banner = Item.NPCtoBanner(NPCID.Zombie);
  26. bannerItem = Item.BannerToItem(banner);
  27. }
  28. public override float SpawnChance(NPCSpawnInfo spawnInfo)
  29. {
  30. if (spawnInfo.player.GetModPlayer<TheDonaldPlayer>().ZoneIndustrialBiome);
  31. return Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type == mod.TileType("ConcreteTile") ? 100f : 0f; //100f is the spown rate so If you want your NPC to be rarer just change that value less the 100f or something.
  32. }
  33. public override void NPCLoot()
  34. {
  35. if (Main.rand.Next(3) == 0)
  36. {
  37. Item.NewItem(npc.getRect(), mod.ItemType("SpikyBracelet"));
  38. }
  39. }
  40. public override void AI()
  41. {
  42. if (npc.type == 466)
  43. {
  44. int num = 200;
  45. if (npc.ai[2] == 0f)
  46. {
  47. npc.alpha = num;
  48. npc.TargetClosest(true);
  49. if (!Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() < 170f)
  50. {
  51. npc.ai[2] = -16f;
  52. }
  53. if (npc.velocity.X != 0f || npc.velocity.Y < 0f || npc.velocity.Y > 2f || npc.justHit)
  54. {
  55. npc.ai[2] = -16f;
  56. }
  57. return;
  58. }
  59. if (npc.ai[2] < 0f)
  60. {
  61. if (npc.alpha > 0)
  62. {
  63. npc.alpha -= num / 16;
  64. if (npc.alpha < 0)
  65. {
  66. npc.alpha = 0;
  67. }
  68. }
  69. npc.ai[2] += 1f;
  70. if (npc.ai[2] == 0f)
  71. {
  72. npc.ai[2] = 1f;
  73. npc.velocity.X = (float)(npc.direction * 2);
  74. }
  75. return;
  76. }
  77. npc.alpha = 0;
  78. }
  79. if (npc.type == 166)
  80. {
  81. if (Main.netMode != 1 && Main.rand.Next(240) == 0)
  82. {
  83. npc.ai[2] = (float)Main.rand.Next(-480, -60);
  84. npc.netUpdate = true;
  85. }
  86. if (npc.ai[2] < 0f)
  87. {
  88. npc.TargetClosest(true);
  89. if (npc.justHit)
  90. {
  91. npc.ai[2] = 0f;
  92. }
  93. if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
  94. {
  95. npc.ai[2] = 0f;
  96. }
  97. }
  98. if (npc.ai[2] < 0f)
  99. {
  100. npc.velocity.X = npc.velocity.X * 0.9f;
  101. if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1)
  102. {
  103. npc.velocity.X = 0f;
  104. }
  105. npc.ai[2] += 1f;
  106. if (npc.ai[2] == 0f)
  107. {
  108. npc.velocity.X = (float)npc.direction * 0.1f;
  109. }
  110. return;
  111. }
  112. }
  113. if (npc.type == 461)
  114. {
  115. if (npc.wet)
  116. {
  117. npc.knockBackResist = 0f;
  118. npc.ai[3] = -0.10101f;
  119. npc.noGravity = true;
  120. Vector2 center = npc.Center;
  121. npc.width = 34;
  122. npc.height = 24;
  123. npc.position.X = center.X - (float)(npc.width / 2);
  124. npc.position.Y = center.Y - (float)(npc.height / 2);
  125. npc.TargetClosest(true);
  126. if (npc.collideX)
  127. {
  128. npc.velocity.X = -npc.oldVelocity.X;
  129. }
  130. if (npc.velocity.X < 0f)
  131. {
  132. npc.direction = -1;
  133. }
  134. if (npc.velocity.X > 0f)
  135. {
  136. npc.direction = 1;
  137. }
  138. if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1))
  139. {
  140. Vector2 value = Main.player[npc.target].Center - npc.Center;
  141. value.Normalize();
  142. value *= 5f;
  143. npc.velocity = (npc.velocity * 19f + value) / 20f;
  144. return;
  145. }
  146. float num2 = 5f;
  147. if (npc.velocity.Y > 0f)
  148. {
  149. num2 = 3f;
  150. }
  151. if (npc.velocity.Y < 0f)
  152. {
  153. num2 = 8f;
  154. }
  155. Vector2 value2 = new Vector2((float)npc.direction, -1f);
  156. value2.Normalize();
  157. value2 *= num2;
  158. if (num2 < 5f)
  159. {
  160. npc.velocity = (npc.velocity * 24f + value2) / 25f;
  161. return;
  162. }
  163. npc.velocity = (npc.velocity * 9f + value2) / 10f;
  164. return;
  165. }
  166. else
  167. {
  168. npc.knockBackResist = 0.4f * Main.knockBackMultiplier;
  169. npc.noGravity = false;
  170. Vector2 center2 = npc.Center;
  171. npc.width = 18;
  172. npc.height = 40;
  173. npc.position.X = center2.X - (float)(npc.width / 2);
  174. npc.position.Y = center2.Y - (float)(npc.height / 2);
  175. if (npc.ai[3] == -0.10101f)
  176. {
  177. npc.ai[3] = 0f;
  178. float num3 = npc.velocity.Length();
  179. num3 *= 2f;
  180. if (num3 > 10f)
  181. {
  182. num3 = 10f;
  183. }
  184. npc.velocity.Normalize();
  185. npc.velocity *= num3;
  186. if (npc.velocity.X < 0f)
  187. {
  188. npc.direction = -1;
  189. }
  190. if (npc.velocity.X > 0f)
  191. {
  192. npc.direction = 1;
  193. }
  194. npc.spriteDirection = npc.direction;
  195. }
  196. }
  197. }
  198. if (npc.type == 379 || npc.type == 380)
  199. {
  200. if (npc.ai[3] < 0f)
  201. {
  202. npc.damage = 0;
  203. npc.velocity.X = npc.velocity.X * 0.93f;
  204. if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1)
  205. {
  206. npc.velocity.X = 0f;
  207. }
  208. int num4 = (int)(-npc.ai[3] - 1f);
  209. int num5 = Math.Sign(Main.npc[num4].Center.X - npc.Center.X);
  210. if (num5 != npc.direction)
  211. {
  212. npc.velocity.X = 0f;
  213. npc.direction = num5;
  214. npc.netUpdate = true;
  215. }
  216. if (npc.justHit && Main.netMode != 1 && Main.npc[num4].localAI[0] == 0f)
  217. {
  218. Main.npc[num4].localAI[0] = 1f;
  219. }
  220. if (npc.ai[0] < 1000f)
  221. {
  222. npc.ai[0] = 1000f;
  223. }
  224. if ((npc.ai[0] += 1f) >= 1300f)
  225. {
  226. npc.ai[0] = 1000f;
  227. npc.netUpdate = true;
  228. }
  229. return;
  230. }
  231. if (npc.ai[0] >= 1000f)
  232. {
  233. npc.ai[0] = 0f;
  234. }
  235. npc.damage = npc.defDamage;
  236. }
  237. if (npc.type == 383 && npc.ai[2] == 0f && npc.localAI[0] == 0f && Main.netMode != 1)
  238. {
  239. int num6 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 384, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
  240. npc.ai[2] = (float)(num6 + 1);
  241. npc.localAI[0] = -1f;
  242. npc.netUpdate = true;
  243. Main.npc[num6].ai[0] = (float)npc.whoAmI;
  244. Main.npc[num6].netUpdate = true;
  245. }
  246. if (npc.type == 383)
  247. {
  248. int num7 = (int)npc.ai[2] - 1;
  249. if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == 384)
  250. {
  251. npc.dontTakeDamage = true;
  252. }
  253. else
  254. {
  255. npc.dontTakeDamage = false;
  256. npc.ai[2] = 0f;
  257. if (npc.localAI[0] == -1f)
  258. {
  259. npc.localAI[0] = 180f;
  260. }
  261. if (npc.localAI[0] > 0f)
  262. {
  263. npc.localAI[0] -= 1f;
  264. }
  265. }
  266. }
  267. if (npc.type == 482)
  268. {
  269. int num8 = 300;
  270. int num9 = 120;
  271. npc.dontTakeDamage = false;
  272. if (npc.ai[2] < 0f)
  273. {
  274. npc.dontTakeDamage = true;
  275. npc.ai[2] += 1f;
  276. npc.velocity.X = npc.velocity.X * 0.9f;
  277. if ((double)Math.Abs(npc.velocity.X) < 0.001)
  278. {
  279. npc.velocity.X = 0.001f * (float)npc.direction;
  280. }
  281. if (Math.Abs(npc.velocity.Y) > 1f)
  282. {
  283. npc.ai[2] += 10f;
  284. }
  285. if (npc.ai[2] >= 0f)
  286. {
  287. npc.netUpdate = true;
  288. npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.3f;
  289. }
  290. return;
  291. }
  292. if (npc.ai[2] < (float)num8)
  293. {
  294. if (npc.justHit)
  295. {
  296. npc.ai[2] += 15f;
  297. }
  298. npc.ai[2] += 1f;
  299. }
  300. else if (npc.velocity.Y == 0f)
  301. {
  302. npc.ai[2] = -(float)num9;
  303. npc.netUpdate = true;
  304. }
  305. }
  306. if (npc.type == 480)
  307. {
  308. int num10 = 180;
  309. int num11 = 300;
  310. int num12 = 180;
  311. int num13 = 60;
  312. int num14 = 20;
  313. if (npc.life < npc.lifeMax / 3)
  314. {
  315. num10 = 120;
  316. num11 = 240;
  317. num12 = 240;
  318. num13 = 90;
  319. }
  320. if (npc.ai[2] > 0f)
  321. {
  322. npc.ai[2] -= 1f;
  323. }
  324. else if (npc.ai[2] == 0f)
  325. {
  326. if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && npc.velocity.Y == 0f && npc.Distance(Main.player[npc.target].Center) < 900f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
  327. {
  328. npc.ai[2] = -(float)num12 - (float)num14;
  329. npc.netUpdate = true;
  330. }
  331. }
  332. else
  333. {
  334. if (npc.ai[2] < 0f && npc.ai[2] < -(float)num12)
  335. {
  336. npc.velocity.X = npc.velocity.X * 0.9f;
  337. if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit)
  338. {
  339. npc.ai[2] = (float)num10;
  340. }
  341. else
  342. {
  343. npc.ai[2] += 1f;
  344. if (npc.ai[2] == 0f)
  345. {
  346. npc.ai[2] = (float)num11;
  347. }
  348. }
  349. float num15 = npc.ai[2] + (float)num12 + (float)num14;
  350. if (num15 == 1f)
  351. {
  352. Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 17, 1f, 0f);
  353. }
  354. if (num15 < (float)num14)
  355. {
  356. Vector2 vector = npc.Top + new Vector2((float)(npc.spriteDirection * 6), 6f);
  357. float scaleFactor = MathHelper.Lerp(20f, 30f, (num15 * 3f + 50f) / 182f);
  358. Main.rand.NextFloat();
  359. for (float num16 = 0f; num16 < 2f; num16 += 1f)
  360. {
  361. Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f);
  362. Dust expr_D5F = Main.dust[Dust.NewDust(vector, 0, 0, 228, 0f, 0f, 0, default(Color), 1f)];
  363. expr_D5F.position = vector + vector2 * scaleFactor;
  364. expr_D5F.noGravity = true;
  365. expr_D5F.velocity = vector2 * 2f;
  366. expr_D5F.scale = 0.5f + Main.rand.NextFloat() * 0.5f;
  367. }
  368. }
  369. Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f);
  370. return;
  371. }
  372. if (npc.ai[2] < 0f && npc.ai[2] >= -(float)num12)
  373. {
  374. Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f);
  375. npc.velocity.X = npc.velocity.X * 0.9f;
  376. if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit)
  377. {
  378. npc.ai[2] = (float)num10;
  379. }
  380. else
  381. {
  382. npc.ai[2] += 1f;
  383. if (npc.ai[2] == 0f)
  384. {
  385. npc.ai[2] = (float)num11;
  386. }
  387. }
  388. float num17 = npc.ai[2] + (float)num12;
  389. if (num17 < 180f && (Main.rand.Next(3) == 0 || npc.ai[2] % 3f == 0f))
  390. {
  391. Vector2 vector3 = npc.Top + new Vector2((float)(npc.spriteDirection * 10), 10f);
  392. float scaleFactor2 = MathHelper.Lerp(20f, 30f, (num17 * 3f + 50f) / 182f);
  393. Main.rand.NextFloat();
  394. for (float num18 = 0f; num18 < 1f; num18 += 1f)
  395. {
  396. Vector2 vector4 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f);
  397. Dust expr_F96 = Main.dust[Dust.NewDust(vector3, 0, 0, 228, 0f, 0f, 0, default(Color), 1f)];
  398. expr_F96.position = vector3 + vector4 * scaleFactor2;
  399. expr_F96.noGravity = true;
  400. expr_F96.velocity = vector4 * 4f;
  401. expr_F96.scale = 0.5f + Main.rand.NextFloat();
  402. }
  403. }
  404. if (Main.netMode != 2)
  405. {
  406. Player player = Main.player[Main.myPlayer];
  407. int arg_100D_0 = Main.myPlayer;
  408. if (!player.dead && player.active && player.FindBuffIndex(156) == -1)
  409. {
  410. Vector2 vector5 = player.Center - npc.Center;
  411. if (vector5.Length() < 700f)
  412. {
  413. bool flag = vector5.Length() < 30f;
  414. if (!flag)
  415. {
  416. float x = 0.7853982f.ToRotationVector2().X;
  417. Vector2 vector6 = Vector2.Normalize(vector5);
  418. if (vector6.X > x || vector6.X < -x)
  419. {
  420. flag = true;
  421. }
  422. }
  423. if ((((player.Center.X < npc.Center.X && npc.direction < 0 && player.direction > 0) || (player.Center.X > npc.Center.X && npc.direction > 0 && player.direction < 0)) & flag) && (Collision.CanHitLine(npc.Center, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center - Vector2.UnitY * 16f, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center + Vector2.UnitY * 8f, 1, 1, player.Center, 1, 1)))
  424. {
  425. player.AddBuff(156, num13 + (int)npc.ai[2] * -1, true);
  426. }
  427. }
  428. }
  429. }
  430. return;
  431. }
  432. }
  433. }
  434. if (npc.type == 471)
  435. {
  436. if (npc.ai[3] < 0f)
  437. {
  438. npc.knockBackResist = 0f;
  439. npc.defense = (int)((double)npc.defDefense * 1.1);
  440. npc.noGravity = true;
  441. npc.noTileCollide = true;
  442. if (npc.velocity.X < 0f)
  443. {
  444. npc.direction = -1;
  445. }
  446. else if (npc.velocity.X > 0f)
  447. {
  448. npc.direction = 1;
  449. }
  450. npc.rotation = npc.velocity.X * 0.1f;
  451. if (Main.netMode != 1)
  452. {
  453. npc.localAI[3] += 1f;
  454. if (npc.localAI[3] > (float)Main.rand.Next(20, 180))
  455. {
  456. npc.localAI[3] = 0f;
  457. Vector2 vector7 = npc.Center;
  458. vector7 += npc.velocity;
  459. NPC.NewNPC((int)vector7.X, (int)vector7.Y, 30, 0, 0f, 0f, 0f, 0f, 255);
  460. }
  461. }
  462. }
  463. else
  464. {
  465. npc.localAI[3] = 0f;
  466. npc.knockBackResist = 0.35f * Main.knockBackMultiplier;
  467. npc.rotation *= 0.9f;
  468. npc.defense = npc.defDefense;
  469. npc.noGravity = false;
  470. npc.noTileCollide = false;
  471. }
  472. if (npc.ai[3] == 1f)
  473. {
  474. npc.knockBackResist = 0f;
  475. npc.defense += 10;
  476. }
  477. if (npc.ai[3] == -1f)
  478. {
  479. npc.TargetClosest(true);
  480. float num19 = 8f;
  481. float num20 = 40f;
  482. Vector2 value3 = Main.player[npc.target].Center - npc.Center;
  483. float num21 = value3.Length();
  484. num19 += num21 / 200f;
  485. value3.Normalize();
  486. value3 *= num19;
  487. npc.velocity = (npc.velocity * (num20 - 1f) + value3) / num20;
  488. if (num21 < 500f && !Collision.SolidCollision(npc.position, npc.width, npc.height))
  489. {
  490. npc.ai[3] = 0f;
  491. npc.ai[2] = 0f;
  492. }
  493. return;
  494. }
  495. if (npc.ai[3] == -2f)
  496. {
  497. npc.velocity.Y = npc.velocity.Y - 0.2f;
  498. if (npc.velocity.Y < -10f)
  499. {
  500. npc.velocity.Y = -10f;
  501. }
  502. if (Main.player[npc.target].Center.Y - npc.Center.Y > 200f)
  503. {
  504. npc.TargetClosest(true);
  505. npc.ai[3] = -3f;
  506. if (Main.player[npc.target].Center.X > npc.Center.X)
  507. {
  508. npc.ai[2] = 1f;
  509. }
  510. else
  511. {
  512. npc.ai[2] = -1f;
  513. }
  514. }
  515. npc.velocity.X = npc.velocity.X * 0.99f;
  516. return;
  517. }
  518. if (npc.ai[3] == -3f)
  519. {
  520. if (npc.direction == 0)
  521. {
  522. npc.TargetClosest(true);
  523. }
  524. if (npc.ai[2] == 0f)
  525. {
  526. npc.ai[2] = (float)npc.direction;
  527. }
  528. npc.velocity.Y = npc.velocity.Y * 0.9f;
  529. npc.velocity.X = npc.velocity.X + npc.ai[2] * 0.3f;
  530. if (npc.velocity.X > 10f)
  531. {
  532. npc.velocity.X = 10f;
  533. }
  534. if (npc.velocity.X < -10f)
  535. {
  536. npc.velocity.X = -10f;
  537. }
  538. float num22 = Main.player[npc.target].Center.X - npc.Center.X;
  539. if ((npc.ai[2] < 0f && num22 > 300f) || (npc.ai[2] > 0f && num22 < -300f))
  540. {
  541. npc.ai[3] = -4f;
  542. npc.ai[2] = 0f;
  543. return;
  544. }
  545. if (Math.Abs(num22) > 800f)
  546. {
  547. npc.ai[3] = -1f;
  548. npc.ai[2] = 0f;
  549. }
  550. return;
  551. }
  552. else
  553. {
  554. if (npc.ai[3] == -4f)
  555. {
  556. npc.ai[2] += 1f;
  557. npc.velocity.Y = npc.velocity.Y + 0.1f;
  558. if (npc.velocity.Length() > 4f)
  559. {
  560. npc.velocity *= 0.9f;
  561. }
  562. int num23 = (int)npc.Center.X / 16;
  563. int num24 = (int)(npc.position.Y + (float)npc.height + 12f) / 16;
  564. bool flag2 = false;
  565. for (int i = num23 - 1; i <= num23 + 1; i++)
  566. {
  567. if (Main.tile[i, num24] == null)
  568. {
  569. Main.tile[num23, num24] = new Tile();
  570. }
  571. if (Main.tile[i, num24].active() && Main.tileSolid[(int)Main.tile[i, num24].type])
  572. {
  573. flag2 = true;
  574. }
  575. }
  576. if (flag2 && !Collision.SolidCollision(npc.position, npc.width, npc.height))
  577. {
  578. npc.ai[3] = 0f;
  579. npc.ai[2] = 0f;
  580. }
  581. else if (npc.ai[2] > 300f || npc.Center.Y > Main.player[npc.target].Center.Y + 200f)
  582. {
  583. npc.ai[3] = -1f;
  584. npc.ai[2] = 0f;
  585. }
  586. }
  587. else
  588. {
  589. if (npc.ai[3] == 1f)
  590. {
  591. Vector2 center3 = npc.Center;
  592. center3.Y -= 70f;
  593. npc.velocity.X = npc.velocity.X * 0.8f;
  594. npc.ai[2] += 1f;
  595. if (npc.ai[2] == 60f)
  596. {
  597. if (Main.netMode != 1)
  598. {
  599. NPC.NewNPC((int)center3.X, (int)center3.Y + 18, 472, 0, 0f, 0f, 0f, 0f, 255);
  600. }
  601. }
  602. else if (npc.ai[2] >= 90f)
  603. {
  604. npc.ai[3] = -2f;
  605. npc.ai[2] = 0f;
  606. }
  607. for (int j = 0; j < 2; j++)
  608. {
  609. Vector2 arg_1922_0 = center3;
  610. Vector2 value4 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
  611. value4.Normalize();
  612. value4 *= (float)Main.rand.Next(0, 100) * 0.1f;
  613. Vector2 arg_196A_0 = arg_1922_0 + value4;
  614. value4.Normalize();
  615. value4 *= (float)Main.rand.Next(50, 90) * 0.1f;
  616. int num25 = Dust.NewDust(arg_196A_0, 1, 1, 27, 0f, 0f, 0, default(Color), 1f);
  617. Main.dust[num25].velocity = -value4 * 0.3f;
  618. Main.dust[num25].alpha = 100;
  619. if (Main.rand.Next(2) == 0)
  620. {
  621. Main.dust[num25].noGravity = true;
  622. Main.dust[num25].scale += 0.3f;
  623. }
  624. }
  625. return;
  626. }
  627. npc.ai[2] += 1f;
  628. int num26 = 10;
  629. if (npc.velocity.Y == 0f && NPC.CountNPCS(472) < num26)
  630. {
  631. if (npc.ai[2] >= 180f)
  632. {
  633. npc.ai[2] = 0f;
  634. npc.ai[3] = 1f;
  635. }
  636. }
  637. else
  638. {
  639. if (NPC.CountNPCS(472) >= num26)
  640. {
  641. npc.ai[2] += 1f;
  642. }
  643. if (npc.ai[2] >= 360f)
  644. {
  645. npc.ai[2] = 0f;
  646. npc.ai[3] = -2f;
  647. npc.velocity.Y = npc.velocity.Y - 3f;
  648. }
  649. }
  650. if (npc.target >= 0 && !Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() > 800f)
  651. {
  652. npc.ai[3] = -1f;
  653. npc.ai[2] = 0f;
  654. }
  655. }
  656. if (Main.player[npc.target].dead)
  657. {
  658. npc.TargetClosest(true);
  659. if (Main.player[npc.target].dead && npc.timeLeft > 1)
  660. {
  661. npc.timeLeft = 1;
  662. }
  663. }
  664. }
  665. }
  666. if (npc.type == 419)
  667. {
  668. npc.reflectingProjectiles = false;
  669. npc.takenDamageMultiplier = 1f;
  670. int num27 = 6;
  671. int num28 = 10;
  672. float scaleFactor3 = 16f;
  673. if (npc.ai[2] > 0f)
  674. {
  675. npc.ai[2] -= 1f;
  676. }
  677. if (npc.ai[2] == 0f)
  678. {
  679. if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
  680. {
  681. npc.ai[2] = -1f;
  682. npc.netUpdate = true;
  683. npc.TargetClosest(true);
  684. }
  685. }
  686. else
  687. {
  688. if (npc.ai[2] < 0f && npc.ai[2] > -(float)num27)
  689. {
  690. npc.ai[2] -= 1f;
  691. npc.velocity.X = npc.velocity.X * 0.9f;
  692. return;
  693. }
  694. if (npc.ai[2] == -(float)num27)
  695. {
  696. npc.ai[2] -= 1f;
  697. npc.TargetClosest(true);
  698. Vector2 vec = npc.DirectionTo(Main.player[npc.target].Top + new Vector2(0f, -30f));
  699. if (vec.HasNaNs())
  700. {
  701. vec = Vector2.Normalize(new Vector2((float)npc.spriteDirection, -1f));
  702. }
  703. npc.velocity = vec * scaleFactor3;
  704. npc.netUpdate = true;
  705. return;
  706. }
  707. if (npc.ai[2] < -(float)num27)
  708. {
  709. npc.ai[2] -= 1f;
  710. if (npc.velocity.Y == 0f)
  711. {
  712. npc.ai[2] = 60f;
  713. }
  714. else if (npc.ai[2] < -(float)num27 - (float)num28)
  715. {
  716. npc.velocity.Y = npc.velocity.Y + 0.15f;
  717. if (npc.velocity.Y > 24f)
  718. {
  719. npc.velocity.Y = 24f;
  720. }
  721. }
  722. npc.reflectingProjectiles = true;
  723. npc.takenDamageMultiplier = 3f;
  724. if (npc.justHit)
  725. {
  726. npc.ai[2] = 60f;
  727. npc.netUpdate = true;
  728. }
  729. return;
  730. }
  731. }
  732. }
  733. if (npc.type == 415)
  734. {
  735. int num29 = 42;
  736. int num30 = 18;
  737. if (npc.justHit)
  738. {
  739. npc.ai[2] = 120f;
  740. npc.netUpdate = true;
  741. }
  742. if (npc.ai[2] > 0f)
  743. {
  744. npc.ai[2] -= 1f;
  745. }
  746. if (npc.ai[2] == 0f)
  747. {
  748. int num31 = 0;
  749. for (int k = 0; k < 200; k++)
  750. {
  751. if (Main.npc[k].active && Main.npc[k].type == 516)
  752. {
  753. num31++;
  754. }
  755. }
  756. if (num31 > 6)
  757. {
  758. npc.ai[2] = 90f;
  759. }
  760. else if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
  761. {
  762. npc.ai[2] = -1f;
  763. npc.netUpdate = true;
  764. npc.TargetClosest(true);
  765. }
  766. }
  767. else if (npc.ai[2] < 0f && npc.ai[2] > -(float)num29)
  768. {
  769. npc.ai[2] -= 1f;
  770. if (npc.ai[2] == -(float)num29)
  771. {
  772. npc.ai[2] = (float)(180 + 30 * Main.rand.Next(10));
  773. }
  774. npc.velocity.X = npc.velocity.X * 0.8f;
  775. if (npc.ai[2] == -(float)num30 || npc.ai[2] == -(float)num30 - 8f || npc.ai[2] == -(float)num30 - 16f)
  776. {
  777. for (int l = 0; l < 20; l++)
  778. {
  779. Vector2 vector8 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * 40f;
  780. Dust arg_2098_0 = Main.dust[Dust.NewDust(vector8, 0, 0, 259, 0f, 0f, 0, default(Color), 1f)];
  781. Vector2 vector9 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
  782. arg_2098_0.position = vector8 + vector9 * 4f;
  783. arg_2098_0.velocity = vector9 * 2f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * 3f;
  784. arg_2098_0.scale = 0.3f + vector9.X * -(float)npc.spriteDirection;
  785. arg_2098_0.fadeIn = 0.7f;
  786. arg_2098_0.noGravity = true;
  787. }
  788. if (npc.velocity.X > -0.5f && npc.velocity.X < 0.5f)
  789. {
  790. npc.velocity.X = 0f;
  791. }
  792. if (Main.netMode != 1)
  793. {
  794. NPC.NewNPC((int)npc.Center.X + npc.spriteDirection * 45, (int)npc.Center.Y + 8, 516, 0, 0f, 0f, 0f, 0f, npc.target);
  795. }
  796. }
  797. return;
  798. }
  799. }
  800. if (npc.type == 428)
  801. {
  802. npc.localAI[0] += 1f;
  803. if (npc.localAI[0] >= 300f)
  804. {
  805. int arg_220E_0 = (int)npc.Center.X / 16 - 1;
  806. int num32 = (int)npc.Center.Y / 16 - 1;
  807. if (!Collision.SolidTiles(arg_220E_0, arg_220E_0 + 2, num32, num32 + 1) && Main.netMode != 1)
  808. {
  809. npc.Transform(427);
  810. npc.life = npc.lifeMax;
  811. npc.localAI[0] = 0f;
  812. return;
  813. }
  814. }
  815. int maxValue;
  816. if (npc.localAI[0] < 60f)
  817. {
  818. maxValue = 16;
  819. }
  820. else if (npc.localAI[0] < 120f)
  821. {
  822. maxValue = 8;
  823. }
  824. else if (npc.localAI[0] < 180f)
  825. {
  826. maxValue = 4;
  827. }
  828. else if (npc.localAI[0] < 240f)
  829. {
  830. maxValue = 2;
  831. }
  832. else if (npc.localAI[0] < 300f)
  833. {
  834. maxValue = 1;
  835. }
  836. else
  837. {
  838. maxValue = 1;
  839. }
  840. if (Main.rand.Next(maxValue) == 0)
  841. {
  842. Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1f)];
  843. dust.noGravity = true;
  844. dust.scale = 1f;
  845. dust.noLight = true;
  846. dust.velocity = npc.DirectionFrom(dust.position) * dust.velocity.Length();
  847. dust.position -= dust.velocity * 5f;
  848. Dust dust2 = dust;
  849. dust2.position.X = dust2.position.X + (float)(npc.direction * 6);
  850. Dust dust3 = dust;
  851. dust3.position.Y = dust3.position.Y + 4f;
  852. }
  853. }
  854. if (npc.type == 427)
  855. {
  856. npc.localAI[0] += 1f;
  857. npc.localAI[0] += Math.Abs(npc.velocity.X) / 2f;
  858. if (npc.localAI[0] >= 1200f && Main.netMode != 1)
  859. {
  860. int arg_2434_0 = (int)npc.Center.X / 16 - 2;
  861. int num33 = (int)npc.Center.Y / 16 - 3;
  862. if (!Collision.SolidTiles(arg_2434_0, arg_2434_0 + 4, num33, num33 + 4))
  863. {
  864. npc.Transform(426);
  865. npc.life = npc.lifeMax;
  866. npc.localAI[0] = 0f;
  867. return;
  868. }
  869. }
  870. int maxValue2;
  871. if (npc.localAI[0] < 360f)
  872. {
  873. maxValue2 = 32;
  874. }
  875. else if (npc.localAI[0] < 720f)
  876. {
  877. maxValue2 = 16;
  878. }
  879. else if (npc.localAI[0] < 1080f)
  880. {
  881. maxValue2 = 6;
  882. }
  883. else if (npc.localAI[0] < 1440f)
  884. {
  885. maxValue2 = 2;
  886. }
  887. else if (npc.localAI[0] < 1800f)
  888. {
  889. maxValue2 = 1;
  890. }
  891. else
  892. {
  893. maxValue2 = 1;
  894. }
  895. if (Main.rand.Next(maxValue2) == 0)
  896. {
  897. Dust expr_251C = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1f)];
  898. expr_251C.noGravity = true;
  899. expr_251C.scale = 1f;
  900. expr_251C.noLight = true;
  901. }
  902. }
  903. bool flag3 = false;
  904. if (npc.velocity.X == 0f)
  905. {
  906. flag3 = true;
  907. }
  908. if (npc.justHit)
  909. {
  910. flag3 = false;
  911. }
  912. if (Main.netMode != 1 && npc.type == 198 && (double)npc.life <= (double)npc.lifeMax * 0.55)
  913. {
  914. npc.Transform(199);
  915. }
  916. if (Main.netMode != 1 && npc.type == 348 && (double)npc.life <= (double)npc.lifeMax * 0.55)
  917. {
  918. npc.Transform(349);
  919. }
  920. int num34 = 60;
  921. if (npc.type == 120)
  922. {
  923. num34 = 180;
  924. if (npc.ai[3] == -120f)
  925. {
  926. npc.velocity *= 0f;
  927. npc.ai[3] = 0f;
  928. Main.PlaySound(SoundID.Item8, npc.position);
  929. Vector2 vector10 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
  930. float num35 = npc.oldPos[2].X + (float)npc.width * 0.5f - vector10.X;
  931. float num36 = npc.oldPos[2].Y + (float)npc.height * 0.5f - vector10.Y;
  932. float num37 = (float)Math.Sqrt((double)(num35 * num35 + num36 * num36));
  933. num37 = 2f / num37;
  934. num35 *= num37;
  935. num36 *= num37;
  936. for (int m = 0; m < 20; m++)
  937. {
  938. int num38 = Dust.NewDust(npc.position, npc.width, npc.height, 71, num35, num36, 200, default(Color), 2f);
  939. Main.dust[num38].noGravity = true;
  940. Dust dust4 = Main.dust[num38];
  941. dust4.velocity.X = dust4.velocity.X * 2f;
  942. }
  943. for (int n = 0; n < 20; n++)
  944. {
  945. int num39 = Dust.NewDust(npc.oldPos[2], npc.width, npc.height, 71, -num35, -num36, 200, default(Color), 2f);
  946. Main.dust[num39].noGravity = true;
  947. Dust dust5 = Main.dust[num39];
  948. dust5.velocity.X = dust5.velocity.X * 2f;
  949. }
  950. }
  951. }
  952. bool flag4 = false;
  953. bool flag5 = true;
  954. if (npc.type == 343 || npc.type == 47 || npc.type == 67 || npc.type == 109 || npc.type == 110 || (npc.type == 111 || true) || npc.type == 120 || npc.type == 163 || npc.type == 164 || npc.type == 239 || npc.type == 168 || npc.type == 199 || npc.type == 206 || npc.type == 214 || npc.type == 215 || npc.type == 216 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 220 || npc.type == 226 || npc.type == 243 || npc.type == 251 || npc.type == 257 || npc.type == 258 || npc.type == 290 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 305 || npc.type == 306 || npc.type == 307 || npc.type == 308 || npc.type == 309 || npc.type == 348 || npc.type == 349 || npc.type == 350 || npc.type == 351 || npc.type == 379 || (npc.type >= 430 && npc.type <= 436) || (npc.type == 380 || npc.type == 381 || npc.type == 382 || npc.type == 383 || npc.type == 386 || npc.type == 391 || (npc.type >= 449 && npc.type <= 452)) || (npc.type == 466 || npc.type == 464 || npc.type == 166 || npc.type == 469 || npc.type == 468 || npc.type == 471 || npc.type == 470 || npc.type == 480 || npc.type == 481 || npc.type == 482 || npc.type == 411 || npc.type == 424 || npc.type == 409 || (npc.type >= 494 && npc.type <= 506)) || (npc.type == 425 || npc.type == 427 || npc.type == 426 || npc.type == 428 || npc.type == 508 || npc.type == 415 || npc.type == 419 || npc.type == 520 || (npc.type >= 524 && npc.type <= 527)) || npc.type == 528 || npc.type == 529 || npc.type == 530 || npc.type == 532)
  955. {
  956. flag5 = false;
  957. }
  958. bool flag6 = false;
  959. int num40 = npc.type;
  960. if (num40 == 425 || num40 == 471)
  961. {
  962. flag6 = true;
  963. }
  964. bool flag7 = true;
  965. num40 = npc.type;
  966. if (num40 <= 350)
  967. {
  968. if (num40 <= 206)
  969. {
  970. if (num40 - 110 > 1 && num40 != 206)
  971. {
  972. goto IL_2D75;
  973. }
  974. }
  975. else if (num40 - 214 > 2 && num40 - 291 > 2 && num40 != 350)
  976. {
  977. goto IL_2D75;
  978. }
  979. }
  980. else if (num40 <= 426)
  981. {
  982. if (num40 - 379 > 3)
  983. {
  984. switch (num40)
  985. {
  986. case 409:
  987. case 411:
  988. break;
  989. case 410:
  990. goto IL_2D75;
  991. default:
  992. switch (num40)
  993. {
  994. case 424:
  995. case 426:
  996. break;
  997. case 425:
  998. goto IL_2D75;
  999. default:
  1000. goto IL_2D75;
  1001. }
  1002. break;
  1003. }
  1004. }
  1005. }
  1006. else if (num40 != 466 && num40 - 498 > 8 && num40 != 520)
  1007. {
  1008. goto IL_2D75;
  1009. }
  1010. if (npc.ai[2] > 0f)
  1011. {
  1012. flag7 = false;
  1013. }
  1014. IL_2D75:
  1015. if (!flag6 & flag7)
  1016. {
  1017. if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0)))
  1018. {
  1019. flag4 = true;
  1020. }
  1021. if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num34) | flag4)
  1022. {
  1023. npc.ai[3] += 1f;
  1024. }
  1025. else if ((double)Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f)
  1026. {
  1027. npc.ai[3] -= 1f;
  1028. }
  1029. if (npc.ai[3] > (float)(num34 * 10))
  1030. {
  1031. npc.ai[3] = 0f;
  1032. }
  1033. if (npc.justHit)
  1034. {
  1035. npc.ai[3] = 0f;
  1036. }
  1037. if (npc.ai[3] == (float)num34)
  1038. {
  1039. npc.netUpdate = true;
  1040. }
  1041. }
  1042. if (npc.type == 463 && Main.netMode != 1)
  1043. {
  1044. if (npc.localAI[3] > 0f)
  1045. {
  1046. npc.localAI[3] -= 1f;
  1047. }
  1048. if (npc.justHit && npc.localAI[3] <= 0f && Main.rand.Next(3) == 0)
  1049. {
  1050. npc.localAI[3] = 30f;
  1051. int num41 = Main.rand.Next(3, 6);
  1052. int[] array = new int[num41];
  1053. int num42 = 0;
  1054. for (int num43 = 0; num43 < 255; num43++)
  1055. {
  1056. if (Main.player[num43].active && !Main.player[num43].dead && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[num43].position, Main.player[num43].width, Main.player[num43].height))
  1057. {
  1058. array[num42] = num43;
  1059. num42++;
  1060. if (num42 == num41)
  1061. {
  1062. break;
  1063. }
  1064. }
  1065. }
  1066. if (num42 > 1)
  1067. {
  1068. for (int num44 = 0; num44 < 100; num44++)
  1069. {
  1070. int num45 = Main.rand.Next(num42);
  1071. int num46;
  1072. for (num46 = num45; num46 == num45; num46 = Main.rand.Next(num42))
  1073. {
  1074. }
  1075. int num47 = array[num45];
  1076. array[num45] = array[num46];
  1077. array[num46] = num47;
  1078. }
  1079. }
  1080. Vector2 vector11 = new Vector2(-1f, -1f);
  1081. for (int num48 = 0; num48 < num42; num48++)
  1082. {
  1083. Vector2 value5 = Main.npc[array[num48]].Center - npc.Center;
  1084. value5.Normalize();
  1085. vector11 += value5;
  1086. }
  1087. vector11.Normalize();
  1088. for (int num49 = 0; num49 < num41; num49++)
  1089. {
  1090. float scaleFactor4 = (float)Main.rand.Next(8, 13);
  1091. Vector2 vector12 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
  1092. vector12.Normalize();
  1093. if (num42 > 0)
  1094. {
  1095. vector12 += vector11;
  1096. vector12.Normalize();
  1097. }
  1098. vector12 *= scaleFactor4;
  1099. if (num42 > 0)
  1100. {
  1101. num42--;
  1102. vector12 = Main.player[array[num42]].Center - npc.Center;
  1103. vector12.Normalize();
  1104. vector12 *= scaleFactor4;
  1105. }
  1106. Projectile.NewProjectile(npc.Center.X, npc.position.Y + (float)(npc.width / 4), vector12.X, vector12.Y, 498, (int)((double)npc.damage * 0.15), 1f, 255, 0f, 0f);
  1107. }
  1108. }
  1109. }
  1110. if (npc.type == 460)
  1111. {
  1112. if (npc.velocity.Y < -0.3f || npc.velocity.Y > 0.3f)
  1113. {
  1114. npc.knockBackResist = 0f;
  1115. }
  1116. else
  1117. {
  1118. npc.knockBackResist = 0.25f * Main.knockBackMultiplier;
  1119. }
  1120. }
  1121. if (npc.type == 469)
  1122. {
  1123. npc.knockBackResist = 0.45f * Main.knockBackMultiplier;
  1124. if (npc.ai[2] == 1f)
  1125. {
  1126. npc.knockBackResist = 0f;
  1127. }
  1128. bool flag8 = false;
  1129. int num50 = (int)npc.Center.X / 16;
  1130. int num51 = (int)npc.Center.Y / 16;
  1131. for (int num52 = num50 - 1; num52 <= num50 + 1; num52++)
  1132. {
  1133. for (int num53 = num51 - 1; num53 <= num51 + 1; num53++)
  1134. {
  1135. if (Main.tile[num52, num53] != null && Main.tile[num52, num53].wall > 0)
  1136. {
  1137. flag8 = true;
  1138. break;
  1139. }
  1140. }
  1141. if (flag8)
  1142. {
  1143. break;
  1144. }
  1145. }
  1146. if (npc.ai[2] == 0f & flag8)
  1147. {
  1148. if (npc.velocity.Y == 0f)
  1149. {
  1150. npc.velocity.Y = -4.6f;
  1151. npc.velocity.X = npc.velocity.X * 1.3f;
  1152. }
  1153. else if (npc.velocity.Y > 0f)
  1154. {
  1155. npc.ai[2] = 1f;
  1156. }
  1157. }
  1158. if (flag8 && npc.ai[2] == 1f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
  1159. {
  1160. Vector2 value6 = Main.player[npc.target].Center - npc.Center;
  1161. float num54 = value6.Length();
  1162. value6.Normalize();
  1163. value6 *= 4.5f + num54 / 300f;
  1164. npc.velocity = (npc.velocity * 29f + value6) / 30f;
  1165. npc.noGravity = true;
  1166. npc.ai[2] = 1f;
  1167. return;
  1168. }
  1169. npc.noGravity = false;
  1170. npc.ai[2] = 0f;
  1171. }
  1172. if (npc.type == 462 && npc.velocity.Y == 0f && (Main.player[npc.target].Center - npc.Center).Length() < 150f && Math.Abs(npc.velocity.X) > 3f && ((npc.velocity.X < 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X > 0f && npc.Center.X < Main.player[npc.target].Center.X)))
  1173. {
  1174. npc.velocity.X = npc.velocity.X * 1.75f;
  1175. npc.velocity.Y = npc.velocity.Y - 4.5f;
  1176. if (npc.Center.Y - Main.player[npc.target].Center.Y > 20f)
  1177. {
  1178. npc.velocity.Y = npc.velocity.Y - 0.5f;
  1179. }
  1180. if (npc.Center.Y - Main.player[npc.target].Center.Y > 40f)
  1181. {
  1182. npc.velocity.Y = npc.velocity.Y - 1f;
  1183. }
  1184. if (npc.Center.Y - Main.player[npc.target].Center.Y > 80f)
  1185. {
  1186. npc.velocity.Y = npc.velocity.Y - 1.5f;
  1187. }
  1188. if (npc.Center.Y - Main.player[npc.target].Center.Y > 100f)
  1189. {
  1190. npc.velocity.Y = npc.velocity.Y - 1.5f;
  1191. }
  1192. if (Math.Abs(npc.velocity.X) > 7f)
  1193. {
  1194. if (npc.velocity.X < 0f)
  1195. {
  1196. npc.velocity.X = -7f;
  1197. }
  1198. else
  1199. {
  1200. npc.velocity.X = 7f;
  1201. }
  1202. }
  1203. }
  1204. if (npc.ai[3] < (float)num34 && (Main.eclipse || !Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0 || (Main.invasionType == 1 && (npc.type == 343 || npc.type == 350)) || (Main.invasionType == 1 && (npc.type == 26 || npc.type == 27 || npc.type == 28 || (npc.type == 111 || true) || npc.type == 471)) || (npc.type == 73 || (Main.invasionType == 3 && npc.type >= 212 && npc.type <= 216)) || (Main.invasionType == 4 && (npc.type == 381 || npc.type == 382 || npc.type == 383 || npc.type == 385 || npc.type == 386 || npc.type == 389 || npc.type == 391 || npc.type == 520)) || (npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 67 || npc.type == 77 || npc.type == 78 || npc.type == 79 || npc.type == 80 || npc.type == 110 || npc.type == 120 || npc.type == 168 || npc.type == 181 || npc.type == 185 || npc.type == 198 || npc.type == 199 || npc.type == 206 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 220 || npc.type == 239 || npc.type == 243 || npc.type == 254 || npc.type == 255 || npc.type == 257 || npc.type == 258 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 379 || npc.type == 380 || npc.type == 464 || npc.type == 470 || npc.type == 424 || (npc.type == 411 && (npc.ai[1] >= 180f || npc.ai[1] < 90f))) || (npc.type == 409 || npc.type == 425 || npc.type == 429 || npc.type == 427 || npc.type == 428 || npc.type == 508 || npc.type == 415 || npc.type == 419 || (npc.type >= 524 && npc.type <= 527)) || npc.type == 528 || npc.type == 529 || npc.type == 530 || npc.type == 532))
  1205. {
  1206. if ((npc.type == 3 || npc.type == 331 || npc.type == 332 || npc.type == 21 || (npc.type >= 449 && npc.type <= 452) || npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 77 || npc.type == 110 || npc.type == 132 || npc.type == 167 || npc.type == 161 || npc.type == 162 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 197 || npc.type == 200 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 223 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 320 || npc.type == 321 || npc.type == 319 || npc.type == 481) && Main.rand.Next(1000) == 0)
  1207. {
  1208. Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f);
  1209. }
  1210. if (npc.type == 489 && Main.rand.Next(800) == 0)
  1211. {
  1212. Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, npc.type, 1f, 0f);
  1213. }
  1214. if ((npc.type == 78 || npc.type == 79 || npc.type == 80) && Main.rand.Next(500) == 0)
  1215. {
  1216. Main.PlaySound(26, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f);
  1217. }
  1218. if (npc.type == 159 && Main.rand.Next(500) == 0)
  1219. {
  1220. Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 7, 1f, 0f);
  1221. }
  1222. if (npc.type == 162 && Main.rand.Next(500) == 0)
  1223. {
  1224. Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 6, 1f, 0f);
  1225. }
  1226. if (npc.type == 181 && Main.rand.Next(500) == 0)
  1227. {
  1228. Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 8, 1f, 0f);
  1229. }
  1230. if (npc.type >= 269 && npc.type <= 280 && Main.rand.Next(1000) == 0)
  1231. {
  1232. Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f);
  1233. }
  1234. npc.TargetClosest(true);
  1235. }
  1236. else if (npc.ai[2] <= 0f || (npc.type != 110 && (npc.type != 111 || false) && npc.type != 206 && npc.type != 216 && npc.type != 214 && npc.type != 215 && npc.type != 291 && npc.type != 292 && npc.type != 293 && npc.type != 350 && npc.type != 381 && npc.type != 382 && npc.type != 383 && npc.type != 385 && npc.type != 386 && npc.type != 389 && npc.type != 391 && npc.type != 469 && npc.type != 166 && npc.type != 466 && npc.type != 471 && npc.type != 411 && npc.type != 409 && npc.type != 424 && npc.type != 425 && npc.type != 426 && npc.type != 415 && npc.type != 419 && npc.type != 520))
  1237. {
  1238. if (Main.dayTime && (double)(npc.position.Y / 16f) < Main.worldSurface && npc.timeLeft > 10)
  1239. {
  1240. npc.timeLeft = 10;
  1241. }
  1242. if (npc.velocity.X == 0f)
  1243. {
  1244. if (npc.velocity.Y == 0f)
  1245. {
  1246. npc.ai[0] += 1f;
  1247. if (npc.ai[0] >= 2f)
  1248. {
  1249. npc.direction *= -1;
  1250. npc.spriteDirection = npc.direction;
  1251. npc.ai[0] = 0f;
  1252. }
  1253. }
  1254. }
  1255. else
  1256. {
  1257. npc.ai[0] = 0f;
  1258. }
  1259. if (npc.direction == 0)
  1260. {
  1261. npc.direction = 1;
  1262. }
  1263. }
  1264. if (npc.type == 159 || npc.type == 349)
  1265. {
  1266. if (npc.type == 159 && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0)))
  1267. {
  1268. npc.velocity.X = npc.velocity.X * 0.95f;
  1269. }
  1270. if (npc.velocity.X < -6f || npc.velocity.X > 6f)
  1271. {
  1272. if (npc.velocity.Y == 0f)
  1273. {
  1274. npc.velocity *= 0.8f;
  1275. }
  1276. }
  1277. else if (npc.velocity.X < 6f && npc.direction == 1)
  1278. {
  1279. if (npc.velocity.Y == 0f && npc.velocity.X < 0f)
  1280. {
  1281. npc.velocity.X = npc.velocity.X * 0.99f;
  1282. }
  1283. npc.velocity.X = npc.velocity.X + 0.07f;
  1284. if (npc.velocity.X > 6f)
  1285. {
  1286. npc.velocity.X = 6f;
  1287. }
  1288. }
  1289. else if (npc.velocity.X > -6f && npc.direction == -1)
  1290. {
  1291. if (npc.velocity.Y == 0f && npc.velocity.X > 0f)
  1292. {
  1293. npc.velocity.X = npc.velocity.X * 0.99f;
  1294. }
  1295. npc.velocity.X = npc.velocity.X - 0.07f;
  1296. if (npc.velocity.X < -6f)
  1297. {
  1298. npc.velocity.X = -6f;
  1299. }
  1300. }
  1301. }
  1302. else if (npc.type == 199)
  1303. {
  1304. if (npc.velocity.X < -4f || npc.velocity.X > 4f)
  1305. {
  1306. if (npc.velocity.Y == 0f)
  1307. {
  1308. npc.velocity *= 0.8f;
  1309. }
  1310. }
  1311. else if (npc.velocity.X < 4f && npc.direction == 1)
  1312. {
  1313. if (npc.velocity.Y == 0f && npc.velocity.X < 0f)
  1314. {
  1315. npc.velocity.X = npc.velocity.X * 0.8f;
  1316. }
  1317. npc.velocity.X = npc.velocity.X + 0.1f;
  1318. if (npc.velocity.X > 4f)
  1319. {
  1320. npc.velocity.X = 4f;
  1321. }
  1322. }
  1323. else if (npc.velocity.X > -4f && npc.direction == -1)
  1324. {
  1325. if (npc.velocity.Y == 0f && npc.velocity.X > 0f)
  1326. {
  1327. npc.velocity.X = npc.velocity.X * 0.8f;
  1328. }
  1329. npc.velocity.X = npc.velocity.X - 0.1f;
  1330. if (npc.velocity.X < -4f)
  1331. {
  1332. npc.velocity.X = -4f;
  1333. }
  1334. }
  1335. }
  1336. else if (npc.type == 120 || npc.type == 166 || npc.type == 213 || npc.type == 258 || npc.type == 528 || npc.type == 529)
  1337. {
  1338. if (npc.velocity.X < -3f || npc.velocity.X > 3f)
  1339. {
  1340. if (npc.velocity.Y == 0f)
  1341. {
  1342. npc.velocity *= 0.8f;
  1343. }
  1344. }
  1345. else if (npc.velocity.X < 3f && npc.direction == 1)
  1346. {
  1347. if (npc.velocity.Y == 0f && npc.velocity.X < 0f)
  1348. {
  1349. npc.velocity.X = npc.velocity.X * 0.99f;
  1350. }
  1351. npc.velocity.X = npc.velocity.X + 0.07f;
  1352. if (npc.velocity.X > 3f)
  1353. {
  1354. npc.velocity.X = 3f;
  1355. }
  1356. }
  1357. else if (npc.velocity.X > -3f && npc.direction == -1)
  1358. {
  1359. if (npc.velocity.Y == 0f && npc.velocity.X > 0f)
  1360. {
  1361. npc.velocity.X = npc.velocity.X * 0.99f;
  1362. }
  1363. npc.velocity.X = npc.velocity.X - 0.07f;
  1364. if (npc.velocity.X < -3f)
  1365. {
  1366. npc.velocity.X = -3f;
  1367. }
  1368. }
  1369. }
  1370. else if (npc.type == 461 || npc.type == 27 || npc.type == 77 || npc.type == 104 || npc.type == 163 || npc.type == 162 || npc.type == 196 || npc.type == 197 || npc.type == 212 || npc.type == 257 || npc.type == 326 || npc.type == 343 || npc.type == 348 || npc.type == 351 || (npc.type >= 524 && npc.type <= 527) || npc.type == 530)
  1371. {
  1372. if (npc.velocity.X < -2f || npc.velocity.X > 2f)
  1373. {
  1374. if (npc.velocity.Y == 0f)
  1375. {
  1376. npc.velocity *= 0.8f;
  1377. }
  1378. }
  1379. else if (npc.velocity.X < 2f && npc.direction == 1)
  1380. {
  1381. npc.velocity.X = npc.velocity.X + 0.07f;
  1382. if (npc.velocity.X > 2f)
  1383. {
  1384. npc.velocity.X = 2f;
  1385. }
  1386. }
  1387. else if (npc.velocity.X > -2f && npc.direction == -1)
  1388. {
  1389. npc.velocity.X = npc.velocity.X - 0.07f;
  1390. if (npc.velocity.X < -2f)
  1391. {
  1392. npc.velocity.X = -2f;
  1393. }
  1394. }
  1395. }
  1396. else if (npc.type == 109)
  1397. {
  1398. if (npc.velocity.X < -2f || npc.velocity.X > 2f)
  1399. {
  1400. if (npc.velocity.Y == 0f)
  1401. {
  1402. npc.velocity *= 0.8f;
  1403. }
  1404. }
  1405. else if (npc.velocity.X < 2f && npc.direction == 1)
  1406. {
  1407. npc.velocity.X = npc.velocity.X + 0.04f;
  1408. if (npc.velocity.X > 2f)
  1409. {
  1410. npc.velocity.X = 2f;
  1411. }
  1412. }
  1413. else if (npc.velocity.X > -2f && npc.direction == -1)
  1414. {
  1415. npc.velocity.X = npc.velocity.X - 0.04f;
  1416. if (npc.velocity.X < -2f)
  1417. {
  1418. npc.velocity.X = -2f;
  1419. }
  1420. }
  1421. }
  1422. else if (npc.type == 21 || npc.type == 26 || npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 73 || npc.type == 140 || npc.type == 164 || npc.type == 239 || npc.type == 167 || npc.type == 168 || npc.type == 185 || npc.type == 198 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 226 || npc.type == 181 || npc.type == 254 || npc.type == 338 || npc.type == 339 || npc.type == 340 || npc.type == 342 || npc.type == 385 || npc.type == 389 || npc.type == 462 || npc.type == 463 || npc.type == 466 || npc.type == 464 || npc.type == 469 || npc.type == 470 || npc.type == 480 || npc.type == 482 || npc.type == 425 || npc.type == 429)
  1423. {
  1424. float num55 = 1.5f;
  1425. if (npc.type == 294)
  1426. {
  1427. num55 = 2f;
  1428. }
  1429. else if (npc.type == 295)
  1430. {
  1431. num55 = 1.75f;
  1432. }
  1433. else if (npc.type == 296)
  1434. {
  1435. num55 = 1.25f;
  1436. }
  1437. else if (npc.type == 201)
  1438. {
  1439. num55 = 1.1f;
  1440. }
  1441. else if (npc.type == 202)
  1442. {
  1443. num55 = 0.9f;
  1444. }
  1445. else if (npc.type == 203)
  1446. {
  1447. num55 = 1.2f;
  1448. }
  1449. else if (npc.type == 338)
  1450. {
  1451. num55 = 1.75f;
  1452. }
  1453. else if (npc.type == 339)
  1454. {
  1455. num55 = 1.25f;
  1456. }
  1457. else if (npc.type == 340)
  1458. {
  1459. num55 = 2f;
  1460. }
  1461. else if (npc.type == 385)
  1462. {
  1463. num55 = 1.8f;
  1464. }
  1465. else if (npc.type == 389)
  1466. {
  1467. num55 = 2.25f;
  1468. }
  1469. else if (npc.type == 462)
  1470. {
  1471. num55 = 4f;
  1472. }
  1473. else if (npc.type == 463)
  1474. {
  1475. num55 = 0.75f;
  1476. }
  1477. else if (npc.type == 466)
  1478. {
  1479. num55 = 3.75f;
  1480. }
  1481. else if (npc.type == 469)
  1482. {
  1483. num55 = 3.25f;
  1484. }
  1485. else if (npc.type == 480)
  1486. {
  1487. num55 = 1.5f + (1f - (float)npc.life / (float)npc.lifeMax) * 2f;
  1488. }
  1489. else if (npc.type == 425)
  1490. {
  1491. num55 = 6f;
  1492. }
  1493. else if (npc.type == 429)
  1494. {
  1495. num55 = 4f;
  1496. }
  1497. if (npc.type == 21 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 342)
  1498. {
  1499. num55 *= 1f + (1f - npc.scale);
  1500. }
  1501. if (npc.velocity.X < -num55 || npc.velocity.X > num55)
  1502. {
  1503. if (npc.velocity.Y == 0f)
  1504. {
  1505. npc.velocity *= 0.8f;
  1506. }
  1507. }
  1508. else if (npc.velocity.X < num55 && npc.direction == 1)
  1509. {
  1510. if (npc.type == 466 && npc.velocity.X < -2f)
  1511. {
  1512. npc.velocity.X = npc.velocity.X * 0.9f;
  1513. }
  1514. npc.velocity.X = npc.velocity.X + 0.07f;
  1515. if (npc.velocity.X > num55)
  1516. {
  1517. npc.velocity.X = num55;
  1518. }
  1519. }
  1520. else if (npc.velocity.X > -num55 && npc.direction == -1)
  1521. {
  1522. if (npc.type == 466 && npc.velocity.X > 2f)
  1523. {
  1524. npc.velocity.X = npc.velocity.X * 0.9f;
  1525. }
  1526. npc.velocity.X = npc.velocity.X - 0.07f;
  1527. if (npc.velocity.X < -num55)
  1528. {
  1529. npc.velocity.X = -num55;
  1530. }
  1531. }
  1532. if (npc.velocity.Y == 0f && npc.type == 462 && ((npc.direction > 0 && npc.velocity.X < 0f) || (npc.direction < 0 && npc.velocity.X > 0f)))
  1533. {
  1534. npc.velocity.X = npc.velocity.X * 0.9f;
  1535. }
  1536. }
  1537. else if (npc.type >= 269 && npc.type <= 280)
  1538. {
  1539. float num56 = 1.5f;
  1540. if (npc.type == 269)
  1541. {
  1542. num56 = 2f;
  1543. }
  1544. if (npc.type == 270)
  1545. {
  1546. num56 = 1f;
  1547. }
  1548. if (npc.type == 271)
  1549. {
  1550. num56 = 1.5f;
  1551. }
  1552. if (npc.type == 272)
  1553. {
  1554. num56 = 3f;
  1555. }
  1556. if (npc.type == 273)
  1557. {
  1558. num56 = 1.25f;
  1559. }
  1560. if (npc.type == 274)
  1561. {
  1562. num56 = 3f;
  1563. }
  1564. if (npc.type == 275)
  1565. {
  1566. num56 = 3.25f;
  1567. }
  1568. if (npc.type == 276)
  1569. {
  1570. num56 = 2f;
  1571. }
  1572. if (npc.type == 277)
  1573. {
  1574. num56 = 2.75f;
  1575. }
  1576. if (npc.type == 278)
  1577. {
  1578. num56 = 1.8f;
  1579. }
  1580. if (npc.type == 279)
  1581. {
  1582. num56 = 1.3f;
  1583. }
  1584. if (npc.type == 280)
  1585. {
  1586. num56 = 2.5f;
  1587. }
  1588. num56 *= 1f + (1f - npc.scale);
  1589. if (npc.velocity.X < -num56 || npc.velocity.X > num56)
  1590. {
  1591. if (npc.velocity.Y == 0f)
  1592. {
  1593. npc.velocity *= 0.8f;
  1594. }
  1595. }
  1596. else if (npc.velocity.X < num56 && npc.direction == 1)
  1597. {
  1598. npc.velocity.X = npc.velocity.X + 0.07f;
  1599. if (npc.velocity.X > num56)
  1600. {
  1601. npc.velocity.X = num56;
  1602. }
  1603. }
  1604. else if (npc.velocity.X > -num56 && npc.direction == -1)
  1605. {
  1606. npc.velocity.X = npc.velocity.X - 0.07f;
  1607. if (npc.velocity.X < -num56)
  1608. {
  1609. npc.velocity.X = -num56;
  1610. }
  1611. }
  1612. }
  1613. else if (npc.type >= 305 && npc.type <= 314)
  1614. {
  1615. float num57 = 1.5f;
  1616. if (npc.type == 305 || npc.type == 310)
  1617. {
  1618. num57 = 2f;
  1619. }
  1620. if (npc.type == 306 || npc.type == 311)
  1621. {
  1622. num57 = 1.25f;
  1623. }
  1624. if (npc.type == 307 || npc.type == 312)
  1625. {
  1626. num57 = 2.25f;
  1627. }
  1628. if (npc.type == 308 || npc.type == 313)
  1629. {
  1630. num57 = 1.5f;
  1631. }
  1632. if (npc.type == 309 || npc.type == 314)
  1633. {
  1634. num57 = 1f;
  1635. }
  1636. if (npc.type < 310)
  1637. {
  1638. if (npc.velocity.Y == 0f)
  1639. {
  1640. npc.velocity.X = npc.velocity.X * 0.85f;
  1641. if ((double)npc.velocity.X > -0.3 && (double)npc.velocity.X < 0.3)
  1642. {
  1643. npc.velocity.Y = -7f;
  1644. npc.velocity.X = num57 * (float)npc.direction;
  1645. }
  1646. }
  1647. else if (npc.spriteDirection == npc.direction)
  1648. {
  1649. npc.velocity.X = (npc.velocity.X * 10f + num57 * (float)npc.direction) / 11f;
  1650. }
  1651. }
  1652. else if (npc.velocity.X < -num57 || npc.velocity.X > num57)
  1653. {
  1654. if (npc.velocity.Y == 0f)
  1655. {
  1656. npc.velocity *= 0.8f;
  1657. }
  1658. }
  1659. else if (npc.velocity.X < num57 && npc.direction == 1)
  1660. {
  1661. npc.velocity.X = npc.velocity.X + 0.07f;
  1662. if (npc.velocity.X > num57)
  1663. {
  1664. npc.velocity.X = num57;
  1665. }
  1666. }
  1667. else if (npc.velocity.X > -num57 && npc.direction == -1)
  1668. {
  1669. npc.velocity.X = npc.velocity.X - 0.07f;
  1670. if (npc.velocity.X < -num57)
  1671. {
  1672. npc.velocity.X = -num57;
  1673. }
  1674. }
  1675. }
  1676. else if (npc.type == 67 || npc.type == 220 || npc.type == 428)
  1677. {
  1678. if (npc.velocity.X < -0.5f || npc.velocity.X > 0.5f)
  1679. {
  1680. if (npc.velocity.Y == 0f)
  1681. {
  1682. npc.velocity *= 0.7f;
  1683. }
  1684. }
  1685. else if (npc.velocity.X < 0.5f && npc.direction == 1)
  1686. {
  1687. npc.velocity.X = npc.velocity.X + 0.03f;
  1688. if (npc.velocity.X > 0.5f)
  1689. {
  1690. npc.velocity.X = 0.5f;
  1691. }
  1692. }
  1693. else if (npc.velocity.X > -0.5f && npc.direction == -1)
  1694. {
  1695. npc.velocity.X = npc.velocity.X - 0.03f;
  1696. if (npc.velocity.X < -0.5f)
  1697. {
  1698. npc.velocity.X = -0.5f;
  1699. }
  1700. }
  1701. }
  1702. else if (npc.type == 78 || npc.type == 79 || npc.type == 80)
  1703. {
  1704. float num58 = 1f;
  1705. float num59 = 0.05f;
  1706. if (npc.life < npc.lifeMax / 2)
  1707. {
  1708. num58 = 2f;
  1709. num59 = 0.1f;
  1710. }
  1711. if (npc.type == 79)
  1712. {
  1713. num58 *= 1.5f;
  1714. }
  1715. if (npc.velocity.X < -num58 || npc.velocity.X > num58)
  1716. {
  1717. if (npc.velocity.Y == 0f)
  1718. {
  1719. npc.velocity *= 0.7f;
  1720. }
  1721. }
  1722. else if (npc.velocity.X < num58 && npc.direction == 1)
  1723. {
  1724. npc.velocity.X = npc.velocity.X + num59;
  1725. if (npc.velocity.X > num58)
  1726. {
  1727. npc.velocity.X = num58;
  1728. }
  1729. }
  1730. else if (npc.velocity.X > -num58 && npc.direction == -1)
  1731. {
  1732. npc.velocity.X = npc.velocity.X - num59;
  1733. if (npc.velocity.X < -num58)
  1734. {
  1735. npc.velocity.X = -num58;
  1736. }
  1737. }
  1738. }
  1739. else if (npc.type == 287)
  1740. {
  1741. float num60 = 5f;
  1742. float num61 = 0.2f;
  1743. if (npc.velocity.X < -num60 || npc.velocity.X > num60)
  1744. {
  1745. if (npc.velocity.Y == 0f)
  1746. {
  1747. npc.velocity *= 0.7f;
  1748. }
  1749. }
  1750. else if (npc.velocity.X < num60 && npc.direction == 1)
  1751. {
  1752. npc.velocity.X = npc.velocity.X + num61;
  1753. if (npc.velocity.X > num60)
  1754. {
  1755. npc.velocity.X = num60;
  1756. }
  1757. }
  1758. else if (npc.velocity.X > -num60 && npc.direction == -1)
  1759. {
  1760. npc.velocity.X = npc.velocity.X - num61;
  1761. if (npc.velocity.X < -num60)
  1762. {
  1763. npc.velocity.X = -num60;
  1764. }
  1765. }
  1766. }
  1767. else if (npc.type == 243)
  1768. {
  1769. float num62 = 1f;
  1770. float num63 = 0.07f;
  1771. num62 += (1f - (float)npc.life / (float)npc.lifeMax) * 1.5f;
  1772. num63 += (1f - (float)npc.life / (float)npc.lifeMax) * 0.15f;
  1773. if (npc.velocity.X < -num62 || npc.velocity.X > num62)
  1774. {
  1775. if (npc.velocity.Y == 0f)
  1776. {
  1777. npc.velocity *= 0.7f;
  1778. }
  1779. }
  1780. else if (npc.velocity.X < num62 && npc.direction == 1)
  1781. {
  1782. npc.velocity.X = npc.velocity.X + num63;
  1783. if (npc.velocity.X > num62)
  1784. {
  1785. npc.velocity.X = num62;
  1786. }
  1787. }
  1788. else if (npc.velocity.X > -num62 && npc.direction == -1)
  1789. {
  1790. npc.velocity.X = npc.velocity.X - num63;
  1791. if (npc.velocity.X < -num62)
  1792. {
  1793. npc.velocity.X = -num62;
  1794. }
  1795. }
  1796. }
  1797. else if (npc.type == 251)
  1798. {
  1799. float num64 = 1f;
  1800. float num65 = 0.08f;
  1801. num64 += (1f - (float)npc.life / (float)npc.lifeMax) * 2f;
  1802. num65 += (1f - (float)npc.life / (float)npc.lifeMax) * 0.2f;
  1803. if (npc.velocity.X < -num64 || npc.velocity.X > num64)
  1804. {
  1805. if (npc.velocity.Y == 0f)
  1806. {
  1807. npc.velocity *= 0.7f;
  1808. }
  1809. }
  1810. else if (npc.velocity.X < num64 && npc.direction == 1)
  1811. {
  1812. npc.velocity.X = npc.velocity.X + num65;
  1813. if (npc.velocity.X > num64)
  1814. {
  1815. npc.velocity.X = num64;
  1816. }
  1817. }
  1818. else if (npc.velocity.X > -num64 && npc.direction == -1)
  1819. {
  1820. npc.velocity.X = npc.velocity.X - num65;
  1821. if (npc.velocity.X < -num64)
  1822. {
  1823. npc.velocity.X = -num64;
  1824. }
  1825. }
  1826. }
  1827. else if (npc.type == 386)
  1828. {
  1829. if (npc.ai[2] > 0f)
  1830. {
  1831. if (npc.velocity.Y == 0f)
  1832. {
  1833. npc.velocity.X = npc.velocity.X * 0.8f;
  1834. }
  1835. }
  1836. else
  1837. {
  1838. float num66 = 0.15f;
  1839. float num67 = 1.5f;
  1840. if (npc.velocity.X < -num67 || npc.velocity.X > num67)
  1841. {
  1842. if (npc.velocity.Y == 0f)
  1843. {
  1844. npc.velocity *= 0.7f;
  1845. }
  1846. }
  1847. else if (npc.velocity.X < num67 && npc.direction == 1)
  1848. {
  1849. npc.velocity.X = npc.velocity.X + num66;
  1850. if (npc.velocity.X > num67)
  1851. {
  1852. npc.velocity.X = num67;
  1853. }
  1854. }
  1855. else if (npc.velocity.X > -num67 && npc.direction == -1)
  1856. {
  1857. npc.velocity.X = npc.velocity.X - num66;
  1858. if (npc.velocity.X < -num67)
  1859. {
  1860. npc.velocity.X = -num67;
  1861. }
  1862. }
  1863. }
  1864. }
  1865. else if (npc.type == 460)
  1866. {
  1867. float num68 = 3f;
  1868. float num69 = 0.1f;
  1869. if (Math.Abs(npc.velocity.X) > 2f)
  1870. {
  1871. num69 *= 0.8f;
  1872. }
  1873. if ((double)Math.Abs(npc.velocity.X) > 2.5)
  1874. {
  1875. num69 *= 0.8f;
  1876. }
  1877. if (Math.Abs(npc.velocity.X) > 3f)
  1878. {
  1879. num69 *= 0.8f;
  1880. }
  1881. if ((double)Math.Abs(npc.velocity.X) > 3.5)
  1882. {
  1883. num69 *= 0.8f;
  1884. }
  1885. if (Math.Abs(npc.velocity.X) > 4f)
  1886. {
  1887. num69 *= 0.8f;
  1888. }
  1889. if ((double)Math.Abs(npc.velocity.X) > 4.5)
  1890. {
  1891. num69 *= 0.8f;
  1892. }
  1893. if (Math.Abs(npc.velocity.X) > 5f)
  1894. {
  1895. num69 *= 0.8f;
  1896. }
  1897. if ((double)Math.Abs(npc.velocity.X) > 5.5)
  1898. {
  1899. num69 *= 0.8f;
  1900. }
  1901. num68 += (1f - (float)npc.life / (float)npc.lifeMax) * 3f;
  1902. if (npc.velocity.X < -num68 || npc.velocity.X > num68)
  1903. {
  1904. if (npc.velocity.Y == 0f)
  1905. {
  1906. npc.velocity *= 0.7f;
  1907. }
  1908. }
  1909. else if (npc.velocity.X < num68 && npc.direction == 1)
  1910. {
  1911. if (npc.velocity.X < 0f)
  1912. {
  1913. npc.velocity.X = npc.velocity.X * 0.93f;
  1914. }
  1915. npc.velocity.X = npc.velocity.X + num69;
  1916. if (npc.velocity.X > num68)
  1917. {
  1918. npc.velocity.X = num68;
  1919. }
  1920. }
  1921. else if (npc.velocity.X > -num68 && npc.direction == -1)
  1922. {
  1923. if (npc.velocity.X > 0f)
  1924. {
  1925. npc.velocity.X = npc.velocity.X * 0.93f;
  1926. }
  1927. npc.velocity.X = npc.velocity.X - num69;
  1928. if (npc.velocity.X < -num68)
  1929. {
  1930. npc.velocity.X = -num68;
  1931. }
  1932. }
  1933. }
  1934. else if (npc.type == 508)
  1935. {
  1936. float num70 = 2.5f;
  1937. float num71 = 40f;
  1938. float num72 = Math.Abs(npc.velocity.X);
  1939. if (num72 > 2.75f)
  1940. {
  1941. num70 = 3.5f;
  1942. num71 += 80f;
  1943. }
  1944. else if ((double)num72 > 2.25)
  1945. {
  1946. num70 = 3f;
  1947. num71 += 60f;
  1948. }
  1949. if ((double)Math.Abs(npc.velocity.Y) < 0.5)
  1950. {
  1951. if (npc.velocity.X > 0f && npc.direction < 0)
  1952. {
  1953. npc.velocity *= 0.9f;
  1954. }
  1955. if (npc.velocity.X < 0f && npc.direction > 0)
  1956. {
  1957. npc.velocity *= 0.9f;
  1958. }
  1959. }
  1960. if (Math.Abs(npc.velocity.Y) > 0.3f)
  1961. {
  1962. num71 *= 3f;
  1963. }
  1964. if (npc.velocity.X <= 0f && npc.direction < 0)
  1965. {
  1966. npc.velocity.X = (npc.velocity.X * num71 - num70) / (num71 + 1f);
  1967. }
  1968. else if (npc.velocity.X >= 0f && npc.direction > 0)
  1969. {
  1970. npc.velocity.X = (npc.velocity.X * num71 + num70) / (num71 + 1f);
  1971. }
  1972. else if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 20f && Math.Abs(npc.velocity.Y) <= 0.3f)
  1973. {
  1974. npc.velocity.X = npc.velocity.X * 0.99f;
  1975. npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.025f;
  1976. }
  1977. }
  1978. else if (npc.type == 391 || npc.type == 427 || npc.type == 415 || npc.type == 419 || npc.type == 518 || npc.type == 532)
  1979. {
  1980. float num73 = 5f;
  1981. float num74 = 0.25f;
  1982. float scaleFactor5 = 0.7f;
  1983. if (npc.type == 427)
  1984. {
  1985. num73 = 6f;
  1986. num74 = 0.2f;
  1987. scaleFactor5 = 0.8f;
  1988. }
  1989. else if (npc.type == 415)
  1990. {
  1991. num73 = 4f;
  1992. num74 = 0.1f;
  1993. scaleFactor5 = 0.95f;
  1994. }
  1995. else if (npc.type == 419)
  1996. {
  1997. num73 = 6f;
  1998. num74 = 0.15f;
  1999. scaleFactor5 = 0.85f;
  2000. }
  2001. else if (npc.type == 518)
  2002. {
  2003. num73 = 5f;
  2004. num74 = 0.1f;
  2005. scaleFactor5 = 0.95f;
  2006. }
  2007. else if (npc.type == 532)
  2008. {
  2009. num73 = 5f;
  2010. num74 = 0.15f;
  2011. scaleFactor5 = 0.98f;
  2012. }
  2013. if (npc.velocity.X < -num73 || npc.velocity.X > num73)
  2014. {
  2015. if (npc.velocity.Y == 0f)
  2016. {
  2017. npc.velocity *= scaleFactor5;
  2018. }
  2019. }
  2020. else if (npc.velocity.X < num73 && npc.direction == 1)
  2021. {
  2022. npc.velocity.X = npc.velocity.X + num74;
  2023. if (npc.velocity.X > num73)
  2024. {
  2025. npc.velocity.X = num73;
  2026. }
  2027. }
  2028. else if (npc.velocity.X > -num73 && npc.direction == -1)
  2029. {
  2030. npc.velocity.X = npc.velocity.X - num74;
  2031. if (npc.velocity.X < -num73)
  2032. {
  2033. npc.velocity.X = -num73;
  2034. }
  2035. }
  2036. }
  2037. else if ((npc.type >= 430 && npc.type <= 436) || npc.type == 494 || npc.type == 495)
  2038. {
  2039. if (npc.ai[2] == 0f)
  2040. {
  2041. npc.damage = npc.defDamage;
  2042. float num75 = 1f;
  2043. num75 *= 1f + (1f - npc.scale);
  2044. if (npc.velocity.X < -num75 || npc.velocity.X > num75)
  2045. {
  2046. if (npc.velocity.Y == 0f)
  2047. {
  2048. npc.velocity *= 0.8f;
  2049. }
  2050. }
  2051. else if (npc.velocity.X < num75 && npc.direction == 1)
  2052. {
  2053. npc.velocity.X = npc.velocity.X + 0.07f;
  2054. if (npc.velocity.X > num75)
  2055. {
  2056. npc.velocity.X = num75;
  2057. }
  2058. }
  2059. else if (npc.velocity.X > -num75 && npc.direction == -1)
  2060. {
  2061. npc.velocity.X = npc.velocity.X - 0.07f;
  2062. if (npc.velocity.X < -num75)
  2063. {
  2064. npc.velocity.X = -num75;
  2065. }
  2066. }
  2067. if (npc.velocity.Y == 0f && (!Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0) && !Main.player[npc.target].dead)
  2068. {
  2069. Vector2 vector13 = npc.Center - Main.player[npc.target].Center;
  2070. int num76 = 50;
  2071. if (npc.type >= 494 && npc.type <= 495)
  2072. {
  2073. num76 = 42;
  2074. }
  2075. if (vector13.Length() < (float)num76 && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
  2076. {
  2077. npc.velocity.X = npc.velocity.X * 0.7f;
  2078. npc.ai[2] = 1f;
  2079. }
  2080. }
  2081. }
  2082. else
  2083. {
  2084. npc.damage = (int)((double)npc.defDamage * 1.5);
  2085. npc.ai[3] = 1f;
  2086. npc.velocity.X = npc.velocity.X * 0.9f;
  2087. if ((double)Math.Abs(npc.velocity.X) < 0.1)
  2088. {
  2089. npc.velocity.X = 0f;
  2090. }
  2091. npc.ai[2] += 1f;
  2092. if (npc.ai[2] >= 20f || npc.velocity.Y != 0f || (Main.dayTime && (double)npc.position.Y < Main.worldSurface * 16.0))
  2093. {
  2094. npc.ai[2] = 0f;
  2095. }
  2096. }
  2097. }
  2098. else if (npc.type != 110 && (npc.type != 111 || false) && npc.type != 206 && npc.type != 214 && npc.type != 215 && npc.type != 216 && npc.type != 290 && npc.type != 291 && npc.type != 292 && npc.type != 293 && npc.type != 350 && npc.type != 379 && npc.type != 380 && npc.type != 381 && npc.type != 382 && (npc.type < 449 || npc.type > 452) && npc.type != 468 && npc.type != 481 && npc.type != 411 && npc.type != 409 && (npc.type < 498 || npc.type > 506) && npc.type != 424 && npc.type != 426 && npc.type != 520)
  2099. {
  2100. float num77 = 1f;
  2101. if (npc.type == 186)
  2102. {
  2103. num77 = 1.1f;
  2104. }
  2105. if (npc.type == 187)
  2106. {
  2107. num77 = 0.9f;
  2108. }
  2109. if (npc.type == 188)
  2110. {
  2111. num77 = 1.2f;
  2112. }
  2113. if (npc.type == 189)
  2114. {
  2115. num77 = 0.8f;
  2116. }
  2117. if (npc.type == 132)
  2118. {
  2119. num77 = 0.95f;
  2120. }
  2121. if (npc.type == 200)
  2122. {
  2123. num77 = 0.87f;
  2124. }
  2125. if (npc.type == 223)
  2126. {
  2127. num77 = 1.05f;
  2128. }
  2129. if (npc.type == 489)
  2130. {
  2131. float num78 = (Main.player[npc.target].Center - npc.Center).Length();
  2132. num78 *= 0.0025f;
  2133. if ((double)num78 > 1.5)
  2134. {
  2135. num78 = 1.5f;
  2136. }
  2137. if (Main.expertMode)
  2138. {
  2139. num77 = 3f - num78;
  2140. }
  2141. else
  2142. {
  2143. num77 = 2.5f - num78;
  2144. }
  2145. num77 *= 0.8f;
  2146. }
  2147. if (npc.type == 489 || npc.type == 3 || npc.type == 132 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 200 || npc.type == 223 || npc.type == 331 || npc.type == 332)
  2148. {
  2149. num77 *= 1f + (1f - npc.scale);
  2150. }
  2151. if (npc.velocity.X < -num77 || npc.velocity.X > num77)
  2152. {
  2153. if (npc.velocity.Y == 0f)
  2154. {
  2155. npc.velocity *= 0.8f;
  2156. }
  2157. }
  2158. else if (npc.velocity.X < num77 && npc.direction == 1)
  2159. {
  2160. npc.velocity.X = npc.velocity.X + 0.07f;
  2161. if (npc.velocity.X > num77)
  2162. {
  2163. npc.velocity.X = num77;
  2164. }
  2165. }
  2166. else if (npc.velocity.X > -num77 && npc.direction == -1)
  2167. {
  2168. npc.velocity.X = npc.velocity.X - 0.07f;
  2169. if (npc.velocity.X < -num77)
  2170. {
  2171. npc.velocity.X = -num77;
  2172. }
  2173. }
  2174. }
  2175. if (npc.type >= 277 && npc.type <= 280)
  2176. {
  2177. Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.2f, 0.1f, 0f);
  2178. }
  2179. else if (npc.type == 520)
  2180. {
  2181. Lighting.AddLight(npc.Top + new Vector2(0f, 20f), 0.3f, 0.3f, 0.7f);
  2182. }
  2183. else if (npc.type == 525)
  2184. {
  2185. Vector3 rgb = new Vector3(0.7f, 1f, 0.2f) * 0.5f;
  2186. Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb);
  2187. }
  2188. else if (npc.type == 526)
  2189. {
  2190. Vector3 rgb2 = new Vector3(1f, 1f, 0.5f) * 0.4f;
  2191. Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb2);
  2192. }
  2193. else if (npc.type == 527)
  2194. {
  2195. Vector3 rgb3 = new Vector3(0.6f, 0.3f, 1f) * 0.4f;
  2196. Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb3);
  2197. }
  2198. else if (npc.type == 415)
  2199. {
  2200. npc.hide = false;
  2201. for (int num79 = 0; num79 < 200; num79++)
  2202. {
  2203. if (Main.npc[num79].active && Main.npc[num79].type == 416 && Main.npc[num79].ai[0] == (float)npc.whoAmI)
  2204. {
  2205. npc.hide = true;
  2206. break;
  2207. }
  2208. }
  2209. }
  2210. else if (npc.type == 258)
  2211. {
  2212. if (npc.velocity.Y != 0f)
  2213. {
  2214. npc.TargetClosest(true);
  2215. npc.spriteDirection = npc.direction;
  2216. if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > 0f)
  2217. {
  2218. npc.velocity.X = npc.velocity.X * 0.95f;
  2219. }
  2220. else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 0f)
  2221. {
  2222. npc.velocity.X = npc.velocity.X * 0.95f;
  2223. }
  2224. if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > -5f)
  2225. {
  2226. npc.velocity.X = npc.velocity.X - 0.1f;
  2227. }
  2228. else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 5f)
  2229. {
  2230. npc.velocity.X = npc.velocity.X + 0.1f;
  2231. }
  2232. }
  2233. else if (Main.player[npc.target].Center.Y + 50f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
  2234. {
  2235. npc.velocity.Y = -7f;
  2236. }
  2237. }
  2238. else if (npc.type == 425)
  2239. {
  2240. if (npc.velocity.Y == 0f)
  2241. {
  2242. npc.ai[2] = 0f;
  2243. }
  2244. if (npc.velocity.Y != 0f && npc.ai[2] == 1f)
  2245. {
  2246. npc.TargetClosest(true);
  2247. npc.spriteDirection = -npc.direction;
  2248. if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
  2249. {
  2250. float num80 = Main.player[npc.target].Center.X - (float)(npc.direction * 400) - npc.Center.X;
  2251. float num81 = Main.player[npc.target].Bottom.Y - npc.Bottom.Y;
  2252. if (num80 < 0f && npc.velocity.X > 0f)
  2253. {
  2254. npc.velocity.X = npc.velocity.X * 0.9f;
  2255. }
  2256. else if (num80 > 0f && npc.velocity.X < 0f)
  2257. {
  2258. npc.velocity.X = npc.velocity.X * 0.9f;
  2259. }
  2260. if (num80 < 0f && npc.velocity.X > -5f)
  2261. {
  2262. npc.velocity.X = npc.velocity.X - 0.1f;
  2263. }
  2264. else if (num80 > 0f && npc.velocity.X < 5f)
  2265. {
  2266. npc.velocity.X = npc.velocity.X + 0.1f;
  2267. }
  2268. if (npc.velocity.X > 6f)
  2269. {
  2270. npc.velocity.X = 6f;
  2271. }
  2272. if (npc.velocity.X < -6f)
  2273. {
  2274. npc.velocity.X = -6f;
  2275. }
  2276. if (num81 < -20f && npc.velocity.Y > 0f)
  2277. {
  2278. npc.velocity.Y = npc.velocity.Y * 0.8f;
  2279. }
  2280. else if (num81 > 20f && npc.velocity.Y < 0f)
  2281. {
  2282. npc.velocity.Y = npc.velocity.Y * 0.8f;
  2283. }
  2284. if (num81 < -20f && npc.velocity.Y > -5f)
  2285. {
  2286. npc.velocity.Y = npc.velocity.Y - 0.3f;
  2287. }
  2288. else if (num81 > 20f && npc.velocity.Y < 5f)
  2289. {
  2290. npc.velocity.Y = npc.velocity.Y + 0.3f;
  2291. }
  2292. }
  2293. if (Main.rand.Next(3) == 0)
  2294. {
  2295. Vector2 position = npc.Center + new Vector2((float)(npc.direction * -14), -8f) - Vector2.One * 4f;
  2296. Vector2 vector14 = new Vector2((float)(npc.direction * -6), 12f) * 0.2f + Utils.RandomVector2(Main.rand, -1f, 1f) * 0.1f;
  2297. Dust expr_73D5 = Main.dust[Dust.NewDust(position, 8, 8, 229, vector14.X, vector14.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 0.5f)];
  2298. expr_73D5.noGravity = true;
  2299. expr_73D5.velocity = vector14;
  2300. expr_73D5.customData = this;
  2301. }
  2302. for (int num82 = 0; num82 < 200; num82++)
  2303. {
  2304. if (num82 != npc.whoAmI && Main.npc[num82].active && Main.npc[num82].type == npc.type && Math.Abs(npc.position.X - Main.npc[num82].position.X) + Math.Abs(npc.position.Y - Main.npc[num82].position.Y) < (float)npc.width)
  2305. {
  2306. if (npc.position.X < Main.npc[num82].position.X)
  2307. {
  2308. npc.velocity.X = npc.velocity.X - 0.05f;
  2309. }
  2310. else
  2311. {
  2312. npc.velocity.X = npc.velocity.X + 0.05f;
  2313. }
  2314. if (npc.position.Y < Main.npc[num82].position.Y)
  2315. {
  2316. npc.velocity.Y = npc.velocity.Y - 0.05f;
  2317. }
  2318. else
  2319. {
  2320. npc.velocity.Y = npc.velocity.Y + 0.05f;
  2321. }
  2322. }
  2323. }
  2324. }
  2325. else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
  2326. {
  2327. npc.velocity.Y = -5f;
  2328. npc.ai[2] = 1f;
  2329. }
  2330. if (Main.netMode != 1)
  2331. {
  2332. npc.localAI[2] += 1f;
  2333. if (npc.localAI[2] >= (float)(360 + Main.rand.Next(360)) && npc.Distance(Main.player[npc.target].Center) < 400f && Math.Abs(npc.DirectionTo(Main.player[npc.target].Center).Y) < 0.5f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
  2334. {
  2335. npc.localAI[2] = 0f;
  2336. Vector2 vector15 = npc.Center + new Vector2((float)(npc.direction * 30), 2f);
  2337. Vector2 vector16 = npc.DirectionTo(Main.player[npc.target].Center) * 7f;
  2338. if (vector16.HasNaNs())
  2339. {
  2340. vector16 = new Vector2((float)(npc.direction * 8), 0f);
  2341. }
  2342. int num83 = Main.expertMode ? 50 : 75;
  2343. for (int num84 = 0; num84 < 4; num84++)
  2344. {
  2345. Vector2 vector17 = vector16 + Utils.RandomVector2(Main.rand, -0.8f, 0.8f);
  2346. Projectile.NewProjectile(vector15.X, vector15.Y, vector17.X, vector17.Y, 577, num83, 1f, Main.myPlayer, 0f, 0f);
  2347. }
  2348. }
  2349. }
  2350. }
  2351. else if (npc.type == 427)
  2352. {
  2353. if (npc.velocity.Y == 0f)
  2354. {
  2355. npc.ai[2] = 0f;
  2356. npc.rotation = 0f;
  2357. }
  2358. else
  2359. {
  2360. npc.rotation = npc.velocity.X * 0.1f;
  2361. }
  2362. if (npc.velocity.Y != 0f && npc.ai[2] == 1f)
  2363. {
  2364. npc.TargetClosest(true);
  2365. npc.spriteDirection = -npc.direction;
  2366. if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
  2367. {
  2368. float num85 = Main.player[npc.target].Center.X - npc.Center.X;
  2369. float num86 = Main.player[npc.target].Center.Y - npc.Center.Y;
  2370. if (num85 < 0f && npc.velocity.X > 0f)
  2371. {
  2372. npc.velocity.X = npc.velocity.X * 0.98f;
  2373. }
  2374. else if (num85 > 0f && npc.velocity.X < 0f)
  2375. {
  2376. npc.velocity.X = npc.velocity.X * 0.98f;
  2377. }
  2378. if (num85 < -20f && npc.velocity.X > -6f)
  2379. {
  2380. npc.velocity.X = npc.velocity.X - 0.015f;
  2381. }
  2382. else if (num85 > 20f && npc.velocity.X < 6f)
  2383. {
  2384. npc.velocity.X = npc.velocity.X + 0.015f;
  2385. }
  2386. if (npc.velocity.X > 6f)
  2387. {
  2388. npc.velocity.X = 6f;
  2389. }
  2390. if (npc.velocity.X < -6f)
  2391. {
  2392. npc.velocity.X = -6f;
  2393. }
  2394. if (num86 < -20f && npc.velocity.Y > 0f)
  2395. {
  2396. npc.velocity.Y = npc.velocity.Y * 0.98f;
  2397. }
  2398. else if (num86 > 20f && npc.velocity.Y < 0f)
  2399. {
  2400. npc.velocity.Y = npc.velocity.Y * 0.98f;
  2401. }
  2402. if (num86 < -20f && npc.velocity.Y > -6f)
  2403. {
  2404. npc.velocity.Y = npc.velocity.Y - 0.15f;
  2405. }
  2406. else if (num86 > 20f && npc.velocity.Y < 6f)
  2407. {
  2408. npc.velocity.Y = npc.velocity.Y + 0.15f;
  2409. }
  2410. }
  2411. for (int num87 = 0; num87 < 200; num87++)
  2412. {
  2413. if (num87 != npc.whoAmI && Main.npc[num87].active && Main.npc[num87].type == npc.type && Math.Abs(npc.position.X - Main.npc[num87].position.X) + Math.Abs(npc.position.Y - Main.npc[num87].position.Y) < (float)npc.width)
  2414. {
  2415. if (npc.position.X < Main.npc[num87].position.X)
  2416. {
  2417. npc.velocity.X = npc.velocity.X - 0.05f;
  2418. }
  2419. else
  2420. {
  2421. npc.velocity.X = npc.velocity.X + 0.05f;
  2422. }
  2423. if (npc.position.Y < Main.npc[num87].position.Y)
  2424. {
  2425. npc.velocity.Y = npc.velocity.Y - 0.05f;
  2426. }
  2427. else
  2428. {
  2429. npc.velocity.Y = npc.velocity.Y + 0.05f;
  2430. }
  2431. }
  2432. }
  2433. }
  2434. else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
  2435. {
  2436. npc.velocity.Y = -5f;
  2437. npc.ai[2] = 1f;
  2438. }
  2439. }
  2440. else if (npc.type == 426)
  2441. {
  2442. if (npc.ai[1] > 0f && npc.velocity.Y > 0f)
  2443. {
  2444. npc.velocity.Y = npc.velocity.Y * 0.85f;
  2445. if (npc.velocity.Y == 0f)
  2446. {
  2447. npc.velocity.Y = -0.4f;
  2448. }
  2449. }
  2450. if (npc.velocity.Y != 0f)
  2451. {
  2452. npc.TargetClosest(true);
  2453. npc.spriteDirection = npc.direction;
  2454. if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
  2455. {
  2456. float num88 = Main.player[npc.target].Center.X - (float)(npc.direction * 300) - npc.Center.X;
  2457. if (num88 < 40f && npc.velocity.X > 0f)
  2458. {
  2459. npc.velocity.X = npc.velocity.X * 0.98f;
  2460. }
  2461. else if (num88 > 40f && npc.velocity.X < 0f)
  2462. {
  2463. npc.velocity.X = npc.velocity.X * 0.98f;
  2464. }
  2465. if (num88 < 40f && npc.velocity.X > -5f)
  2466. {
  2467. npc.velocity.X = npc.velocity.X - 0.2f;
  2468. }
  2469. else if (num88 > 40f && npc.velocity.X < 5f)
  2470. {
  2471. npc.velocity.X = npc.velocity.X + 0.2f;
  2472. }
  2473. if (npc.velocity.X > 6f)
  2474. {
  2475. npc.velocity.X = 6f;
  2476. }
  2477. if (npc.velocity.X < -6f)
  2478. {
  2479. npc.velocity.X = -6f;
  2480. }
  2481. }
  2482. }
  2483. else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
  2484. {
  2485. npc.velocity.Y = -6f;
  2486. }
  2487. for (int num89 = 0; num89 < 200; num89++)
  2488. {
  2489. if (num89 != npc.whoAmI && Main.npc[num89].active && Main.npc[num89].type == npc.type && Math.Abs(npc.position.X - Main.npc[num89].position.X) + Math.Abs(npc.position.Y - Main.npc[num89].position.Y) < (float)npc.width)
  2490. {
  2491. if (npc.position.X < Main.npc[num89].position.X)
  2492. {
  2493. npc.velocity.X = npc.velocity.X - 0.1f;
  2494. }
  2495. else
  2496. {
  2497. npc.velocity.X = npc.velocity.X + 0.1f;
  2498. }
  2499. if (npc.position.Y < Main.npc[num89].position.Y)
  2500. {
  2501. npc.velocity.Y = npc.velocity.Y - 0.1f;
  2502. }
  2503. else
  2504. {
  2505. npc.velocity.Y = npc.velocity.Y + 0.1f;
  2506. }
  2507. }
  2508. }
  2509. if (Main.rand.Next(6) == 0 && npc.ai[1] <= 20f)
  2510. {
  2511. Dust expr_80E3 = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, 229, npc.velocity.X, npc.velocity.Y, 100, default(Color), 1f)];
  2512. expr_80E3.velocity = expr_80E3.velocity / 4f + npc.velocity / 2f;
  2513. expr_80E3.scale = 0.6f;
  2514. expr_80E3.noLight = true;
  2515. }
  2516. if (npc.ai[1] >= 57f)
  2517. {
  2518. int num90 = Utils.SelectRandom<int>(Main.rand, new int[]
  2519. {
  2520. 161,
  2521. 229
  2522. });
  2523. Dust expr_81AD = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, num90, npc.velocity.X, npc.velocity.Y, 100, default(Color), 1f)];
  2524. expr_81AD.velocity = expr_81AD.velocity / 4f + npc.DirectionTo(Main.player[npc.target].Top);
  2525. expr_81AD.scale = 1.2f;
  2526. expr_81AD.noLight = true;
  2527. }
  2528. if (Main.rand.Next(6) == 0)
  2529. {
  2530. Dust dust6 = Main.dust[Dust.NewDust(npc.Center, 2, 2, 229, 0f, 0f, 0, default(Color), 1f)];
  2531. dust6.position = npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 26 : -26), 24f);
  2532. dust6.velocity.X = 0f;
  2533. if (dust6.velocity.Y < 0f)
  2534. {
  2535. dust6.velocity.Y = 0f;
  2536. }
  2537. dust6.noGravity = true;
  2538. dust6.scale = 1f;
  2539. dust6.noLight = true;
  2540. }
  2541. }
  2542. else if (npc.type == 185)
  2543. {
  2544. if (npc.velocity.Y == 0f)
  2545. {
  2546. npc.rotation = 0f;
  2547. npc.localAI[0] = 0f;
  2548. }
  2549. else if (npc.localAI[0] == 1f)
  2550. {
  2551. npc.rotation += npc.velocity.X * 0.05f;
  2552. }
  2553. }
  2554. else if (npc.type == 428)
  2555. {
  2556. if (npc.velocity.Y == 0f)
  2557. {
  2558. npc.rotation = 0f;
  2559. }
  2560. else
  2561. {
  2562. npc.rotation += npc.velocity.X * 0.08f;
  2563. }
  2564. }
  2565. if (npc.type == 159 && Main.netMode != 1)
  2566. {
  2567. Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
  2568. float arg_842C_0 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector18.X;
  2569. float num91 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector18.Y;
  2570. if ((float)Math.Sqrt((double)(arg_842C_0 * arg_842C_0 + num91 * num91)) > 300f)
  2571. {
  2572. npc.Transform(158);
  2573. }
  2574. }
  2575. if (npc.type == 164 && Main.netMode != 1 && npc.velocity.Y == 0f)
  2576. {
  2577. int num92 = (int)npc.Center.X / 16;
  2578. int num93 = (int)npc.Center.Y / 16;
  2579. bool flag9 = false;
  2580. for (int num94 = num92 - 1; num94 <= num92 + 1; num94++)
  2581. {
  2582. for (int num95 = num93 - 1; num95 <= num93 + 1; num95++)
  2583. {
  2584. if (Main.tile[num94, num95].wall > 0)
  2585. {
  2586. flag9 = true;
  2587. }
  2588. }
  2589. }
  2590. if (flag9)
  2591. {
  2592. npc.Transform(165);
  2593. }
  2594. }
  2595. if (npc.type == 239 && Main.netMode != 1 && npc.velocity.Y == 0f)
  2596. {
  2597. int num96 = (int)npc.Center.X / 16;
  2598. int num97 = (int)npc.Center.Y / 16;
  2599. bool flag10 = false;
  2600. for (int num98 = num96 - 1; num98 <= num96 + 1; num98++)
  2601. {
  2602. for (int num99 = num97 - 1; num99 <= num97 + 1; num99++)
  2603. {
  2604. if (Main.tile[num98, num99].wall > 0)
  2605. {
  2606. flag10 = true;
  2607. }
  2608. }
  2609. }
  2610. if (flag10)
  2611. {
  2612. npc.Transform(240);
  2613. }
  2614. }
  2615. if (npc.type == 530 && Main.netMode != 1 && npc.velocity.Y == 0f)
  2616. {
  2617. int num100 = (int)npc.Center.X / 16;
  2618. int num101 = (int)npc.Center.Y / 16;
  2619. bool flag11 = false;
  2620. for (int num102 = num100 - 1; num102 <= num100 + 1; num102++)
  2621. {
  2622. for (int num103 = num101 - 1; num103 <= num101 + 1; num103++)
  2623. {
  2624. if (Main.tile[num102, num103].wall > 0)
  2625. {
  2626. flag11 = true;
  2627. }
  2628. }
  2629. }
  2630. if (flag11)
  2631. {
  2632. npc.Transform(531);
  2633. }
  2634. }
  2635. if (Main.netMode != 1 && Main.expertMode && npc.target >= 0 && (npc.type == 163 || npc.type == 238) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
  2636. {
  2637. npc.localAI[0] += 1f;
  2638. if (npc.justHit)
  2639. {
  2640. npc.localAI[0] -= (float)Main.rand.Next(20, 60);
  2641. if (npc.localAI[0] < 0f)
  2642. {
  2643. npc.localAI[0] = 0f;
  2644. }
  2645. }
  2646. if (npc.localAI[0] > (float)Main.rand.Next(180, 900))
  2647. {
  2648. npc.localAI[0] = 0f;
  2649. Vector2 vector19 = Main.player[npc.target].Center - npc.Center;
  2650. vector19.Normalize();
  2651. vector19 *= 8f;
  2652. Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector19.X, vector19.Y, 472, 18, 0f, Main.myPlayer, 0f, 0f);
  2653. }
  2654. }
  2655. if (npc.type == 163 && Main.netMode != 1 && npc.velocity.Y == 0f)
  2656. {
  2657. int num104 = (int)npc.Center.X / 16;
  2658. int num105 = (int)npc.Center.Y / 16;
  2659. bool flag12 = false;
  2660. for (int num106 = num104 - 1; num106 <= num104 + 1; num106++)
  2661. {
  2662. for (int num107 = num105 - 1; num107 <= num105 + 1; num107++)
  2663. {
  2664. if (Main.tile[num106, num107].wall > 0)
  2665. {
  2666. flag12 = true;
  2667. }
  2668. }
  2669. }
  2670. if (flag12)
  2671. {
  2672. npc.Transform(238);
  2673. }
  2674. }
  2675. if (npc.type == 236 && Main.netMode != 1 && npc.velocity.Y == 0f)
  2676. {
  2677. int num108 = (int)npc.Center.X / 16;
  2678. int num109 = (int)npc.Center.Y / 16;
  2679. bool flag13 = false;
  2680. for (int num110 = num108 - 1; num110 <= num108 + 1; num110++)
  2681. {
  2682. for (int num111 = num109 - 1; num111 <= num109 + 1; num111++)
  2683. {
  2684. if (Main.tile[num110, num111].wall > 0)
  2685. {
  2686. flag13 = true;
  2687. }
  2688. }
  2689. }
  2690. if (flag13)
  2691. {
  2692. npc.Transform(237);
  2693. }
  2694. }
  2695. if (npc.type == 243)
  2696. {
  2697. if (npc.justHit && Main.rand.Next(3) == 0)
  2698. {
  2699. npc.ai[2] -= (float)Main.rand.Next(30);
  2700. }
  2701. if (npc.ai[2] < 0f)
  2702. {
  2703. npc.ai[2] = 0f;
  2704. }
  2705. if (npc.confused)
  2706. {
  2707. npc.ai[2] = 0f;
  2708. }
  2709. npc.ai[2] += 1f;
  2710. float num112 = (float)Main.rand.Next(30, 900);
  2711. num112 *= (float)npc.life / (float)npc.lifeMax;
  2712. num112 += 30f;
  2713. if (Main.netMode != 1 && npc.ai[2] >= num112 && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
  2714. {
  2715. float arg_8BB1_0 = 15f;
  2716. Vector2 vector20 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + 20f);
  2717. vector20.X += (float)(10 * npc.direction);
  2718. float num113 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector20.X;
  2719. float num114 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector20.Y;
  2720. num113 += (float)Main.rand.Next(-40, 41);
  2721. num114 += (float)Main.rand.Next(-40, 41);
  2722. float num115 = (float)Math.Sqrt((double)(num113 * num113 + num114 * num114));
  2723. npc.netUpdate = true;
  2724. num115 = arg_8BB1_0 / num115;
  2725. num113 *= num115;
  2726. num114 *= num115;
  2727. int num116 = 32;
  2728. int num117 = 257;
  2729. vector20.X += num113 * 3f;
  2730. vector20.Y += num114 * 3f;
  2731. Projectile.NewProjectile(vector20.X, vector20.Y, num113, num114, num117, num116, 0f, Main.myPlayer, 0f, 0f);
  2732. npc.ai[2] = 0f;
  2733. }
  2734. }
  2735. if (npc.type == 251)
  2736. {
  2737. if (npc.justHit)
  2738. {
  2739. npc.ai[2] -= (float)Main.rand.Next(30);
  2740. }
  2741. if (npc.ai[2] < 0f)
  2742. {
  2743. npc.ai[2] = 0f;
  2744. }
  2745. if (npc.confused)
  2746. {
  2747. npc.ai[2] = 0f;
  2748. }
  2749. npc.ai[2] += 1f;
  2750. float num118 = (float)Main.rand.Next(60, 1800);
  2751. num118 *= (float)npc.life / (float)npc.lifeMax;
  2752. num118 += 15f;
  2753. if (Main.netMode != 1 && npc.ai[2] >= num118 && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
  2754. {
  2755. float arg_8EE5_0 = 15f;
  2756. Vector2 vector21 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + 12f);
  2757. vector21.X += (float)(6 * npc.direction);
  2758. float num119 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector21.X;
  2759. float num120 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector21.Y;
  2760. num119 += (float)Main.rand.Next(-40, 41);
  2761. num120 += (float)Main.rand.Next(-30, 0);
  2762. float num121 = (float)Math.Sqrt((double)(num119 * num119 + num120 * num120));
  2763. npc.netUpdate = true;
  2764. num121 = arg_8EE5_0 / num121;
  2765. num119 *= num121;
  2766. num120 *= num121;
  2767. int num122 = 30;
  2768. int num123 = 83;
  2769. vector21.X += num119 * 3f;
  2770. vector21.Y += num120 * 3f;
  2771. Projectile.NewProjectile(vector21.X, vector21.Y, num119, num120, num123, num122, 0f, Main.myPlayer, 0f, 0f);
  2772. npc.ai[2] = 0f;
  2773. }
  2774. }
  2775. if (npc.type == 386)
  2776. {
  2777. if (npc.confused)
  2778. {
  2779. npc.ai[2] = -60f;
  2780. }
  2781. else
  2782. {
  2783. if (npc.ai[2] < 60f)
  2784. {
  2785. npc.ai[2] += 1f;
  2786. }
  2787. if (npc.ai[2] > 0f && NPC.CountNPCS(387) >= 4 * NPC.CountNPCS(386))
  2788. {
  2789. npc.ai[2] = 0f;
  2790. }
  2791. if (npc.justHit)
  2792. {
  2793. npc.ai[2] = -30f;
  2794. }
  2795. if (npc.ai[2] == 30f)
  2796. {
  2797. int num124 = (int)npc.position.X / 16;
  2798. int num125 = (int)npc.position.Y / 16;
  2799. int num126 = (int)npc.position.X / 16;
  2800. int num127 = (int)npc.position.Y / 16;
  2801. int num128 = 5;
  2802. int num129 = 0;
  2803. bool flag14 = false;
  2804. int num130 = 2;
  2805. int num131 = 0;
  2806. while (!flag14 && num129 < 100)
  2807. {
  2808. num129++;
  2809. int num132 = Main.rand.Next(num124 - num128, num124 + num128);
  2810. for (int num133 = Main.rand.Next(num125 - num128, num125 + num128); num133 < num125 + num128; num133++)
  2811. {
  2812. if ((num133 < num125 - num130 || num133 > num125 + num130 || num132 < num124 - num130 || num132 > num124 + num130) && (num133 < num127 - num131 || num133 > num127 + num131 || num132 < num126 - num131 || num132 > num126 + num131) && Main.tile[num132, num133].nactive())
  2813. {
  2814. bool flag15 = true;
  2815. if (Main.tile[num132, num133 - 1].lava())
  2816. {
  2817. flag15 = false;
  2818. }
  2819. if (flag15 && Main.tileSolid[(int)Main.tile[num132, num133].type] && !Collision.SolidTiles(num132 - 1, num132 + 1, num133 - 4, num133 - 1))
  2820. {
  2821. int num134 = NPC.NewNPC(num132 * 16 - npc.width / 2, num133 * 16, 387, 0, 0f, 0f, 0f, 0f, 255);
  2822. Main.npc[num134].position.Y = (float)(num133 * 16 - Main.npc[num134].height);
  2823. flag14 = true;
  2824. npc.netUpdate = true;
  2825. break;
  2826. }
  2827. }
  2828. }
  2829. }
  2830. }
  2831. if (npc.ai[2] == 60f)
  2832. {
  2833. npc.ai[2] = -120f;
  2834. }
  2835. }
  2836. }
  2837. if (npc.type == 389)
  2838. {
  2839. if (npc.confused)
  2840. {
  2841. npc.ai[2] = -60f;
  2842. }
  2843. else
  2844. {
  2845. if (npc.ai[2] < 20f)
  2846. {
  2847. npc.ai[2] += 1f;
  2848. }
  2849. if (npc.justHit)
  2850. {
  2851. npc.ai[2] = -30f;
  2852. }
  2853. if (npc.ai[2] == 20f && Main.netMode != 1)
  2854. {
  2855. npc.ai[2] = (float)(-10 + Main.rand.Next(3) * -10);
  2856. Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 8f, (float)(npc.direction * 6), 0f, 437, 25, 1f, Main.myPlayer, 0f, 0f);
  2857. }
  2858. }
  2859. }
  2860. if (npc.type == 110 || (npc.type == 111 || true) || npc.type == 206 || npc.type == 214 || npc.type == 215 || npc.type == 216 || npc.type == 290 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 350 || npc.type == 379 || npc.type == 380 || npc.type == 381 || npc.type == 382 || (npc.type >= 449 && npc.type <= 452) || (npc.type == 468 || npc.type == 481 || npc.type == 411 || npc.type == 409 || (npc.type >= 498 && npc.type <= 506)) || npc.type == 424 || npc.type == 426 || npc.type == 520)
  2861. {
  2862. bool flag16 = npc.type == 381 || npc.type == 382 || npc.type == 520;
  2863. bool flag17 = npc.type == 426;
  2864. bool flag18 = true;
  2865. int num135 = -1;
  2866. int num136 = -1;
  2867. if (npc.type == 411)
  2868. {
  2869. flag16 = true;
  2870. num135 = 90;
  2871. num136 = 90;
  2872. if (npc.ai[1] <= 150f)
  2873. {
  2874. flag18 = false;
  2875. }
  2876. }
  2877. if (npc.confused)
  2878. {
  2879. npc.ai[2] = 0f;
  2880. }
  2881. else
  2882. {
  2883. if (npc.ai[1] > 0f)
  2884. {
  2885. npc.ai[1] -= 1f;
  2886. }
  2887. if (npc.justHit)
  2888. {
  2889. npc.ai[1] = 30f;
  2890. npc.ai[2] = 0f;
  2891. }
  2892. int num137 = 70;
  2893. if (npc.type == 379 || npc.type == 380)
  2894. {
  2895. num137 = 80;
  2896. }
  2897. if (npc.type == 381 || npc.type == 382)
  2898. {
  2899. num137 = 80;
  2900. }
  2901. if (npc.type == 520)
  2902. {
  2903. num137 = 15;
  2904. }
  2905. if (npc.type == 350)
  2906. {
  2907. num137 = 110;
  2908. }
  2909. if (npc.type == 291)
  2910. {
  2911. num137 = 200;
  2912. }
  2913. if (npc.type == 292)
  2914. {
  2915. num137 = 120;
  2916. }
  2917. if (npc.type == 293)
  2918. {
  2919. num137 = 90;
  2920. }
  2921. if (npc.type == 111 || true)
  2922. {
  2923. num137 = 180;
  2924. }
  2925. if (npc.type == 206)
  2926. {
  2927. num137 = 50;
  2928. }
  2929. if (npc.type == 481)
  2930. {
  2931. num137 = 100;
  2932. }
  2933. if (npc.type == 214)
  2934. {
  2935. num137 = 40;
  2936. }
  2937. if (npc.type == 215)
  2938. {
  2939. num137 = 80;
  2940. }
  2941. if (npc.type == 290)
  2942. {
  2943. num137 = 30;
  2944. }
  2945. if (npc.type == 411)
  2946. {
  2947. num137 = 300;
  2948. }
  2949. if (npc.type == 409)
  2950. {
  2951. num137 = 60;
  2952. }
  2953. if (npc.type == 424)
  2954. {
  2955. num137 = 180;
  2956. }
  2957. if (npc.type == 426)
  2958. {
  2959. num137 = 60;
  2960. }
  2961. bool flag19 = false;
  2962. if (npc.type == 216)
  2963. {
  2964. if (npc.localAI[2] >= 20f)
  2965. {
  2966. flag19 = true;
  2967. }
  2968. if (flag19)
  2969. {
  2970. num137 = 60;
  2971. }
  2972. else
  2973. {
  2974. num137 = 8;
  2975. }
  2976. }
  2977. int num138 = num137 / 2;
  2978. if (npc.type == 424)
  2979. {
  2980. num138 = num137 - 1;
  2981. }
  2982. if (npc.type == 426)
  2983. {
  2984. num138 = num137 - 1;
  2985. }
  2986. if (npc.ai[2] > 0f)
  2987. {
  2988. if (flag18)
  2989. {
  2990. npc.TargetClosest(true);
  2991. }
  2992. if (npc.ai[1] == (float)num138)
  2993. {
  2994. if (npc.type == 216)
  2995. {
  2996. npc.localAI[2] += 1f;
  2997. }
  2998. float num139 = 11f;
  2999. if (npc.type == 111 || true)
  3000. {
  3001. num139 = 9f;
  3002. }
  3003. if (npc.type == 206)
  3004. {
  3005. num139 = 7f;
  3006. }
  3007. if (npc.type == 290)
  3008. {
  3009. num139 = 9f;
  3010. }
  3011. if (npc.type == 293)
  3012. {
  3013. num139 = 4f;
  3014. }
  3015. if (npc.type == 214)
  3016. {
  3017. num139 = 14f;
  3018. }
  3019. if (npc.type == 215)
  3020. {
  3021. num139 = 50f;
  3022. }
  3023. if (npc.type == 382)
  3024. {
  3025. num139 = 7f;
  3026. }
  3027. if (npc.type == 520)
  3028. {
  3029. num139 = 8f;
  3030. }
  3031. if (npc.type == 409)
  3032. {
  3033. num139 = 4f;
  3034. }
  3035. if (npc.type >= 449 && npc.type <= 452)
  3036. {
  3037. num139 = 7f;
  3038. }
  3039. if (npc.type == 481)
  3040. {
  3041. num139 = 8f;
  3042. }
  3043. if (npc.type == 468)
  3044. {
  3045. num139 = 7.5f;
  3046. }
  3047. if (npc.type == 411)
  3048. {
  3049. num139 = 1f;
  3050. }
  3051. if (npc.type >= 498 && npc.type <= 506)
  3052. {
  3053. num139 = 7f;
  3054. }
  3055. Vector2 vector22 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
  3056. if (npc.type == 481)
  3057. {
  3058. vector22.Y -= 14f;
  3059. }
  3060. if (npc.type == 206)
  3061. {
  3062. vector22.Y -= 10f;
  3063. }
  3064. if (npc.type == 290)
  3065. {
  3066. vector22.Y -= 10f;
  3067. }
  3068. if (npc.type == 381 || npc.type == 382)
  3069. {
  3070. vector22.Y += 6f;
  3071. }
  3072. if (npc.type == 520)
  3073. {
  3074. vector22.Y = npc.position.Y + 20f;
  3075. }
  3076. if (npc.type >= 498 && npc.type <= 506)
  3077. {
  3078. vector22.Y -= 8f;
  3079. }
  3080. if (npc.type == 426)
  3081. {
  3082. vector22 += new Vector2((float)(npc.spriteDirection * 2), -12f);
  3083. }
  3084. float num140 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * .5f - vector22.X;
  3085. float num141 = Math.Abs(num140) * 0.1f;
  3086. if (npc.type == 291 || npc.type == 292)
  3087. {
  3088. num141 = 0f;
  3089. }
  3090. if (npc.type == 215)
  3091. {
  3092. num141 = Math.Abs(num140) * .5f;
  3093. }
  3094. if (npc.type == 214 || (npc.type == 216 && !flag19))
  3095. {
  3096. num141 = 0f;
  3097. }
  3098. if (npc.type == 381 || npc.type == 382 || npc.type == 520)
  3099. {
  3100. num141 = 0f;
  3101. }
  3102. if (npc.type >= 449 && npc.type <= 452)
  3103. {
  3104. num141 = Math.Abs(num140) * (float)Main.rand.Next(10, 50) * 0.01f;
  3105. }
  3106. if (npc.type == 468)
  3107. {
  3108. num141 = Math.Abs(num140) * (float)Main.rand.Next(10, 50) * 0.01f;
  3109. }
  3110. if (npc.type == 481)
  3111. {
  3112. num141 = Math.Abs(num140) * (float)Main.rand.Next(-10, 11) * 0.0035f;
  3113. }
  3114. if (npc.type >= 498 && npc.type <= 506)
  3115. {
  3116. num141 = Math.Abs(num140) * (float)Main.rand.Next(1, 11) * 0.0025f;
  3117. }
  3118. float num142 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector22.Y - num141;
  3119. if (npc.type == 291)
  3120. {
  3121. num140 += (float)Main.rand.Next(-40, 41) * 0.2f;
  3122. num142 += (float)Main.rand.Next(-40, 41) * 0.2f;
  3123. }
  3124. else if (npc.type == 381 || npc.type == 382 || npc.type == 520)
  3125. {
  3126. num140 += (float)Main.rand.Next(-100, 101) * 0.4f;
  3127. num142 += (float)Main.rand.Next(-100, 101) * 0.4f;
  3128. num140 *= (float)Main.rand.Next(85, 116) * 0.01f;
  3129. num142 *= (float)Main.rand.Next(85, 116) * 0.01f;
  3130. if (npc.type == 520)
  3131. {
  3132. num140 += (float)Main.rand.Next(-100, 101) * 0.6f;
  3133. num142 += (float)Main.rand.Next(-100, 101) * 0.6f;
  3134. num140 *= (float)Main.rand.Next(85, 116) * 0.015f;
  3135. num142 *= (float)Main.rand.Next(85, 116) * 0.015f;
  3136. }
  3137. }
  3138. else if (npc.type == 481)
  3139. {
  3140. num140 += (float)Main.rand.Next(-40, 41) * 0.4f;
  3141. num142 += (float)Main.rand.Next(-40, 41) * 0.4f;
  3142. }
  3143. else if (npc.type >= 498 && npc.type <= 506)
  3144. {
  3145. num140 += (float)Main.rand.Next(-40, 41) * 0.3f;
  3146. num142 += (float)Main.rand.Next(-40, 41) * 0.3f;
  3147. }
  3148. else if (npc.type != 292)
  3149. {
  3150. num140 += (float)Main.rand.Next(-40, 41);
  3151. num142 += (float)Main.rand.Next(-40, 41);
  3152. }
  3153. float num143 = (float)Math.Sqrt((double)(num140 * num140 + num142 * num142));
  3154. npc.netUpdate = true;
  3155. num143 = num139 / num143;
  3156. num140 *= num143;
  3157. num142 *= num143;
  3158. int num144 = 35;
  3159. int num145 = 82;
  3160. if (npc.type == 111 || true)
  3161. {
  3162. num144 = 11;
  3163. }
  3164. if (npc.type == 206)
  3165. {
  3166. num144 = 37;
  3167. }
  3168. if (npc.type == 379 || npc.type == 380)
  3169. {
  3170. num144 = 40;
  3171. }
  3172. if (npc.type == 350)
  3173. {
  3174. num144 = 45;
  3175. }
  3176. if (npc.type == 468)
  3177. {
  3178. num144 = 50;
  3179. }
  3180. if (npc.type == 111 || true)
  3181. {
  3182. num145 = mod.ProjectileType("FBIbullet");
  3183. }
  3184. if (npc.type == 379 || npc.type == 380)
  3185. {
  3186. num145 = 81;
  3187. }
  3188. if (npc.type == 381)
  3189. {
  3190. num145 = 436;
  3191. num144 = 24;
  3192. }
  3193. if (npc.type == 382)
  3194. {
  3195. num145 = 438;
  3196. num144 = 30;
  3197. }
  3198. if (npc.type == 520)
  3199. {
  3200. num145 = 592;
  3201. num144 = 35;
  3202. }
  3203. if (npc.type >= 449 && npc.type <= 452)
  3204. {
  3205. num145 = 471;
  3206. num144 = 20;
  3207. }
  3208. if (npc.type >= 498 && npc.type <= 506)
  3209. {
  3210. num145 = 572;
  3211. num144 = 14;
  3212. }
  3213. if (npc.type == 481)
  3214. {
  3215. num145 = 508;
  3216. num144 = 18;
  3217. }
  3218. if (npc.type == 206)
  3219. {
  3220. num145 = 177;
  3221. }
  3222. if (npc.type == 468)
  3223. {
  3224. num145 = 501;
  3225. }
  3226. if (npc.type == 411)
  3227. {
  3228. num145 = 537;
  3229. num144 = (Main.expertMode ? 45 : 60);
  3230. }
  3231. if (npc.type == 424)
  3232. {
  3233. num145 = 573;
  3234. num144 = (Main.expertMode ? 45 : 60);
  3235. }
  3236. if (npc.type == 426)
  3237. {
  3238. num145 = 581;
  3239. num144 = (Main.expertMode ? 45 : 60);
  3240. }
  3241. if (npc.type == 291)
  3242. {
  3243. num145 = 302;
  3244. num144 = 100;
  3245. }
  3246. if (npc.type == 290)
  3247. {
  3248. num145 = 300;
  3249. num144 = 60;
  3250. }
  3251. if (npc.type == 293)
  3252. {
  3253. num145 = 303;
  3254. num144 = 60;
  3255. }
  3256. if (npc.type == 214)
  3257. {
  3258. num145 = 180;
  3259. num144 = 25;
  3260. }
  3261. if (npc.type == 215)
  3262. {
  3263. num145 = mod.ProjectileType("FBIbullet");
  3264. num144 = 40;
  3265. }
  3266. if (npc.type == 292)
  3267. {
  3268. num144 = 50;
  3269. num145 = 180;
  3270. }
  3271. if (npc.type == 216)
  3272. {
  3273. num145 = 180;
  3274. num144 = 30;
  3275. if (flag19)
  3276. {
  3277. num144 = 100;
  3278. num145 = 240;
  3279. npc.localAI[2] = 0f;
  3280. }
  3281. }
  3282. vector22.X += num140;
  3283. vector22.Y += num142;
  3284. if (Main.expertMode && npc.type == 290)
  3285. {
  3286. num144 = (int)((double)num144 * 0.75);
  3287. }
  3288. if (Main.expertMode && npc.type >= 381 && npc.type <= 392)
  3289. {
  3290. num144 = (int)((double)num144 * 0.8);
  3291. }
  3292. if (Main.netMode != 1)
  3293. {
  3294. if (npc.type == 292)
  3295. {
  3296. for (int num146 = 0; num146 < 4; num146++)
  3297. {
  3298. num140 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector22.X;
  3299. num142 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector22.Y;
  3300. num143 = (float)Math.Sqrt((double)(num140 * num140 + num142 * num142));
  3301. num143 = 12f / num143;
  3302. num140 += (float)Main.rand.Next(-40, 41);
  3303. num142 += (float)Main.rand.Next(-40, 41);
  3304. num140 *= num143;
  3305. num142 *= num143;
  3306. Projectile.NewProjectile(vector22.X, vector22.Y, num140, num142, num145, num144, 0f, Main.myPlayer, 0f, 0f);
  3307. }
  3308. }
  3309. else if (npc.type == 411)
  3310. {
  3311. Projectile.NewProjectile(vector22.X, vector22.Y, num140, num142, num145, num144, 0f, Main.myPlayer, 0f, (float)npc.whoAmI);
  3312. }
  3313. else if (npc.type == 424)
  3314. {
  3315. for (int num147 = 0; num147 < 4; num147++)
  3316. {
  3317. Projectile.NewProjectile(npc.Center.X - (float)(npc.spriteDirection * 4), npc.Center.Y + 6f, (float)(-3 + 2 * num147) * 0.15f, -(float)Main.rand.Next(0, 3) * 0.2f - 0.1f, num145, num144, 0f, Main.myPlayer, 0f, (float)npc.whoAmI);
  3318. }
  3319. }
  3320. else if (npc.type == 409)
  3321. {
  3322. int num148 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 410, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
  3323. Main.npc[num148].velocity = new Vector2(num140, -6f + num142);
  3324. }
  3325. else
  3326. {
  3327. Projectile.NewProjectile(vector22.X, vector22.Y, num140, num142, num145, num144, 0f, Main.myPlayer, 0f, 0f);
  3328. }
  3329. }
  3330. if (Math.Abs(num142) > Math.Abs(num140) * 2f)
  3331. {
  3332. if (num142 > 0f)
  3333. {
  3334. npc.ai[2] = 1f;
  3335. }
  3336. else
  3337. {
  3338. npc.ai[2] = 5f;
  3339. }
  3340. }
  3341. else if (Math.Abs(num140) > Math.Abs(num142) * 2f)
  3342. {
  3343. npc.ai[2] = 3f;
  3344. }
  3345. else if (num142 > 0f)
  3346. {
  3347. npc.ai[2] = 2f;
  3348. }
  3349. else
  3350. {
  3351. npc.ai[2] = 4f;
  3352. }
  3353. }
  3354. if ((npc.velocity.Y != 0f && !flag17) || npc.ai[1] <= 0f)
  3355. {
  3356. npc.ai[2] = 0f;
  3357. npc.ai[1] = 0f;
  3358. }
  3359. else if (!flag16 || (num135 != -1 && npc.ai[1] >= (float)num135 && npc.ai[1] < (float)(num135 + num136) && (!flag17 || npc.velocity.Y == 0f)))
  3360. {
  3361. npc.velocity.X = npc.velocity.X * 0.9f;
  3362. npc.spriteDirection = npc.direction;
  3363. }
  3364. }
  3365. if (npc.type == 468 && !Main.eclipse)
  3366. {
  3367. flag16 = true;
  3368. }
  3369. else if ((npc.ai[2] <= 0f | flag16) && (npc.velocity.Y == 0f | flag17) && npc.ai[1] <= 0f && !Main.player[npc.target].dead)
  3370. {
  3371. bool flag20 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height);
  3372. if (npc.type == 520)
  3373. {
  3374. flag20 = Collision.CanHitLine(npc.Top + new Vector2(0f, 20f), 0, 0, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height);
  3375. }
  3376. if (Main.player[npc.target].stealth == 0f && Main.player[npc.target].itemAnimation == 0)
  3377. {
  3378. flag20 = false;
  3379. }
  3380. if (flag20)
  3381. {
  3382. float num149 = 10f;
  3383. Vector2 vector23 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
  3384. float num150 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector23.X;
  3385. float num151 = Math.Abs(num150) * 0.1f;
  3386. float num152 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector23.Y - num151;
  3387. num150 += (float)Main.rand.Next(-40, 41);
  3388. num152 += (float)Main.rand.Next(-40, 41);
  3389. float num153 = (float)Math.Sqrt((double)(num150 * num150 + num152 * num152));
  3390. float num154 = 700f;
  3391. if (npc.type == 214)
  3392. {
  3393. num154 = 550f;
  3394. }
  3395. if (npc.type == 215)
  3396. {
  3397. num154 = 1500f;
  3398. }
  3399. if (npc.type >= 498 && npc.type <= 506)
  3400. {
  3401. num154 = 190f;
  3402. }
  3403. if (npc.type >= 449 && npc.type <= 452)
  3404. {
  3405. num154 = 200f;
  3406. }
  3407. if (npc.type == 481)
  3408. {
  3409. num154 = 400f;
  3410. }
  3411. if (npc.type == 468)
  3412. {
  3413. num154 = 400f;
  3414. }
  3415. if (num153 < num154)
  3416. {
  3417. npc.netUpdate = true;
  3418. npc.velocity.X = npc.velocity.X * 0.5f;
  3419. num153 = num149 / num153;
  3420. num150 *= num153;
  3421. num152 *= num153;
  3422. npc.ai[2] = 3f;
  3423. npc.ai[1] = (float)num137;
  3424. if (Math.Abs(num152) > Math.Abs(num150) * 2f)
  3425. {
  3426. if (num152 > 0f)
  3427. {
  3428. npc.ai[2] = 1f;
  3429. }
  3430. else
  3431. {
  3432. npc.ai[2] = 5f;
  3433. }
  3434. }
  3435. else if (Math.Abs(num150) > Math.Abs(num152) * 2f)
  3436. {
  3437. npc.ai[2] = 3f;
  3438. }
  3439. else if (num152 > 0f)
  3440. {
  3441. npc.ai[2] = 2f;
  3442. }
  3443. else
  3444. {
  3445. npc.ai[2] = 4f;
  3446. }
  3447. }
  3448. }
  3449. }
  3450. if (npc.ai[2] <= 0f || (flag16 && (num135 == -1 || npc.ai[1] < (float)num135 || npc.ai[1] >= (float)(num135 + num136))))
  3451. {
  3452. float num155 = 1f;
  3453. float num156 = 0.07f;
  3454. float scaleFactor6 = 0.8f;
  3455. if (npc.type == 214)
  3456. {
  3457. num155 = 2f;
  3458. num156 = 0.09f;
  3459. }
  3460. else if (npc.type == 215)
  3461. {
  3462. num155 = 1f;
  3463. num156 = 1f;
  3464. }
  3465. else if (npc.type == 381 || npc.type == 382)
  3466. {
  3467. num155 = 2f;
  3468. num156 = 0.5f;
  3469. }
  3470. else if (npc.type == 520)
  3471. {
  3472. num155 = 4f;
  3473. num156 = 1f;
  3474. scaleFactor6 = 0.7f;
  3475. }
  3476. else if (npc.type == 411)
  3477. {
  3478. num155 = 2f;
  3479. num156 = 0.5f;
  3480. }
  3481. else if (npc.type == 409)
  3482. {
  3483. num155 = 2f;
  3484. num156 = 0.5f;
  3485. }
  3486. bool flag21 = false;
  3487. if ((npc.type == 381 || npc.type == 382) && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 300f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
  3488. {
  3489. flag21 = true;
  3490. npc.ai[3] = 0f;
  3491. }
  3492. if (npc.type == 520 && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 400f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
  3493. {
  3494. flag21 = true;
  3495. npc.ai[3] = 0f;
  3496. }
  3497. if ((npc.velocity.X < -num155 || npc.velocity.X > num155) | flag21)
  3498. {
  3499. if (npc.velocity.Y == 0f)
  3500. {
  3501. npc.velocity *= scaleFactor6;
  3502. }
  3503. }
  3504. else if (npc.velocity.X < num155 && npc.direction == 1)
  3505. {
  3506. npc.velocity.X = npc.velocity.X + num156;
  3507. if (npc.velocity.X > num155)
  3508. {
  3509. npc.velocity.X = num155;
  3510. }
  3511. }
  3512. else if (npc.velocity.X > -num155 && npc.direction == -1)
  3513. {
  3514. npc.velocity.X = npc.velocity.X - num156;
  3515. if (npc.velocity.X < -num155)
  3516. {
  3517. npc.velocity.X = -num155;
  3518. }
  3519. }
  3520. }
  3521. if (npc.type == 520)
  3522. {
  3523. npc.localAI[2] += 1f;
  3524. if (npc.localAI[2] >= 6f)
  3525. {
  3526. npc.localAI[2] = 0f;
  3527. npc.localAI[3] = Main.player[npc.target].DirectionFrom(npc.Top + new Vector2(0f, 20f)).ToRotation();
  3528. }
  3529. }
  3530. }
  3531. }
  3532. if (npc.type == 109 && Main.netMode != 1 && !Main.player[npc.target].dead)
  3533. {
  3534. if (npc.justHit)
  3535. {
  3536. npc.ai[2] = 0f;
  3537. }
  3538. npc.ai[2] += 1f;
  3539. if (npc.ai[2] > 450f)
  3540. {
  3541. Vector2 vector24 = new Vector2(npc.position.X + (float)npc.width * 0.5f - (float)(npc.direction * 24), npc.position.Y + 4f);
  3542. int num157 = 3 * npc.direction;
  3543. int num158 = -5;
  3544. int num159 = Projectile.NewProjectile(vector24.X, vector24.Y, (float)num157, (float)num158, 75, 0, 0f, Main.myPlayer, 0f, 0f);
  3545. Main.projectile[num159].timeLeft = 300;
  3546. npc.ai[2] = 0f;
  3547. }
  3548. }
  3549. bool flag22 = false;
  3550. if (npc.velocity.Y == 0f)
  3551. {
  3552. int num160 = (int)(npc.position.Y + (float)npc.height + 7f) / 16;
  3553. int arg_AD06_0 = (int)npc.position.X / 16;
  3554. int num161 = (int)(npc.position.X + (float)npc.width) / 16;
  3555. for (int num162 = arg_AD06_0; num162 <= num161; num162++)
  3556. {
  3557. if (Main.tile[num162, num160] == null)
  3558. {
  3559. return;
  3560. }
  3561. if (Main.tile[num162, num160].nactive() && Main.tileSolid[(int)Main.tile[num162, num160].type])
  3562. {
  3563. flag22 = true;
  3564. break;
  3565. }
  3566. }
  3567. }
  3568. if (npc.type == 428)
  3569. {
  3570. flag22 = false;
  3571. }
  3572. if (npc.velocity.Y >= 0f)
  3573. {
  3574. int num163 = 0;
  3575. if (npc.velocity.X < 0f)
  3576. {
  3577. num163 = -1;
  3578. }
  3579. if (npc.velocity.X > 0f)
  3580. {
  3581. num163 = 1;
  3582. }
  3583. Vector2 position2 = npc.position;
  3584. position2.X += npc.velocity.X;
  3585. int num164 = (int)((position2.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num163)) / 16f);
  3586. int num165 = (int)((position2.Y + (float)npc.height - 1f) / 16f);
  3587. if (Main.tile[num164, num165] == null)
  3588. {
  3589. Main.tile[num164, num165] = new Tile();
  3590. }
  3591. if (Main.tile[num164, num165 - 1] == null)
  3592. {
  3593. Main.tile[num164, num165 - 1] = new Tile();
  3594. }
  3595. if (Main.tile[num164, num165 - 2] == null)
  3596. {
  3597. Main.tile[num164, num165 - 2] = new Tile();
  3598. }
  3599. if (Main.tile[num164, num165 - 3] == null)
  3600. {
  3601. Main.tile[num164, num165 - 3] = new Tile();
  3602. }
  3603. if (Main.tile[num164, num165 + 1] == null)
  3604. {
  3605. Main.tile[num164, num165 + 1] = new Tile();
  3606. }
  3607. if (Main.tile[num164 - num163, num165 - 3] == null)
  3608. {
  3609. Main.tile[num164 - num163, num165 - 3] = new Tile();
  3610. }
  3611. if ((float)(num164 * 16) < position2.X + (float)npc.width && (float)(num164 * 16 + 16) > position2.X && ((Main.tile[num164, num165].nactive() && !Main.tile[num164, num165].topSlope() && !Main.tile[num164, num165 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num164, num165].type] && !Main.tileSolidTop[(int)Main.tile[num164, num165].type]) || (Main.tile[num164, num165 - 1].halfBrick() && Main.tile[num164, num165 - 1].nactive())) && (!Main.tile[num164, num165 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 1].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 1].type] || (Main.tile[num164, num165 - 1].halfBrick() && (!Main.tile[num164, num165 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 4].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 4].type]))) && (!Main.tile[num164, num165 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 2].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 2].type]) && (!Main.tile[num164, num165 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 3].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 3].type]) && (!Main.tile[num164 - num163, num165 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num164 - num163, num165 - 3].type]))
  3612. {
  3613. float num166 = (float)(num165 * 16);
  3614. if (Main.tile[num164, num165].halfBrick())
  3615. {
  3616. num166 += 8f;
  3617. }
  3618. if (Main.tile[num164, num165 - 1].halfBrick())
  3619. {
  3620. num166 -= 8f;
  3621. }
  3622. if (num166 < position2.Y + (float)npc.height)
  3623. {
  3624. float num167 = position2.Y + (float)npc.height - num166;
  3625. float num168 = 16.1f;
  3626. if (npc.type == 163 || npc.type == 164 || npc.type == 236 || npc.type == 239 || npc.type == 530)
  3627. {
  3628. num168 += 8f;
  3629. }
  3630. if (num167 <= num168)
  3631. {
  3632. npc.gfxOffY += npc.position.Y + (float)npc.height - num166;
  3633. npc.position.Y = num166 - (float)npc.height;
  3634. if (num167 < 9f)
  3635. {
  3636. npc.stepSpeed = 4f;
  3637. }
  3638. else
  3639. {
  3640. npc.stepSpeed = 4f;
  3641. }
  3642. }
  3643. }
  3644. }
  3645. }
  3646. if (flag22)
  3647. {
  3648. int num169 = (int)((npc.position.X + (float)(npc.width / 2) + (float)(15 * npc.direction)) / 16f);
  3649. int num170 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f);
  3650. if (npc.type == 109 || npc.type == 163 || npc.type == 164 || npc.type == 199 || npc.type == 236 || npc.type == 239 || npc.type == 257 || npc.type == 258 || npc.type == 290 || npc.type == 391 || npc.type == 425 || npc.type == 427 || npc.type == 426 || npc.type == 508 || npc.type == 415 || npc.type == 530 || npc.type == 532)
  3651. {
  3652. num169 = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 16) * npc.direction)) / 16f);
  3653. }
  3654. if (Main.tile[num169, num170] == null)
  3655. {
  3656. Main.tile[num169, num170] = new Tile();
  3657. }
  3658. if (Main.tile[num169, num170 - 1] == null)
  3659. {
  3660. Main.tile[num169, num170 - 1] = new Tile();
  3661. }
  3662. if (Main.tile[num169, num170 - 2] == null)
  3663. {
  3664. Main.tile[num169, num170 - 2] = new Tile();
  3665. }
  3666. if (Main.tile[num169, num170 - 3] == null)
  3667. {
  3668. Main.tile[num169, num170 - 3] = new Tile();
  3669. }
  3670. if (Main.tile[num169, num170 + 1] == null)
  3671. {
  3672. Main.tile[num169, num170 + 1] = new Tile();
  3673. }
  3674. if (Main.tile[num169 + npc.direction, num170 - 1] == null)
  3675. {
  3676. Main.tile[num169 + npc.direction, num170 - 1] = new Tile();
  3677. }
  3678. if (Main.tile[num169 + npc.direction, num170 + 1] == null)
  3679. {
  3680. Main.tile[num169 + npc.direction, num170 + 1] = new Tile();
  3681. }
  3682. if (Main.tile[num169 - npc.direction, num170 + 1] == null)
  3683. {
  3684. Main.tile[num169 - npc.direction, num170 + 1] = new Tile();
  3685. }
  3686. Main.tile[num169, num170 + 1].halfBrick();
  3687. if ((Main.tile[num169, num170 - 1].nactive() && (TileLoader.IsClosedDoor(Main.tile[num169, num170 - 1]) || Main.tile[num169, num170 - 1].type == 388)) & flag5)
  3688. {
  3689. npc.ai[2] += 1f;
  3690. npc.ai[3] = 0f;
  3691. if (npc.ai[2] >= 60f)
  3692. {
  3693. if (!Main.bloodMoon && (npc.type == 3 || npc.type == 331 || npc.type == 332 || npc.type == 132 || npc.type == 161 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 200 || npc.type == 223 || npc.type == 320 || npc.type == 321 || npc.type == 319))
  3694. {
  3695. npc.ai[1] = 0f;
  3696. }
  3697. npc.velocity.X = 0.5f * -(float)npc.direction;
  3698. int num171 = 5;
  3699. if (Main.tile[num169, num170 - 1].type == 388)
  3700. {
  3701. num171 = 2;
  3702. }
  3703. npc.ai[1] += (float)num171;
  3704. if (npc.type == 27)
  3705. {
  3706. npc.ai[1] += 1f;
  3707. }
  3708. if (npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296)
  3709. {
  3710. npc.ai[1] += 6f;
  3711. }
  3712. npc.ai[2] = 0f;
  3713. bool flag23 = false;
  3714. if (npc.ai[1] >= 10f)
  3715. {
  3716. flag23 = true;
  3717. npc.ai[1] = 10f;
  3718. }
  3719. if (npc.type == 460)
  3720. {
  3721. flag23 = true;
  3722. }
  3723. WorldGen.KillTile(num169, num170 - 1, true, false, false);
  3724. if (((Main.netMode != 1 || !flag23) & flag23) && Main.netMode != 1)
  3725. {
  3726. if (npc.type == 26)
  3727. {
  3728. WorldGen.KillTile(num169, num170 - 1, false, false, false);
  3729. if (Main.netMode == 2)
  3730. {
  3731. NetMessage.SendData(17, -1, -1, null, 0, (float)num169, (float)(num170 - 1), 0f, 0, 0, 0);
  3732. }
  3733. }
  3734. else
  3735. {
  3736. if (TileLoader.OpenDoorID(Main.tile[num169, num170 - 1]) >= 0)
  3737. {
  3738. bool flag24 = WorldGen.OpenDoor(num169, num170 - 1, npc.direction);
  3739. if (!flag24)
  3740. {
  3741. npc.ai[3] = (float)num34;
  3742. npc.netUpdate = true;
  3743. }
  3744. if (Main.netMode == 2 & flag24)
  3745. {
  3746. NetMessage.SendData(19, -1, -1, null, 0, (float)num169, (float)(num170 - 1), (float)npc.direction, 0, 0, 0);
  3747. }
  3748. }
  3749. if (Main.tile[num169, num170 - 1].type == 388)
  3750. {
  3751. bool flag25 = WorldGen.ShiftTallGate(num169, num170 - 1, false);
  3752. if (!flag25)
  3753. {
  3754. npc.ai[3] = (float)num34;
  3755. npc.netUpdate = true;
  3756. }
  3757. if (Main.netMode == 2 & flag25)
  3758. {
  3759. NetMessage.SendData(19, -1, -1, null, 4, (float)num169, (float)(num170 - 1), 0f, 0, 0, 0);
  3760. }
  3761. }
  3762. }
  3763. }
  3764. }
  3765. }
  3766. else
  3767. {
  3768. int num172 = npc.spriteDirection;
  3769. if (npc.type == 425)
  3770. {
  3771. num172 *= -1;
  3772. }
  3773. if ((npc.velocity.X < 0f && num172 == -1) || (npc.velocity.X > 0f && num172 == 1))
  3774. {
  3775. if (npc.height >= 32 && Main.tile[num169, num170 - 2].nactive() && Main.tileSolid[(int)Main.tile[num169, num170 - 2].type])
  3776. {
  3777. if (Main.tile[num169, num170 - 3].nactive() && Main.tileSolid[(int)Main.tile[num169, num170 - 3].type])
  3778. {
  3779. npc.velocity.Y = -8f;
  3780. npc.netUpdate = true;
  3781. }
  3782. else
  3783. {
  3784. npc.velocity.Y = -7f;
  3785. npc.netUpdate = true;
  3786. }
  3787. }
  3788. else if (Main.tile[num169, num170 - 1].nactive() && Main.tileSolid[(int)Main.tile[num169, num170 - 1].type])
  3789. {
  3790. npc.velocity.Y = -6f;
  3791. npc.netUpdate = true;
  3792. }
  3793. else if (npc.position.Y + (float)npc.height - (float)(num170 * 16) > 20f && Main.tile[num169, num170].nactive() && !Main.tile[num169, num170].topSlope() && Main.tileSolid[(int)Main.tile[num169, num170].type])
  3794. {
  3795. npc.velocity.Y = -5f;
  3796. npc.netUpdate = true;
  3797. }
  3798. else if (npc.directionY < 0 && npc.type != 67 && (!Main.tile[num169, num170 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num169, num170 + 1].type]) && (!Main.tile[num169 + npc.direction, num170 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num169 + npc.direction, num170 + 1].type]))
  3799. {
  3800. npc.velocity.Y = -8f;
  3801. npc.velocity.X = npc.velocity.X * 1.5f;
  3802. npc.netUpdate = true;
  3803. }
  3804. else if (flag5)
  3805. {
  3806. npc.ai[1] = 0f;
  3807. npc.ai[2] = 0f;
  3808. }
  3809. if ((npc.velocity.Y == 0f & flag3) && npc.ai[3] == 1f)
  3810. {
  3811. npc.velocity.Y = -5f;
  3812. }
  3813. }
  3814. if ((npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 77 || npc.type == 104 || npc.type == 168 || npc.type == 196 || npc.type == 385 || npc.type == 389 || npc.type == 464 || npc.type == 470 || (npc.type >= 524 && npc.type <= 527)) && npc.velocity.Y == 0f && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 100f && Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f)))
  3815. {
  3816. npc.velocity.X = npc.velocity.X * 2f;
  3817. if (npc.velocity.X > 3f)
  3818. {
  3819. npc.velocity.X = 3f;
  3820. }
  3821. if (npc.velocity.X < -3f)
  3822. {
  3823. npc.velocity.X = -3f;
  3824. }
  3825. npc.velocity.Y = -4f;
  3826. npc.netUpdate = true;
  3827. }
  3828. if (npc.type == 120 && npc.velocity.Y < 0f)
  3829. {
  3830. npc.velocity.Y = npc.velocity.Y * 1.1f;
  3831. }
  3832. if (npc.type == 287 && npc.velocity.Y == 0f && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 150f && Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f)))
  3833. {
  3834. npc.velocity.X = (float)(8 * npc.direction);
  3835. npc.velocity.Y = -4f;
  3836. npc.netUpdate = true;
  3837. }
  3838. if (npc.type == 287 && npc.velocity.Y < 0f)
  3839. {
  3840. npc.velocity.X = npc.velocity.X * 1.2f;
  3841. npc.velocity.Y = npc.velocity.Y * 1.1f;
  3842. }
  3843. if (npc.type == 460 && npc.velocity.Y < 0f)
  3844. {
  3845. npc.velocity.X = npc.velocity.X * 1.3f;
  3846. npc.velocity.Y = npc.velocity.Y * 1.1f;
  3847. }
  3848. }
  3849. }
  3850. else if (flag5)
  3851. {
  3852. npc.ai[1] = 0f;
  3853. npc.ai[2] = 0f;
  3854. }
  3855. if (Main.netMode != 1 && npc.type == 120 && npc.ai[3] >= (float)num34)
  3856. {
  3857. int num173 = (int)Main.player[npc.target].position.X / 16;
  3858. int num174 = (int)Main.player[npc.target].position.Y / 16;
  3859. int num175 = (int)npc.position.X / 16;
  3860. int num176 = (int)npc.position.Y / 16;
  3861. int num177 = 20;
  3862. int num178 = 0;
  3863. bool flag26 = false;
  3864. if (Math.Abs(npc.position.X - Main.player[npc.target].position.X) + Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f)
  3865. {
  3866. num178 = 100;
  3867. flag26 = true;
  3868. }
  3869. while (!flag26 && num178 < 100)
  3870. {
  3871. num178++;
  3872. int num179 = Main.rand.Next(num173 - num177, num173 + num177);
  3873. for (int num180 = Main.rand.Next(num174 - num177, num174 + num177); num180 < num174 + num177; num180++)
  3874. {
  3875. if ((num180 < num174 - 4 || num180 > num174 + 4 || num179 < num173 - 4 || num179 > num173 + 4) && (num180 < num176 - 1 || num180 > num176 + 1 || num179 < num175 - 1 || num179 > num175 + 1) && Main.tile[num179, num180].nactive())
  3876. {
  3877. bool flag27 = true;
  3878. if (npc.type == 32 && Main.tile[num179, num180 - 1].wall == 0)
  3879. {
  3880. flag27 = false;
  3881. }
  3882. else if (Main.tile[num179, num180 - 1].lava())
  3883. {
  3884. flag27 = false;
  3885. }
  3886. if (flag27 && Main.tileSolid[(int)Main.tile[num179, num180].type] && !Collision.SolidTiles(num179 - 1, num179 + 1, num180 - 4, num180 - 1))
  3887. {
  3888. npc.position.X = (float)(num179 * 16 - npc.width / 2);
  3889. npc.position.Y = (float)(num180 * 16 - npc.height);
  3890. npc.netUpdate = true;
  3891. npc.ai[3] = -120f;
  3892. }
  3893. }
  3894. }
  3895. }
  3896. }
  3897. }
  3898. }
  3899. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement