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

◆ AI_067_FreakingPirates()

void Terraria.Projectile.AI_067_FreakingPirates ( )
inlineprivate

Definition at line 40427 of file Projectile.cs.

40428 {
40429 Player player = Main.player[owner];
40430 if (!player.active)
40431 {
40432 active = false;
40433 return;
40434 }
40435 bool flag = type == 393 || type == 394 || type == 395;
40436 bool flag2 = type == 758;
40437 bool flag3 = type == 833 || type == 834 || type == 835;
40438 bool flag4 = type == 834 || type == 835;
40439 bool flag5 = type == 951;
40440 int num = 450;
40441 float num2 = 500f;
40442 float num3 = 300f;
40443 int num4 = 15;
40444 if (flag5)
40445 {
40446 if (player.dead)
40447 {
40448 player.flinxMinion = false;
40449 }
40450 if (player.flinxMinion)
40451 {
40452 timeLeft = 2;
40453 }
40454 num = 800;
40455 }
40456 if (flag)
40457 {
40458 if (player.dead)
40459 {
40460 player.pirateMinion = false;
40461 }
40462 if (player.pirateMinion)
40463 {
40464 timeLeft = 2;
40465 }
40466 num = 800;
40467 }
40468 if (flag3)
40469 {
40470 if (player.dead)
40471 {
40472 player.stormTiger = false;
40473 }
40474 if (player.stormTiger)
40475 {
40476 timeLeft = 2;
40477 }
40478 num = 800;
40479 if (ai[0] != 4f)
40480 {
40481 if (velocity != Vector2.Zero && Main.rand.Next(18) == 0)
40482 {
40483 Dust obj = Main.dust[Dust.NewDust(position, width, height, 269)];
40484 obj.fadeIn = 0.5f;
40485 obj.scale = 0.3f;
40486 obj.noLight = true;
40487 obj.velocity += velocity * 0.005f;
40488 }
40489 if (type == 833)
40490 {
40491 Lighting.AddLight(base.Center, Vector3.One * 0.5f);
40492 }
40493 if (type == 834)
40494 {
40495 Lighting.AddLight(base.Center, Vector3.One * 0.8f);
40496 }
40497 if (type == 835)
40498 {
40499 Lighting.AddLight(base.Center, Color.Lerp(Main.OurFavoriteColor, Color.White, 0.8f).ToVector3() * 1f);
40500 }
40501 }
40502 if (owner == Main.myPlayer)
40503 {
40504 if (localAI[0] <= 0f)
40505 {
40506 int num5 = type switch
40507 {
40508 834 => 300,
40509 835 => 240,
40510 _ => 360,
40511 };
40512 if (damage != 0)
40513 {
40515 localAI[0] = (flag6 ? num5 : 10);
40516 }
40517 }
40518 else
40519 {
40520 localAI[0] -= 1f;
40521 }
40522 }
40523 }
40524 if (flag2)
40525 {
40526 if (player.dead)
40527 {
40528 player.vampireFrog = false;
40529 }
40530 if (player.vampireFrog)
40531 {
40532 timeLeft = 2;
40533 }
40534 num = 800;
40535 }
40536 if (type == 500)
40537 {
40538 num2 = 200f;
40539 if (player.dead)
40540 {
40541 player.crimsonHeart = false;
40542 }
40543 if (player.crimsonHeart)
40544 {
40545 timeLeft = 2;
40546 }
40547 }
40548 if (type == 653)
40549 {
40550 num2 = 300f;
40551 if (player.dead)
40552 {
40553 player.companionCube = false;
40554 }
40555 if (player.companionCube)
40556 {
40557 timeLeft = 2;
40558 }
40559 }
40560 if (type == 1018)
40561 {
40562 num2 = 200f;
40563 if (player.dead)
40564 {
40565 player.petFlagDirtiestBlock = false;
40566 }
40567 if (player.petFlagDirtiestBlock)
40568 {
40569 timeLeft = 2;
40570 }
40571 }
40572 if (flag3 && ai[0] == 4f)
40573 {
40575 frame = 9;
40576 if (flag4)
40577 {
40578 frame = 11;
40579 }
40580 ai[1] -= 1f;
40581 if (!(ai[1] <= 0f))
40582 {
40583 return;
40584 }
40585 ai[0] = 0f;
40586 ai[1] = 0f;
40587 netUpdate = true;
40588 }
40589 Vector2 vector = player.Center;
40590 if (flag5)
40591 {
40592 vector.X -= (45 + player.width / 2) * player.direction;
40593 vector.X -= minionPos * 30 * player.direction;
40594 }
40595 else if (flag)
40596 {
40597 vector.X -= (15 + player.width / 2) * player.direction;
40598 vector.X -= minionPos * 20 * player.direction;
40599 }
40600 else if (flag3)
40601 {
40602 vector.X -= (15 + player.width / 2) * player.direction;
40603 vector.X -= minionPos * 40 * player.direction;
40604 }
40605 else if (flag2)
40606 {
40607 vector.X -= (35 + player.width / 2) * player.direction;
40608 vector.X -= minionPos * 40 * player.direction;
40609 }
40610 else if (type == 500)
40611 {
40612 vector.X -= (15 + player.width / 2) * player.direction;
40613 vector.X -= 40 * player.direction;
40614 }
40615 else if (type == 1018)
40616 {
40617 vector.X = player.Center.X;
40618 }
40619 else if (type == 653)
40620 {
40621 vector.X = player.Center.X;
40622 }
40623 if (type == 500)
40624 {
40625 Lighting.AddLight(base.Center, 0.9f, 0.1f, 0.3f);
40626 int num6 = 6;
40627 if (frame == 0 || frame == 2)
40628 {
40629 num6 = 12;
40630 }
40631 if (++frameCounter >= num6)
40632 {
40633 frameCounter = 0;
40634 if (++frame >= Main.projFrames[type])
40635 {
40636 frame = 0;
40637 }
40638 }
40639 rotation += velocity.X / 20f;
40640 Vector2 vector2 = (-Vector2.UnitY).RotatedBy(rotation).RotatedBy((float)direction * 0.2f);
40641 int num7 = Dust.NewDust(base.Center + vector2 * 10f - new Vector2(4f), 0, 0, 5, vector2.X, vector2.Y, 0, Color.Transparent);
40642 Main.dust[num7].scale = 1f;
40643 Main.dust[num7].velocity = vector2.RotatedByRandom(0.7853981852531433) * 3.5f;
40644 Main.dust[num7].noGravity = true;
40645 Main.dust[num7].shader = GameShaders.Armor.GetSecondaryShader(Main.player[owner].cLight, Main.player[owner]);
40646 }
40647 if (type == 1018)
40648 {
40649 rotation += velocity.X / 20f;
40650 }
40651 if (type == 653)
40652 {
40653 rotation += velocity.X / 20f;
40654 bool flag7 = owner >= 0 && owner < 255;
40655 if (flag7)
40656 {
40659 {
40661 }
40662 }
40663 Tile tileSafely = Framing.GetTileSafely(base.Center);
40664 if (tileSafely.liquid > 0 && tileSafely.lava())
40665 {
40666 localAI[0] += 1f;
40667 }
40668 else
40669 {
40670 localAI[0] -= 1f;
40671 }
40672 localAI[0] = MathHelper.Clamp(localAI[0], 0f, 20f);
40673 if (localAI[0] >= 20f)
40674 {
40676 {
40678 SoundEngine.PlaySound((Main.rand.Next(10) == 0) ? SoundID.NPCDeath61 : SoundID.NPCDeath59, position);
40679 }
40680 Kill();
40681 }
40682 if (flag7 && owner == Main.myPlayer && Main.netMode != 2)
40683 {
40684 Vector3 vector3 = Lighting.GetColor((int)base.Center.X / 16, (int)base.Center.Y / 16).ToVector3();
40685 Vector3 vector4 = Lighting.GetColor((int)player.Center.X / 16, (int)player.Center.Y / 16).ToVector3();
40686 if (vector3.Length() < 0.15f && vector4.Length() < 0.15f)
40687 {
40688 localAI[1] += 1f;
40689 }
40690 else if (localAI[1] > 0f)
40691 {
40692 localAI[1] -= 1f;
40693 }
40694 localAI[1] = MathHelper.Clamp(localAI[1], -3600f, 120f);
40695 if (localAI[1] > (float)Main.rand.Next(30, 120) && !player.immune && player.velocity == Vector2.Zero)
40696 {
40697 if (Main.rand.Next(5) == 0)
40698 {
40700 localAI[1] = -600f;
40701 }
40702 else
40703 {
40705 player.Hurt(PlayerDeathReason.ByOther(6), 3, 0);
40706 player.immune = false;
40707 player.immuneTime = 0;
40708 localAI[1] = -300 + Main.rand.Next(30) * -10;
40709 }
40710 }
40711 }
40712 }
40713 bool flag8 = true;
40714 if (type == 500 || type == 653 || type == 1018)
40715 {
40716 flag8 = false;
40717 }
40718 shouldFallThrough = player.position.Y + (float)player.height - 12f > position.Y + (float)height;
40719 friendly = false;
40720 int num8 = 0;
40721 int num9 = 15;
40722 int attackTarget = -1;
40723 bool flag9 = true;
40724 bool flag10 = ai[0] == 5f;
40725 if (flag5)
40726 {
40727 flag9 = false;
40728 friendly = true;
40729 }
40730 if (flag2)
40731 {
40732 friendly = true;
40733 num9 = 20;
40734 num8 = 60;
40735 }
40736 if (flag3)
40737 {
40738 flag9 = false;
40739 friendly = true;
40740 originalDamage = player.highestStormTigerGemOriginalDamage;
40741 }
40742 bool flag11 = ai[0] == 0f;
40743 if (flag3 && flag10)
40744 {
40745 flag11 = true;
40746 }
40747 if (flag11 && flag8)
40748 {
40750 }
40751 if (flag3 && flag10)
40752 {
40753 if (attackTarget >= 0)
40754 {
40755 float maxDistance = num;
40756 NPC nPC = Main.npc[attackTarget];
40757 vector = nPC.Center;
40759 {
40760 ai[0] = 0f;
40761 ai[1] = 0f;
40762 return;
40763 }
40764 Point point = nPC.Top.ToTileCoordinates();
40765 int num10 = 0;
40766 int num11 = point.Y;
40767 while (num10 < num4)
40768 {
40769 Tile tile = Main.tile[point.X, num11];
40770 if (tile == null || tile.active())
40771 {
40772 break;
40773 }
40774 num10++;
40775 num11++;
40776 }
40777 int num12 = num4 / 2;
40778 if (num10 < num12)
40779 {
40780 ai[0] = 0f;
40781 ai[1] = 0f;
40782 return;
40783 }
40784 if (base.Hitbox.Intersects(nPC.Hitbox) && velocity.Y >= 0f)
40785 {
40786 velocity.Y = -8f;
40787 velocity.X = direction * 10;
40788 }
40789 float num13 = 20f;
40790 float maxAmountAllowedToMove = 4f;
40791 float num14 = 40f;
40792 float num15 = 40f;
40793 Vector2 top = nPC.Top;
40794 float num16 = (float)Math.Cos(Main.timeForVisualEffects / (double)num14 * 6.2831854820251465);
40795 if (num16 > 0f)
40796 {
40797 num16 *= -1f;
40798 }
40799 num16 *= num15;
40800 top.Y += num16;
40801 Vector2 vector5 = top - base.Center;
40802 if (vector5.Length() > num13)
40803 {
40804 vector5 = vector5.SafeNormalize(Vector2.Zero) * num13;
40805 }
40807 frame = 8;
40808 if (flag4)
40809 {
40810 frame = 10;
40811 }
40812 rotation += 0.6f * (float)spriteDirection;
40813 }
40814 else
40815 {
40816 ai[0] = 0f;
40817 ai[1] = 0f;
40818 }
40819 return;
40820 }
40821 if (ai[0] == 1f)
40822 {
40823 tileCollide = false;
40824 float num17 = 0.2f;
40825 float num18 = 10f;
40826 int num19 = 200;
40827 if (num18 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y))
40828 {
40829 num18 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y);
40830 }
40831 Vector2 vector6 = player.Center - base.Center;
40832 float num20 = vector6.Length();
40833 if (num20 > 2000f)
40834 {
40835 position = player.Center - new Vector2(width, height) / 2f;
40836 }
40837 if (num20 < (float)num19 && player.velocity.Y == 0f && position.Y + (float)height <= player.position.Y + (float)player.height && !Collision.SolidCollision(position, width, height))
40838 {
40839 ai[0] = 0f;
40840 netUpdate = true;
40841 if (velocity.Y < -6f)
40842 {
40843 velocity.Y = -6f;
40844 }
40845 }
40846 if (!(num20 < 60f))
40847 {
40848 vector6.Normalize();
40849 vector6 *= num18;
40850 if (velocity.X < vector6.X)
40851 {
40852 velocity.X += num17;
40853 if (velocity.X < 0f)
40854 {
40855 velocity.X += num17 * 1.5f;
40856 }
40857 }
40858 if (velocity.X > vector6.X)
40859 {
40860 velocity.X -= num17;
40861 if (velocity.X > 0f)
40862 {
40863 velocity.X -= num17 * 1.5f;
40864 }
40865 }
40866 if (velocity.Y < vector6.Y)
40867 {
40868 velocity.Y += num17;
40869 if (velocity.Y < 0f)
40870 {
40871 velocity.Y += num17 * 1.5f;
40872 }
40873 }
40874 if (velocity.Y > vector6.Y)
40875 {
40876 velocity.Y -= num17;
40877 if (velocity.Y > 0f)
40878 {
40879 velocity.Y -= num17 * 1.5f;
40880 }
40881 }
40882 }
40883 if (velocity.X != 0f)
40884 {
40886 }
40887 if (flag5)
40888 {
40889 frameCounter++;
40890 if (frameCounter > 3)
40891 {
40892 frame++;
40893 frameCounter = 0;
40894 }
40895 if (frame < 2 || frame >= Main.projFrames[type])
40896 {
40897 frame = 2;
40898 }
40899 rotation = rotation.AngleTowards(rotation + 0.25f * (float)spriteDirection, 0.25f);
40900 }
40901 if (flag)
40902 {
40903 frameCounter++;
40904 if (frameCounter > 3)
40905 {
40906 frame++;
40907 frameCounter = 0;
40908 }
40909 if ((frame < 10) | (frame > 13))
40910 {
40911 frame = 10;
40912 }
40913 rotation = velocity.X * 0.1f;
40914 }
40915 if (flag2)
40916 {
40917 int num21 = 3;
40918 if (++frameCounter >= num21 * 4)
40919 {
40920 frameCounter = 0;
40921 }
40922 frame = 14 + frameCounter / num21;
40923 rotation = velocity.X * 0.15f;
40924 }
40925 if (flag3)
40926 {
40927 frame = 8;
40928 if (flag4)
40929 {
40930 frame = 10;
40931 }
40932 rotation += 0.6f * (float)spriteDirection;
40933 }
40934 if (type == 1018 && Main.LocalPlayer.miscCounter % 3 == 0)
40935 {
40936 int num22 = 2;
40937 Dust obj2 = Main.dust[Dust.NewDust(position + new Vector2(-num22, -num22), 16 + num22 * 2, 16 + num22 * 2, 0, 0f, 0f, 0, default(Color), 0.8f)];
40938 obj2.velocity = -velocity * 0.25f;
40939 obj2.velocity = obj2.velocity.RotatedByRandom(0.2617993950843811);
40940 }
40941 }
40942 if (ai[0] == 2f && ai[1] < 0f)
40943 {
40944 friendly = false;
40945 ai[1] += 1f;
40946 if (num9 >= 0)
40947 {
40948 ai[1] = 0f;
40949 ai[0] = 0f;
40950 netUpdate = true;
40951 return;
40952 }
40953 }
40954 else if (ai[0] == 2f)
40955 {
40957 rotation = 0f;
40958 if (flag)
40959 {
40960 friendly = true;
40961 frame = 4 + (int)((float)num9 - ai[1]) / (num9 / 3);
40962 if (velocity.Y != 0f)
40963 {
40964 frame += 3;
40965 }
40966 }
40967 if (flag2)
40968 {
40969 float num23 = ((float)num9 - ai[1]) / (float)num9;
40970 if ((double)num23 > 0.25 && (double)num23 < 0.75)
40971 {
40972 friendly = true;
40973 }
40974 int num24 = (int)(num23 * 5f);
40975 if (num24 > 2)
40976 {
40977 num24 = 4 - num24;
40978 }
40979 if (velocity.Y != 0f)
40980 {
40981 frame = 21 + num24;
40982 }
40983 else
40984 {
40985 frame = 18 + num24;
40986 }
40987 if (velocity.Y == 0f)
40988 {
40989 velocity.X *= 0.8f;
40990 }
40991 }
40992 velocity.Y += 0.4f;
40993 if (velocity.Y > 10f)
40994 {
40995 velocity.Y = 10f;
40996 }
40997 ai[1] -= 1f;
40998 if (ai[1] <= 0f)
40999 {
41000 if (num8 <= 0)
41001 {
41002 ai[1] = 0f;
41003 ai[0] = 0f;
41004 netUpdate = true;
41005 return;
41006 }
41007 ai[1] = -num8;
41008 }
41009 }
41010 if (attackTarget >= 0)
41011 {
41012 float maxDistance2 = num;
41013 float num25 = 20f;
41014 if (flag2)
41015 {
41016 num25 = 50f;
41017 }
41018 NPC nPC2 = Main.npc[attackTarget];
41019 Vector2 center = nPC2.Center;
41020 vector = center;
41022 {
41023 shouldFallThrough = nPC2.Center.Y > base.Bottom.Y;
41024 bool flag12 = velocity.Y == 0f;
41025 if (wet && velocity.Y > 0f && !shouldFallThrough)
41026 {
41027 flag12 = true;
41028 }
41029 if (center.Y < base.Center.Y - 30f && flag12)
41030 {
41031 float num26 = (center.Y - base.Center.Y) * -1f;
41032 float num27 = 0.4f;
41033 float num28 = (float)Math.Sqrt(num26 * 2f * num27);
41034 if (num28 > 26f)
41035 {
41036 num28 = 26f;
41037 }
41038 velocity.Y = 0f - num28;
41039 }
41040 if (flag9 && Vector2.Distance(base.Center, vector) < num25)
41041 {
41042 if (velocity.Length() > 10f)
41043 {
41044 velocity /= velocity.Length() / 10f;
41045 }
41046 ai[0] = 2f;
41047 ai[1] = num9;
41048 netUpdate = true;
41049 direction = ((center.X - base.Center.X > 0f) ? 1 : (-1));
41050 }
41051 if (flag3)
41052 {
41053 Point point2 = nPC2.Top.ToTileCoordinates();
41054 int num29 = 0;
41055 int num30 = point2.Y;
41056 while (num29 < num4)
41057 {
41058 Tile tile2 = Main.tile[point2.X, num30];
41059 if (tile2 == null || tile2.active())
41060 {
41061 break;
41062 }
41063 num29++;
41064 num30++;
41065 }
41066 if (num29 >= num4)
41067 {
41068 ai[0] = 5f;
41069 ai[1] = 0f;
41070 netUpdate = true;
41071 return;
41072 }
41073 if (base.Hitbox.Intersects(nPC2.Hitbox) && velocity.Y >= 0f)
41074 {
41075 velocity.Y = -4f;
41076 velocity.X = direction * 10;
41077 }
41078 }
41079 }
41080 if (flag2)
41081 {
41082 int num31 = 1;
41083 if (center.X - base.Center.X < 0f)
41084 {
41085 num31 = -1;
41086 }
41087 vector.X += 20 * -num31;
41088 }
41089 }
41090 if (ai[0] == 0f && attackTarget < 0)
41091 {
41092 if (Main.player[owner].rocketDelay2 > 0)
41093 {
41094 ai[0] = 1f;
41095 netUpdate = true;
41096 }
41097 Vector2 vector7 = player.Center - base.Center;
41098 if (vector7.Length() > 2000f)
41099 {
41100 position = player.Center - new Vector2(width, height) / 2f;
41101 }
41102 else if (vector7.Length() > num2 || Math.Abs(vector7.Y) > num3)
41103 {
41104 ai[0] = 1f;
41105 netUpdate = true;
41106 if (velocity.Y > 0f && vector7.Y < 0f)
41107 {
41108 velocity.Y = 0f;
41109 }
41110 if (velocity.Y < 0f && vector7.Y > 0f)
41111 {
41112 velocity.Y = 0f;
41113 }
41114 }
41115 }
41116 if (ai[0] == 0f)
41117 {
41118 if (attackTarget < 0)
41119 {
41120 if (Distance(player.Center) > 60f && Distance(vector) > 60f && Math.Sign(vector.X - player.Center.X) != Math.Sign(base.Center.X - player.Center.X))
41121 {
41122 vector = player.Center;
41123 }
41124 Rectangle r = Utils.CenteredRectangle(vector, base.Size);
41125 for (int i = 0; i < 20; i++)
41126 {
41127 if (Collision.SolidCollision(r.TopLeft(), r.Width, r.Height))
41128 {
41129 break;
41130 }
41131 r.Y += 16;
41132 vector.Y += 16f;
41133 }
41134 Vector2 vector8 = Collision.TileCollision(player.Center - base.Size / 2f, vector - player.Center, width, height);
41135 vector = player.Center - base.Size / 2f + vector8;
41136 if (Distance(vector) < 32f)
41137 {
41138 float num32 = player.Center.Distance(vector);
41139 if (player.Center.Distance(base.Center) < num32)
41140 {
41141 vector = base.Center;
41142 }
41143 }
41144 Vector2 vector9 = player.Center - vector;
41145 if (vector9.Length() > num2 || Math.Abs(vector9.Y) > num3)
41146 {
41147 Rectangle r2 = Utils.CenteredRectangle(player.Center, base.Size);
41148 Vector2 vector10 = vector - player.Center;
41149 Vector2 vector11 = r2.TopLeft();
41150 for (float num33 = 0f; num33 < 1f; num33 += 0.05f)
41151 {
41152 Vector2 vector12 = r2.TopLeft() + vector10 * num33;
41153 if (Collision.SolidCollision(r2.TopLeft() + vector10 * num33, r.Width, r.Height))
41154 {
41155 break;
41156 }
41158 }
41159 vector = vector11 + base.Size / 2f;
41160 }
41161 }
41162 tileCollide = true;
41163 float num34 = 0.5f;
41164 float num35 = 4f;
41165 float num36 = 4f;
41166 float num37 = 0.1f;
41167 if (flag5 && attackTarget != -1)
41168 {
41169 num34 = 0.65f;
41170 num35 = 5.5f;
41171 num36 = 5.5f;
41172 }
41173 if (flag && attackTarget != -1)
41174 {
41175 num34 = 1f;
41176 num35 = 8f;
41177 num36 = 8f;
41178 }
41179 if (flag2 && attackTarget != -1)
41180 {
41181 num34 = 0.7f;
41182 num35 = 6f;
41183 num36 = 6f;
41184 }
41185 if (flag3 && attackTarget != -1)
41186 {
41187 num34 = 1f;
41188 num35 = 8f;
41189 num36 = 8f;
41190 }
41191 if (num36 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y))
41192 {
41193 num36 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y);
41194 num34 = 0.7f;
41195 }
41196 if (type == 653 || type == 1018)
41197 {
41198 float num38 = player.velocity.Length();
41199 if (num38 < 0.1f)
41200 {
41201 num38 = 0f;
41202 }
41203 if (num38 != 0f && num38 < num36)
41204 {
41205 num36 = num38;
41206 }
41207 }
41208 int num39 = 0;
41209 bool flag13 = false;
41210 float num40 = vector.X - base.Center.X;
41211 Vector2 vector13 = vector - base.Center;
41212 if (type == 1018 && Math.Abs(num40) < 50f)
41213 {
41214 rotation = rotation.AngleTowards(0f, 0.2f);
41215 velocity.X *= 0.9f;
41216 if ((double)Math.Abs(velocity.X) < 0.1)
41217 {
41218 velocity.X = 0f;
41219 }
41220 }
41221 else if (type == 653 && Math.Abs(num40) < 150f)
41222 {
41223 rotation = rotation.AngleTowards(0f, 0.2f);
41224 velocity.X *= 0.9f;
41225 if ((double)Math.Abs(velocity.X) < 0.1)
41226 {
41227 velocity.X = 0f;
41228 }
41229 }
41230 else if (Math.Abs(num40) > 5f)
41231 {
41232 if (num40 < 0f)
41233 {
41234 num39 = -1;
41235 if (velocity.X > 0f - num35)
41236 {
41237 velocity.X -= num34;
41238 }
41239 else
41240 {
41241 velocity.X -= num37;
41242 }
41243 }
41244 else
41245 {
41246 num39 = 1;
41247 if (velocity.X < num35)
41248 {
41249 velocity.X += num34;
41250 }
41251 else
41252 {
41253 velocity.X += num37;
41254 }
41255 }
41256 bool flag14 = true;
41257 if (flag)
41258 {
41259 flag14 = false;
41260 }
41261 if (type == 653)
41262 {
41263 flag14 = false;
41264 }
41265 if (type == 1018)
41266 {
41267 flag14 = false;
41268 }
41269 if (flag2 && attackTarget == -1)
41270 {
41271 flag14 = false;
41272 }
41273 if (flag3)
41274 {
41275 flag14 = vector13.Y < -80f;
41276 }
41277 if (flag5)
41278 {
41279 flag14 = attackTarget > -1 && Main.npc[attackTarget].Hitbox.Intersects(base.Hitbox);
41280 }
41281 if (flag14)
41282 {
41283 flag13 = true;
41284 }
41285 }
41286 else
41287 {
41288 velocity.X *= 0.9f;
41289 if (Math.Abs(velocity.X) < num34 * 2f)
41290 {
41291 velocity.X = 0f;
41292 }
41293 }
41294 bool flag15 = Math.Abs(vector13.X) >= 64f || (vector13.Y <= -48f && Math.Abs(vector13.X) >= 8f);
41295 if (num39 != 0 && flag15)
41296 {
41297 int num41 = (int)(position.X + (float)(width / 2)) / 16;
41298 int num42 = (int)position.Y / 16;
41299 num41 += num39;
41300 num41 += (int)velocity.X;
41301 for (int j = num42; j < num42 + height / 16 + 1; j++)
41302 {
41303 if (WorldGen.SolidTile(num41, j))
41304 {
41305 flag13 = true;
41306 }
41307 }
41308 }
41309 if (type == 500 && velocity.X != 0f)
41310 {
41311 flag13 = true;
41312 }
41313 if (type == 653 && Math.Abs(velocity.X) > 3f)
41314 {
41315 flag13 = true;
41316 }
41317 if (type == 1018 && Math.Abs(velocity.X) > 3f)
41318 {
41319 flag13 = true;
41320 }
41321 Collision.StepUp(ref position, ref velocity, width, height, ref stepSpeed, ref gfxOffY);
41322 float num43 = Utils.GetLerpValue(0f, 100f, vector13.Y, clamped: true) * Utils.GetLerpValue(-2f, -6f, velocity.Y, clamped: true);
41323 if (velocity.Y == 0f)
41324 {
41325 if (flag13)
41326 {
41327 for (int k = 0; k < 3; k++)
41328 {
41329 int num44 = (int)(position.X + (float)(width / 2)) / 16;
41330 if (k == 0)
41331 {
41332 num44 = (int)position.X / 16;
41333 }
41334 if (k == 2)
41335 {
41336 num44 = (int)(position.X + (float)width) / 16;
41337 }
41338 int num45 = (int)(position.Y + (float)height) / 16;
41339 if (!WorldGen.SolidTile(num44, num45) && !Main.tile[num44, num45].halfBrick() && Main.tile[num44, num45].slope() <= 0 && (!TileID.Sets.Platforms[Main.tile[num44, num45].type] || !Main.tile[num44, num45].active() || Main.tile[num44, num45].inActive()))
41340 {
41341 continue;
41342 }
41343 try
41344 {
41345 num44 = (int)(position.X + (float)(width / 2)) / 16;
41346 num45 = (int)(position.Y + (float)(height / 2)) / 16;
41347 num44 += num39;
41348 num44 += (int)velocity.X;
41349 if (!WorldGen.SolidTile(num44, num45 - 1) && !WorldGen.SolidTile(num44, num45 - 2))
41350 {
41351 velocity.Y = -5.1f;
41352 }
41353 else if (!WorldGen.SolidTile(num44, num45 - 2))
41354 {
41355 velocity.Y = -7.1f;
41356 }
41357 else if (WorldGen.SolidTile(num44, num45 - 5))
41358 {
41359 velocity.Y = -11.1f;
41360 }
41361 else if (WorldGen.SolidTile(num44, num45 - 4))
41362 {
41363 velocity.Y = -10.1f;
41364 }
41365 else
41366 {
41367 velocity.Y = -9.1f;
41368 }
41369 }
41370 catch
41371 {
41372 velocity.Y = -9.1f;
41373 }
41374 }
41375 if (vector.Y - base.Center.Y < -48f)
41376 {
41377 float num46 = vector.Y - base.Center.Y;
41378 num46 *= -1f;
41379 if (num46 < 60f)
41380 {
41381 velocity.Y = -6f;
41382 }
41383 else if (num46 < 80f)
41384 {
41385 velocity.Y = -7f;
41386 }
41387 else if (num46 < 100f)
41388 {
41389 velocity.Y = -8f;
41390 }
41391 else if (num46 < 120f)
41392 {
41393 velocity.Y = -9f;
41394 }
41395 else if (num46 < 140f)
41396 {
41397 velocity.Y = -10f;
41398 }
41399 else if (num46 < 160f)
41400 {
41401 velocity.Y = -11f;
41402 }
41403 else if (num46 < 190f)
41404 {
41405 velocity.Y = -12f;
41406 }
41407 else if (num46 < 210f)
41408 {
41409 velocity.Y = -13f;
41410 }
41411 else if (num46 < 270f)
41412 {
41413 velocity.Y = -14f;
41414 }
41415 else if (num46 < 310f)
41416 {
41417 velocity.Y = -15f;
41418 }
41419 else
41420 {
41421 velocity.Y = -16f;
41422 }
41423 }
41424 if (wet && num43 == 0f)
41425 {
41426 velocity.Y *= 2f;
41427 }
41428 }
41429 if (type == 1018 && localAI[2] == 0f)
41430 {
41431 localAI[2] = 1f;
41432 for (int l = 0; l < 6; l++)
41433 {
41434 Dust obj4 = Main.dust[Dust.NewDust(position + velocity, 16, 16, 0, 0f, 0f, 0, default(Color), 0.8f)];
41435 obj4.velocity.X = velocity.X * 0.25f;
41436 obj4.velocity.Y = -2f + Math.Abs(velocity.Y) * 0.25f;
41437 obj4.velocity = obj4.velocity.RotatedByRandom(0.2617993950843811);
41438 }
41439 }
41440 }
41441 else if (type == 1018)
41442 {
41443 localAI[2] = 0f;
41444 }
41445 if (velocity.X > num36)
41446 {
41447 velocity.X = num36;
41448 }
41449 if (velocity.X < 0f - num36)
41450 {
41451 velocity.X = 0f - num36;
41452 }
41453 if (velocity.X < 0f)
41454 {
41455 direction = -1;
41456 }
41457 if (velocity.X > 0f)
41458 {
41459 direction = 1;
41460 }
41461 if (velocity.X == 0f)
41462 {
41463 direction = ((player.Center.X > base.Center.X) ? 1 : (-1));
41464 }
41465 if (velocity.X > num34 && num39 == 1)
41466 {
41467 direction = 1;
41468 }
41469 if (velocity.X < 0f - num34 && num39 == -1)
41470 {
41471 direction = -1;
41472 }
41474 if (flag5)
41475 {
41476 if (velocity.Y == 0f)
41477 {
41478 rotation = rotation.AngleTowards(0f, 0.3f);
41479 if (velocity.X == 0f)
41480 {
41481 frame = 0;
41482 frameCounter = 0;
41483 }
41484 else if (Math.Abs(velocity.X) >= 0.5f)
41485 {
41486 frameCounter += (int)Math.Abs(velocity.X);
41487 frameCounter++;
41488 if (frameCounter > 10)
41489 {
41490 frame++;
41491 frameCounter = 0;
41492 }
41493 if (frame < 2 || frame >= Main.projFrames[type])
41494 {
41495 frame = 2;
41496 }
41497 }
41498 else
41499 {
41500 frame = 0;
41501 frameCounter = 0;
41502 }
41503 }
41504 else if (velocity.Y != 0f)
41505 {
41506 rotation = Math.Min(4f, velocity.Y) * -0.1f;
41507 if (spriteDirection == -1)
41508 {
41509 rotation -= (float)Math.PI * 2f;
41510 }
41511 frameCounter = 0;
41512 frame = 1;
41513 }
41514 }
41515 if (flag)
41516 {
41517 rotation = 0f;
41518 if (velocity.Y == 0f)
41519 {
41520 if (velocity.X == 0f)
41521 {
41522 frame = 0;
41523 frameCounter = 0;
41524 }
41525 else if (Math.Abs(velocity.X) >= 0.5f)
41526 {
41527 frameCounter += (int)Math.Abs(velocity.X);
41528 frameCounter++;
41529 if (frameCounter > 10)
41530 {
41531 frame++;
41532 frameCounter = 0;
41533 }
41534 if (frame >= 4)
41535 {
41536 frame = 0;
41537 }
41538 }
41539 else
41540 {
41541 frame = 0;
41542 frameCounter = 0;
41543 }
41544 }
41545 else if (velocity.Y != 0f)
41546 {
41547 frameCounter = 0;
41548 frame = 14;
41549 }
41550 }
41551 if (flag2)
41552 {
41553 rotation = 0f;
41554 if (velocity.Y == 0f)
41555 {
41556 if (velocity.X == 0f)
41557 {
41558 int num47 = 4;
41559 if (++frameCounter >= 7 * num47 && Main.rand.Next(50) == 0)
41560 {
41561 frameCounter = 0;
41562 }
41563 int num48 = frameCounter / num47;
41564 if (num48 >= 4)
41565 {
41566 num48 = 6 - num48;
41567 }
41568 if (num48 < 0)
41569 {
41570 num48 = 0;
41571 }
41572 frame = 1 + num48;
41573 }
41574 else if (Math.Abs(velocity.X) >= 0.5f)
41575 {
41576 frameCounter += (int)Math.Abs(velocity.X);
41577 frameCounter++;
41578 int num49 = 15;
41579 int num50 = 8;
41580 if (frameCounter >= num50 * num49)
41581 {
41582 frameCounter = 0;
41583 }
41584 int num51 = frameCounter / num49;
41585 frame = num51 + 5;
41586 }
41587 else
41588 {
41589 frame = 0;
41590 frameCounter = 0;
41591 }
41592 }
41593 else if (velocity.Y != 0f)
41594 {
41595 if (velocity.Y < 0f)
41596 {
41597 if (frame > 9 || frame < 5)
41598 {
41599 frame = 5;
41600 frameCounter = 0;
41601 }
41602 if (++frameCounter >= 1 && frame < 9)
41603 {
41604 frame++;
41605 frameCounter = 0;
41606 }
41607 }
41608 else
41609 {
41610 if (frame > 13 || frame < 9)
41611 {
41612 frame = 9;
41613 frameCounter = 0;
41614 }
41615 if (++frameCounter >= 2 && frame < 11)
41616 {
41617 frame++;
41618 frameCounter = 0;
41619 }
41620 }
41621 }
41622 }
41623 if (flag3)
41624 {
41625 int num52 = 8;
41626 if (flag4)
41627 {
41628 num52 = 10;
41629 }
41630 rotation = 0f;
41631 if (velocity.Y == 0f)
41632 {
41633 if (velocity.X == 0f)
41634 {
41635 frame = 0;
41636 frameCounter = 0;
41637 }
41638 else if (Math.Abs(velocity.X) >= 0.5f)
41639 {
41640 frameCounter += (int)Math.Abs(velocity.X);
41641 frameCounter++;
41642 if (frameCounter > 10)
41643 {
41644 frame++;
41645 frameCounter = 0;
41646 }
41647 if (frame >= num52 || frame < 2)
41648 {
41649 frame = 2;
41650 }
41651 }
41652 else
41653 {
41654 frame = 0;
41655 frameCounter = 0;
41656 }
41657 }
41658 else if (velocity.Y != 0f)
41659 {
41660 frameCounter = 0;
41661 frame = 1;
41662 if (flag4)
41663 {
41664 frame = 9;
41665 }
41666 }
41667 }
41668 velocity.Y += 0.4f + num43 * 1f;
41669 if (velocity.Y > 10f)
41670 {
41671 velocity.Y = 10f;
41672 }
41673 }
41674 if (!flag)
41675 {
41676 return;
41677 }
41678 localAI[0] += 1f;
41679 if (velocity.X == 0f)
41680 {
41681 localAI[0] += 1f;
41682 }
41683 if (localAI[0] >= (float)Main.rand.Next(900, 1200))
41684 {
41685 localAI[0] = 0f;
41686 for (int m = 0; m < 6; m++)
41687 {
41688 int num53 = Dust.NewDust(base.Center + Vector2.UnitX * -direction * 8f - Vector2.One * 5f + Vector2.UnitY * 8f, 3, 6, 216, -direction, 1f);
41689 Main.dust[num53].velocity /= 2f;
41690 Main.dust[num53].scale = 0.8f;
41691 }
41692 int num54 = Gore.NewGore(base.Center + Vector2.UnitX * -direction * 8f, Vector2.Zero, Main.rand.Next(580, 583));
41693 Main.gore[num54].velocity /= 2f;
41694 Main.gore[num54].velocity.Y = Math.Abs(Main.gore[num54].velocity.Y);
41695 Main.gore[num54].velocity.X = (0f - Math.Abs(Main.gore[num54].velocity.X)) * (float)direction;
41696 }
41697 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static double Cos(double d)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Sqrt(double d)
static double Abs(double value)
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static void PlaySound(int type, Vector2 position, int style=1)
static PlayerDeathReason ByOther(int type)
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static readonly LegacySoundStyle Item16
Definition SoundID.cs:446
static readonly LegacySoundStyle Item1
Definition SoundID.cs:416
static readonly LegacySoundStyle NPCDeath59
Definition SoundID.cs:398
static bool[] Platforms
Definition TileID.cs:163
bool IsInRangeOfMeOrMyOwner(Entity entity, float maxDistance, out float myDistance, out float playerDistance, out bool closerIsMe)
void Minion_FindTargetInRange(int startAttackRange, ref int attackTarget, bool skipIfCannotHitWithOwnBody, Func< Entity, int, bool > customEliminationCheck=null)
static float[] _CompanionCubeScreamCooldown
bool AI_067_TigerSpecialAttack()
bool AI_067_CustomEliminationCheck_Pirates(Entity otherEntity, int currentTarget)
static Color Transparent
Definition Color.cs:76
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References System.Math.Abs(), Terraria.Entity.active, Terraria.Tile.active(), Terraria.Lighting.AddLight(), Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.DataStructures.PlayerDeathReason.ByOther(), Terraria.Entity.Center, Terraria.Utils.CenteredRectangle(), Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.Player.companionCube, System.Math.Cos(), Terraria.Player.crimsonHeart, Terraria.Player.dead, Terraria.Entity.direction, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Main.dust, Terraria.Player.flinxMinion, Terraria.Lighting.GetColor(), Terraria.Utils.GetLerpValue(), Terraria.Framing.GetTileSafely(), Terraria.Main.gore, Terraria.Entity.height, Terraria.Player.highestStormTigerGemOriginalDamage, Terraria.Player.Hurt(), Terraria.Player.immune, Terraria.ID.SoundID.Item1, Terraria.ID.SoundID.Item16, Microsoft.Xna.Framework.Vector2.Length(), Microsoft.Xna.Framework.Color.Lerp(), Terraria.Main.LocalPlayer, System.Math.Min(), Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Dust.NewDust(), Terraria.Gore.NewGore(), Terraria.Main.npc, Terraria.ID.SoundID.NPCDeath59, System.obj, Microsoft.Xna.Framework.Vector2.One, Microsoft.Xna.Framework.Vector3.One, Terraria.Main.OurFavoriteColor, Terraria.Player.petFlagDirtiestBlock, System.Math.PI, Terraria.Player.pirateMinion, Terraria.ID.TileID.Sets.Platforms, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.projFrames, Terraria.Main.rand, System.Math.Sign(), Terraria.Collision.SolidCollision(), Terraria.WorldGen.SolidTile(), System.Math.Sqrt(), Terraria.Collision.StepUp(), Terraria.Player.stormTiger, Terraria.Main.tile, Terraria.Collision.TileCollision(), Terraria.Main.timeForVisualEffects, Microsoft.Xna.Framework.Color.Transparent, System.type, Microsoft.Xna.Framework.Vector2.UnitX, Microsoft.Xna.Framework.Vector2.UnitY, Terraria.Player.vampireFrog, Terraria.Entity.velocity, Microsoft.Xna.Framework.Color.White, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Point.Y, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.