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

◆ AI_007_GrapplingHooks()

void Terraria.Projectile.AI_007_GrapplingHooks ( )
inlineprivate

Definition at line 55312 of file Projectile.cs.

55313 {
55314 //IL_005f: Unknown result type (might be due to invalid IL or missing references)
55315 //IL_0064: Unknown result type (might be due to invalid IL or missing references)
55316 //IL_009e: Unknown result type (might be due to invalid IL or missing references)
55317 //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
55318 //IL_00ac: Unknown result type (might be due to invalid IL or missing references)
55319 //IL_00b2: Unknown result type (might be due to invalid IL or missing references)
55320 //IL_0132: Unknown result type (might be due to invalid IL or missing references)
55321 //IL_0146: Unknown result type (might be due to invalid IL or missing references)
55322 //IL_022e: Unknown result type (might be due to invalid IL or missing references)
55323 //IL_0283: Unknown result type (might be due to invalid IL or missing references)
55324 //IL_0288: Unknown result type (might be due to invalid IL or missing references)
55325 //IL_028e: Unknown result type (might be due to invalid IL or missing references)
55326 //IL_0293: Unknown result type (might be due to invalid IL or missing references)
55327 //IL_031f: Unknown result type (might be due to invalid IL or missing references)
55328 //IL_0324: Unknown result type (might be due to invalid IL or missing references)
55329 //IL_0e16: Unknown result type (might be due to invalid IL or missing references)
55330 //IL_0e1b: Unknown result type (might be due to invalid IL or missing references)
55331 //IL_0e20: Unknown result type (might be due to invalid IL or missing references)
55332 //IL_0e27: Unknown result type (might be due to invalid IL or missing references)
55333 //IL_0e2e: Unknown result type (might be due to invalid IL or missing references)
55334 //IL_03ab: Unknown result type (might be due to invalid IL or missing references)
55335 //IL_03ac: Unknown result type (might be due to invalid IL or missing references)
55336 //IL_03b4: Unknown result type (might be due to invalid IL or missing references)
55337 //IL_03b9: Unknown result type (might be due to invalid IL or missing references)
55338 //IL_03c0: Unknown result type (might be due to invalid IL or missing references)
55339 //IL_03c2: Unknown result type (might be due to invalid IL or missing references)
55340 //IL_03c8: Unknown result type (might be due to invalid IL or missing references)
55341 //IL_03cd: Unknown result type (might be due to invalid IL or missing references)
55342 //IL_0e68: Unknown result type (might be due to invalid IL or missing references)
55343 //IL_0e6f: Unknown result type (might be due to invalid IL or missing references)
55344 //IL_0e47: Unknown result type (might be due to invalid IL or missing references)
55345 //IL_0e4e: Unknown result type (might be due to invalid IL or missing references)
55346 //IL_0650: Unknown result type (might be due to invalid IL or missing references)
55347 //IL_065a: Unknown result type (might be due to invalid IL or missing references)
55348 //IL_065f: Unknown result type (might be due to invalid IL or missing references)
55349 //IL_0664: Unknown result type (might be due to invalid IL or missing references)
55350 //IL_0667: Unknown result type (might be due to invalid IL or missing references)
55351 //IL_0671: Unknown result type (might be due to invalid IL or missing references)
55352 //IL_0676: Unknown result type (might be due to invalid IL or missing references)
55353 //IL_067b: Unknown result type (might be due to invalid IL or missing references)
55354 //IL_0682: Unknown result type (might be due to invalid IL or missing references)
55355 //IL_0687: Unknown result type (might be due to invalid IL or missing references)
55356 //IL_068c: Unknown result type (might be due to invalid IL or missing references)
55357 //IL_0691: Unknown result type (might be due to invalid IL or missing references)
55358 //IL_0698: Unknown result type (might be due to invalid IL or missing references)
55359 //IL_069d: Unknown result type (might be due to invalid IL or missing references)
55360 //IL_06a2: Unknown result type (might be due to invalid IL or missing references)
55361 //IL_06a7: Unknown result type (might be due to invalid IL or missing references)
55362 //IL_06b0: Unknown result type (might be due to invalid IL or missing references)
55363 //IL_06b8: Unknown result type (might be due to invalid IL or missing references)
55364 //IL_0801: Unknown result type (might be due to invalid IL or missing references)
55365 //IL_0749: Unknown result type (might be due to invalid IL or missing references)
55366 //IL_074e: Unknown result type (might be due to invalid IL or missing references)
55367 //IL_0753: Unknown result type (might be due to invalid IL or missing references)
55368 //IL_0755: Unknown result type (might be due to invalid IL or missing references)
55369 //IL_0861: Unknown result type (might be due to invalid IL or missing references)
55370 //IL_086e: Unknown result type (might be due to invalid IL or missing references)
55371 //IL_087a: Unknown result type (might be due to invalid IL or missing references)
55372 //IL_0881: Unknown result type (might be due to invalid IL or missing references)
55373 //IL_078b: Unknown result type (might be due to invalid IL or missing references)
55374 //IL_0795: Unknown result type (might be due to invalid IL or missing references)
55375 //IL_07a4: Unknown result type (might be due to invalid IL or missing references)
55376 //IL_0893: Unknown result type (might be due to invalid IL or missing references)
55377 //IL_08a0: Unknown result type (might be due to invalid IL or missing references)
55378 //IL_07ce: Unknown result type (might be due to invalid IL or missing references)
55379 //IL_08ac: Unknown result type (might be due to invalid IL or missing references)
55380 //IL_08b3: Unknown result type (might be due to invalid IL or missing references)
55381 //IL_08ea: Unknown result type (might be due to invalid IL or missing references)
55382 //IL_0928: Unknown result type (might be due to invalid IL or missing references)
55383 //IL_0bd6: Unknown result type (might be due to invalid IL or missing references)
55384 //IL_0bdb: Unknown result type (might be due to invalid IL or missing references)
55385 //IL_0bdf: Unknown result type (might be due to invalid IL or missing references)
55386 //IL_0be4: Unknown result type (might be due to invalid IL or missing references)
55387 //IL_0c23: Unknown result type (might be due to invalid IL or missing references)
55388 if (Main.player[owner].dead || Main.player[owner].stoned || Main.player[owner].webbed || Main.player[owner].frozen)
55389 {
55390 Kill();
55391 return;
55392 }
55393 Vector2 mountedCenter = Main.player[owner].MountedCenter;
55394 Vector2 vector = default(Vector2);
55395 ((Vector2)(ref vector))._002Ector(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
55396 float num = mountedCenter.X - vector.X;
55397 float num12 = mountedCenter.Y - vector.Y;
55398 float num13 = (float)Math.Sqrt(num * num + num12 * num12);
55399 rotation = (float)Math.Atan2(num12, num) - 1.57f;
55400 if (ai[0] == 2f && type == 865)
55401 {
55402 float num14 = (float)Math.PI / 2f;
55403 int num15 = (int)Math.Round(rotation / num14);
55404 rotation = (float)num15 * num14;
55405 }
55406 if (Main.myPlayer == owner)
55407 {
55408 int num16 = (int)(base.Center.X / 16f);
55409 int num17 = (int)(base.Center.Y / 16f);
55410 if (num16 > 0 && num17 > 0 && num16 < Main.maxTilesX && num17 < Main.maxTilesY && Main.tile[num16, num17].nactive() && TileID.Sets.CrackedBricks[Main.tile[num16, num17].type] && Main.rand.Next(16) == 0)
55411 {
55412 WorldGen.KillTile(num16, num17);
55413 if (Main.netMode != 0)
55414 {
55415 NetMessage.SendData(17, -1, -1, null, 20, num16, num17);
55416 }
55417 }
55418 }
55419 if (num13 > 2500f)
55420 {
55421 Kill();
55422 }
55423 if (type == 256)
55424 {
55425 rotation = (float)Math.Atan2(num12, num) + 3.9250002f;
55426 }
55427 if (type == 446)
55428 {
55429 Lighting.AddLight(mountedCenter, 0f, 0.4f, 0.3f);
55430 localAI[0] += 1f;
55431 if (localAI[0] >= 28f)
55432 {
55433 localAI[0] = 0f;
55434 }
55435 DelegateMethods.v3_1 = new Vector3(0f, 0.4f, 0.3f);
55436 Utils.PlotTileLine(base.Center, mountedCenter, 8f, DelegateMethods.CastLightOpen);
55437 }
55438 if (type == 652 && ++frameCounter >= 7)
55439 {
55440 frameCounter = 0;
55441 if (++frame >= Main.projFrames[type])
55442 {
55443 frame = 0;
55444 }
55445 }
55446 if (type >= 646 && type <= 649)
55447 {
55448 Vector3 vector2 = Vector3.Zero;
55449 switch (type)
55450 {
55451 case 646:
55452 ((Vector3)(ref vector2))._002Ector(0.7f, 0.5f, 0.1f);
55453 break;
55454 case 647:
55455 ((Vector3)(ref vector2))._002Ector(0f, 0.6f, 0.7f);
55456 break;
55457 case 648:
55458 ((Vector3)(ref vector2))._002Ector(0.6f, 0.2f, 0.6f);
55459 break;
55460 case 649:
55461 ((Vector3)(ref vector2))._002Ector(0.6f, 0.6f, 0.9f);
55462 break;
55463 }
55464 Lighting.AddLight(mountedCenter, vector2);
55465 Lighting.AddLight(base.Center, vector2);
55466 DelegateMethods.v3_1 = vector2;
55467 Utils.PlotTileLine(base.Center, mountedCenter, 8f, DelegateMethods.CastLightOpen);
55468 }
55469 if (ai[0] == 0f)
55470 {
55471 if ((num13 > 300f && type == 13) || (num13 > 400f && type == 32) || (num13 > 440f && type == 73) || (num13 > 440f && type == 74) || (num13 > 375f && type == 165) || (num13 > 350f && type == 256) || (num13 > 500f && type == 315) || (num13 > 550f && type == 322) || (num13 > 400f && type == 331) || (num13 > 550f && type == 332) || (num13 > 400f && type == 372) || (num13 > 300f && type == 396) || (num13 > 550f && type >= 646 && type <= 649) || (num13 > 600f && type == 652) || (num13 > 300f && type == 865) || (num13 > 500f && type == 935) || (num13 > 480f && type >= 486 && type <= 489) || (num13 > 500f && type == 446))
55472 {
55473 ai[0] = 1f;
55474 }
55475 else if (type >= 230 && type <= 235)
55476 {
55477 int num18 = 300 + (type - 230) * 30;
55478 if (num13 > (float)num18)
55479 {
55480 ai[0] = 1f;
55481 }
55482 }
55483 else if (type == 753)
55484 {
55485 int num19 = 420;
55486 if (num13 > (float)num19)
55487 {
55488 ai[0] = 1f;
55489 }
55490 }
55492 {
55493 ai[0] = 1f;
55494 }
55495 Vector2 vector3 = base.Center - new Vector2(5f);
55496 Vector2 val = base.Center + new Vector2(5f);
55497 Point point = (vector3 - new Vector2(16f)).ToTileCoordinates();
55498 Point val2 = (val + new Vector2(32f)).ToTileCoordinates();
55499 int num2 = point.X;
55500 int num3 = val2.X;
55501 int num4 = point.Y;
55502 int num5 = val2.Y;
55503 if (num2 < 0)
55504 {
55505 num2 = 0;
55506 }
55507 if (num3 > Main.maxTilesX)
55508 {
55509 num3 = Main.maxTilesX;
55510 }
55511 if (num4 < 0)
55512 {
55513 num4 = 0;
55514 }
55515 if (num5 > Main.maxTilesY)
55516 {
55517 num5 = Main.maxTilesY;
55518 }
55519 Player player = Main.player[owner];
55520 List<Point> list = new List<Point>();
55521 Point point2 = default(Point);
55522 for (int i = 0; i < player.grapCount; i++)
55523 {
55524 Projectile projectile = Main.projectile[player.grappling[i]];
55525 if (projectile.aiStyle != 7 || projectile.ai[0] != 2f)
55526 {
55527 continue;
55528 }
55529 Point pt = projectile.Center.ToTileCoordinates();
55530 Tile tileSafely = Framing.GetTileSafely(pt);
55531 if (tileSafely.type != 314 && !TileID.Sets.Platforms[tileSafely.type])
55532 {
55533 continue;
55534 }
55535 for (int j = -2; j <= 2; j++)
55536 {
55537 for (int k = -2; k <= 2; k++)
55538 {
55539 ((Point)(ref point2))._002Ector(pt.X + j, pt.Y + k);
55540 Tile tileSafely2 = Framing.GetTileSafely(point2);
55541 if (tileSafely2.type == 314 || TileID.Sets.Platforms[tileSafely2.type])
55542 {
55543 list.Add(point2);
55544 }
55545 }
55546 }
55547 }
55548 Vector2 vector4 = default(Vector2);
55549 for (int l = num2; l < num3; l++)
55550 {
55551 for (int m = num4; m < num5; m++)
55552 {
55553 if (Main.tile[l, m] == null)
55554 {
55555 Main.tile[l, m] = default(Tile);
55556 }
55557 vector4.X = l * 16;
55558 vector4.Y = m * 16;
55559 if (!(vector3.X + 10f > vector4.X) || !(vector3.X < vector4.X + 16f) || !(vector3.Y + 10f > vector4.Y) || !(vector3.Y < vector4.Y + 16f))
55560 {
55561 continue;
55562 }
55563 Tile tile = Main.tile[l, m];
55564 if (!AI_007_GrapplingHooks_CanTileBeLatchedOnTo(l, m) || list.Contains(new Point(l, m)) || (type == 403 && tile.type != 314) || Main.player[owner].IsBlacklistedForGrappling(new Point(l, m)))
55565 {
55566 continue;
55567 }
55568 if (Main.player[owner].grapCount < 10)
55569 {
55570 Main.player[owner].grappling[Main.player[owner].grapCount] = whoAmI;
55571 Main.player[owner].grapCount++;
55572 }
55573 if (Main.myPlayer != owner)
55574 {
55575 continue;
55576 }
55577 int num6 = 0;
55578 int num7 = -1;
55579 int num8 = 100000;
55580 if (type == 73 || type == 74)
55581 {
55582 for (int n = 0; n < 1000; n++)
55583 {
55584 if (n != whoAmI && Main.projectile[n].active && Main.projectile[n].owner == owner && Main.projectile[n].aiStyle == 7 && Main.projectile[n].ai[0] == 2f)
55585 {
55586 Main.projectile[n].Kill();
55587 }
55588 }
55589 }
55590 else
55591 {
55592 int num9 = 3;
55593 if (type == 165)
55594 {
55595 num9 = 8;
55596 }
55597 if (type == 256)
55598 {
55599 num9 = 2;
55600 }
55601 if (type == 372)
55602 {
55603 num9 = 2;
55604 }
55605 if (type == 652)
55606 {
55607 num9 = 1;
55608 }
55609 if (type >= 646 && type <= 649)
55610 {
55611 num9 = 4;
55612 }
55613 ProjectileLoader.NumGrappleHooks(this, Main.player[owner], ref num9);
55614 for (int num10 = 0; num10 < 1000; num10++)
55615 {
55616 if (Main.projectile[num10].active && Main.projectile[num10].owner == owner && Main.projectile[num10].aiStyle == 7)
55617 {
55618 if (Main.projectile[num10].timeLeft < num8)
55619 {
55620 num7 = num10;
55621 num8 = Main.projectile[num10].timeLeft;
55622 }
55623 num6++;
55624 }
55625 }
55626 if (num6 > num9)
55627 {
55628 Main.projectile[num7].Kill();
55629 }
55630 }
55631 WorldGen.KillTile(l, m, fail: true, effectOnly: true);
55632 SoundEngine.PlaySound(0, l * 16, m * 16);
55633 velocity.X = 0f;
55634 velocity.Y = 0f;
55635 ai[0] = 2f;
55636 position.X = l * 16 + 8 - width / 2;
55637 position.Y = m * 16 + 8 - height / 2;
55638 Rectangle? tileVisualHitbox = WorldGen.GetTileVisualHitbox(l, m);
55639 if (tileVisualHitbox.HasValue)
55640 {
55641 Rectangle value = tileVisualHitbox.Value;
55642 base.Center = ((Rectangle)(ref value)).Center.ToVector2();
55643 }
55644 damage = 0;
55645 netUpdate = true;
55646 if (Main.myPlayer == owner)
55647 {
55648 if (type == 935)
55649 {
55650 Main.player[owner].DoQueenSlimeHookTeleport(base.Center);
55651 }
55652 NetMessage.SendData(13, -1, -1, null, owner);
55653 }
55654 break;
55655 }
55656 if (ai[0] == 2f)
55657 {
55658 break;
55659 }
55660 }
55661 }
55662 else if (ai[0] == 1f)
55663 {
55664 float num11 = 11f;
55665 if (type == 32)
55666 {
55667 num11 = 15f;
55668 }
55669 if (type == 73 || type == 74)
55670 {
55671 num11 = 17f;
55672 }
55673 if (type == 315)
55674 {
55675 num11 = 20f;
55676 }
55677 if (type == 322)
55678 {
55679 num11 = 22f;
55680 }
55681 if (type >= 230 && type <= 235)
55682 {
55683 num11 = 11f + (float)(type - 230) * 0.75f;
55684 }
55685 if (type == 753)
55686 {
55687 num11 = 15f;
55688 }
55689 if (type == 446)
55690 {
55691 num11 = 20f;
55692 }
55693 if (type >= 486 && type <= 489)
55694 {
55695 num11 = 18f;
55696 }
55697 if (type >= 646 && type <= 649)
55698 {
55699 num11 = 24f;
55700 }
55701 if (type == 652)
55702 {
55703 num11 = 24f;
55704 }
55705 if (type == 332)
55706 {
55707 num11 = 17f;
55708 }
55709 ProjectileLoader.GrappleRetreatSpeed(this, Main.player[owner], ref num11);
55710 if (num13 < 24f)
55711 {
55712 Kill();
55713 }
55714 num13 = num11 / num13;
55715 num *= num13;
55716 num12 *= num13;
55717 velocity.X = num;
55718 velocity.Y = num12;
55719 }
55720 else if (ai[0] == 2f)
55721 {
55722 Point point3 = base.Center.ToTileCoordinates();
55723 if (Main.tile[point3.X, point3.Y] == null)
55724 {
55725 Main.tile[point3.X, point3.Y] = default(Tile);
55726 }
55727 bool flag = true;
55729 {
55730 flag = false;
55731 }
55732 if (flag)
55733 {
55734 ai[0] = 1f;
55735 }
55736 else if (Main.player[owner].grapCount < 10)
55737 {
55738 Main.player[owner].grappling[Main.player[owner].grapCount] = whoAmI;
55739 Main.player[owner].grapCount++;
55740 }
55741 }
55742 }
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 ...
Vector2 Center
Definition Entity.cs:70
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
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
static bool[] CrackedBricks
Definition TileID.cs:161
static bool[] Platforms
Definition TileID.cs:219
static void GrappleRetreatSpeed(Projectile projectile, Player player, ref float speed)
static bool GrappleOutOfRange(float distance, Projectile projectile)
static void NumGrappleHooks(Projectile projectile, Player player, ref int numHooks)
This serves as the central class from which projectile-related functions are carried out....
int owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...
int damage
This will always be set in Projectile.NewProjectile based on the weapons damage and player stat modif...
float[] ai
An array with 3 slots used for any sort of data storage, which is occasionally synced to 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 frame
The frame number in the spritesheet that this projectile will be drawn with. Assign in M: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...
bool AI_007_GrapplingHooks_CanTileBeLatchedOnTo(int x, int y)
int frameCounter
Used as a timer to decide when to change F:Terraria.Projectile.frame. Defaults to 0.

References Terraria.Lighting.AddLight(), Terraria.Projectile.ai, Terraria.Projectile.aiStyle, Terraria.DelegateMethods.CastLightOpen(), Terraria.Entity.Center, Terraria.ID.TileID.Sets.CrackedBricks, Terraria.Framing.GetTileSafely(), Terraria.WorldGen.GetTileVisualHitbox(), Terraria.Player.grapCount, Terraria.ModLoader.ProjectileLoader.GrappleOutOfRange(), Terraria.ModLoader.ProjectileLoader.GrappleRetreatSpeed(), Terraria.Player.grappling, Terraria.WorldGen.KillTile(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.ModLoader.ProjectileLoader.NumGrappleHooks(), Terraria.ID.TileID.Sets.Platforms, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Utils.PlotTileLine(), Terraria.Main.projectile, Terraria.Main.projFrames, Terraria.Main.rand, Terraria.NetMessage.SendData(), Terraria.Main.tile, and Terraria.Tile.type.

+ Here is the call graph for this function: