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

◆ AI_065_Butterflies()

void Terraria.NPC.AI_065_Butterflies ( )
inlineprivate

Definition at line 45500 of file NPC.cs.

45501 {
45502 //IL_0042: Unknown result type (might be due to invalid IL or missing references)
45503 //IL_0047: Unknown result type (might be due to invalid IL or missing references)
45504 //IL_004b: Unknown result type (might be due to invalid IL or missing references)
45505 //IL_0055: Unknown result type (might be due to invalid IL or missing references)
45506 //IL_005a: Unknown result type (might be due to invalid IL or missing references)
45507 //IL_005b: Unknown result type (might be due to invalid IL or missing references)
45508 //IL_005c: Unknown result type (might be due to invalid IL or missing references)
45509 //IL_0066: Unknown result type (might be due to invalid IL or missing references)
45510 //IL_006b: Unknown result type (might be due to invalid IL or missing references)
45511 //IL_0070: Unknown result type (might be due to invalid IL or missing references)
45512 //IL_0072: Unknown result type (might be due to invalid IL or missing references)
45513 //IL_0077: Unknown result type (might be due to invalid IL or missing references)
45514 //IL_009c: Unknown result type (might be due to invalid IL or missing references)
45515 //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
45516 //IL_068a: Unknown result type (might be due to invalid IL or missing references)
45517 //IL_069b: Unknown result type (might be due to invalid IL or missing references)
45518 //IL_077e: Unknown result type (might be due to invalid IL or missing references)
45519 //IL_078f: Unknown result type (might be due to invalid IL or missing references)
45520 //IL_0476: Unknown result type (might be due to invalid IL or missing references)
45521 //IL_048c: Unknown result type (might be due to invalid IL or missing references)
45522 //IL_088f: Unknown result type (might be due to invalid IL or missing references)
45523 //IL_0894: Unknown result type (might be due to invalid IL or missing references)
45524 //IL_0912: Unknown result type (might be due to invalid IL or missing references)
45525 //IL_0916: Unknown result type (might be due to invalid IL or missing references)
45526 //IL_091b: Unknown result type (might be due to invalid IL or missing references)
45527 //IL_091d: Unknown result type (might be due to invalid IL or missing references)
45528 //IL_0924: Unknown result type (might be due to invalid IL or missing references)
45529 //IL_0929: Unknown result type (might be due to invalid IL or missing references)
45530 //IL_092d: Unknown result type (might be due to invalid IL or missing references)
45531 //IL_0932: Unknown result type (might be due to invalid IL or missing references)
45532 //IL_0934: Unknown result type (might be due to invalid IL or missing references)
45533 //IL_0939: Unknown result type (might be due to invalid IL or missing references)
45534 //IL_01d3: Unknown result type (might be due to invalid IL or missing references)
45535 //IL_01dd: Unknown result type (might be due to invalid IL or missing references)
45536 //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
45537 //IL_01e5: Unknown result type (might be due to invalid IL or missing references)
45538 //IL_0206: Unknown result type (might be due to invalid IL or missing references)
45539 //IL_021d: Unknown result type (might be due to invalid IL or missing references)
45540 //IL_0235: Unknown result type (might be due to invalid IL or missing references)
45541 //IL_023a: Unknown result type (might be due to invalid IL or missing references)
45542 //IL_023f: Unknown result type (might be due to invalid IL or missing references)
45543 //IL_024d: Unknown result type (might be due to invalid IL or missing references)
45544 //IL_0262: Unknown result type (might be due to invalid IL or missing references)
45545 //IL_0267: Unknown result type (might be due to invalid IL or missing references)
45546 //IL_0275: Unknown result type (might be due to invalid IL or missing references)
45547 //IL_027b: Unknown result type (might be due to invalid IL or missing references)
45548 //IL_0285: Unknown result type (might be due to invalid IL or missing references)
45549 //IL_028a: Unknown result type (might be due to invalid IL or missing references)
45550 //IL_028f: Unknown result type (might be due to invalid IL or missing references)
45551 //IL_0952: Unknown result type (might be due to invalid IL or missing references)
45552 //IL_0957: Unknown result type (might be due to invalid IL or missing references)
45553 //IL_095c: Unknown result type (might be due to invalid IL or missing references)
45554 //IL_0966: Unknown result type (might be due to invalid IL or missing references)
45555 //IL_096b: Unknown result type (might be due to invalid IL or missing references)
45556 //IL_0322: Unknown result type (might be due to invalid IL or missing references)
45557 //IL_032c: Unknown result type (might be due to invalid IL or missing references)
45558 //IL_0331: Unknown result type (might be due to invalid IL or missing references)
45559 //IL_08c3: Unknown result type (might be due to invalid IL or missing references)
45560 //IL_08c9: Unknown result type (might be due to invalid IL or missing references)
45561 //IL_0a31: Unknown result type (might be due to invalid IL or missing references)
45562 //IL_0a37: Unknown result type (might be due to invalid IL or missing references)
45563 //IL_0a3c: Unknown result type (might be due to invalid IL or missing references)
45564 //IL_0a41: Unknown result type (might be due to invalid IL or missing references)
45565 //IL_0a47: Unknown result type (might be due to invalid IL or missing references)
45566 //IL_0a56: Unknown result type (might be due to invalid IL or missing references)
45567 //IL_08e4: Unknown result type (might be due to invalid IL or missing references)
45568 //IL_08e9: Unknown result type (might be due to invalid IL or missing references)
45569 //IL_08ee: Unknown result type (might be due to invalid IL or missing references)
45570 //IL_08f3: Unknown result type (might be due to invalid IL or missing references)
45571 //IL_08f8: Unknown result type (might be due to invalid IL or missing references)
45572 //IL_0add: Unknown result type (might be due to invalid IL or missing references)
45573 //IL_0ae3: Unknown result type (might be due to invalid IL or missing references)
45574 //IL_0ae8: Unknown result type (might be due to invalid IL or missing references)
45575 //IL_0aed: Unknown result type (might be due to invalid IL or missing references)
45576 //IL_0a87: Unknown result type (might be due to invalid IL or missing references)
45577 //IL_0aaa: Unknown result type (might be due to invalid IL or missing references)
45578 //IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
45579 //IL_0ac7: Unknown result type (might be due to invalid IL or missing references)
45580 //IL_0ad1: Unknown result type (might be due to invalid IL or missing references)
45581 //IL_0ad6: Unknown result type (might be due to invalid IL or missing references)
45582 float num = ai[0];
45583 float num12 = ai[1];
45584 Color newColor2;
45585 if (type == 661)
45586 {
45587 newColor2 = Main.hslToRgb(Main.GlobalTimeWrappedHourly * 0.33f % 1f, 1f, 0.5f);
45588 Vector3 rgb = ((Color)(ref newColor2)).ToVector3() * 0.3f;
45589 rgb += Vector3.One * 0.1f;
45590 Lighting.AddLight(base.Center, rgb);
45591 int num22 = 60;
45592 bool flag = false;
45593 int num28 = 50;
45595 if (targetData.Invalid || targetData.Center.Distance(base.Center) >= 300f)
45596 {
45597 flag = true;
45598 }
45599 if (!Main.remixWorld && !targetData.Invalid && targetData.Type == NPCTargetType.Player && !Main.player[target].ZoneHallow)
45600 {
45601 num28 = num22;
45602 flag = true;
45603 }
45604 ai[2] = MathHelper.Clamp(ai[2] + (float)flag.ToDirectionInt(), 0f, (float)num28);
45605 if (ai[2] >= (float)num22)
45606 {
45607 active = false;
45608 if (Main.netMode != 1)
45609 {
45610 NetMessage.SendData(23, -1, -1, null, whoAmI);
45611 }
45612 return;
45613 }
45614 Opacity = Utils.GetLerpValue(num22, (float)num28 / 2f, ai[2], clamped: true);
45615 if (ai[2] > 0f)
45616 {
45617 int num29 = 1;
45618 for (int i = 0; i < num29; i++)
45619 {
45620 if (Main.rand.Next(5) == 0)
45621 {
45622 float num30 = MathHelper.Lerp(0.9f, 0.6f, Opacity);
45623 Color newColor = Main.hslToRgb(Main.GlobalTimeWrappedHourly * 0.3f % 1f, 1f, 0.5f) * 0.5f;
45624 int num31 = Dust.NewDust(position, width, height, 267, 0f, 0f, 0, newColor);
45625 Main.dust[num31].position = base.Center + Main.rand.NextVector2Circular(width, height);
45626 Dust obj = Main.dust[num31];
45627 obj.velocity *= Main.rand.NextFloat() * 0.8f;
45628 Dust obj2 = Main.dust[num31];
45629 obj2.velocity += velocity * 0.6f;
45630 Main.dust[num31].noGravity = true;
45631 Main.dust[num31].fadeIn = 0.6f + Main.rand.NextFloat() * 0.7f * num30;
45632 Main.dust[num31].scale = 0.35f;
45633 if (num31 != 6000)
45634 {
45635 Dust dust = Dust.CloneDust(num31);
45636 dust.scale /= 2f;
45637 dust.fadeIn *= 0.85f;
45638 dust.color = new Color(255, 255, 255, 255) * 0.5f;
45639 }
45640 }
45641 }
45642 }
45643 dontTakeDamage = ai[2] >= (float)(num28 / 2);
45644 }
45645 if (Main.netMode != 1)
45646 {
45647 if (ai[2] == 0f && type != 661)
45648 {
45649 int num32 = 0;
45650 int num33 = 4;
45651 int num2 = 6;
45652 int num3 = 3;
45653 int num4 = 7;
45654 int num5 = 2;
45655 int num6 = 1;
45656 int num7 = 5;
45657 int num8 = Main.rand.Next(100);
45658 num8 = ((num8 == 0) ? num7 : ((num8 < 3) ? num6 : ((num8 < 9) ? num5 : ((num8 < 19) ? num4 : ((num8 < 34) ? num3 : ((num8 < 53) ? num2 : ((num8 >= 75) ? num32 : num33)))))));
45659 ai[2] = 1 + num8;
45660 }
45661 if (ai[3] == 0f)
45662 {
45663 ai[3] = (float)Main.rand.Next(75, 111) * 0.01f;
45664 }
45665 localAI[0] -= 1f;
45666 if (localAI[0] <= 0f)
45667 {
45668 localAI[0] = Main.rand.Next(90, 240);
45669 TargetClosest();
45670 float num9 = Math.Abs(base.Center.X - Main.player[target].Center.X);
45671 if (num9 > 700f && localAI[3] == 0f)
45672 {
45673 float num10 = (float)Main.rand.Next(50, 151) * 0.01f;
45674 if (num9 > 1000f)
45675 {
45676 num10 = (float)Main.rand.Next(150, 201) * 0.01f;
45677 }
45678 else if (num9 > 850f)
45679 {
45680 num10 = (float)Main.rand.Next(100, 151) * 0.01f;
45681 }
45682 int num11 = direction * Main.rand.Next(100, 251);
45683 int num13 = Main.rand.Next(-50, 51);
45684 if (position.Y > Main.player[target].position.Y - 100f)
45685 {
45686 num13 -= Main.rand.Next(100, 251);
45687 }
45688 float num14 = num10 / (float)Math.Sqrt(num11 * num11 + num13 * num13);
45689 num = (float)num11 * num14;
45690 num12 = (float)num13 * num14;
45691 }
45692 else
45693 {
45694 localAI[3] = 1f;
45695 float num34 = (float)Main.rand.Next(26, 301) * 0.01f;
45696 int num15 = Main.rand.Next(-100, 101);
45697 int num16 = Main.rand.Next(-100, 101);
45698 float num17 = num34 / (float)Math.Sqrt(num15 * num15 + num16 * num16);
45699 num = (float)num15 * num17;
45700 num12 = (float)num16 * num17;
45701 }
45702 netUpdate = true;
45703 }
45704 }
45705 scale = ai[3];
45706 int num18 = 60;
45707 velocity.X = (velocity.X * (float)(num18 - 1) + num) / (float)num18;
45708 velocity.Y = (velocity.Y * (float)(num18 - 1) + num12) / (float)num18;
45709 if (velocity.Y > 0f)
45710 {
45711 int num19 = 3;
45712 int num20 = (int)base.Center.X / 16;
45713 int num21 = (int)base.Center.Y / 16;
45714 for (int j = num21; j < num21 + num19; j++)
45715 {
45716 if (Main.tile[num20, j] != null && ((Main.tile[num20, j].nactive() && Main.tileSolid[Main.tile[num20, j].type]) || Main.tile[num20, j].liquid > 0))
45717 {
45718 num12 *= -1f;
45719 if (velocity.Y > 0f)
45720 {
45721 velocity.Y *= 0.9f;
45722 }
45723 }
45724 }
45725 }
45726 if (velocity.Y < 0f)
45727 {
45728 int num23 = 30;
45729 bool flag2 = false;
45730 int num24 = (int)base.Center.X / 16;
45731 int num25 = (int)base.Center.Y / 16;
45732 for (int k = num25; k < num25 + num23; k++)
45733 {
45734 if (Main.tile[num24, k] != null && Main.tile[num24, k].nactive() && Main.tileSolid[Main.tile[num24, k].type])
45735 {
45736 flag2 = true;
45737 }
45738 }
45739 if (!flag2)
45740 {
45741 num12 *= -1f;
45742 if (velocity.Y < 0f)
45743 {
45744 velocity.Y *= 0.9f;
45745 }
45746 }
45747 }
45748 if (localAI[1] > 0f)
45749 {
45750 localAI[1] -= 1f;
45751 }
45752 else
45753 {
45754 localAI[1] = 15f;
45755 if (type == 661)
45756 {
45757 localAI[1] = 10f;
45758 }
45759 float num26 = 0f;
45760 Vector2 zero = Vector2.Zero;
45761 for (int l = 0; l < 200; l++)
45762 {
45763 NPC nPC = Main.npc[l];
45764 if (nPC.active && nPC.damage > 0 && !nPC.friendly && nPC.Hitbox.Distance(base.Center) <= 100f)
45765 {
45766 num26 += 1f;
45767 zero += DirectionFrom(nPC.Center);
45768 }
45769 }
45770 if (num26 > 0f)
45771 {
45772 zero /= num26;
45773 zero *= 2f;
45774 velocity += zero;
45775 if (((Vector2)(ref velocity)).Length() > 16f)
45776 {
45777 velocity = velocity.SafeNormalize(Vector2.Zero) * 16f;
45778 }
45779 }
45780 }
45781 if (collideX)
45782 {
45783 num = ((!(velocity.X < 0f)) ? (0f - Math.Abs(num)) : Math.Abs(num));
45784 velocity.X *= -0.2f;
45785 }
45786 if (velocity.X < 0f)
45787 {
45788 direction = -1;
45789 }
45790 if (velocity.X > 0f)
45791 {
45792 direction = 1;
45793 }
45794 ai[0] = num;
45795 ai[1] = num12;
45796 if (type == 356)
45797 {
45798 catchItem = (short)(1994f + ai[2] - 1f);
45799 }
45800 if (type == 653)
45801 {
45803 Lighting.AddLight((int)base.Center.X / 16, (int)base.Center.Y / 16, 0.6f, 0.3f, 0.1f);
45804 if (Main.rand.Next(60) == 0)
45805 {
45806 Vector2 val = position;
45807 int num35 = width;
45808 int num36 = height;
45809 newColor2 = default(Color);
45810 int num27 = Dust.NewDust(val, num35, num36, 6, 0f, 0f, 254, newColor2);
45811 Dust obj3 = Main.dust[num27];
45812 obj3.velocity *= 0f;
45813 }
45815 }
45816 }
Vector2 DirectionFrom(Vector2 Source)
Definition Entity.cs:298
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
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
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
Definition Entity.cs:21
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
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
float Opacity
Definition NPC.cs:1517
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:83247
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
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
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 catchItem
The numerical ID of the item that this NPC becomes when caught. Mainly used for critters that can be...
Definition NPC.cs:509
bool netUpdate
Definition NPC.cs:1130
int target
Definition NPC.cs:1019

References Terraria.Entity.active, Terraria.Lighting.AddLight(), Terraria.NPC.ai, Terraria.NPC.catchItem, Terraria.Dust.CloneDust(), Terraria.NPC.collideX, Terraria.Entity.direction, Terraria.Entity.DirectionFrom(), Terraria.NPC.dontTakeDamage, Terraria.Main.dust, Terraria.Utils.GetLerpValue(), Terraria.NPC.GetTargetData(), Terraria.Main.GlobalTimeWrappedHourly, Terraria.Entity.height, Terraria.Main.hslToRgb(), Terraria.NPC.localAI, Terraria.Main.netMode, Terraria.NPC.netOffset, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.Main.npc, Terraria.NPC.Opacity, Terraria.Main.player, Terraria.Entity.position, Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.NPC.scale, Terraria.NetMessage.SendData(), Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.NPC.type, Terraria.Entity.velocity, Terraria.Entity.whoAmI, and Terraria.Entity.width.

Referenced by Terraria.NPC.VanillaAI_Inner().

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