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

◆ AI_123_Deerclops_Movement()

void Terraria.NPC.AI_123_Deerclops_Movement ( bool haltMovement,
bool goHome )
inlineprivate

Definition at line 45141 of file NPC.cs.

45142 {
45143 //IL_0048: Unknown result type (might be due to invalid IL or missing references)
45144 //IL_004d: Unknown result type (might be due to invalid IL or missing references)
45145 //IL_00ab: Unknown result type (might be due to invalid IL or missing references)
45146 //IL_00b7: Unknown result type (might be due to invalid IL or missing references)
45147 //IL_0072: Unknown result type (might be due to invalid IL or missing references)
45148 //IL_0077: Unknown result type (might be due to invalid IL or missing references)
45149 //IL_008b: Unknown result type (might be due to invalid IL or missing references)
45150 //IL_01b3: Unknown result type (might be due to invalid IL or missing references)
45151 //IL_01e3: Unknown result type (might be due to invalid IL or missing references)
45152 //IL_01ea: Unknown result type (might be due to invalid IL or missing references)
45153 //IL_01f4: Unknown result type (might be due to invalid IL or missing references)
45154 //IL_0203: Unknown result type (might be due to invalid IL or missing references)
45155 //IL_020a: Unknown result type (might be due to invalid IL or missing references)
45156 //IL_0218: Unknown result type (might be due to invalid IL or missing references)
45157 //IL_0223: Unknown result type (might be due to invalid IL or missing references)
45158 //IL_022a: Unknown result type (might be due to invalid IL or missing references)
45159 //IL_023b: Unknown result type (might be due to invalid IL or missing references)
45160 //IL_0254: Unknown result type (might be due to invalid IL or missing references)
45161 //IL_0263: Unknown result type (might be due to invalid IL or missing references)
45162 //IL_0274: Unknown result type (might be due to invalid IL or missing references)
45163 //IL_0285: Unknown result type (might be due to invalid IL or missing references)
45164 //IL_028a: Unknown result type (might be due to invalid IL or missing references)
45165 float num = (float)life / (float)lifeMax;
45166 float num6 = 1f - num;
45167 float num7 = 3.5f + 1f * num6;
45168 float num8 = 4f;
45169 float num9 = -0.4f;
45170 float min = -8f;
45171 float num10 = 0.4f;
45172 Rectangle rectangle = GetTargetData().Hitbox;
45173 if (goHome)
45174 {
45175 ((Rectangle)(ref rectangle))._002Ector(homeTileX * 16, homeTileY * 16, 16, 16);
45176 if (Distance(((Rectangle)(ref rectangle)).Center.ToVector2()) < 240f)
45177 {
45178 rectangle.X = (int)(base.Center.X + (float)(160 * direction));
45179 }
45180 }
45181 float num11 = (float)((Rectangle)(ref rectangle)).Center.X - base.Center.X;
45182 float num13 = Math.Abs(num11);
45183 if (goHome && num11 != 0f)
45184 {
45185 direction = (spriteDirection = Math.Sign(num11));
45186 }
45187 bool flag = num13 < 80f;
45188 bool flag2 = flag || haltMovement;
45189 if (ai[0] == -1f)
45190 {
45191 num11 = 5f;
45192 num7 = 5.35f;
45193 flag2 = false;
45194 }
45195 if (flag2)
45196 {
45197 velocity.X *= 0.9f;
45198 if ((double)velocity.X > -0.1 && (double)velocity.X < 0.1)
45199 {
45200 velocity.X = 0f;
45201 }
45202 }
45203 else
45204 {
45205 int num12 = Math.Sign(num11);
45206 velocity.X = MathHelper.Lerp(velocity.X, (float)num12 * num7, 1f / num8);
45207 }
45208 int num2 = 40;
45209 int num3 = 20;
45210 int num4 = 0;
45211 Vector2 vector = default(Vector2);
45212 ((Vector2)(ref vector))._002Ector(base.Center.X - (float)(num2 / 2), position.Y + (float)height - (float)num3 + (float)num4);
45213 bool num14 = vector.X < (float)rectangle.X && vector.X + (float)width > (float)(rectangle.X + rectangle.Width);
45214 bool flag3 = vector.Y + (float)num3 < (float)(rectangle.Y + rectangle.Height - 16);
45215 bool acceptTopSurfaces = base.Bottom.Y >= (float)((Rectangle)(ref rectangle)).Top;
45216 bool flag4 = Collision.SolidCollision(vector, num2, num3, acceptTopSurfaces);
45217 bool flag5 = Collision.SolidCollision(vector, num2, num3 - 4, acceptTopSurfaces);
45218 bool flag6 = !Collision.SolidCollision(vector + new Vector2((float)(num2 * direction), 0f), 16, 80, acceptTopSurfaces);
45219 float num5 = 8f;
45220 if (flag4 || flag5)
45221 {
45222 localAI[0] = 0f;
45223 }
45224 if ((num14 || flag) && flag3)
45225 {
45226 velocity.Y = MathHelper.Clamp(velocity.Y + num10 * 2f, 0.001f, 16f);
45227 }
45228 else if (flag4 && !flag5)
45229 {
45230 velocity.Y = 0f;
45231 }
45232 else if (flag4)
45233 {
45234 velocity.Y = MathHelper.Clamp(velocity.Y + num9, min, 0f);
45235 }
45236 else if (velocity.Y == 0f && flag6)
45237 {
45238 velocity.Y = 0f - num5;
45239 localAI[0] = 1f;
45240 }
45241 else
45242 {
45243 velocity.Y = MathHelper.Clamp(velocity.Y + num10, 0f - num5, 16f);
45244 }
45245 }
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
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
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
int lifeMax
The maximum life of this NPC.
Definition NPC.cs:1077
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
int homeTileX
Definition NPC.cs:1180
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 homeTileY
Definition NPC.cs:1182

References Terraria.NPC.ai, Terraria.Entity.direction, Terraria.Entity.Distance(), Terraria.NPC.GetTargetData(), Terraria.Entity.height, Terraria.DataStructures.NPCAimedTarget.Hitbox, Terraria.NPC.homeTileX, Terraria.NPC.homeTileY, Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.NPC.localAI, Terraria.Entity.position, Terraria.Collision.SolidCollision(), Terraria.NPC.spriteDirection, Terraria.Entity.velocity, and Terraria.Entity.width.

Referenced by Terraria.NPC.AI_123_Deerclops().

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