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

◆ AI_174_MultisegmentPet()

void Terraria.Projectile.AI_174_MultisegmentPet ( )
inlineprivate

Definition at line 47770 of file Projectile.cs.

47771 {
47772 //IL_009f: Unknown result type (might be due to invalid IL or missing references)
47773 //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
47774 //IL_00a6: Unknown result type (might be due to invalid IL or missing references)
47775 //IL_00cc: Unknown result type (might be due to invalid IL or missing references)
47776 //IL_00ce: Unknown result type (might be due to invalid IL or missing references)
47777 //IL_00d3: Unknown result type (might be due to invalid IL or missing references)
47778 //IL_00d8: Unknown result type (might be due to invalid IL or missing references)
47779 //IL_010f: Unknown result type (might be due to invalid IL or missing references)
47780 //IL_0114: Unknown result type (might be due to invalid IL or missing references)
47781 //IL_00b4: Unknown result type (might be due to invalid IL or missing references)
47782 //IL_00bb: Unknown result type (might be due to invalid IL or missing references)
47783 //IL_00c0: Unknown result type (might be due to invalid IL or missing references)
47784 //IL_0139: Unknown result type (might be due to invalid IL or missing references)
47785 //IL_013e: Unknown result type (might be due to invalid IL or missing references)
47786 //IL_017e: Unknown result type (might be due to invalid IL or missing references)
47787 //IL_0187: Unknown result type (might be due to invalid IL or missing references)
47788 //IL_01a7: Unknown result type (might be due to invalid IL or missing references)
47789 //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
47790 //IL_01b2: Unknown result type (might be due to invalid IL or missing references)
47791 //IL_01c7: Unknown result type (might be due to invalid IL or missing references)
47792 //IL_01cc: Unknown result type (might be due to invalid IL or missing references)
47793 //IL_01d1: Unknown result type (might be due to invalid IL or missing references)
47794 //IL_01d7: Unknown result type (might be due to invalid IL or missing references)
47795 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
47796 //IL_0145: Unknown result type (might be due to invalid IL or missing references)
47797 //IL_0148: Unknown result type (might be due to invalid IL or missing references)
47798 //IL_014d: Unknown result type (might be due to invalid IL or missing references)
47799 //IL_0152: Unknown result type (might be due to invalid IL or missing references)
47800 //IL_015c: Unknown result type (might be due to invalid IL or missing references)
47801 //IL_015e: Unknown result type (might be due to invalid IL or missing references)
47802 //IL_020e: Unknown result type (might be due to invalid IL or missing references)
47803 Player player = Main.player[owner];
47804 if (!player.active)
47805 {
47806 active = false;
47807 return;
47808 }
47809 if (type == 883)
47810 {
47811 if (player.dead)
47812 {
47813 player.petFlagEaterOfWorldsPet = false;
47814 }
47815 if (player.petFlagEaterOfWorldsPet)
47816 {
47817 timeLeft = 2;
47818 }
47819 }
47820 if (type == 887)
47821 {
47822 if (player.dead)
47823 {
47824 player.petFlagDestroyerPet = false;
47825 }
47826 if (player.petFlagDestroyerPet)
47827 {
47828 timeLeft = 2;
47829 }
47830 }
47831 if (type == 893)
47832 {
47833 if (player.dead)
47834 {
47835 player.petFlagLunaticCultistPet = false;
47836 }
47837 if (player.petFlagLunaticCultistPet)
47838 {
47839 timeLeft = 2;
47840 }
47841 }
47842 Vector2 center = player.Center;
47843 if (Distance(center) > 2000f)
47844 {
47845 base.Center = center;
47846 velocity = Vector2.Zero;
47847 netUpdate = true;
47848 }
47849 Vector2 val = center - base.Center;
47850 float num = ((Vector2)(ref val)).Length();
47851 float num2 = Math.Min(12f, Math.Max(4f, ((Vector2)(ref player.velocity)).Length()));
47852 ((Vector2)(ref velocity)).Length();
47853 if (velocity == Vector2.Zero)
47854 {
47855 velocity.X = 2f * (float)player.direction;
47856 Vector2 vector = position;
47857 for (int i = 0; i < oldPos.Length; i++)
47858 {
47859 vector -= velocity;
47860 oldPos[i] = vector;
47861 }
47862 }
47863 if (!(num < 120f))
47864 {
47865 float targetAngle = AngleTo(center);
47866 float f = velocity.ToRotation().AngleTowards(targetAngle, MathHelper.ToRadians(5f));
47867 velocity = f.ToRotationVector2() * num2;
47868 }
47869 if (((Vector2)(ref velocity)).Length() > num2)
47870 {
47871 velocity = velocity.SafeNormalize(Vector2.Zero) * num2;
47872 }
47873 if (Math.Abs(velocity.Y) < 1f)
47874 {
47875 velocity.Y -= 0.1f;
47876 }
47877 rotation = velocity.ToRotation() + (float)Math.PI / 2f;
47878 int num3 = direction;
47879 direction = (spriteDirection = ((velocity.X > 0f) ? 1 : (-1)));
47880 if (num3 != direction)
47881 {
47882 netUpdate = true;
47883 }
47884 position.X = MathHelper.Clamp(position.X, 160f, (float)(Main.maxTilesX * 16 - 160));
47885 position.Y = MathHelper.Clamp(position.Y, 160f, (float)(Main.maxTilesY * 16 - 160));
47886 }
float AngleTo(Vector2 Destination)
Definition Entity.cs:257
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
float Distance(Vector2 Other)
Definition Entity.cs:275
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
Definition Entity.cs:21
int owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...
bool netUpdate
Set manually to true in M:Terraria.ModLoader.ModProjectile.AI once to make it sync its current F:Terr...
Vector2[] oldPos
Holds the value of F:Terraria.Entity.position from previous updates from newest to oldest....
int type
The Projectile ID of this projectile. The Projectile ID is a unique number assigned to each Projectil...
int timeLeft
Time in ticks before this projectile will naturally despawn. Each update timeLeft is decreased by 1...
float rotation
Rotation of the projectile. Radians not Degrees. Use T:Microsoft.Xna.Framework.MathHelper if you want...

References Terraria.Entity.active, Terraria.Entity.Center, Terraria.Player.dead, Terraria.Entity.direction, Terraria.Player.petFlagDestroyerPet, Terraria.Player.petFlagEaterOfWorldsPet, Terraria.Player.petFlagLunaticCultistPet, Terraria.Main.player, and Terraria.Entity.velocity.