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

◆ AI_156_Think()

void Terraria.Projectile.AI_156_Think ( List< int > blacklist)
inlineprivate

Definition at line 54162 of file Projectile.cs.

54163 {
54164 //IL_006e: Unknown result type (might be due to invalid IL or missing references)
54165 //IL_0074: Unknown result type (might be due to invalid IL or missing references)
54166 //IL_00cf: Unknown result type (might be due to invalid IL or missing references)
54167 //IL_00d4: Unknown result type (might be due to invalid IL or missing references)
54168 //IL_00db: Unknown result type (might be due to invalid IL or missing references)
54169 //IL_00e0: Unknown result type (might be due to invalid IL or missing references)
54170 //IL_00e7: Unknown result type (might be due to invalid IL or missing references)
54171 //IL_010a: Unknown result type (might be due to invalid IL or missing references)
54172 //IL_015c: Unknown result type (might be due to invalid IL or missing references)
54173 //IL_0161: Unknown result type (might be due to invalid IL or missing references)
54174 //IL_0168: Unknown result type (might be due to invalid IL or missing references)
54175 //IL_016d: Unknown result type (might be due to invalid IL or missing references)
54176 //IL_0174: Unknown result type (might be due to invalid IL or missing references)
54177 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
54178 //IL_01e1: Unknown result type (might be due to invalid IL or missing references)
54179 //IL_01e8: Unknown result type (might be due to invalid IL or missing references)
54180 //IL_01ed: Unknown result type (might be due to invalid IL or missing references)
54181 //IL_01f4: Unknown result type (might be due to invalid IL or missing references)
54182 //IL_02fa: Unknown result type (might be due to invalid IL or missing references)
54183 //IL_0304: Unknown result type (might be due to invalid IL or missing references)
54184 //IL_0309: Unknown result type (might be due to invalid IL or missing references)
54185 //IL_038d: Unknown result type (might be due to invalid IL or missing references)
54186 //IL_0392: Unknown result type (might be due to invalid IL or missing references)
54187 //IL_0394: Unknown result type (might be due to invalid IL or missing references)
54188 //IL_0396: Unknown result type (might be due to invalid IL or missing references)
54189 //IL_0398: Unknown result type (might be due to invalid IL or missing references)
54190 //IL_03a4: Unknown result type (might be due to invalid IL or missing references)
54191 //IL_03ab: Unknown result type (might be due to invalid IL or missing references)
54192 //IL_0384: Unknown result type (might be due to invalid IL or missing references)
54193 //IL_0389: Unknown result type (might be due to invalid IL or missing references)
54194 //IL_0322: Unknown result type (might be due to invalid IL or missing references)
54195 //IL_0335: Unknown result type (might be due to invalid IL or missing references)
54196 //IL_0645: Unknown result type (might be due to invalid IL or missing references)
54197 //IL_0651: Unknown result type (might be due to invalid IL or missing references)
54198 //IL_03da: Unknown result type (might be due to invalid IL or missing references)
54199 //IL_03df: Unknown result type (might be due to invalid IL or missing references)
54200 //IL_0406: Unknown result type (might be due to invalid IL or missing references)
54201 //IL_040d: Unknown result type (might be due to invalid IL or missing references)
54202 //IL_0413: Unknown result type (might be due to invalid IL or missing references)
54203 //IL_0415: Unknown result type (might be due to invalid IL or missing references)
54204 //IL_041a: Unknown result type (might be due to invalid IL or missing references)
54205 //IL_041c: Unknown result type (might be due to invalid IL or missing references)
54206 //IL_041e: Unknown result type (might be due to invalid IL or missing references)
54207 //IL_0420: Unknown result type (might be due to invalid IL or missing references)
54208 //IL_0425: Unknown result type (might be due to invalid IL or missing references)
54209 //IL_0436: Unknown result type (might be due to invalid IL or missing references)
54210 //IL_0438: Unknown result type (might be due to invalid IL or missing references)
54211 //IL_043f: Unknown result type (might be due to invalid IL or missing references)
54212 //IL_0444: Unknown result type (might be due to invalid IL or missing references)
54213 //IL_0448: Unknown result type (might be due to invalid IL or missing references)
54214 //IL_044d: Unknown result type (might be due to invalid IL or missing references)
54215 //IL_0452: Unknown result type (might be due to invalid IL or missing references)
54216 //IL_0455: Unknown result type (might be due to invalid IL or missing references)
54217 //IL_046c: Unknown result type (might be due to invalid IL or missing references)
54218 //IL_0476: Unknown result type (might be due to invalid IL or missing references)
54219 //IL_047b: Unknown result type (might be due to invalid IL or missing references)
54220 //IL_047e: Unknown result type (might be due to invalid IL or missing references)
54221 //IL_0480: Unknown result type (might be due to invalid IL or missing references)
54222 //IL_0487: Unknown result type (might be due to invalid IL or missing references)
54223 //IL_048d: Unknown result type (might be due to invalid IL or missing references)
54224 //IL_0492: Unknown result type (might be due to invalid IL or missing references)
54225 //IL_0497: Unknown result type (might be due to invalid IL or missing references)
54226 //IL_084b: Unknown result type (might be due to invalid IL or missing references)
54227 //IL_086a: Unknown result type (might be due to invalid IL or missing references)
54228 //IL_086f: Unknown result type (might be due to invalid IL or missing references)
54229 //IL_0874: Unknown result type (might be due to invalid IL or missing references)
54230 //IL_0878: Unknown result type (might be due to invalid IL or missing references)
54231 //IL_087d: Unknown result type (might be due to invalid IL or missing references)
54232 //IL_087f: Unknown result type (might be due to invalid IL or missing references)
54233 //IL_0884: Unknown result type (might be due to invalid IL or missing references)
54234 //IL_0886: Unknown result type (might be due to invalid IL or missing references)
54235 //IL_0888: Unknown result type (might be due to invalid IL or missing references)
54236 //IL_088d: Unknown result type (might be due to invalid IL or missing references)
54237 //IL_08a8: Unknown result type (might be due to invalid IL or missing references)
54238 //IL_08ad: Unknown result type (might be due to invalid IL or missing references)
54239 //IL_08b1: Unknown result type (might be due to invalid IL or missing references)
54240 //IL_08b6: Unknown result type (might be due to invalid IL or missing references)
54241 //IL_08b8: Unknown result type (might be due to invalid IL or missing references)
54242 //IL_08bd: Unknown result type (might be due to invalid IL or missing references)
54243 //IL_08e7: Unknown result type (might be due to invalid IL or missing references)
54244 //IL_08e9: Unknown result type (might be due to invalid IL or missing references)
54245 //IL_08ee: Unknown result type (might be due to invalid IL or missing references)
54246 //IL_0919: Unknown result type (might be due to invalid IL or missing references)
54247 //IL_091d: Unknown result type (might be due to invalid IL or missing references)
54248 //IL_0924: Unknown result type (might be due to invalid IL or missing references)
54249 //IL_06fc: Unknown result type (might be due to invalid IL or missing references)
54250 //IL_0701: Unknown result type (might be due to invalid IL or missing references)
54251 //IL_0703: Unknown result type (might be due to invalid IL or missing references)
54252 //IL_0705: Unknown result type (might be due to invalid IL or missing references)
54253 //IL_0707: Unknown result type (might be due to invalid IL or missing references)
54254 //IL_06d8: Unknown result type (might be due to invalid IL or missing references)
54255 //IL_06e9: Unknown result type (might be due to invalid IL or missing references)
54256 //IL_06f3: Unknown result type (might be due to invalid IL or missing references)
54257 //IL_06f8: Unknown result type (might be due to invalid IL or missing references)
54258 //IL_093a: Unknown result type (might be due to invalid IL or missing references)
54259 //IL_093f: Unknown result type (might be due to invalid IL or missing references)
54260 //IL_0943: Unknown result type (might be due to invalid IL or missing references)
54261 //IL_067b: Unknown result type (might be due to invalid IL or missing references)
54262 //IL_068e: Unknown result type (might be due to invalid IL or missing references)
54263 //IL_0742: Unknown result type (might be due to invalid IL or missing references)
54264 //IL_0747: Unknown result type (might be due to invalid IL or missing references)
54265 //IL_0784: Unknown result type (might be due to invalid IL or missing references)
54266 //IL_078b: Unknown result type (might be due to invalid IL or missing references)
54267 //IL_0791: Unknown result type (might be due to invalid IL or missing references)
54268 //IL_0793: Unknown result type (might be due to invalid IL or missing references)
54269 //IL_0798: Unknown result type (might be due to invalid IL or missing references)
54270 //IL_079a: Unknown result type (might be due to invalid IL or missing references)
54271 //IL_079c: Unknown result type (might be due to invalid IL or missing references)
54272 //IL_079e: Unknown result type (might be due to invalid IL or missing references)
54273 //IL_07a3: Unknown result type (might be due to invalid IL or missing references)
54274 //IL_07b4: Unknown result type (might be due to invalid IL or missing references)
54275 //IL_07b6: Unknown result type (might be due to invalid IL or missing references)
54276 //IL_07bd: Unknown result type (might be due to invalid IL or missing references)
54277 //IL_07c2: Unknown result type (might be due to invalid IL or missing references)
54278 //IL_07c6: Unknown result type (might be due to invalid IL or missing references)
54279 //IL_07cb: Unknown result type (might be due to invalid IL or missing references)
54280 //IL_07d0: Unknown result type (might be due to invalid IL or missing references)
54281 //IL_07d3: Unknown result type (might be due to invalid IL or missing references)
54282 //IL_07fc: Unknown result type (might be due to invalid IL or missing references)
54283 //IL_0806: Unknown result type (might be due to invalid IL or missing references)
54284 //IL_080b: Unknown result type (might be due to invalid IL or missing references)
54285 //IL_080e: Unknown result type (might be due to invalid IL or missing references)
54286 //IL_0810: Unknown result type (might be due to invalid IL or missing references)
54287 //IL_0817: Unknown result type (might be due to invalid IL or missing references)
54288 //IL_081d: Unknown result type (might be due to invalid IL or missing references)
54289 //IL_0822: Unknown result type (might be due to invalid IL or missing references)
54290 //IL_0827: Unknown result type (might be due to invalid IL or missing references)
54291 bool flag = type == 755;
54292 bool flag2 = type == 946;
54293 int num = 60;
54294 int num12 = num - 1;
54295 int num19 = num + 60;
54296 int num20 = num19 - 1;
54297 int num21 = num + 1;
54298 if (flag)
54299 {
54300 num = 66;
54301 }
54302 if (flag2)
54303 {
54304 num = 40;
54305 num12 = num - 1;
54306 num19 = num + 40;
54307 num20 = num19 - 1;
54308 num21 = num + 1;
54309 }
54310 Player player = Main.player[owner];
54311 if (player.active && Vector2.Distance(player.Center, base.Center) > 2000f)
54312 {
54313 ai[0] = 0f;
54314 ai[1] = 0f;
54315 netUpdate = true;
54316 }
54317 if (ai[0] == -1f)
54318 {
54321 velocity = Vector2.Zero;
54322 base.Center = base.Center.MoveTowards(idleSpot, 32f);
54323 rotation = rotation.AngleLerp(idleRotation, 0.2f);
54324 if (Distance(idleSpot) < 2f)
54325 {
54326 ai[0] = 0f;
54327 netUpdate = true;
54328 }
54329 return;
54330 }
54331 if (ai[0] == 0f)
54332 {
54333 if (flag)
54334 {
54337 velocity = Vector2.Zero;
54338 base.Center = Vector2.SmoothStep(base.Center, idleSpot2, 0.45f);
54339 if (Main.rand.Next(20) == 0)
54340 {
54342 if (num22 != -1)
54343 {
54345 ai[0] = num;
54346 ai[1] = num22;
54347 netUpdate = true;
54348 return;
54349 }
54350 }
54351 }
54352 if (!flag2)
54353 {
54354 return;
54355 }
54358 velocity = Vector2.Zero;
54359 base.Center = Vector2.SmoothStep(base.Center, idleSpot3, 0.45f);
54360 rotation = rotation.AngleLerp(idleRotation2, 0.45f);
54361 if (Main.rand.Next(20) == 0)
54362 {
54364 if (num23 != -1)
54365 {
54367 ai[0] = Main.rand.NextFromList<int>(num, num19);
54368 ai[0] = num19;
54369 ai[1] = num23;
54370 netUpdate = true;
54371 }
54372 }
54373 return;
54374 }
54375 Vector2 center5;
54376 if (flag)
54377 {
54378 int num24 = (int)ai[1];
54379 if (!Main.npc.IndexInRange(num24))
54380 {
54381 ai[0] = 0f;
54382 netUpdate = true;
54383 return;
54384 }
54385 NPC nPC = Main.npc[num24];
54386 if (!nPC.CanBeChasedBy(this))
54387 {
54388 ai[0] = 0f;
54389 netUpdate = true;
54390 return;
54391 }
54392 ai[0] -= 1f;
54393 if (ai[0] >= (float)num12)
54394 {
54395 velocity *= 0.8f;
54396 if (ai[0] == (float)num12)
54397 {
54398 localAI[0] = base.Center.X;
54399 localAI[1] = base.Center.Y;
54400 }
54401 return;
54402 }
54403 float lerpValue = Utils.GetLerpValue(num12, 0f, ai[0], clamped: true);
54404 Vector2 vector = default(Vector2);
54405 ((Vector2)(ref vector))._002Ector(localAI[0], localAI[1]);
54406 if (lerpValue >= 0.5f)
54407 {
54408 vector = Main.player[owner].Center;
54409 }
54410 Vector2 center = nPC.Center;
54411 float num25 = (center - vector).ToRotation();
54412 float num2 = ((center.X > vector.X) ? (-(float)Math.PI) : ((float)Math.PI));
54413 float num3 = num2 + (0f - num2) * lerpValue * 2f;
54414 Vector2 spinningpoint = num3.ToRotationVector2();
54415 spinningpoint.Y *= (float)Math.Sin((float)identity * 2.3f) * 0.5f;
54416 Vector2 spinningpoint3 = spinningpoint;
54417 double radians = num25;
54418 center5 = default(Vector2);
54420 center5 = center - vector;
54421 float num4 = ((Vector2)(ref center5)).Length() / 2f;
54422 Vector2 center2 = Vector2.Lerp(vector, center, 0.5f) + spinningpoint * num4;
54423 base.Center = center2;
54424 Vector2 vector2 = MathHelper.WrapAngle(num25 + num3 + 0f).ToRotationVector2() * 10f;
54425 velocity = vector2;
54426 position -= velocity;
54427 if (ai[0] == 0f)
54428 {
54430 if (num5 != -1)
54431 {
54432 ai[0] = num;
54433 ai[1] = num5;
54435 netUpdate = true;
54436 return;
54437 }
54438 ai[1] = 0f;
54439 netUpdate = true;
54440 }
54441 }
54442 if (!flag2)
54443 {
54444 return;
54445 }
54446 bool skipBodyCheck = true;
54447 int num6 = 0;
54448 int num7 = num12;
54449 int num8 = 0;
54450 if (ai[0] >= (float)num21)
54451 {
54452 num6 = 1;
54453 num7 = num20;
54454 num8 = num21;
54455 }
54456 int num9 = (int)ai[1];
54457 if (!Main.npc.IndexInRange(num9))
54458 {
54460 if (num10 != -1)
54461 {
54462 ai[0] = Main.rand.NextFromList<int>(num, num19);
54463 ai[1] = num10;
54465 netUpdate = true;
54466 }
54467 else
54468 {
54469 ai[0] = -1f;
54470 ai[1] = 0f;
54471 netUpdate = true;
54472 }
54473 return;
54474 }
54475 NPC nPC2 = Main.npc[num9];
54476 if (!nPC2.CanBeChasedBy(this))
54477 {
54479 if (num11 != -1)
54480 {
54481 ai[0] = Main.rand.NextFromList<int>(num, num19);
54483 ai[1] = num11;
54484 netUpdate = true;
54485 }
54486 else
54487 {
54488 ai[0] = -1f;
54489 ai[1] = 0f;
54490 netUpdate = true;
54491 }
54492 return;
54493 }
54494 ai[0] -= 1f;
54495 if (ai[0] >= (float)num7)
54496 {
54497 direction = ((base.Center.X < nPC2.Center.X) ? 1 : (-1));
54498 if (ai[0] == (float)num7)
54499 {
54500 localAI[0] = base.Center.X;
54501 localAI[1] = base.Center.Y;
54502 }
54503 }
54504 float lerpValue2 = Utils.GetLerpValue(num7, num8, ai[0], clamped: true);
54505 if (num6 == 0)
54506 {
54507 Vector2 vector3 = default(Vector2);
54508 ((Vector2)(ref vector3))._002Ector(localAI[0], localAI[1]);
54509 if (lerpValue2 >= 0.5f)
54510 {
54511 vector3 = Vector2.Lerp(nPC2.Center, Main.player[owner].Center, 0.5f);
54512 }
54513 Vector2 center3 = nPC2.Center;
54514 float num13 = (center3 - vector3).ToRotation();
54515 float num14 = ((direction == 1) ? (-(float)Math.PI) : ((float)Math.PI));
54516 float num15 = num14 + (0f - num14) * lerpValue2 * 2f;
54517 Vector2 spinningpoint2 = num15.ToRotationVector2();
54518 spinningpoint2.Y *= 0.5f;
54519 spinningpoint2.Y *= 0.8f + (float)Math.Sin((float)identity * 2.3f) * 0.2f;
54521 double radians2 = num13;
54522 center5 = default(Vector2);
54525 float num16 = ((Vector2)(ref center5)).Length() / 2f;
54526 Vector2 center4 = Vector2.Lerp(vector3, center3, 0.5f) + spinningpoint2 * num16;
54527 base.Center = center4;
54528 float num17 = MathHelper.WrapAngle(num13 + num15 + 0f);
54529 rotation = num17 + (float)Math.PI / 2f;
54530 Vector2 vector4 = num17.ToRotationVector2() * 10f;
54531 velocity = vector4;
54532 position -= velocity;
54533 }
54534 if (num6 == 1)
54535 {
54536 Vector2 vector5 = default(Vector2);
54537 ((Vector2)(ref vector5))._002Ector(localAI[0], localAI[1]);
54538 vector5 += new Vector2(0f, Utils.GetLerpValue(0f, 0.4f, lerpValue2, clamped: true) * -100f);
54539 Vector2 v = nPC2.Center - vector5;
54540 Vector2 vector6 = v.SafeNormalize(Vector2.Zero) * MathHelper.Clamp(((Vector2)(ref v)).Length(), 60f, 150f);
54541 Vector2 value = nPC2.Center + vector6;
54542 float lerpValue3 = Utils.GetLerpValue(0.4f, 0.6f, lerpValue2, clamped: true);
54543 float lerpValue4 = Utils.GetLerpValue(0.6f, 1f, lerpValue2, clamped: true);
54544 float targetAngle = v.SafeNormalize(Vector2.Zero).ToRotation() + (float)Math.PI / 2f;
54545 rotation = rotation.AngleTowards(targetAngle, (float)Math.PI / 5f);
54546 base.Center = Vector2.Lerp(vector5, nPC2.Center, lerpValue3);
54547 if (lerpValue4 > 0f)
54548 {
54549 base.Center = Vector2.Lerp(nPC2.Center, value, lerpValue4);
54550 }
54551 }
54552 if (ai[0] == (float)num8)
54553 {
54555 if (num18 != -1)
54556 {
54557 ai[0] = Main.rand.NextFromList<int>(num, num19);
54558 ai[1] = num18;
54560 netUpdate = true;
54561 }
54562 else
54563 {
54564 ai[0] = -1f;
54565 ai[1] = 0f;
54566 netUpdate = true;
54567 }
54568 }
54569 }
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 owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...
void AI_156_GetIdlePosition(int stackedIndex, int totalIndexes, out Vector2 idleSpot, out float idleRotation)
float[] ai
An array with 3 slots used for any sort of data storage, which is occasionally synced to the server....
int identity
The projectile's universal unique identifier, which is the same on all clients and the server....
bool netUpdate
Set manually to true in M:Terraria.ModLoader.ModProjectile.AI once to make it sync its current F:Terr...
float[] localAI
Acts like F:Terraria.Projectile.ai, but does not sync to the server. Many vanilla T:Terraria....
int type
The Projectile ID of this projectile. The Projectile ID is a unique number assigned to each Projectil...
float rotation
Rotation of the projectile. Radians not Degrees. Use T:Microsoft.Xna.Framework.MathHelper if you want...
void AI_GetMyGroupIndexAndFillBlackList(List< int > blackListedTargets, out int index, out int totalIndexesInGroup)
int AI_156_TryAttackingNPCs(List< int > blackListedTargets, bool skipBodyCheck=false)

References Terraria.Entity.active, Terraria.Entity.Center, Terraria.Utils.GetLerpValue(), Terraria.Main.npc, Terraria.Main.player, and Terraria.Main.rand.

+ Here is the call graph for this function: