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

◆ AI_005_EaterOfSouls()

void Terraria.NPC.AI_005_EaterOfSouls ( )
inlineprivate

Definition at line 53130 of file NPC.cs.

53131 {
53132 //IL_0092: Unknown result type (might be due to invalid IL or missing references)
53133 //IL_0098: Unknown result type (might be due to invalid IL or missing references)
53134 //IL_009d: Unknown result type (might be due to invalid IL or missing references)
53135 //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
53136 //IL_066d: Unknown result type (might be due to invalid IL or missing references)
53137 //IL_0684: Unknown result type (might be due to invalid IL or missing references)
53138 //IL_06b8: Unknown result type (might be due to invalid IL or missing references)
53139 //IL_06d0: Unknown result type (might be due to invalid IL or missing references)
53140 //IL_06e8: Unknown result type (might be due to invalid IL or missing references)
53141 //IL_06f4: Unknown result type (might be due to invalid IL or missing references)
53142 //IL_026c: Unknown result type (might be due to invalid IL or missing references)
53143 //IL_0272: Unknown result type (might be due to invalid IL or missing references)
53144 //IL_0277: Unknown result type (might be due to invalid IL or missing references)
53145 //IL_027c: Unknown result type (might be due to invalid IL or missing references)
53146 //IL_00dc: Unknown result type (might be due to invalid IL or missing references)
53147 //IL_00fb: Unknown result type (might be due to invalid IL or missing references)
53148 //IL_0101: Unknown result type (might be due to invalid IL or missing references)
53149 //IL_010f: Unknown result type (might be due to invalid IL or missing references)
53150 //IL_0119: Unknown result type (might be due to invalid IL or missing references)
53151 //IL_011e: Unknown result type (might be due to invalid IL or missing references)
53152 //IL_015c: Unknown result type (might be due to invalid IL or missing references)
53153 //IL_0162: Unknown result type (might be due to invalid IL or missing references)
53154 //IL_016c: Unknown result type (might be due to invalid IL or missing references)
53155 //IL_0171: Unknown result type (might be due to invalid IL or missing references)
53156 //IL_0176: Unknown result type (might be due to invalid IL or missing references)
53157 //IL_01bd: Unknown result type (might be due to invalid IL or missing references)
53158 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
53159 //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
53160 //IL_01f0: Unknown result type (might be due to invalid IL or missing references)
53161 //IL_01fa: Unknown result type (might be due to invalid IL or missing references)
53162 //IL_01ff: Unknown result type (might be due to invalid IL or missing references)
53163 //IL_023d: Unknown result type (might be due to invalid IL or missing references)
53164 //IL_0243: Unknown result type (might be due to invalid IL or missing references)
53165 //IL_024d: Unknown result type (might be due to invalid IL or missing references)
53166 //IL_0252: Unknown result type (might be due to invalid IL or missing references)
53167 //IL_0257: Unknown result type (might be due to invalid IL or missing references)
53168 //IL_09c6: Unknown result type (might be due to invalid IL or missing references)
53169 //IL_09d2: Unknown result type (might be due to invalid IL or missing references)
53170 //IL_0adc: Unknown result type (might be due to invalid IL or missing references)
53171 //IL_0ae1: Unknown result type (might be due to invalid IL or missing references)
53172 //IL_0ae3: Unknown result type (might be due to invalid IL or missing references)
53173 //IL_0ae8: Unknown result type (might be due to invalid IL or missing references)
53174 //IL_0aea: Unknown result type (might be due to invalid IL or missing references)
53175 //IL_0af6: Unknown result type (might be due to invalid IL or missing references)
53176 //IL_0afb: Unknown result type (might be due to invalid IL or missing references)
53177 //IL_0b00: Unknown result type (might be due to invalid IL or missing references)
53178 //IL_0b03: Unknown result type (might be due to invalid IL or missing references)
53179 //IL_0b0d: Unknown result type (might be due to invalid IL or missing references)
53180 //IL_0b12: Unknown result type (might be due to invalid IL or missing references)
53181 //IL_129f: Unknown result type (might be due to invalid IL or missing references)
53182 //IL_12a5: Unknown result type (might be due to invalid IL or missing references)
53183 //IL_12aa: Unknown result type (might be due to invalid IL or missing references)
53184 //IL_12af: Unknown result type (might be due to invalid IL or missing references)
53185 //IL_12c2: Unknown result type (might be due to invalid IL or missing references)
53186 //IL_12fa: Unknown result type (might be due to invalid IL or missing references)
53187 //IL_1300: Unknown result type (might be due to invalid IL or missing references)
53188 //IL_1317: Unknown result type (might be due to invalid IL or missing references)
53189 //IL_1321: Unknown result type (might be due to invalid IL or missing references)
53190 //IL_1326: Unknown result type (might be due to invalid IL or missing references)
53191 //IL_0e52: Unknown result type (might be due to invalid IL or missing references)
53192 //IL_0e59: Unknown result type (might be due to invalid IL or missing references)
53193 //IL_0e60: Unknown result type (might be due to invalid IL or missing references)
53194 //IL_0e67: Unknown result type (might be due to invalid IL or missing references)
53195 //IL_0e0d: Unknown result type (might be due to invalid IL or missing references)
53196 //IL_0e13: Unknown result type (might be due to invalid IL or missing references)
53197 //IL_0e18: Unknown result type (might be due to invalid IL or missing references)
53198 //IL_0e1e: Unknown result type (might be due to invalid IL or missing references)
53199 //IL_0e28: Unknown result type (might be due to invalid IL or missing references)
53200 //IL_0e2d: Unknown result type (might be due to invalid IL or missing references)
53201 //IL_0e39: Unknown result type (might be due to invalid IL or missing references)
53202 //IL_0e3e: Unknown result type (might be due to invalid IL or missing references)
53203 //IL_0e45: Unknown result type (might be due to invalid IL or missing references)
53204 //IL_0e4a: Unknown result type (might be due to invalid IL or missing references)
53205 //IL_147b: Unknown result type (might be due to invalid IL or missing references)
53206 //IL_1481: Unknown result type (might be due to invalid IL or missing references)
53207 //IL_1486: Unknown result type (might be due to invalid IL or missing references)
53208 //IL_148b: Unknown result type (might be due to invalid IL or missing references)
53209 //IL_1711: Unknown result type (might be due to invalid IL or missing references)
53210 //IL_14da: Unknown result type (might be due to invalid IL or missing references)
53211 //IL_1507: Unknown result type (might be due to invalid IL or missing references)
53212 //IL_150d: Unknown result type (might be due to invalid IL or missing references)
53213 //IL_1403: Unknown result type (might be due to invalid IL or missing references)
53214 //IL_1431: Unknown result type (might be due to invalid IL or missing references)
53215 //IL_1a99: Unknown result type (might be due to invalid IL or missing references)
53216 //IL_1a9e: Unknown result type (might be due to invalid IL or missing references)
53217 //IL_1aa0: Unknown result type (might be due to invalid IL or missing references)
53218 //IL_1aa3: Unknown result type (might be due to invalid IL or missing references)
53219 //IL_1aa8: Unknown result type (might be due to invalid IL or missing references)
53220 //IL_1aad: Unknown result type (might be due to invalid IL or missing references)
53221 //IL_1ac0: Unknown result type (might be due to invalid IL or missing references)
53222 //IL_1ac2: Unknown result type (might be due to invalid IL or missing references)
53223 //IL_1ac4: Unknown result type (might be due to invalid IL or missing references)
53224 //IL_1ac9: Unknown result type (might be due to invalid IL or missing references)
53225 //IL_1ad1: Unknown result type (might be due to invalid IL or missing references)
53226 //IL_1ad6: Unknown result type (might be due to invalid IL or missing references)
53227 //IL_1875: Unknown result type (might be due to invalid IL or missing references)
53228 //IL_187f: Unknown result type (might be due to invalid IL or missing references)
53229 //IL_189b: Unknown result type (might be due to invalid IL or missing references)
53230 //IL_18a5: Unknown result type (might be due to invalid IL or missing references)
53231 //IL_1959: Unknown result type (might be due to invalid IL or missing references)
53232 //IL_1960: Unknown result type (might be due to invalid IL or missing references)
53233 //IL_1d21: Unknown result type (might be due to invalid IL or missing references)
53234 //IL_1d28: Unknown result type (might be due to invalid IL or missing references)
53235 //IL_1d2d: Unknown result type (might be due to invalid IL or missing references)
53236 //IL_1d32: Unknown result type (might be due to invalid IL or missing references)
53237 //IL_1d48: Unknown result type (might be due to invalid IL or missing references)
53238 //IL_1d53: Unknown result type (might be due to invalid IL or missing references)
53239 //IL_1d5d: Unknown result type (might be due to invalid IL or missing references)
53240 //IL_1d62: Unknown result type (might be due to invalid IL or missing references)
53241 //IL_1d67: Unknown result type (might be due to invalid IL or missing references)
53242 //IL_1d6a: Unknown result type (might be due to invalid IL or missing references)
53243 //IL_1d6c: Unknown result type (might be due to invalid IL or missing references)
53244 //IL_1d76: Unknown result type (might be due to invalid IL or missing references)
53245 //IL_1d7b: Unknown result type (might be due to invalid IL or missing references)
53246 //IL_1d97: Unknown result type (might be due to invalid IL or missing references)
53247 //IL_1db2: Unknown result type (might be due to invalid IL or missing references)
53248 //IL_1dcc: Unknown result type (might be due to invalid IL or missing references)
53249 //IL_1dd1: Unknown result type (might be due to invalid IL or missing references)
53250 //IL_1dd6: Unknown result type (might be due to invalid IL or missing references)
53251 //IL_1ddf: Unknown result type (might be due to invalid IL or missing references)
53252 //IL_1de4: Unknown result type (might be due to invalid IL or missing references)
53253 //IL_1deb: Unknown result type (might be due to invalid IL or missing references)
53254 if (type == 210 || type == 211)
53255 {
53257 }
53258 else if (target < 0 || target <= 255 || Main.player[target].dead)
53259 {
53260 TargetClosest();
53261 }
53262 if (type == 619)
53263 {
53264 if (Main.dayTime)
53265 {
53266 velocity.Y -= 0.3f;
53267 EncourageDespawn(60);
53268 }
53270 if (alpha == 255)
53271 {
53273 velocity.Y = -6f;
53274 for (int i = 0; i < 35; i++)
53275 {
53276 Dust dust = Dust.NewDustDirect(position, width, height, 5);
53277 dust.velocity *= 1f;
53278 dust.scale = 1f + Main.rand.NextFloat() * 0.5f;
53279 dust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f;
53280 dust.velocity += velocity * 0.5f;
53281 }
53282 }
53283 alpha -= 15;
53284 if (alpha < 0)
53285 {
53286 alpha = 0;
53287 }
53288 if (alpha != 0)
53289 {
53290 for (int j = 0; j < 2; j++)
53291 {
53292 Dust dust2 = Dust.NewDustDirect(position, width, height, 5);
53293 dust2.velocity *= 1f;
53294 dust2.scale = 1f + Main.rand.NextFloat() * 0.5f;
53295 dust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f;
53296 dust2.velocity += velocity * 0.3f;
53297 }
53298 }
53300 }
53302 bool flag = false;
53303 if (targetData.Type == NPCTargetType.Player)
53304 {
53305 flag = Main.player[target].dead;
53306 }
53307 float num = 6f;
53308 float num12 = 0.05f;
53309 if (type == 6 || type == 173)
53310 {
53311 num = 4f;
53312 num12 = 0.02f;
53313 if (type == 6 && Main.expertMode)
53314 {
53315 num12 = 0.035f;
53316 }
53317 if (Main.remixWorld)
53318 {
53319 num12 = 0.06f;
53320 num = 5f;
53321 }
53322 }
53323 else if (type == 94)
53324 {
53325 num = 4.2f;
53326 num12 = 0.022f;
53327 }
53328 else if (type == 619)
53329 {
53330 num = 6f;
53331 num12 = 0.1f;
53332 }
53333 else if (type == 252)
53334 {
53335 if (targetData.Type != 0 && Collision.CanHit(this, targetData))
53336 {
53337 num = 6f;
53338 num12 = 0.1f;
53339 }
53340 else
53341 {
53342 num12 = 0.01f;
53343 num = 2f;
53344 }
53345 }
53346 else if (type == 42 || (type >= 231 && type <= 235))
53347 {
53348 num = 3.5f;
53349 num12 = 0.021f;
53350 if (type == 231)
53351 {
53352 num = 3f;
53353 num12 = 0.017f;
53354 }
53355 num *= 1f - scale;
53356 num12 *= 1f - scale;
53357 if ((double)(position.Y / 16f) < Main.worldSurface)
53358 {
53359 if (Main.player[target].position.Y - position.Y > 300f && velocity.Y < 0f)
53360 {
53361 velocity.Y *= 0.97f;
53362 }
53363 if (Main.player[target].position.Y - position.Y < 80f && velocity.Y > 0f)
53364 {
53365 velocity.Y *= 0.97f;
53366 }
53367 }
53368 }
53369 else if (type == 205)
53370 {
53371 num = 3.25f;
53372 num12 = 0.018f;
53373 }
53374 else if (type == 176)
53375 {
53376 num = 4f;
53377 num12 = 0.017f;
53378 }
53379 else if (type == 23)
53380 {
53381 num = 1f;
53382 num12 = 0.03f;
53383 }
53384 else if (type == 5)
53385 {
53386 num = 5f;
53387 num12 = 0.03f;
53388 }
53389 else if (type == 210 || type == 211)
53390 {
53391 ai[1] += 1f;
53392 float num22 = (ai[1] - 60f) / 60f;
53393 if (num22 > 1f)
53394 {
53395 num22 = 1f;
53396 }
53397 else
53398 {
53399 if (velocity.X > 6f)
53400 {
53401 velocity.X = 6f;
53402 }
53403 if (velocity.X < -6f)
53404 {
53405 velocity.X = -6f;
53406 }
53407 if (velocity.Y > 6f)
53408 {
53409 velocity.Y = 6f;
53410 }
53411 if (velocity.Y < -6f)
53412 {
53413 velocity.Y = -6f;
53414 }
53415 }
53416 num = 5f;
53417 num12 = 0.1f;
53418 num12 *= num22;
53419 }
53420 else if (type == 139 && Main.zenithWorld)
53421 {
53422 num = 3f;
53423 }
53424 Vector2 vector = default(Vector2);
53425 ((Vector2)(ref vector))._002Ector(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
53426 float num23 = targetData.Position.X + (float)(targetData.Width / 2);
53427 float num24 = targetData.Position.Y + (float)(targetData.Height / 2);
53428 num23 = (int)(num23 / 8f) * 8;
53429 num24 = (int)(num24 / 8f) * 8;
53430 vector.X = (int)(vector.X / 8f) * 8;
53431 vector.Y = (int)(vector.Y / 8f) * 8;
53432 num23 -= vector.X;
53433 num24 -= vector.Y;
53434 float num25 = (float)Math.Sqrt(num23 * num23 + num24 * num24);
53435 float num26 = num25;
53436 bool flag2 = false;
53437 if (num25 > 600f)
53438 {
53439 flag2 = true;
53440 }
53441 if (num25 == 0f)
53442 {
53443 num23 = velocity.X;
53444 num24 = velocity.Y;
53445 }
53446 else
53447 {
53448 num25 = num / num25;
53449 num23 *= num25;
53450 num24 *= num25;
53451 }
53452 bool num28 = type == 6 || type == 139 || type == 173 || type == 205;
53453 bool flag3 = type == 42 || type == 94 || type == 619 || type == 176 || type == 210 || type == 211 || (type >= 231 && type <= 235);
53454 bool flag4 = type != 173 && type != 6 && type != 42 && (type < 231 || type > 235) && type != 94 && type != 139 && type != 619;
53455 if (num28 || flag3)
53456 {
53457 if (num26 > 100f || flag3)
53458 {
53459 ai[0] += 1f;
53460 if (ai[0] > 0f)
53461 {
53462 velocity.Y += 0.023f;
53463 }
53464 else
53465 {
53466 velocity.Y -= 0.023f;
53467 }
53468 if (ai[0] < -100f || ai[0] > 100f)
53469 {
53470 velocity.X += 0.023f;
53471 }
53472 else
53473 {
53474 velocity.X -= 0.023f;
53475 }
53476 if (ai[0] > 200f)
53477 {
53478 ai[0] = -200f;
53479 }
53480 }
53481 if (num26 < 150f && (type == 6 || type == 94 || type == 173 || type == 619))
53482 {
53483 velocity.X += num23 * 0.007f;
53484 velocity.Y += num24 * 0.007f;
53485 }
53486 }
53487 if (flag)
53488 {
53489 num23 = (float)direction * num / 2f;
53490 num24 = (0f - num) / 2f;
53491 }
53492 else if (type == 619 && base.Center.Y > targetData.Center.Y - 200f)
53493 {
53494 velocity.Y -= 0.3f;
53495 }
53496 if (type == 139 && ai[3] != 0f)
53497 {
53498 if (IsMechQueenUp)
53499 {
53500 NPC nPC = Main.npc[mechQueen];
53501 Vector2 vector2 = default(Vector2);
53502 ((Vector2)(ref vector2))._002Ector(26f * ai[3], 0f);
53503 int num27 = (int)ai[2];
53504 if (num27 < 0 || num27 >= 200)
53505 {
53506 num27 = FindFirstNPC(134);
53507 ai[2] = num27;
53508 netUpdate = true;
53509 }
53510 if (num27 > -1)
53511 {
53512 NPC nPC2 = Main.npc[num27];
53513 if (!nPC2.active || nPC2.type != 134)
53514 {
53515 dontTakeDamage = false;
53516 if (ai[3] > 0f)
53517 {
53518 netUpdate = true;
53519 }
53520 ai[3] = 0f;
53521 }
53522 else
53523 {
53524 Vector2 spinningpoint = nPC2.Center + vector2;
53525 spinningpoint = spinningpoint.RotatedBy(nPC2.rotation, nPC2.Center);
53526 base.Center = spinningpoint;
53527 velocity = nPC.velocity;
53528 dontTakeDamage = true;
53529 }
53530 }
53531 else
53532 {
53533 dontTakeDamage = false;
53534 if (ai[3] > 0f)
53535 {
53536 netUpdate = true;
53537 }
53538 ai[3] = 0f;
53539 }
53540 }
53541 else
53542 {
53543 dontTakeDamage = false;
53544 if (ai[3] > 0f)
53545 {
53546 netUpdate = true;
53547 }
53548 ai[3] = 0f;
53549 }
53550 }
53551 else
53552 {
53553 if (type == 139)
53554 {
53555 dontTakeDamage = false;
53556 }
53557 if (velocity.X < num23)
53558 {
53559 velocity.X += num12;
53560 if (flag4 && velocity.X < 0f && num23 > 0f)
53561 {
53562 velocity.X += num12;
53563 }
53564 }
53565 else if (velocity.X > num23)
53566 {
53567 velocity.X -= num12;
53568 if (flag4 && velocity.X > 0f && num23 < 0f)
53569 {
53570 velocity.X -= num12;
53571 }
53572 }
53573 if (velocity.Y < num24)
53574 {
53575 velocity.Y += num12;
53576 if (flag4 && velocity.Y < 0f && num24 > 0f)
53577 {
53578 velocity.Y += num12;
53579 }
53580 }
53581 else if (velocity.Y > num24)
53582 {
53583 velocity.Y -= num12;
53584 if (flag4 && velocity.Y > 0f && num24 < 0f)
53585 {
53586 velocity.Y -= num12;
53587 }
53588 }
53589 }
53590 if (type == 23)
53591 {
53592 if (num23 > 0f)
53593 {
53594 spriteDirection = 1;
53595 rotation = (float)Math.Atan2(num24, num23);
53596 }
53597 else if (num23 < 0f)
53598 {
53599 spriteDirection = -1;
53600 rotation = (float)Math.Atan2(num24, num23) + 3.14f;
53601 }
53602 }
53603 else if (type == 139)
53604 {
53605 localAI[0] += 1f;
53606 if (ai[3] != 0f)
53607 {
53608 localAI[0] += 2f;
53609 }
53610 if (justHit)
53611 {
53612 localAI[0] = 0f;
53613 }
53614 float num2 = 120f;
53615 if (IsMechQueenUp)
53616 {
53617 num2 = 360f;
53618 }
53619 if (Main.netMode != 1 && localAI[0] >= num2)
53620 {
53621 localAI[0] = 0f;
53622 if (targetData.Type != 0 && Collision.CanHit(this, targetData))
53623 {
53625 int num3 = 84;
53626 Vector2 vector3 = default(Vector2);
53627 ((Vector2)(ref vector3))._002Ector(num23, num24);
53628 if (IsMechQueenUp)
53629 {
53630 Vector2 v3 = targetData.Center - base.Center - targetData.Velocity * 20f;
53631 float num4 = 8f;
53632 vector3 = v3.SafeNormalize(Vector2.UnitY) * num4;
53633 }
53634 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector.X, vector.Y, vector3.X, vector3.Y, num3, attackDamage_ForProjectiles, 0f, Main.myPlayer);
53635 }
53636 }
53637 int num5 = (int)position.X + width / 2;
53638 int num6 = (int)position.Y + height / 2;
53639 num5 /= 16;
53640 num6 /= 16;
53641 if (WorldGen.InWorld(num5, num6) && !WorldGen.SolidTile(num5, num6))
53642 {
53643 Lighting.AddLight((int)((position.X + (float)(width / 2)) / 16f), (int)((position.Y + (float)(height / 2)) / 16f), 0.3f, 0.1f, 0.05f);
53644 }
53645 if (num23 > 0f)
53646 {
53647 spriteDirection = 1;
53648 rotation = (float)Math.Atan2(num24, num23);
53649 }
53650 if (num23 < 0f)
53651 {
53652 spriteDirection = -1;
53653 rotation = (float)Math.Atan2(num24, num23) + 3.14f;
53654 }
53655 }
53656 else if (type == 6 || type == 94 || type == 173 || type == 619)
53657 {
53658 rotation = (float)Math.Atan2(num24, num23) - 1.57f;
53659 }
53660 else if (type == 42 || type == 176 || type == 205 || (type >= 231 && type <= 235))
53661 {
53662 if (velocity.X > 0f)
53663 {
53664 spriteDirection = 1;
53665 }
53666 if (velocity.X < 0f)
53667 {
53668 spriteDirection = -1;
53669 }
53670 rotation = velocity.X * 0.1f;
53671 }
53672 else
53673 {
53674 rotation = (float)Math.Atan2(velocity.Y, velocity.X) - 1.57f;
53675 }
53676 if (type == 6 || type == 619 || type == 23 || type == 42 || type == 94 || type == 139 || type == 173 || type == 176 || type == 205 || type == 210 || type == 211 || (type >= 231 && type <= 235))
53677 {
53678 float num7 = 0.7f;
53679 if (type == 6 || type == 173)
53680 {
53681 num7 = 0.4f;
53682 }
53683 if (collideX)
53684 {
53685 netUpdate = true;
53686 velocity.X = oldVelocity.X * (0f - num7);
53687 if (direction == -1 && velocity.X > 0f && velocity.X < 2f)
53688 {
53689 velocity.X = 2f;
53690 }
53691 if (direction == 1 && velocity.X < 0f && velocity.X > -2f)
53692 {
53693 velocity.X = -2f;
53694 }
53695 }
53696 if (collideY)
53697 {
53698 netUpdate = true;
53699 velocity.Y = oldVelocity.Y * (0f - num7);
53700 if (velocity.Y > 0f && (double)velocity.Y < 1.5)
53701 {
53702 velocity.Y = 2f;
53703 }
53704 if (velocity.Y < 0f && (double)velocity.Y > -1.5)
53705 {
53706 velocity.Y = -2f;
53707 }
53708 }
53710 if (type == 619)
53711 {
53712 int num8 = Dust.NewDust(position, width, height, 5, velocity.X * 0.2f, velocity.Y * 0.2f, 100);
53713 Dust obj = Main.dust[num8];
53714 obj.velocity *= 0.5f;
53715 }
53716 else if (type != 42 && type != 139 && type != 176 && type != 205 && type != 210 && type != 211 && type != 252 && (type < 231 || type > 235) && Main.rand.Next(20) == 0)
53717 {
53718 int num9 = 18;
53719 if (type == 173)
53720 {
53721 num9 = 5;
53722 }
53723 int num10 = Dust.NewDust(new Vector2(position.X, position.Y + (float)height * 0.25f), width, (int)((float)height * 0.5f), num9, velocity.X, 2f, 75, color, scale);
53724 Main.dust[num10].velocity.X *= 0.5f;
53725 Main.dust[num10].velocity.Y *= 0.1f;
53726 }
53728 }
53729 else if (type != 252 && Main.rand.Next(40) == 0)
53730 {
53731 int num11 = Dust.NewDust(new Vector2(position.X, position.Y + (float)height * 0.25f), width, (int)((float)height * 0.5f), 5, velocity.X, 2f);
53732 Main.dust[num11].velocity.X *= 0.5f;
53733 Main.dust[num11].velocity.Y *= 0.1f;
53734 }
53735 if ((type == 6 || type == 94 || type == 173 || type == 619) && wet)
53736 {
53737 if (velocity.Y > 0f)
53738 {
53739 velocity.Y *= 0.95f;
53740 }
53741 velocity.Y -= 0.3f;
53742 if (velocity.Y < -2f)
53743 {
53744 velocity.Y = -2f;
53745 }
53746 }
53747 if (type == 205 && wet)
53748 {
53749 if (velocity.Y > 0f)
53750 {
53751 velocity.Y *= 0.95f;
53752 }
53753 velocity.Y -= 0.5f;
53754 if (velocity.Y < -4f)
53755 {
53756 velocity.Y = -4f;
53757 }
53758 TargetClosest();
53759 }
53760 if (type == 42 || type == 176 || (type >= 231 && type <= 235))
53761 {
53762 if (wet)
53763 {
53764 if (velocity.Y > 0f)
53765 {
53766 velocity.Y *= 0.95f;
53767 }
53768 velocity.Y -= 0.5f;
53769 if (velocity.Y < -4f)
53770 {
53771 velocity.Y = -4f;
53772 }
53773 TargetClosest();
53774 }
53775 if (ai[1] == 101f)
53776 {
53778 ai[1] = 0f;
53779 }
53780 if (Main.netMode != 1)
53781 {
53782 ai[1] += (float)Main.rand.Next(5, 20) * 0.1f * scale;
53783 if (type == 176)
53784 {
53785 ai[1] += (float)Main.rand.Next(5, 20) * 0.1f * scale;
53786 }
53787 if (Main.getGoodWorld)
53788 {
53789 ai[1] += (float)Main.rand.Next(5, 20) * 0.1f * scale;
53790 }
53791 if (targetData.Type == NPCTargetType.Player)
53792 {
53793 Player player = Main.player[target];
53794 if (player != null && player.stealth == 0f && player.itemAnimation == 0)
53795 {
53796 ai[1] = 0f;
53797 }
53798 }
53799 if (ai[1] >= 130f)
53800 {
53801 if (targetData.Type != 0 && Collision.CanHit(this, targetData))
53802 {
53803 float num13 = 8f;
53804 Vector2 vector4 = default(Vector2);
53805 ((Vector2)(ref vector4))._002Ector(position.X + (float)width * 0.5f, position.Y + (float)(height / 2));
53806 float num14 = targetData.Center.X - vector4.X + (float)Main.rand.Next(-20, 21);
53807 float num15 = targetData.Center.Y - vector4.Y + (float)Main.rand.Next(-20, 21);
53808 if ((num14 < 0f && velocity.X < 0f) || (num14 > 0f && velocity.X > 0f))
53809 {
53810 float num16 = (float)Math.Sqrt(num14 * num14 + num15 * num15);
53811 num16 = num13 / num16;
53812 num14 *= num16;
53813 num15 *= num16;
53814 int num17 = (int)(10f * scale);
53815 if (type == 176)
53816 {
53817 num17 = (int)(30f * scale);
53818 }
53819 int num18 = 55;
53820 int num19 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector4.X, vector4.Y, num14, num15, num18, num17, 0f, Main.myPlayer);
53821 Main.projectile[num19].timeLeft = 300;
53822 ai[1] = 101f;
53823 netUpdate = true;
53824 }
53825 else
53826 {
53827 ai[1] = 0f;
53828 }
53829 }
53830 else
53831 {
53832 ai[1] = 0f;
53833 }
53834 }
53835 }
53836 }
53837 if (type == 139 && flag2)
53838 {
53839 if ((velocity.X > 0f && num23 > 0f) || (velocity.X < 0f && num23 < 0f))
53840 {
53841 int num20 = 12;
53842 if (IsMechQueenUp)
53843 {
53844 num20 = 5;
53845 }
53846 if (Math.Abs(velocity.X) < (float)num20)
53847 {
53848 velocity.X *= 1.05f;
53849 }
53850 }
53851 else
53852 {
53853 velocity.X *= 0.9f;
53854 }
53855 }
53856 if (type == 139 && IsMechQueenUp && ai[2] == 0f)
53857 {
53858 Vector2 center = GetTargetData().Center;
53859 Vector2 v2 = center - base.Center;
53860 int num21 = 120;
53861 if (((Vector2)(ref v2)).Length() < (float)num21)
53862 {
53863 base.Center = center - v2.SafeNormalize(Vector2.UnitY) * (float)num21;
53864 }
53865 }
53866 if (Main.netMode != 1)
53867 {
53868 if (Main.getGoodWorld && type == 6 && AnyNPCs(13))
53869 {
53870 if (justHit)
53871 {
53872 localAI[0] = 0f;
53873 }
53874 localAI[0] += 1f;
53875 if (localAI[0] == 60f)
53876 {
53877 if (targetData.Type != 0 && Collision.CanHit(this, targetData))
53878 {
53879 NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)(position.X + (float)(width / 2) + velocity.X), (int)(position.Y + (float)(height / 2) + velocity.Y), 666);
53880 }
53881 localAI[0] = 0f;
53882 }
53883 }
53884 if (type == 94 && !flag)
53885 {
53886 if (justHit)
53887 {
53888 localAI[0] = 0f;
53889 }
53890 localAI[0] += 1f;
53891 if (localAI[0] == 180f)
53892 {
53893 if (targetData.Type != 0 && Collision.CanHit(this, targetData))
53894 {
53895 NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)(position.X + (float)(width / 2) + velocity.X), (int)(position.Y + (float)(height / 2) + velocity.Y), 112);
53896 }
53897 localAI[0] = 0f;
53898 }
53899 }
53900 if (type == 619 && !flag)
53901 {
53902 if (justHit)
53903 {
53904 localAI[0] += 10f;
53905 }
53906 localAI[0] += 1f;
53907 if (localAI[0] >= 120f)
53908 {
53909 if (targetData.Type != 0 && Collision.CanHit(this, targetData))
53910 {
53911 Vector2 val = base.Center - targetData.Center;
53912 if (((Vector2)(ref val)).Length() < 400f)
53913 {
53914 Vector2 vector5 = DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y));
53915 velocity = -vector5 * 5f;
53916 netUpdate = true;
53917 localAI[0] = 0f;
53918 vector5 = DirectionTo(new Vector2(targetData.Center.X + (float)Main.rand.Next(-100, 101), targetData.Position.Y + (float)Main.rand.Next(-100, 101)));
53919 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center, vector5 * 15f, 811, 35, 1f, Main.myPlayer);
53920 }
53921 else
53922 {
53923 localAI[0] = 50f;
53924 }
53925 }
53926 else
53927 {
53928 localAI[0] = 50f;
53929 }
53930 }
53931 }
53932 }
53933 if ((Main.IsItDay() && type != 173 && type != 619 && type != 6 && type != 23 && type != 42 && type != 94 && type != 176 && type != 205 && type != 210 && type != 211 && type != 252 && (type < 231 || type > 235)) || flag)
53934 {
53935 velocity.Y -= num12 * 2f;
53936 EncourageDespawn(10);
53937 }
53938 if (((velocity.X > 0f && oldVelocity.X < 0f) || (velocity.X < 0f && oldVelocity.X > 0f) || (velocity.Y > 0f && oldVelocity.Y < 0f) || (velocity.Y < 0f && oldVelocity.Y > 0f)) && !justHit)
53939 {
53940 netUpdate = true;
53941 }
53942 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
bool wet
The Entity is currently in water. Projectile: Affects movement speed and some projectiles die when ...
Definition Entity.cs:57
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
Vector2 oldVelocity
Definition Entity.cs:37
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:289
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static readonly SoundStyle Item17
Definition SoundID.cs:711
Vector2 netOffset
Definition NPC.cs:502
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
Definition NPC.cs:1003
int spriteDirection
Definition NPC.cs:1143
void EncourageDespawn(int despawnTime)
Definition NPC.cs:2199
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:83247
static int FindFirstNPC(int Type)
Returns the index within F:Terraria.Main.npc of the the first active NPC in the world of the given NP...
Definition NPC.cs:106632
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:1668
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
Definition NPC.cs:997
bool dontTakeDamage
Definition NPC.cs:1160
static bool IsMechQueenUp
Definition NPC.cs:1541
float scale
Makes the NPC bigger or smaller. Bigger than 1f is bigger. Defaults to 1f.
Definition NPC.cs:1104
bool collideX
Definition NPC.cs:1134
bool collideY
Definition NPC.cs:1136
static bool AnyNPCs(int Type)
Returns true if there are any active NPC in the world of the given NPC type (F:Terraria....
Definition NPC.cs:106615
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990
int alpha
0 is opaque, and 255 is transparent. Note that this is the opposite of how alpha is typically express...
Definition NPC.cs:1092
Color color
Definition NPC.cs:1085
float rotation
Definition NPC.cs:1116
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:107568
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Spawns an NPC into the game world with the given type. This method should not be called on multipla...
Definition NPC.cs:91239
int GetAttackDamage_ForProjectiles(float normalDamage, float expertDamage)
Definition NPC.cs:1891
bool justHit
Definition NPC.cs:1015
static int mechQueen
Definition NPC.cs:1223
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:107558
bool netUpdate
Definition NPC.cs:1130
int target
Definition NPC.cs:1019
static void TargetClosestNonBees(NPC searcher, bool faceTarget=true, Vector2? checkPosition=null)
Definition NPCUtils.cs:296

References Terraria.Lighting.AddLight(), Terraria.NPC.ai, Terraria.NPC.alpha, Terraria.NPC.AnyNPCs(), Terraria.Collision.CanHit(), Terraria.DataStructures.NPCAimedTarget.Center, Terraria.NPC.collideX, Terraria.NPC.collideY, Terraria.NPC.color, Terraria.Main.dayTime, Terraria.Entity.direction, Terraria.Entity.DirectionTo(), Terraria.NPC.dontTakeDamage, Terraria.Main.dust, Terraria.NPC.EncourageDespawn(), Terraria.Main.expertMode, Terraria.NPC.FindFirstNPC(), Terraria.NPC.GetAttackDamage_ForProjectiles(), Terraria.Main.getGoodWorld, Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetSpawnSourceForNPCFromNPCAI(), Terraria.NPC.GetTargetData(), Terraria.Entity.height, Terraria.WorldGen.InWorld(), Terraria.Main.IsItDay(), Terraria.NPC.IsMechQueenUp, Terraria.ID.SoundID.Item17, Terraria.Player.itemAnimation, Terraria.NPC.justHit, Terraria.NPC.localAI, Terraria.NPC.mechQueen, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netOffset, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), Terraria.NPC.NewNPC(), Terraria.Projectile.NewProjectile(), Terraria.Main.npc, Terraria.Entity.oldVelocity, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.projectile, Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.NPC.rotation, Terraria.NPC.scale, Terraria.WorldGen.SolidTile(), Terraria.NPC.spriteDirection, Terraria.Player.stealth, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.Utilities.NPCUtils.TargetClosestNonBees(), Terraria.NPC.type, Terraria.Entity.velocity, Terraria.Entity.wet, Terraria.Entity.width, Terraria.Main.worldSurface, and Terraria.Main.zenithWorld.

Referenced by Terraria.NPC.VanillaAI_Inner().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: