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

◆ AI_165_Whip()

void Terraria.Projectile.AI_165_Whip ( )
inlineprivate

Definition at line 39469 of file Projectile.cs.

39470 {
39471 Player player = Main.player[owner];
39472 rotation = velocity.ToRotation() + (float)Math.PI / 2f;
39473 ai[0] += 1f;
39475 base.Center = Main.GetPlayerArmPosition(this) + velocity * (ai[0] - 1f);
39476 spriteDirection = ((!(Vector2.Dot(velocity, Vector2.UnitX) < 0f)) ? 1 : (-1));
39477 if (ai[0] >= timeToFlyOut)
39478 {
39479 Kill();
39480 return;
39481 }
39482 player.heldProj = whoAmI;
39483 player.MatchItemTimeToItemAnimation();
39484 if (ai[0] == (float)(int)(timeToFlyOut / 2f))
39485 {
39488 Vector2 vector = WhipPointsForCollision[WhipPointsForCollision.Count - 1];
39490 }
39491 switch (type)
39492 {
39493 case 848:
39494 {
39495 float t3 = ai[0] / timeToFlyOut;
39496 float num5 = Utils.GetLerpValue(0.1f, 0.7f, t3, clamped: true) * Utils.GetLerpValue(0.9f, 0.7f, t3, clamped: true);
39497 if (num5 > 0.1f && Main.rand.NextFloat() < num5 / 2f)
39498 {
39501 Rectangle r4 = Utils.CenteredRectangle(WhipPointsForCollision[WhipPointsForCollision.Count - 1], new Vector2(30f, 30f));
39502 int num6 = Dust.NewDust(r4.TopLeft(), r4.Width, r4.Height, 172, 0f, 0f, 100, default(Color), 1.5f);
39503 Main.dust[num6].noGravity = true;
39504 Main.dust[num6].velocity.X /= 2f;
39505 Main.dust[num6].velocity.Y /= 2f;
39506 }
39507 break;
39508 }
39509 case 847:
39510 {
39511 float t2 = ai[0] / timeToFlyOut;
39512 if (Utils.GetLerpValue(0.1f, 0.7f, t2, clamped: true) * Utils.GetLerpValue(0.9f, 0.7f, t2, clamped: true) > 0.5f && Main.rand.Next(3) != 0)
39513 {
39516 int num2 = Main.rand.Next(WhipPointsForCollision.Count - 10, WhipPointsForCollision.Count);
39517 Rectangle r2 = Utils.CenteredRectangle(WhipPointsForCollision[num2], new Vector2(30f, 30f));
39518 int num3 = 57;
39519 if (Main.rand.Next(3) == 0)
39520 {
39521 num3 = 43;
39522 }
39523 Dust dust3 = Dust.NewDustDirect(r2.TopLeft(), r2.Width, r2.Height, num3, 0f, 0f, 100, Color.White);
39524 dust3.position = WhipPointsForCollision[num2];
39525 dust3.fadeIn = 0.3f;
39527 dust3.noGravity = true;
39528 dust3.velocity *= 0.5f;
39529 dust3.velocity += spinningpoint.RotatedBy((float)player.direction * ((float)Math.PI / 2f));
39530 dust3.velocity *= 0.5f;
39531 }
39532 break;
39533 }
39534 case 849:
39535 {
39536 float num4 = ai[0] / timeToFlyOut;
39537 Utils.GetLerpValue(0.1f, 0.7f, num4, clamped: true);
39538 Utils.GetLerpValue(0.9f, 0.7f, num4, clamped: true);
39539 if (num4 > 0.4f && Main.rand.Next(9) != 0)
39540 {
39543 Rectangle r3 = Utils.CenteredRectangle(WhipPointsForCollision[WhipPointsForCollision.Count - 1], new Vector2(30f, 30f));
39544 Vector2 vector3 = WhipPointsForCollision[WhipPointsForCollision.Count - 2].DirectionTo(WhipPointsForCollision[WhipPointsForCollision.Count - 1]).SafeNormalize(Vector2.Zero);
39545 Dust dust4 = Dust.NewDustDirect(r3.TopLeft(), r3.Width, r3.Height, 191, 0f, 0f, 0, default(Color), 1.3f);
39546 dust4.noGravity = true;
39547 dust4.velocity += vector3 * 2f;
39548 if (Main.rand.Next(2) == 0)
39549 {
39551 {
39552 MovementVector = vector3,
39553 PositionInWorld = r3.Center.ToVector2()
39554 }, owner);
39555 }
39556 Lighting.AddLight(r3.Center.ToVector2(), new Vector3(0.2f, 0f, 0.4f));
39557 }
39558 break;
39559 }
39560 case 915:
39561 {
39562 float t5 = ai[0] / timeToFlyOut;
39563 if (Utils.GetLerpValue(0.1f, 0.7f, t5, clamped: true) * Utils.GetLerpValue(0.9f, 0.7f, t5, clamped: true) > 0.1f)
39564 {
39567 Rectangle r6 = Utils.CenteredRectangle(WhipPointsForCollision[WhipPointsForCollision.Count - 1], new Vector2(30f, 30f));
39568 Vector2 vector5 = WhipPointsForCollision[WhipPointsForCollision.Count - 2].DirectionTo(WhipPointsForCollision[WhipPointsForCollision.Count - 1]).SafeNormalize(Vector2.Zero);
39569 Dust dust7 = Dust.NewDustDirect(r6.TopLeft(), r6.Width, r6.Height, 267, 0f, 0f, 0, Main.hslToRgb(player.miscCounterNormalized * 9f % 1f, 1f, 0.5f), 1.3f);
39570 dust7.velocity *= Main.rand.NextFloat() * 0.8f;
39571 dust7.noGravity = true;
39572 dust7.scale = 0.9f + Main.rand.NextFloat() * 0.9f;
39573 dust7.fadeIn = Main.rand.NextFloat() * 0.9f;
39574 dust7.velocity += vector5 * 2f;
39575 if (dust7.dustIndex != 6000)
39576 {
39577 Dust dust8 = Dust.CloneDust(dust7);
39578 dust8.scale /= 2f;
39579 dust8.fadeIn *= 0.85f;
39580 dust8.color = new Color(255, 255, 255, 255);
39581 }
39582 }
39583 break;
39584 }
39585 case 914:
39586 {
39587 float t6 = ai[0] / timeToFlyOut;
39588 float num8 = Utils.GetLerpValue(0.1f, 0.7f, t6, clamped: true) * Utils.GetLerpValue(0.9f, 0.7f, t6, clamped: true);
39589 if (num8 > 0.1f && Main.rand.NextFloat() < num8 / 2f)
39590 {
39593 Rectangle r7 = Utils.CenteredRectangle(WhipPointsForCollision[WhipPointsForCollision.Count - 1], new Vector2(30f, 30f));
39594 Vector2 vector6 = WhipPointsForCollision[WhipPointsForCollision.Count - 2].DirectionTo(WhipPointsForCollision[WhipPointsForCollision.Count - 1]).SafeNormalize(Vector2.Zero);
39595 Dust dust9 = Dust.NewDustDirect(r7.TopLeft(), r7.Width, r7.Height, 39, 0f, 0f, 0, default(Color), 1.2f);
39596 dust9.noGravity = Main.rand.Next(3) == 0;
39597 dust9.velocity += vector6 * 2f;
39598 }
39599 break;
39600 }
39601 case 952:
39602 {
39603 float t7 = ai[0] / timeToFlyOut;
39604 float num9 = Utils.GetLerpValue(0.1f, 0.7f, t7, clamped: true) * Utils.GetLerpValue(0.9f, 0.7f, t7, clamped: true);
39605 if (num9 > 0.15f && Main.rand.NextFloat() < num9)
39606 {
39609 Rectangle r8 = Utils.CenteredRectangle(WhipPointsForCollision[WhipPointsForCollision.Count - 1], new Vector2(30f, 30f));
39610 Vector2 vector7 = WhipPointsForCollision[WhipPointsForCollision.Count - 2].DirectionTo(WhipPointsForCollision[WhipPointsForCollision.Count - 1]).SafeNormalize(Vector2.Zero);
39611 Dust dust10 = Dust.NewDustDirect(r8.TopLeft(), r8.Width, r8.Height, 26, 0f, 0f, 0, default(Color), 0.7f);
39612 dust10.noGravity = Main.rand.Next(3) == 0;
39613 if (dust10.noGravity)
39614 {
39615 dust10.scale += 0.4f;
39616 }
39617 dust10.velocity += vector7 * 2f;
39618 }
39619 break;
39620 }
39621 case 912:
39622 {
39623 float t4 = ai[0] / timeToFlyOut;
39624 float num7 = Utils.GetLerpValue(0.1f, 0.7f, t4, clamped: true) * Utils.GetLerpValue(0.9f, 0.7f, t4, clamped: true);
39625 if (!(num7 > 0.1f) || !(Main.rand.NextFloat() < num7 / 2f))
39626 {
39627 break;
39628 }
39631 Rectangle r5 = Utils.CenteredRectangle(WhipPointsForCollision[WhipPointsForCollision.Count - 1], new Vector2(30f, 30f));
39632 Vector2 vector4 = WhipPointsForCollision[WhipPointsForCollision.Count - 2].DirectionTo(WhipPointsForCollision[WhipPointsForCollision.Count - 1]).SafeNormalize(Vector2.Zero);
39633 for (int j = 0; j < 3; j++)
39634 {
39635 Dust dust5 = Dust.NewDustDirect(r5.TopLeft(), r5.Width, r5.Height, 16, 0f, 0f, 0, default(Color), 1.2f);
39636 dust5.noGravity = true;
39637 dust5.velocity += vector4 * 2f;
39638 }
39639 for (int k = 0; k < 1; k++)
39640 {
39641 Dust.NewDustDirect(r5.TopLeft(), r5.Width, r5.Height, 13, 0f, 0f, 0, default(Color), 0.8f).velocity += vector4 * 2f;
39642 }
39643 for (int l = 0; l < 3; l++)
39644 {
39645 if (Main.rand.Next(2) != 0)
39646 {
39647 Dust dust6 = Dust.NewDustDirect(r5.TopLeft(), r5.Width, r5.Height, 261, 0f, 0f, 0, Color.Transparent, 0.8f);
39648 dust6.velocity += vector4 * 2f;
39649 dust6.velocity *= 0.3f;
39650 dust6.noGravity = true;
39651 }
39652 }
39653 Lighting.AddLight(r5.Center.ToVector2(), new Vector3(0.1f, 0.1f, 0.2f));
39654 break;
39655 }
39656 case 913:
39657 {
39658 float t = ai[0] / timeToFlyOut;
39659 float num = Utils.GetLerpValue(0.1f, 0.7f, t, clamped: true) * Utils.GetLerpValue(0.9f, 0.7f, t, clamped: true);
39660 if (!(num > 0.1f) || !(Main.rand.NextFloat() < num))
39661 {
39662 break;
39663 }
39666 Rectangle r = Utils.CenteredRectangle(WhipPointsForCollision[WhipPointsForCollision.Count - 1], new Vector2(20f, 20f));
39667 Vector2 vector2 = WhipPointsForCollision[WhipPointsForCollision.Count - 2].DirectionTo(WhipPointsForCollision[WhipPointsForCollision.Count - 1]).SafeNormalize(Vector2.Zero);
39668 for (int i = 0; i < 3; i++)
39669 {
39670 if (Main.rand.Next(3) != 0)
39671 {
39672 continue;
39673 }
39674 if (Main.rand.Next(7) == 0)
39675 {
39676 Dust dust = Dust.NewDustDirect(r.TopLeft(), r.Width, r.Height, 31);
39677 dust.velocity.X /= 2f;
39678 dust.velocity.Y /= 2f;
39679 dust.velocity += vector2 * 2f;
39680 dust.fadeIn = 1f + Main.rand.NextFloat() * 0.6f;
39681 dust.noGravity = true;
39682 continue;
39683 }
39684 Dust dust2 = Dust.NewDustDirect(r.TopLeft(), r.Width, r.Height, 6, 0f, 0f, 0, default(Color), 1.2f);
39685 dust2.velocity += vector2 * 2f;
39686 if (Main.rand.Next(3) != 0)
39687 {
39688 dust2.fadeIn = 0.7f + Main.rand.NextFloat() * 0.9f;
39689 dust2.scale = 0.6f;
39690 dust2.noGravity = true;
39691 }
39692 }
39693 break;
39694 }
39695 }
39696 }
const double PI
Definition Math.cs:16
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 velocity
Definition Entity.cs:16
static void RequestParticleSpawn(bool clientOnly, ParticleOrchestraType type, ParticleOrchestraSettings settings, int? overrideInvokingPlayerIndex=null)
static readonly LegacySoundStyle Item153
Definition SoundID.cs:720
static void FillWhipControlPoints(Projectile proj, List< Vector2 > controlPoints)
List< Vector2 > WhipPointsForCollision
static void GetWhipSettings(Projectile proj, out float timeToFlyOut, out int segments, out float rangeMultiplier)
static Color Transparent
Definition Color.cs:76
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121

References Terraria.Lighting.AddLight(), Terraria.Utils.CenteredRectangle(), System.Collections.Generic.Dictionary< TKey, TValue >.Clear(), Terraria.Dust.CloneDust(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, Terraria.Entity.direction, Microsoft.Xna.Framework.Vector2.Dot(), Terraria.Main.dust, Terraria.Utils.GetLerpValue(), Terraria.Main.GetPlayerArmPosition(), Terraria.Main.hslToRgb(), Terraria.ID.SoundID.Item153, Terraria.Player.MatchItemTimeToItemAnimation(), Terraria.Player.miscCounterNormalized, Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.rand, Terraria.GameContent.Drawing.ParticleOrchestrator.RequestParticleSpawn(), Microsoft.Xna.Framework.Color.Transparent, System.type, Microsoft.Xna.Framework.Vector2.UnitX, Microsoft.Xna.Framework.Color.White, and Microsoft.Xna.Framework.Vector2.Zero.