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

◆ AI_002_FloatingEye()

void Terraria.NPC.AI_002_FloatingEye ( )
inlineprivate

Definition at line 55518 of file NPC.cs.

55519 {
55520 //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
55521 //IL_023b: Unknown result type (might be due to invalid IL or missing references)
55522 //IL_0258: Unknown result type (might be due to invalid IL or missing references)
55523 //IL_0296: Unknown result type (might be due to invalid IL or missing references)
55524 //IL_0a4a: Unknown result type (might be due to invalid IL or missing references)
55525 //IL_0a50: Unknown result type (might be due to invalid IL or missing references)
55526 //IL_0a55: Unknown result type (might be due to invalid IL or missing references)
55527 //IL_0a5a: Unknown result type (might be due to invalid IL or missing references)
55528 //IL_0a83: Unknown result type (might be due to invalid IL or missing references)
55529 //IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
55530 //IL_0ab6: Unknown result type (might be due to invalid IL or missing references)
55531 //IL_0af8: Unknown result type (might be due to invalid IL or missing references)
55532 //IL_0afe: Unknown result type (might be due to invalid IL or missing references)
55533 //IL_0b03: Unknown result type (might be due to invalid IL or missing references)
55534 //IL_0b08: Unknown result type (might be due to invalid IL or missing references)
55535 //IL_13e6: Unknown result type (might be due to invalid IL or missing references)
55536 //IL_13ec: Unknown result type (might be due to invalid IL or missing references)
55537 //IL_13f1: Unknown result type (might be due to invalid IL or missing references)
55538 //IL_13f6: Unknown result type (might be due to invalid IL or missing references)
55539 //IL_141f: Unknown result type (might be due to invalid IL or missing references)
55540 //IL_144c: Unknown result type (might be due to invalid IL or missing references)
55541 //IL_1452: Unknown result type (might be due to invalid IL or missing references)
55542 //IL_1497: Unknown result type (might be due to invalid IL or missing references)
55543 //IL_149d: Unknown result type (might be due to invalid IL or missing references)
55544 //IL_14a2: Unknown result type (might be due to invalid IL or missing references)
55545 //IL_14a7: Unknown result type (might be due to invalid IL or missing references)
55546 if ((type == 170 || type == 171 || type == 180) && Main.rand.Next(1000) == 0)
55547 {
55548 SoundEngine.PlaySound(29, (int)position.X, (int)position.Y, 9);
55549 }
55550 noGravity = true;
55551 if (!noTileCollide)
55552 {
55553 if (collideX)
55554 {
55555 velocity.X = oldVelocity.X * -0.5f;
55556 if (direction == -1 && velocity.X > 0f && velocity.X < 2f)
55557 {
55558 velocity.X = 2f;
55559 }
55560 if (direction == 1 && velocity.X < 0f && velocity.X > -2f)
55561 {
55562 velocity.X = -2f;
55563 }
55564 }
55565 if (collideY)
55566 {
55567 velocity.Y = oldVelocity.Y * -0.5f;
55568 if (velocity.Y > 0f && velocity.Y < 1f)
55569 {
55570 velocity.Y = 1f;
55571 }
55572 if (velocity.Y < 0f && velocity.Y > -1f)
55573 {
55574 velocity.Y = -1f;
55575 }
55576 }
55577 }
55579 {
55580 EncourageDespawn(10);
55581 directionY = -1;
55582 if (velocity.Y > 0f)
55583 {
55584 direction = 1;
55585 }
55586 direction = -1;
55587 if (velocity.X > 0f)
55588 {
55589 direction = 1;
55590 }
55591 }
55592 else
55593 {
55594 TargetClosest();
55595 }
55596 if (type == 170 || type == 171 || type == 180)
55597 {
55598 if (Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
55599 {
55600 if (ai[1] > 0f && !Collision.SolidCollision(position, width, height))
55601 {
55602 ai[1] = 0f;
55603 ai[0] = 0f;
55604 netUpdate = true;
55605 }
55606 }
55607 else if (ai[1] == 0f)
55608 {
55609 ai[0] += 1f;
55610 }
55611 if (ai[0] >= 300f)
55612 {
55613 ai[1] = 1f;
55614 ai[0] = 0f;
55615 netUpdate = true;
55616 }
55617 if (ai[1] == 0f)
55618 {
55619 alpha = 0;
55620 noTileCollide = false;
55621 }
55622 else
55623 {
55624 wet = false;
55625 alpha = 200;
55626 noTileCollide = true;
55627 }
55628 rotation = velocity.Y * 0.1f * (float)direction;
55629 TargetClosest();
55630 if (direction == -1 && velocity.X > -4f && position.X > Main.player[target].position.X + (float)Main.player[target].width)
55631 {
55632 velocity.X -= 0.08f;
55633 if (velocity.X > 4f)
55634 {
55635 velocity.X -= 0.04f;
55636 }
55637 else if (velocity.X > 0f)
55638 {
55639 velocity.X -= 0.2f;
55640 }
55641 if (velocity.X < -4f)
55642 {
55643 velocity.X = -4f;
55644 }
55645 }
55646 else if (direction == 1 && velocity.X < 4f && position.X + (float)width < Main.player[target].position.X)
55647 {
55648 velocity.X += 0.08f;
55649 if (velocity.X < -4f)
55650 {
55651 velocity.X += 0.04f;
55652 }
55653 else if (velocity.X < 0f)
55654 {
55655 velocity.X += 0.2f;
55656 }
55657 if (velocity.X > 4f)
55658 {
55659 velocity.X = 4f;
55660 }
55661 }
55662 if (directionY == -1 && (double)velocity.Y > -2.5 && position.Y > Main.player[target].position.Y + (float)Main.player[target].height)
55663 {
55664 velocity.Y -= 0.1f;
55665 if ((double)velocity.Y > 2.5)
55666 {
55667 velocity.Y -= 0.05f;
55668 }
55669 else if (velocity.Y > 0f)
55670 {
55671 velocity.Y -= 0.15f;
55672 }
55673 if ((double)velocity.Y < -2.5)
55674 {
55675 velocity.Y = -2.5f;
55676 }
55677 }
55678 else if (directionY == 1 && (double)velocity.Y < 2.5 && position.Y + (float)height < Main.player[target].position.Y)
55679 {
55680 velocity.Y += 0.1f;
55681 if ((double)velocity.Y < -2.5)
55682 {
55683 velocity.Y += 0.05f;
55684 }
55685 else if (velocity.Y < 0f)
55686 {
55687 velocity.Y += 0.15f;
55688 }
55689 if ((double)velocity.Y > 2.5)
55690 {
55691 velocity.Y = 2.5f;
55692 }
55693 }
55694 }
55695 else if (type == 116)
55696 {
55697 TargetClosest();
55698 Lighting.AddLight((int)(position.X + (float)(width / 2)) / 16, (int)(position.Y + (float)(height / 2)) / 16, 0.3f, 0.2f, 0.1f);
55699 if (direction == -1 && velocity.X > -6f)
55700 {
55701 velocity.X -= 0.1f;
55702 if (velocity.X > 6f)
55703 {
55704 velocity.X -= 0.1f;
55705 }
55706 else if (velocity.X > 0f)
55707 {
55708 velocity.X -= 0.2f;
55709 }
55710 if (velocity.X < -6f)
55711 {
55712 velocity.X = -6f;
55713 }
55714 }
55715 else if (direction == 1 && velocity.X < 6f)
55716 {
55717 velocity.X += 0.1f;
55718 if (velocity.X < -6f)
55719 {
55720 velocity.X += 0.1f;
55721 }
55722 else if (velocity.X < 0f)
55723 {
55724 velocity.X += 0.2f;
55725 }
55726 if (velocity.X > 6f)
55727 {
55728 velocity.X = 6f;
55729 }
55730 }
55731 if (directionY == -1 && (double)velocity.Y > -2.5)
55732 {
55733 velocity.Y -= 0.04f;
55734 if ((double)velocity.Y > 2.5)
55735 {
55736 velocity.Y -= 0.05f;
55737 }
55738 else if (velocity.Y > 0f)
55739 {
55740 velocity.Y -= 0.15f;
55741 }
55742 if ((double)velocity.Y < -2.5)
55743 {
55744 velocity.Y = -2.5f;
55745 }
55746 }
55747 else if (directionY == 1 && (double)velocity.Y < 1.5)
55748 {
55749 velocity.Y += 0.04f;
55750 if ((double)velocity.Y < -2.5)
55751 {
55752 velocity.Y += 0.05f;
55753 }
55754 else if (velocity.Y < 0f)
55755 {
55756 velocity.Y += 0.15f;
55757 }
55758 if ((double)velocity.Y > 2.5)
55759 {
55760 velocity.Y = 2.5f;
55761 }
55762 }
55763 if (Main.rand.Next(40) == 0)
55764 {
55766 int num = Dust.NewDust(new Vector2(position.X, position.Y + (float)height * 0.25f), width, (int)((float)height * 0.5f), 5, velocity.X, 2f);
55767 Main.dust[num].velocity.X *= 0.5f;
55768 Main.dust[num].velocity.Y *= 0.1f;
55770 }
55771 }
55772 else if (type == 133)
55773 {
55774 if ((double)life < (double)lifeMax * 0.5)
55775 {
55776 if (direction == -1 && velocity.X > -6f)
55777 {
55778 velocity.X -= 0.1f;
55779 if (velocity.X > 6f)
55780 {
55781 velocity.X -= 0.1f;
55782 }
55783 else if (velocity.X > 0f)
55784 {
55785 velocity.X += 0.05f;
55786 }
55787 if (velocity.X < -6f)
55788 {
55789 velocity.X = -6f;
55790 }
55791 }
55792 else if (direction == 1 && velocity.X < 6f)
55793 {
55794 velocity.X += 0.1f;
55795 if (velocity.X < -6f)
55796 {
55797 velocity.X += 0.1f;
55798 }
55799 else if (velocity.X < 0f)
55800 {
55801 velocity.X -= 0.05f;
55802 }
55803 if (velocity.X > 6f)
55804 {
55805 velocity.X = 6f;
55806 }
55807 }
55808 if (directionY == -1 && velocity.Y > -4f)
55809 {
55810 velocity.Y -= 0.1f;
55811 if (velocity.Y > 4f)
55812 {
55813 velocity.Y -= 0.1f;
55814 }
55815 else if (velocity.Y > 0f)
55816 {
55817 velocity.Y += 0.05f;
55818 }
55819 if (velocity.Y < -4f)
55820 {
55821 velocity.Y = -4f;
55822 }
55823 }
55824 else if (directionY == 1 && velocity.Y < 4f)
55825 {
55826 velocity.Y += 0.1f;
55827 if (velocity.Y < -4f)
55828 {
55829 velocity.Y += 0.1f;
55830 }
55831 else if (velocity.Y < 0f)
55832 {
55833 velocity.Y -= 0.05f;
55834 }
55835 if (velocity.Y > 4f)
55836 {
55837 velocity.Y = 4f;
55838 }
55839 }
55840 }
55841 else
55842 {
55843 if (direction == -1 && velocity.X > -4f)
55844 {
55845 velocity.X -= 0.1f;
55846 if (velocity.X > 4f)
55847 {
55848 velocity.X -= 0.1f;
55849 }
55850 else if (velocity.X > 0f)
55851 {
55852 velocity.X += 0.05f;
55853 }
55854 if (velocity.X < -4f)
55855 {
55856 velocity.X = -4f;
55857 }
55858 }
55859 else if (direction == 1 && velocity.X < 4f)
55860 {
55861 velocity.X += 0.1f;
55862 if (velocity.X < -4f)
55863 {
55864 velocity.X += 0.1f;
55865 }
55866 else if (velocity.X < 0f)
55867 {
55868 velocity.X -= 0.05f;
55869 }
55870 if (velocity.X > 4f)
55871 {
55872 velocity.X = 4f;
55873 }
55874 }
55875 if (directionY == -1 && (double)velocity.Y > -1.5)
55876 {
55877 velocity.Y -= 0.04f;
55878 if ((double)velocity.Y > 1.5)
55879 {
55880 velocity.Y -= 0.05f;
55881 }
55882 else if (velocity.Y > 0f)
55883 {
55884 velocity.Y += 0.03f;
55885 }
55886 if ((double)velocity.Y < -1.5)
55887 {
55888 velocity.Y = -1.5f;
55889 }
55890 }
55891 else if (directionY == 1 && (double)velocity.Y < 1.5)
55892 {
55893 velocity.Y += 0.04f;
55894 if ((double)velocity.Y < -1.5)
55895 {
55896 velocity.Y += 0.05f;
55897 }
55898 else if (velocity.Y < 0f)
55899 {
55900 velocity.Y -= 0.03f;
55901 }
55902 if ((double)velocity.Y > 1.5)
55903 {
55904 velocity.Y = 1.5f;
55905 }
55906 }
55907 }
55908 }
55909 else
55910 {
55911 float num2 = 4f;
55912 float num3 = 1.5f;
55913 num2 *= 1f + (1f - scale);
55914 num3 *= 1f + (1f - scale);
55915 if (direction == -1 && velocity.X > 0f - num2)
55916 {
55917 velocity.X -= 0.1f;
55918 if (velocity.X > num2)
55919 {
55920 velocity.X -= 0.1f;
55921 }
55922 else if (velocity.X > 0f)
55923 {
55924 velocity.X += 0.05f;
55925 }
55926 if (velocity.X < 0f - num2)
55927 {
55928 velocity.X = 0f - num2;
55929 }
55930 }
55931 else if (direction == 1 && velocity.X < num2)
55932 {
55933 velocity.X += 0.1f;
55934 if (velocity.X < 0f - num2)
55935 {
55936 velocity.X += 0.1f;
55937 }
55938 else if (velocity.X < 0f)
55939 {
55940 velocity.X -= 0.05f;
55941 }
55942 if (velocity.X > num2)
55943 {
55944 velocity.X = num2;
55945 }
55946 }
55947 if (directionY == -1 && velocity.Y > 0f - num3)
55948 {
55949 velocity.Y -= 0.04f;
55950 if (velocity.Y > num3)
55951 {
55952 velocity.Y -= 0.05f;
55953 }
55954 else if (velocity.Y > 0f)
55955 {
55956 velocity.Y += 0.03f;
55957 }
55958 if (velocity.Y < 0f - num3)
55959 {
55960 velocity.Y = 0f - num3;
55961 }
55962 }
55963 else if (directionY == 1 && velocity.Y < num3)
55964 {
55965 velocity.Y += 0.04f;
55966 if (velocity.Y < 0f - num3)
55967 {
55968 velocity.Y += 0.05f;
55969 }
55970 else if (velocity.Y < 0f)
55971 {
55972 velocity.Y -= 0.03f;
55973 }
55974 if (velocity.Y > num3)
55975 {
55976 velocity.Y = num3;
55977 }
55978 }
55979 }
55980 if ((type == 2 || type == 133 || type == 190 || type == 191 || type == 192 || type == 193 || type == 194) && Main.rand.Next(40) == 0)
55981 {
55983 int num4 = Dust.NewDust(new Vector2(position.X, position.Y + (float)height * 0.25f), width, (int)((float)height * 0.5f), 5, velocity.X, 2f);
55984 Main.dust[num4].velocity.X *= 0.5f;
55985 Main.dust[num4].velocity.Y *= 0.1f;
55987 }
55988 if (wet && type != 170 && type != 171 && type != 172)
55989 {
55990 if (velocity.Y > 0f)
55991 {
55992 velocity.Y *= 0.95f;
55993 }
55994 velocity.Y -= 0.5f;
55995 if (velocity.Y < -4f)
55996 {
55997 velocity.Y = -4f;
55998 }
55999 TargetClosest();
56000 }
56001 }
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
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
Vector2 netOffset
Definition NPC.cs:502
void EncourageDespawn(int despawnTime)
Definition NPC.cs:2199
int lifeMax
The maximum life of this NPC.
Definition NPC.cs:1077
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:83247
bool noGravity
If true, the npc will not be affected by gravity. Demon Eyes and other floating npc use this....
Definition NPC.cs:1122
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
float scale
Makes the NPC bigger or smaller. Bigger than 1f is bigger. Defaults to 1f.
Definition NPC.cs:1104
static bool DespawnEncouragement_AIStyle2_FloatingEye_IsDiscouraged(int npcID, Vector2 npcPosition, int target=255)
Definition NPC.cs:56031
bool collideX
Definition NPC.cs:1134
bool collideY
Definition NPC.cs:1136
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
float rotation
Definition NPC.cs:1116
bool noTileCollide
If true, the npc does not collide with tiles, making the npc pass through tiles freely....
Definition NPC.cs:1128
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
Definition NPC.cs:1072
int directionY
Definition NPC.cs:983
bool netUpdate
Definition NPC.cs:1130
int target
Definition NPC.cs:1019

References Terraria.Lighting.AddLight(), Terraria.NPC.ai, Terraria.NPC.alpha, Terraria.Collision.CanHit(), Terraria.NPC.collideX, Terraria.NPC.collideY, Terraria.NPC.DespawnEncouragement_AIStyle2_FloatingEye_IsDiscouraged(), Terraria.Entity.direction, Terraria.NPC.directionY, Terraria.Main.dust, Terraria.NPC.EncourageDespawn(), Terraria.Entity.height, Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.NPC.netOffset, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.NPC.noGravity, Terraria.NPC.noTileCollide, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.rand, Terraria.NPC.rotation, Terraria.NPC.scale, Terraria.Collision.SolidCollision(), Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.NPC.type, Terraria.Entity.velocity, Terraria.Entity.wet, 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: