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

◆ AI_001_Slimes()

void Terraria.NPC.AI_001_Slimes ( )
inlineprivate

Definition at line 53292 of file NPC.cs.

53293 {
53294 if (type == 1 && (ai[1] == 1f || ai[1] == 2f || ai[1] == 3f))
53295 {
53296 ai[1] = -1f;
53297 }
53298 if (type == 1 && ai[1] == 75f)
53299 {
53300 float num = 0.3f;
53301 Lighting.AddLight((int)(base.Center.X / 16f), (int)(base.Center.Y / 16f), 0.8f * num, 0.7f * num, 0.1f * num);
53302 if (Main.rand.Next(12) == 0)
53303 {
53304 Dust dust = Dust.NewDustPerfect(base.Center + new Vector2(0f, (float)height * 0.2f) + Main.rand.NextVector2CircularEdge(width, (float)height * 0.6f) * (0.3f + Main.rand.NextFloat() * 0.5f), 228, new Vector2(0f, (0f - Main.rand.NextFloat()) * 0.3f - 1.5f), 127);
53305 dust.scale = 0.5f;
53306 dust.fadeIn = 1.1f;
53307 dust.noGravity = true;
53308 dust.noLight = true;
53309 }
53310 }
53311 if (type == 1 && ai[1] == 0f && Main.netMode != 1 && value > 0f)
53312 {
53313 ai[1] = -1f;
53314 if (Main.remixWorld && ai[0] != -999f && Main.rand.Next(3) == 0)
53315 {
53316 ai[1] = 75f;
53317 netUpdate = true;
53318 }
53319 else if (Main.rand.Next(20) == 0)
53320 {
53321 int num2 = AI_001_Slimes_GenerateItemInsideBody(ai[0] == -999f);
53322 ai[1] = num2;
53323 netUpdate = true;
53324 }
53325 }
53326 if (type == 1 && ai[0] == -999f)
53327 {
53328 frame.Y = 0;
53329 frameCounter = 0.0;
53330 rotation = 0f;
53331 return;
53332 }
53333 if (type == 244)
53334 {
53335 float num3 = (float)Main.DiscoR / 255f;
53336 float num4 = (float)Main.DiscoG / 255f;
53337 float num5 = (float)Main.DiscoB / 255f;
53338 num3 *= 1f;
53339 num4 *= 1f;
53340 num5 *= 1f;
53341 Lighting.AddLight((int)((position.X + (float)(width / 2)) / 16f), (int)((position.Y + (float)(height / 2)) / 16f), num3, num4, num5);
53343 }
53344 bool flag = false;
53345 if (!Main.dayTime || life != lifeMax || (double)position.Y > Main.worldSurface * 16.0 || Main.slimeRain)
53346 {
53347 flag = true;
53348 }
53349 if (Main.remixWorld && type == 59 && life == lifeMax)
53350 {
53351 flag = false;
53352 }
53353 if (type == 81)
53354 {
53355 flag = true;
53356 if (Main.rand.Next(30) == 0)
53357 {
53359 int num6 = Dust.NewDust(position, width, height, 14, 0f, 0f, alpha, this.color);
53360 Main.dust[num6].velocity *= 0.3f;
53362 }
53363 }
53364 if ((type == 377 || type == 446) && target != 255 && !Main.player[target].dead && Vector2.Distance(base.Center, Main.player[target].Center) <= 200f && !wet)
53365 {
53366 flag = true;
53367 }
53368 if (type == 183)
53369 {
53370 flag = true;
53371 }
53372 if (type == 304)
53373 {
53374 flag = true;
53375 }
53376 if (type == 667)
53377 {
53378 flag = true;
53379 }
53380 if (type == 244)
53381 {
53382 flag = true;
53383 ai[0] += 2f;
53384 }
53385 if (type == 147 && Main.rand.Next(10) == 0)
53386 {
53388 int num7 = Dust.NewDust(position, width, height, 76);
53389 Main.dust[num7].noGravity = true;
53390 Main.dust[num7].velocity *= 0.1f;
53392 }
53393 if (type == 667)
53394 {
53395 Color color = new Color(204, 181, 72, 255);
53396 Lighting.AddLight((int)(base.Center.X / 16f), (int)(base.Center.Y / 16f), (float)(int)color.R / 255f * 1.1f, (float)(int)color.G / 255f * 1.1f, (float)(int)color.B / 255f * 1.1f);
53397 if (velocity.Length() > 1f || Main.rand.Next(4) != 0)
53398 {
53399 int num8 = 8;
53400 Vector2 vector = position + new Vector2(-num8, -num8);
53401 int num9 = width + num8 * 2;
53402 int num10 = height + num8 * 2;
53404 int num11 = Dust.NewDust(vector, num9, num10, 246);
53405 Main.dust[num11].noGravity = true;
53406 Main.dust[num11].noLightEmittence = true;
53407 Main.dust[num11].velocity *= 0.2f;
53408 Main.dust[num11].scale = 1.5f;
53410 }
53411 }
53412 if (type == 676)
53413 {
53414 Lighting.AddLight(base.Center, 23);
53415 if ((velocity.Length() > 1f && Main.rand.Next(3) == 0) || Main.rand.Next(5) == 0)
53416 {
53417 Dust dust2 = Dust.NewDustPerfect(Main.rand.NextVector2FromRectangle(base.Hitbox), 306);
53418 dust2.noGravity = true;
53419 dust2.noLightEmittence = true;
53420 dust2.alpha = 127;
53421 dust2.color = Main.hslToRgb(((float)Main.timeForVisualEffects / 300f + Main.rand.NextFloat() * 0.1f) % 1f, 1f, 0.65f);
53422 dust2.color.A = 0;
53423 dust2.velocity = dust2.position - base.Center;
53424 dust2.velocity *= 0.1f;
53425 dust2.velocity.X *= 0.25f;
53426 if (dust2.velocity.Y > 0f)
53427 {
53428 dust2.velocity.Y *= -1f;
53429 }
53430 dust2.scale = Main.rand.NextFloat() * 0.3f + 0.5f;
53431 dust2.fadeIn = 0.9f;
53432 dust2.position += netOffset;
53433 }
53434 }
53435 if (type == 184)
53436 {
53437 if (Main.rand.Next(8) == 0)
53438 {
53440 int num12 = Dust.NewDust(position - velocity, width, height, 76);
53441 Main.dust[num12].noGravity = true;
53442 Main.dust[num12].velocity *= 0.15f;
53444 }
53445 flag = true;
53446 if (localAI[0] > 0f)
53447 {
53448 localAI[0] -= 1f;
53449 }
53450 if (!wet && !Main.player[target].npcTypeNoAggro[type])
53451 {
53452 Vector2 vector2 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
53453 float num13 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - vector2.X;
53454 float num14 = Main.player[target].position.Y - vector2.Y;
53455 float num15 = (float)Math.Sqrt(num13 * num13 + num14 * num14);
53456 if (Main.expertMode && num15 < 120f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53457 {
53458 ai[0] = -40f;
53459 if (velocity.Y == 0f)
53460 {
53461 velocity.X *= 0.9f;
53462 }
53463 if (Main.netMode != 1 && localAI[0] == 0f)
53464 {
53465 for (int i = 0; i < 5; i++)
53466 {
53467 Vector2 vector3 = new Vector2(i - 2, -4f);
53468 vector3.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
53469 vector3.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
53470 vector3.Normalize();
53471 vector3 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f;
53473 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector2.X, vector2.Y, vector3.X, vector3.Y, 174, attackDamage_ForProjectiles, 0f, Main.myPlayer);
53474 localAI[0] = 30f;
53475 }
53476 }
53477 }
53478 else if (num15 < 200f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53479 {
53480 ai[0] = -40f;
53481 if (velocity.Y == 0f)
53482 {
53483 velocity.X *= 0.9f;
53484 }
53485 if (Main.netMode != 1 && localAI[0] == 0f)
53486 {
53487 num14 = Main.player[target].position.Y - vector2.Y - (float)Main.rand.Next(0, 200);
53488 num15 = (float)Math.Sqrt(num13 * num13 + num14 * num14);
53489 num15 = 4.5f / num15;
53490 num13 *= num15;
53491 num14 *= num15;
53492 localAI[0] = 50f;
53493 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector2.X, vector2.Y, num13, num14, 174, 9, 0f, Main.myPlayer);
53494 }
53495 }
53496 }
53497 }
53498 if (type == 535)
53499 {
53500 flag = true;
53501 if (localAI[0] > 0f)
53502 {
53503 localAI[0] -= 1f;
53504 }
53505 if (!wet && !Main.player[target].npcTypeNoAggro[type])
53506 {
53507 Vector2 vector4 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
53508 float num16 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - vector4.X;
53509 float num17 = Main.player[target].position.Y - vector4.Y;
53510 float num18 = (float)Math.Sqrt(num16 * num16 + num17 * num17);
53511 if (Main.expertMode && num18 < 120f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53512 {
53513 ai[0] = -40f;
53514 if (velocity.Y == 0f)
53515 {
53516 velocity.X *= 0.9f;
53517 }
53518 if (Main.netMode != 1 && localAI[0] == 0f)
53519 {
53520 for (int j = 0; j < 5; j++)
53521 {
53522 Vector2 vector5 = new Vector2(j - 2, -4f);
53523 vector5.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
53524 vector5.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
53525 vector5.Normalize();
53526 vector5 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f;
53528 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector4.X, vector4.Y, vector5.X, vector5.Y, 605, attackDamage_ForProjectiles2, 0f, Main.myPlayer);
53529 localAI[0] = 30f;
53530 }
53531 }
53532 }
53533 else if (num18 < 200f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53534 {
53535 ai[0] = -40f;
53536 if (velocity.Y == 0f)
53537 {
53538 velocity.X *= 0.9f;
53539 }
53540 if (Main.netMode != 1 && localAI[0] == 0f)
53541 {
53542 num17 = Main.player[target].position.Y - vector4.Y - (float)Main.rand.Next(0, 200);
53543 num18 = (float)Math.Sqrt(num16 * num16 + num17 * num17);
53544 num18 = 4.5f / num18;
53545 num16 *= num18;
53546 num17 *= num18;
53547 localAI[0] = 50f;
53548 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector4.X, vector4.Y, num16, num17, 605, 9, 0f, Main.myPlayer);
53549 }
53550 }
53551 }
53552 }
53553 if (type == 658)
53554 {
53555 flag = true;
53556 if (localAI[0] > 0f)
53557 {
53558 localAI[0] -= 1f;
53559 }
53560 if (!wet && Main.player[target].active && !Main.player[target].dead && !Main.player[target].npcTypeNoAggro[type])
53561 {
53562 Player obj = Main.player[target];
53563 Vector2 center = base.Center;
53564 float num19 = obj.Center.X - center.X;
53565 float num20 = obj.Center.Y - center.Y;
53566 float num21 = (float)Math.Sqrt(num19 * num19 + num20 * num20);
53567 int num22 = CountNPCS(658);
53568 if (Main.expertMode && num22 < 5 && Math.Abs(num19) < 500f && Math.Abs(num20) < 550f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53569 {
53570 ai[0] = -40f;
53571 if (velocity.Y == 0f)
53572 {
53573 velocity.X *= 0.9f;
53574 }
53575 if (Main.netMode != 1 && localAI[0] == 0f)
53576 {
53577 for (int k = 0; k < 3; k++)
53578 {
53579 Vector2 vector6 = new Vector2(k - 1, -4f);
53580 vector6.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
53581 vector6.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
53582 vector6.Normalize();
53583 vector6 *= 6f + (float)Main.rand.Next(-50, 51) * 0.01f;
53584 if (num21 > 350f)
53585 {
53586 vector6 *= 2f;
53587 }
53588 else if (num21 > 250f)
53589 {
53590 vector6 *= 1.5f;
53591 }
53593 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), center.X, center.Y, vector6.X, vector6.Y, 920, attackDamage_ForProjectiles_MultiLerp, 0f, Main.myPlayer);
53594 localAI[0] = 25f;
53595 if (num22 > 4)
53596 {
53597 break;
53598 }
53599 }
53600 }
53601 }
53602 else if (Math.Abs(num19) < 500f && Math.Abs(num20) < 550f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53603 {
53604 float num23 = num21;
53605 ai[0] = -40f;
53606 if (velocity.Y == 0f)
53607 {
53608 velocity.X *= 0.9f;
53609 }
53610 if (Main.netMode != 1 && localAI[0] == 0f)
53611 {
53612 num20 = Main.player[target].position.Y - center.Y - (float)Main.rand.Next(0, 200);
53613 num21 = (float)Math.Sqrt(num19 * num19 + num20 * num20);
53614 num21 = 4.5f / num21;
53615 num21 *= 2f;
53616 if (num23 > 350f)
53617 {
53618 num21 *= 2f;
53619 }
53620 else if (num23 > 250f)
53621 {
53622 num21 *= 1.5f;
53623 }
53624 num19 *= num21;
53625 num20 *= num21;
53626 localAI[0] = 50f;
53628 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), center.X, center.Y, num19, num20, 920, attackDamage_ForProjectiles_MultiLerp2, 0f, Main.myPlayer);
53629 }
53630 }
53631 }
53632 }
53633 if (type == 659)
53634 {
53635 flag = true;
53636 if (localAI[0] > 0f)
53637 {
53638 localAI[0] -= 1f;
53639 }
53640 if (!wet && Main.player[target].active && !Main.player[target].dead && !Main.player[target].npcTypeNoAggro[type])
53641 {
53642 Player obj2 = Main.player[target];
53643 Vector2 center2 = base.Center;
53644 float num24 = obj2.Center.X - center2.X;
53645 float num25 = obj2.Center.Y - center2.Y;
53646 float num26 = (float)Math.Sqrt(num24 * num24 + num25 * num25);
53647 float num27 = num26;
53648 if (Math.Abs(num24) < 500f && Math.Abs(num25) < 550f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53649 {
53650 ai[0] = -40f;
53651 if (velocity.Y == 0f)
53652 {
53653 velocity.X *= 0.9f;
53654 }
53655 if (Main.netMode != 1 && localAI[0] == 0f)
53656 {
53657 num25 = Main.player[target].position.Y - center2.Y - (float)Main.rand.Next(0, 200);
53658 num26 = (float)Math.Sqrt(num24 * num24 + num25 * num25);
53659 num26 = 4.5f / num26;
53660 num26 *= 2f;
53661 if (num27 > 350f)
53662 {
53663 num26 *= 1.75f;
53664 }
53665 else if (num27 > 250f)
53666 {
53667 num26 *= 1.25f;
53668 }
53669 num24 *= num26;
53670 num25 *= num26;
53671 localAI[0] = 40f;
53672 if (Main.expertMode)
53673 {
53674 localAI[0] = 30f;
53675 }
53677 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), center2.X, center2.Y, num24, num25, 921, attackDamage_ForProjectiles_MultiLerp3, 0f, Main.myPlayer);
53678 }
53679 }
53680 }
53681 }
53682 if (type == 204)
53683 {
53684 flag = true;
53685 if (localAI[0] > 0f)
53686 {
53687 localAI[0] -= 1f;
53688 }
53689 if (!wet && !Main.player[target].npcTypeNoAggro[type])
53690 {
53691 Vector2 vector7 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
53692 float num28 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - vector7.X;
53693 float num29 = Main.player[target].position.Y - vector7.Y;
53694 float num30 = (float)Math.Sqrt(num28 * num28 + num29 * num29);
53695 if (Main.expertMode && num30 < 200f && Collision.CanHit(new Vector2(position.X, position.Y - 20f), width, height + 20, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53696 {
53697 ai[0] = -40f;
53698 if (velocity.Y == 0f)
53699 {
53700 velocity.X *= 0.9f;
53701 }
53702 if (Main.netMode != 1 && localAI[0] == 0f)
53703 {
53704 for (int l = 0; l < 5; l++)
53705 {
53706 Vector2 vector8 = new Vector2(l - 2, -2f);
53707 vector8.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.02f;
53708 vector8.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.02f;
53709 vector8.Normalize();
53710 vector8 *= 3f + (float)Main.rand.Next(-50, 51) * 0.01f;
53712 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector7.X, vector7.Y, vector8.X, vector8.Y, 176, attackDamage_ForProjectiles3, 0f, Main.myPlayer);
53713 localAI[0] = 80f;
53714 }
53715 }
53716 }
53717 if (num30 < 400f && Collision.CanHit(new Vector2(position.X, position.Y - 20f), width, height + 20, Main.player[target].position, Main.player[target].width, Main.player[target].height) && velocity.Y == 0f)
53718 {
53719 ai[0] = -80f;
53720 if (velocity.Y == 0f)
53721 {
53722 velocity.X *= 0.9f;
53723 }
53724 if (Main.netMode != 1 && localAI[0] == 0f)
53725 {
53726 num29 = Main.player[target].position.Y - vector7.Y - (float)Main.rand.Next(-30, 20);
53727 num29 -= num30 * 0.05f;
53728 num28 = Main.player[target].position.X - vector7.X - (float)Main.rand.Next(-20, 20);
53729 num30 = (float)Math.Sqrt(num28 * num28 + num29 * num29);
53730 num30 = 7f / num30;
53731 num28 *= num30;
53732 num29 *= num30;
53733 localAI[0] = 65f;
53734 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector7.X, vector7.Y, num28, num29, 176, 13, 0f, Main.myPlayer);
53735 }
53736 }
53737 }
53738 }
53739 if (type == 377 || type == 446)
53740 {
53741 if (localAI[2] < 90f)
53742 {
53743 localAI[2] += 1f;
53744 }
53745 else
53746 {
53747 friendly = false;
53748 }
53749 }
53750 if (type == 59)
53751 {
53753 Lighting.AddLight((int)((position.X + (float)(width / 2)) / 16f), (int)((position.Y + (float)(height / 2)) / 16f), 1f, 0.3f, 0.1f);
53754 int num31 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 6, velocity.X * 0.2f, velocity.Y * 0.2f, 100, default(Color), 1.7f);
53755 Main.dust[num31].noGravity = true;
53757 }
53758 if (ai[2] > 1f)
53759 {
53760 ai[2] -= 1f;
53761 }
53762 if (wet)
53763 {
53764 if (collideY)
53765 {
53766 velocity.Y = -2f;
53767 }
53768 if (velocity.Y < 0f && ai[3] == position.X)
53769 {
53770 direction *= -1;
53771 ai[2] = 200f;
53772 }
53773 if (velocity.Y > 0f)
53774 {
53775 ai[3] = position.X;
53776 }
53777 if (type == 59 && !Main.remixWorld)
53778 {
53779 if (velocity.Y > 2f)
53780 {
53781 velocity.Y *= 0.9f;
53782 }
53783 else if (directionY < 0)
53784 {
53785 velocity.Y -= 0.8f;
53786 }
53787 velocity.Y -= 0.5f;
53788 if (velocity.Y < -10f)
53789 {
53790 velocity.Y = -10f;
53791 }
53792 }
53793 else
53794 {
53795 if (velocity.Y > 2f)
53796 {
53797 velocity.Y *= 0.9f;
53798 }
53799 velocity.Y -= 0.5f;
53800 if (velocity.Y < -4f)
53801 {
53802 velocity.Y = -4f;
53803 }
53804 }
53805 if (ai[2] == 1f && flag)
53806 {
53807 TargetClosest();
53808 }
53809 }
53810 aiAction = 0;
53811 if (ai[2] == 0f)
53812 {
53813 ai[0] = -100f;
53814 ai[2] = 1f;
53815 TargetClosest();
53816 }
53817 if (velocity.Y == 0f)
53818 {
53819 if (collideY && oldVelocity.Y != 0f && Collision.SolidCollision(position, width, height))
53820 {
53821 position.X -= velocity.X + (float)direction;
53822 }
53823 if (ai[3] == position.X)
53824 {
53825 direction *= -1;
53826 ai[2] = 200f;
53827 }
53828 ai[3] = 0f;
53829 velocity.X *= 0.8f;
53830 if ((double)velocity.X > -0.1 && (double)velocity.X < 0.1)
53831 {
53832 velocity.X = 0f;
53833 }
53834 if (flag)
53835 {
53836 ai[0] += 1f;
53837 }
53838 ai[0] += 1f;
53839 if (type == 59 && !Main.remixWorld)
53840 {
53841 ai[0] += 2f;
53842 }
53843 if (type == 71)
53844 {
53845 ai[0] += 3f;
53846 }
53847 if (type == 667)
53848 {
53849 ai[0] += 3f;
53850 }
53851 if (type == 138)
53852 {
53853 ai[0] += 2f;
53854 }
53855 if (type == 183)
53856 {
53857 ai[0] += 1f;
53858 }
53859 if (type == 658)
53860 {
53861 ai[0] += 5f;
53862 }
53863 if (type == 659)
53864 {
53865 ai[0] += 3f;
53866 }
53867 if (type == 304)
53868 {
53869 float num32 = (1 - life / lifeMax) * 10;
53870 ai[0] += num32;
53871 }
53872 if (type == 377 || type == 446)
53873 {
53874 ai[0] += 3f;
53875 }
53876 if (type == 81)
53877 {
53878 if (scale >= 0f)
53879 {
53880 ai[0] += 4f;
53881 }
53882 else
53883 {
53884 ai[0] += 1f;
53885 }
53886 }
53887 float num33 = -1000f;
53888 if (type == 659)
53889 {
53890 num33 = -500f;
53891 }
53892 if (type == 667)
53893 {
53894 num33 = -400f;
53895 }
53896 int num34 = 0;
53897 if (ai[0] >= 0f)
53898 {
53899 num34 = 1;
53900 }
53901 if (ai[0] >= num33 && ai[0] <= num33 * 0.5f)
53902 {
53903 num34 = 2;
53904 }
53905 if (ai[0] >= num33 * 2f && ai[0] <= num33 * 1.5f)
53906 {
53907 num34 = 3;
53908 }
53909 if (num34 > 0)
53910 {
53911 netUpdate = true;
53912 if (flag && ai[2] == 1f)
53913 {
53914 TargetClosest();
53915 }
53916 if (num34 == 3)
53917 {
53918 velocity.Y = -8f;
53919 if (type == 59 && !Main.remixWorld)
53920 {
53921 velocity.Y -= 2f;
53922 }
53923 velocity.X += 3 * direction;
53924 if (type == 59 && !Main.remixWorld)
53925 {
53926 velocity.X += 0.5f * (float)direction;
53927 }
53928 ai[0] = -200f;
53929 ai[3] = position.X;
53930 }
53931 else
53932 {
53933 velocity.Y = -6f;
53934 velocity.X += 2 * direction;
53935 if (type == 59 && !Main.remixWorld)
53936 {
53937 velocity.X += 2 * direction;
53938 }
53939 ai[0] = -120f;
53940 if (num34 == 1)
53941 {
53942 ai[0] += num33;
53943 }
53944 else
53945 {
53946 ai[0] += num33 * 2f;
53947 }
53948 }
53949 if (type == 659)
53950 {
53951 velocity.Y *= 1.6f;
53952 velocity.X *= 1.2f;
53953 }
53954 if (type == 685)
53955 {
53956 velocity.Y *= 0.5f;
53957 velocity.X *= 0.2f;
53958 if (Main.rand.Next(2) == 0)
53959 {
53960 direction *= -1;
53961 }
53962 }
53963 if (type == 141)
53964 {
53965 velocity.Y *= 1.3f;
53966 velocity.X *= 1.2f;
53967 }
53968 if (type == 377 || type == 446)
53969 {
53970 velocity.Y *= 0.9f;
53971 velocity.X *= 0.6f;
53972 if (flag)
53973 {
53975 velocity.X *= -1f;
53976 }
53977 int i2 = (int)(base.Center.X / 16f);
53978 int j2 = (int)(base.Center.Y / 16f) - 1;
53979 if (WorldGen.SolidTile(i2, j2) && 0f - velocity.Y + (float)height > 16f)
53980 {
53981 velocity.Y = -(16 - height);
53982 }
53983 }
53984 }
53985 else if (ai[0] >= -30f)
53986 {
53987 aiAction = 1;
53988 }
53989 }
53990 else if (target < 255 && ((direction == 1 && velocity.X < 3f) || (direction == -1 && velocity.X > -3f)))
53991 {
53992 if (collideX && Math.Abs(velocity.X) == 0.2f)
53993 {
53994 position.X -= 1.4f * (float)direction;
53995 }
53996 if (collideY && oldVelocity.Y != 0f && Collision.SolidCollision(position, width, height))
53997 {
53998 position.X -= velocity.X + (float)direction;
53999 }
54000 if ((direction == -1 && (double)velocity.X < 0.01) || (direction == 1 && (double)velocity.X > -0.01))
54001 {
54002 velocity.X += 0.2f * (float)direction;
54003 }
54004 else
54005 {
54006 velocity.X *= 0.93f;
54007 }
54008 }
54009 }
static double Sqrt(double d)
static double Abs(double value)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
Vector2 oldVelocity
Definition Entity.cs:20
Vector2 netOffset
Definition NPC.cs:103
int GetAttackDamage_ForProjectiles_MultiLerp(float normalDamage, float expertDamage, float masterDamage)
Definition NPC.cs:1092
static int CountNPCS(int Type)
Definition NPC.cs:86664
float[] localAI
Definition NPC.cs:449
void AI_001_SetRainbowSlimeColor()
Definition NPC.cs:54011
int aiAction
Definition NPC.cs:451
int lifeMax
Definition NPC.cs:479
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
float[] ai
Definition NPC.cs:447
bool friendly
Definition NPC.cs:555
float value
Definition NPC.cs:523
float scale
Definition NPC.cs:493
bool collideX
Definition NPC.cs:511
bool collideY
Definition NPC.cs:513
int type
Definition NPC.cs:445
int alpha
Definition NPC.cs:489
Color color
Definition NPC.cs:487
float rotation
Definition NPC.cs:501
static int AI_001_Slimes_GenerateItemInsideBody(bool isBallooned)
Definition NPC.cs:54020
double frameCounter
Definition NPC.cs:483
int GetAttackDamage_ForProjectiles(float normalDamage, float expertDamage)
Definition NPC.cs:1082
int life
Definition NPC.cs:477
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
int directionY
Definition NPC.cs:443
bool netUpdate
Definition NPC.cs:507
int target
Definition NPC.cs:459
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References System.Math.Abs(), Terraria.Lighting.AddLight(), Terraria.NPC.ai, Terraria.NPC.AI_001_SetRainbowSlimeColor(), Terraria.NPC.AI_001_Slimes_GenerateItemInsideBody(), Terraria.NPC.aiAction, Terraria.NPC.alpha, Microsoft.Xna.Framework.Color.B, Terraria.Collision.CanHit(), Terraria.NPC.collideX, Terraria.NPC.collideY, Microsoft.Xna.Framework.Graphics.Color, Terraria.NPC.color, Terraria.NPC.CountNPCS(), Terraria.Main.dayTime, Terraria.Entity.direction, Terraria.NPC.directionY, Terraria.Main.DiscoB, Terraria.Main.DiscoG, Terraria.Main.DiscoR, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Main.dust, Terraria.Main.expertMode, Terraria.NPC.frameCounter, Terraria.NPC.friendly, Microsoft.Xna.Framework.Color.G, Terraria.NPC.GetAttackDamage_ForProjectiles(), Terraria.NPC.GetAttackDamage_ForProjectiles_MultiLerp(), Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.Entity.height, Terraria.Main.hslToRgb(), Microsoft.Xna.Framework.Vector2.Length(), Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.NPC.localAI, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netOffset, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.Dust.NewDustPerfect(), Terraria.Projectile.NewProjectile(), System.obj, Terraria.Entity.oldVelocity, Terraria.Main.player, Terraria.Entity.position, Microsoft.Xna.Framework.Color.R, Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.NPC.rotation, Terraria.NPC.scale, Terraria.Main.slimeRain, Terraria.Collision.SolidCollision(), Terraria.WorldGen.SolidTile(), System.Math.Sqrt(), Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.Main.timeForVisualEffects, Terraria.NPC.type, Terraria.NPC.value, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, Terraria.Entity.wet, Terraria.Entity.width, Terraria.Main.worldSurface, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.

Referenced by Terraria.NPC.AI().