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

◆ AI_144_DD2Pet()

void Terraria.Projectile.AI_144_DD2Pet ( )
inlineprivate

Definition at line 58937 of file Projectile.cs.

58938 {
58939 Player player = Main.player[owner];
58940 float num = 4f;
58941 int num2 = 6;
58942 int num3 = 4;
58943 int num4 = Main.projFrames[type];
58944 int num5 = 0;
58945 float num6 = 0.08f;
58946 bool flag = false;
58947 float num7 = 0.1f;
58948 Vector2 vector = new Vector2(player.direction * 30, -20f);
58949 if (player.dead)
58950 {
58951 Kill();
58952 return;
58953 }
58954 bool flag2 = true;
58955 switch (type)
58956 {
58957 case 702:
58958 {
58959 if (player.petFlagDD2Ghost)
58960 {
58961 timeLeft = 2;
58962 }
58963 vector.Y += (float)Math.Cos(localAI[0] * ((float)Math.PI / 60f)) * 2f;
58964 num3 = 4;
58965 num2 = 10;
58966 flag2 = false;
58967 num = 6f;
58968 Vector2 vector3 = new Vector2((spriteDirection == -1) ? (-6) : (-2), -26f).RotatedBy(rotation);
58969 if (Main.rand.Next(24) == 0)
58970 {
58971 Dust dust2 = Dust.NewDustDirect(base.Center + vector3, 4, 4, 135, 0f, 0f, 100);
58972 if (Main.rand.Next(3) != 0)
58973 {
58974 dust2.noGravity = true;
58975 dust2.velocity.Y -= 3f;
58976 dust2.noLight = true;
58977 }
58978 else if (Main.rand.Next(2) != 0)
58979 {
58980 dust2.noLight = true;
58981 }
58982 dust2.velocity *= 0.5f;
58983 dust2.velocity.Y -= 0.9f;
58984 dust2.scale += 0.1f + Main.rand.NextFloat() * 0.6f;
58985 }
58986 DelegateMethods.v3_1 = new Vector3(0.3f, 0.5f, 1f);
58987 Utils.PlotTileLine(base.Center, base.Center + velocity * 6f, 20f, DelegateMethods.CastLightOpen);
58988 Utils.PlotTileLine(base.Left, base.Right, 20f, DelegateMethods.CastLightOpen);
58989 Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 40f, DelegateMethods.CastLightOpen);
58990 Utils.PlotTileLine(player.Left, player.Right, 40f, DelegateMethods.CastLightOpen);
58991 break;
58992 }
58993 case 703:
58994 if (player.petFlagDD2Gato)
58995 {
58996 timeLeft = 2;
58997 }
58998 vector.Y += (float)Math.Cos(localAI[0] * ((float)Math.PI / 30f)) * 2f;
58999 num2 = 4;
59000 num3 = 2;
59001 num = 3f;
59002 num4 = 4;
59003 break;
59004 case 701:
59005 if (player.petFlagDD2Dragon)
59006 {
59007 timeLeft = 2;
59008 }
59009 break;
59010 case 764:
59011 {
59012 num7 = 0.025f;
59013 num6 = 0.04f;
59014 flag = true;
59015 localAI[0] += 1f;
59016 if (localAI[0] > 120f)
59017 {
59018 localAI[0] = 0f;
59019 }
59020 localAI[1] += velocity.X * 0.01f;
59021 localAI[1] += 1f / 120f;
59022 if (localAI[1] < (float)Math.PI * -2f)
59023 {
59024 localAI[1] += (float)Math.PI * 2f;
59025 }
59026 if (localAI[1] > (float)Math.PI * 2f)
59027 {
59028 localAI[1] -= (float)Math.PI * 2f;
59029 }
59030 if (velocity.Length() < 4f)
59031 {
59032 localAI[1] *= 0.9f;
59033 if (velocity.Length() > 0.1f && Main.rand.Next(30) == 0)
59034 {
59035 Dust dust = Dust.NewDustDirect(position - velocity, width, height, 292, velocity.X * 0.5f, velocity.Y * 0.5f, 150);
59036 dust.velocity *= 0.3f;
59037 dust.noLightEmittence = true;
59038 }
59039 }
59040 else
59041 {
59042 Vector2 vector2 = new Vector2(Main.screenWidth, Main.screenHeight);
59043 base.Hitbox.Intersects(Utils.CenteredRectangle(Main.screenPosition + vector2 / 2f, vector2 + new Vector2(400f)));
59044 if (Main.rand.Next(15) == 0)
59045 {
59046 Dust.NewDustDirect(position - velocity, width, height, 292, velocity.X * 0.5f, velocity.Y * 0.5f, 150, default(Color), 0.9f).noLightEmittence = true;
59047 }
59048 }
59049 float num8 = localAI[0] / 120f * 2f;
59050 if (num8 > 1f)
59051 {
59052 num8 = 2f - num8;
59053 }
59054 Opacity = MathHelper.Lerp(0.4f, 0.75f, num8);
59055 vector.Y += (float)Math.Cos(localAI[0] / 120f * ((float)Math.PI * 2f)) * 2f;
59056 if (player.petFlagUpbeatStar)
59057 {
59058 timeLeft = 2;
59059 }
59060 break;
59061 }
59062 }
59063 if (flag2 && (player.suspiciouslookingTentacle || player.petFlagDD2Ghost))
59064 {
59065 vector.X += -player.direction * 64;
59066 }
59067 direction = (spriteDirection = player.direction);
59068 Vector2 vector4 = player.MountedCenter + vector;
59069 float num9 = Vector2.Distance(base.Center, vector4);
59070 if (num9 > 1000f)
59071 {
59072 base.Center = player.Center + vector;
59073 }
59074 Vector2 vector5 = vector4 - base.Center;
59075 if (num9 < num)
59076 {
59077 velocity *= 0.25f;
59078 }
59079 if (vector5 != Vector2.Zero)
59080 {
59081 if (vector5.Length() < num * 0.5f)
59082 {
59083 velocity = vector5;
59084 }
59085 else
59086 {
59087 velocity = vector5 * num7;
59088 }
59089 }
59090 if (velocity.Length() > 6f)
59091 {
59092 float num10 = velocity.X * num6 + velocity.Y * (float)spriteDirection * 0.02f;
59093 if (Math.Abs(rotation - num10) >= (float)Math.PI)
59094 {
59095 if (num10 < rotation)
59096 {
59097 rotation -= (float)Math.PI * 2f;
59098 }
59099 else
59100 {
59101 rotation += (float)Math.PI * 2f;
59102 }
59103 }
59104 float num11 = 12f;
59105 rotation = (rotation * (num11 - 1f) + num10) / num11;
59106 if (++frameCounter >= num3)
59107 {
59108 frameCounter = 0;
59109 if (++frame >= num4)
59110 {
59111 frame = num5;
59112 }
59113 }
59114 }
59115 else
59116 {
59117 if (rotation > (float)Math.PI)
59118 {
59119 rotation -= (float)Math.PI * 2f;
59120 }
59121 if (rotation > -0.005f && rotation < 0.005f)
59122 {
59123 rotation = 0f;
59124 }
59125 else
59126 {
59127 rotation *= 0.96f;
59128 }
59129 if (++frameCounter >= num2)
59130 {
59131 frameCounter = 0;
59132 if (++frame >= num4)
59133 {
59134 frame = num5;
59135 }
59136 }
59137 }
59138 if (!flag)
59139 {
59140 localAI[0] += 1f;
59141 if (localAI[0] > 120f)
59142 {
59143 localAI[0] = 0f;
59144 }
59145 }
59146 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static double Cos(double d)
static double Abs(double value)
const double PI
Definition Math.cs:16
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References System.Math.Abs(), Terraria.DelegateMethods.CastLightOpen(), Terraria.Entity.Center, Terraria.Utils.CenteredRectangle(), System.Math.Cos(), Terraria.Player.dead, Terraria.Entity.direction, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Entity.Left, Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Dust.NewDustDirect(), Terraria.Player.petFlagDD2Dragon, Terraria.Player.petFlagDD2Gato, Terraria.Player.petFlagDD2Ghost, Terraria.Player.petFlagUpbeatStar, System.Math.PI, Terraria.Main.player, Terraria.Utils.PlotTileLine(), Terraria.Main.projFrames, Terraria.Main.rand, Terraria.Entity.Right, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.Player.suspiciouslookingTentacle, System.type, Terraria.Entity.velocity, and Microsoft.Xna.Framework.Vector2.Zero.