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

◆ ItemCheck_EmitUseVisuals()

Rectangle Terraria.Player.ItemCheck_EmitUseVisuals ( Item sItem,
Rectangle itemRectangle )
inlineprivate

Definition at line 42565 of file Player.cs.

42566 {
42567 if (sItem.type == 989 && Main.rand.Next(5) == 0)
42568 {
42569 int num = Main.rand.Next(3);
42570 int num2 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, num switch
42571 {
42572 0 => 15,
42573 1 => 57,
42574 _ => 58,
42575 }, direction * 2, 0f, 150, default(Color), 1.3f);
42576 Main.dust[num2].velocity *= 0.2f;
42577 }
42578 if (sItem.type == 2880 && Main.rand.Next(2) == 0)
42579 {
42580 int type = Utils.SelectRandom<int>(Main.rand, 226, 229);
42581 int num3 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, type, direction * 2, 0f, 150);
42582 Main.dust[num3].velocity *= 0.2f;
42583 Main.dust[num3].noGravity = true;
42584 }
42585 if ((sItem.type == 44 || sItem.type == 45 || sItem.type == 103 || sItem.type == 104) && Main.rand.Next(15) == 0)
42586 {
42587 Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 14, direction * 2, 0f, 150, default(Color), 1.3f);
42588 }
42589 if (sItem.type == 46 && Main.rand.Next(15) == 0)
42590 {
42591 Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 14, direction * 2, 0f, 150, default(Color), 1.3f);
42592 }
42593 if (sItem.type == 273 || sItem.type == 675)
42594 {
42595 if (Main.rand.Next(5) == 0)
42596 {
42597 Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 14, direction * 2, 0f, 150, default(Color), 1.4f);
42598 }
42599 int num4 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 27, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 1.2f);
42600 Main.dust[num4].noGravity = true;
42601 Main.dust[num4].velocity.X /= 2f;
42602 Main.dust[num4].velocity.Y /= 2f;
42603 }
42604 if (sItem.type == 723 && Main.rand.Next(2) == 0)
42605 {
42606 int num5 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 64, 0f, 0f, 150, default(Color), 1.2f);
42607 Main.dust[num5].noGravity = true;
42608 }
42609 if (sItem.type == 65)
42610 {
42611 if (Main.rand.Next(5) == 0)
42612 {
42613 Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 58, 0f, 0f, 150, default(Color), 1.2f);
42614 }
42615 if (Main.rand.Next(10) == 0)
42616 {
42617 Gore.NewGore(new Vector2(itemRectangle.X, itemRectangle.Y), default(Vector2), Main.rand.Next(16, 18));
42618 }
42619 }
42620 if (sItem.type == 3065)
42621 {
42622 int num6 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 58, 0f, 0f, 150, default(Color), 1.2f);
42623 Main.dust[num6].velocity *= 0.5f;
42624 if (Main.rand.Next(8) == 0)
42625 {
42626 int num7 = Gore.NewGore(new Vector2(itemRectangle.Center.X, itemRectangle.Center.Y), default(Vector2), 16);
42627 Main.gore[num7].velocity *= 0.5f;
42628 Main.gore[num7].velocity += new Vector2(direction, 0f);
42629 }
42630 }
42631 if (sItem.type == 190)
42632 {
42633 int num8 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 40, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 0, default(Color), 1.2f);
42634 Main.dust[num8].noGravity = true;
42635 }
42636 else if (sItem.type == 213 || sItem.type == 5295)
42637 {
42638 int num9 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 3, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 0, default(Color), 1.2f);
42639 Main.dust[num9].noGravity = true;
42640 }
42641 if (sItem.type == 121)
42642 {
42643 for (int i = 0; i < 2; i++)
42644 {
42645 GetPointOnSwungItemPath(70f, 70f, 0.2f + 0.8f * Main.rand.NextFloat(), GetAdjustedItemScale(sItem), out var location, out var outwardDirection);
42646 Vector2 vector = outwardDirection.RotatedBy((float)Math.PI / 2f * (float)direction * gravDir);
42647 Dust.NewDustPerfect(location, 6, vector * 4f, 100, default(Color), 2.5f).noGravity = true;
42648 }
42649 }
42650 if (sItem.type == 122 || sItem.type == 217)
42651 {
42652 int num10 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 6, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 1.9f);
42653 Main.dust[num10].noGravity = true;
42654 }
42655 if (sItem.type == 155)
42656 {
42657 int num11 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 172, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 0.9f);
42658 Main.dust[num11].noGravity = true;
42659 Main.dust[num11].velocity *= 0.1f;
42660 }
42661 if (sItem.type == 676 && Main.rand.Next(3) == 0)
42662 {
42663 int num12 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 67, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 90, default(Color), 1.5f);
42664 Main.dust[num12].noGravity = true;
42665 Main.dust[num12].velocity *= 0.2f;
42666 }
42667 if (sItem.type == 3063)
42668 {
42669 int num13 = Dust.NewDust(itemRectangle.TopLeft(), itemRectangle.Width, itemRectangle.Height, 66, 0f, 0f, 150, Color.Transparent, 0.85f);
42670 Main.dust[num13].color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f);
42671 Main.dust[num13].noGravity = true;
42672 Main.dust[num13].velocity /= 2f;
42673 }
42674 if (sItem.type == 3823)
42675 {
42676 Dust dust = Dust.NewDustDirect(itemRectangle.TopLeft(), itemRectangle.Width, itemRectangle.Height, 6, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, Color.Transparent, 0.7f);
42677 dust.noGravity = true;
42678 dust.velocity *= 2f;
42679 dust.fadeIn = 0.9f;
42680 }
42681 if (sItem.type == 724 && Main.rand.Next(5) == 0)
42682 {
42683 int num14 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 67, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 90, default(Color), 1.5f);
42684 Main.dust[num14].noGravity = true;
42685 Main.dust[num14].velocity *= 0.2f;
42686 }
42687 if (sItem.type >= 795 && sItem.type <= 802)
42688 {
42689 for (int j = 0; j < 2; j++)
42690 {
42691 GetPointOnSwungItemPath(60f, 60f, 0.2f + 0.8f * Main.rand.NextFloat(), GetAdjustedItemScale(sItem), out var location2, out var outwardDirection2);
42692 Vector2 vector2 = outwardDirection2.RotatedBy((float)Math.PI / 2f * (float)direction * gravDir);
42693 Dust.NewDustPerfect(location2, 5, vector2 * 2f, 100, default(Color), 0.7f + Main.rand.NextFloat() * 0.6f);
42694 if (Main.rand.Next(20) == 0)
42695 {
42696 int num15 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 115, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 140, default(Color), 0.7f);
42697 Main.dust[num15].position = location2;
42698 Main.dust[num15].fadeIn = 1.2f;
42699 Main.dust[num15].noGravity = true;
42700 Main.dust[num15].velocity *= 0.25f;
42701 Main.dust[num15].velocity += vector2 * 5f;
42702 }
42703 }
42704 }
42705 if (sItem.type == 367)
42706 {
42707 int num16 = 0;
42708 if (Main.rand.Next(3) == 0)
42709 {
42710 num16 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 57, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 1.1f);
42711 Main.dust[num16].noGravity = true;
42712 Main.dust[num16].velocity.X /= 2f;
42713 Main.dust[num16].velocity.Y /= 2f;
42714 Main.dust[num16].velocity.X += direction * 2;
42715 }
42716 if (Main.rand.Next(4) == 0)
42717 {
42718 num16 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 43, 0f, 0f, 254, default(Color), 0.3f);
42719 Main.dust[num16].velocity *= 0f;
42720 }
42721 }
42722 else if (sItem.type != 368)
42723 {
42724 _ = sItem.type;
42725 _ = 674;
42726 }
42727 if (sItem.type == 4258 || sItem.type == 4259 || (sItem.type >= 198 && sItem.type <= 203) || (sItem.type >= 3764 && sItem.type <= 3769))
42728 {
42729 float num17 = 0.5f;
42730 float num18 = 0.5f;
42731 float num19 = 0.5f;
42732 if (sItem.type == 198 || sItem.type == 3764)
42733 {
42734 num17 *= 0.1f;
42735 num18 *= 0.5f;
42736 num19 *= 1.2f;
42737 }
42738 else if (sItem.type == 199 || sItem.type == 3765)
42739 {
42740 num17 *= 1f;
42741 num18 *= 0.2f;
42742 num19 *= 0.1f;
42743 }
42744 else if (sItem.type == 200 || sItem.type == 3766)
42745 {
42746 num17 *= 0.1f;
42747 num18 *= 1f;
42748 num19 *= 0.2f;
42749 }
42750 else if (sItem.type == 201 || sItem.type == 3767)
42751 {
42752 num17 *= 0.8f;
42753 num18 *= 0.1f;
42754 num19 *= 1f;
42755 }
42756 else if (sItem.type == 202 || sItem.type == 3768)
42757 {
42758 num17 *= 0.8f;
42759 num18 *= 0.9f;
42760 num19 *= 1f;
42761 }
42762 else if (sItem.type == 203 || sItem.type == 3769)
42763 {
42764 num17 *= 0.8f;
42765 num18 *= 0.8f;
42766 num19 *= 0f;
42767 }
42768 else if (sItem.type == 4258 || sItem.type == 4259)
42769 {
42770 num17 *= 0.9f;
42771 num18 *= 0.5f;
42772 num19 *= 0f;
42773 }
42774 Lighting.AddLight((int)((itemLocation.X + 6f + velocity.X) / 16f), (int)((itemLocation.Y - 14f) / 16f), num17, num18, num19);
42775 }
42776 if (frostBurn && sItem.melee && !sItem.noMelee && !sItem.noUseGraphic && Main.rand.Next(2) == 0)
42777 {
42778 int num20 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 135, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 2.5f);
42779 Main.dust[num20].noGravity = true;
42780 Main.dust[num20].velocity *= 0.7f;
42781 Main.dust[num20].velocity.Y -= 0.5f;
42782 }
42783 if (sItem.melee && !sItem.noMelee && !sItem.noUseGraphic && meleeEnchant > 0)
42784 {
42785 if (meleeEnchant == 1)
42786 {
42787 if (Main.rand.Next(3) == 0)
42788 {
42789 int num21 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 171, 0f, 0f, 100);
42790 Main.dust[num21].noGravity = true;
42791 Main.dust[num21].fadeIn = 1.5f;
42792 Main.dust[num21].velocity *= 0.25f;
42793 }
42794 }
42795 else if (meleeEnchant == 2)
42796 {
42797 if (Main.rand.Next(2) == 0)
42798 {
42799 int num22 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 75, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 2.5f);
42800 Main.dust[num22].noGravity = true;
42801 Main.dust[num22].velocity *= 0.7f;
42802 Main.dust[num22].velocity.Y -= 0.5f;
42803 }
42804 }
42805 else if (meleeEnchant == 3)
42806 {
42807 if (Main.rand.Next(2) == 0)
42808 {
42809 int num23 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 6, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 2.5f);
42810 Main.dust[num23].noGravity = true;
42811 Main.dust[num23].velocity *= 0.7f;
42812 Main.dust[num23].velocity.Y -= 0.5f;
42813 }
42814 }
42815 else if (meleeEnchant == 4)
42816 {
42817 int num24 = 0;
42818 if (Main.rand.Next(2) == 0)
42819 {
42820 num24 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 57, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 1.1f);
42821 Main.dust[num24].noGravity = true;
42822 Main.dust[num24].velocity.X /= 2f;
42823 Main.dust[num24].velocity.Y /= 2f;
42824 }
42825 }
42826 else if (meleeEnchant == 5)
42827 {
42828 if (Main.rand.Next(2) == 0)
42829 {
42830 int num25 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 169, 0f, 0f, 100);
42831 Main.dust[num25].velocity.X += direction;
42832 Main.dust[num25].velocity.Y += 0.2f;
42833 Main.dust[num25].noGravity = true;
42834 }
42835 }
42836 else if (meleeEnchant == 6)
42837 {
42838 if (Main.rand.Next(2) == 0)
42839 {
42840 int num26 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 135, 0f, 0f, 100);
42841 Main.dust[num26].velocity.X += direction;
42842 Main.dust[num26].velocity.Y += 0.2f;
42843 Main.dust[num26].noGravity = true;
42844 }
42845 }
42846 else if (meleeEnchant == 7)
42847 {
42848 if (Main.rand.Next(20) == 0)
42849 {
42850 int type2 = Main.rand.Next(139, 143);
42851 int num27 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, type2, velocity.X, velocity.Y, 0, default(Color), 1.2f);
42852 Main.dust[num27].velocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
42853 Main.dust[num27].velocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
42854 Main.dust[num27].velocity.X += (float)Main.rand.Next(-50, 51) * 0.05f;
42855 Main.dust[num27].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.05f;
42856 Main.dust[num27].scale *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
42857 }
42858 if (Main.rand.Next(40) == 0)
42859 {
42860 int type3 = Main.rand.Next(276, 283);
42861 int num28 = Gore.NewGore(new Vector2(itemRectangle.X, itemRectangle.Y), velocity, type3);
42862 Main.gore[num28].velocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
42863 Main.gore[num28].velocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f;
42864 Main.gore[num28].scale *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
42865 Main.gore[num28].velocity.X += (float)Main.rand.Next(-50, 51) * 0.05f;
42866 Main.gore[num28].velocity.Y += (float)Main.rand.Next(-50, 51) * 0.05f;
42867 }
42868 }
42869 else if (meleeEnchant == 8 && Main.rand.Next(4) == 0)
42870 {
42871 int num29 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 46, 0f, 0f, 100);
42872 Main.dust[num29].noGravity = true;
42873 Main.dust[num29].fadeIn = 1.5f;
42874 Main.dust[num29].velocity *= 0.25f;
42875 }
42876 }
42877 if (magmaStone && sItem.melee && !sItem.noMelee && !sItem.noUseGraphic && Main.rand.Next(3) != 0)
42878 {
42879 int num30 = Dust.NewDust(new Vector2(itemRectangle.X, itemRectangle.Y), itemRectangle.Width, itemRectangle.Height, 6, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 2.5f);
42880 Main.dust[num30].noGravity = true;
42881 Main.dust[num30].velocity.X *= 2f;
42882 Main.dust[num30].velocity.Y *= 2f;
42883 }
42884 return itemRectangle;
42885 }
const double PI
Definition Math.cs:16
Vector2 velocity
Definition Entity.cs:16
void GetPointOnSwungItemPath(float spriteWidth, float spriteHeight, float normalizedPointOnPath, float itemScale, out Vector2 location, out Vector2 outwardDirection)
Definition Player.cs:42553
byte meleeEnchant
Definition Player.cs:831
float GetAdjustedItemScale(Item item)
Definition Player.cs:40623
Vector2 itemLocation
Definition Player.cs:1183
static Color Transparent
Definition Color.cs:76

References Terraria.Lighting.AddLight(), Terraria.Main.dust, Terraria.Main.gore, Terraria.Main.hslToRgb(), Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), Terraria.Dust.NewDustPerfect(), Terraria.Gore.NewGore(), System.Math.PI, Terraria.Main.rand, Microsoft.Xna.Framework.Color.Transparent, System.type, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.