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

◆ ItemCheck_GetMeleeHitbox()

void Terraria.Player.ItemCheck_GetMeleeHitbox ( Item sItem,
Rectangle heldItemFrame,
out bool dontAttack,
out Rectangle itemRectangle )
inlineprivate

Definition at line 42887 of file Player.cs.

42888 {
42889 dontAttack = false;
42890 itemRectangle = new Rectangle((int)itemLocation.X, (int)itemLocation.Y, 32, 32);
42891 if (!Main.dedServ)
42892 {
42893 int num = heldItemFrame.Width;
42894 int num2 = heldItemFrame.Height;
42895 switch (sItem.type)
42896 {
42897 case 5094:
42898 num -= 10;
42899 num2 -= 10;
42900 break;
42901 case 5095:
42902 num -= 10;
42903 num2 -= 10;
42904 break;
42905 case 5096:
42906 num -= 12;
42907 num2 -= 12;
42908 break;
42909 case 5097:
42910 num -= 8;
42911 num2 -= 8;
42912 break;
42913 }
42914 itemRectangle = new Rectangle((int)itemLocation.X, (int)itemLocation.Y, num, num2);
42915 }
42917 itemRectangle.Width = (int)((float)itemRectangle.Width * adjustedItemScale);
42918 itemRectangle.Height = (int)((float)itemRectangle.Height * adjustedItemScale);
42919 if (direction == -1)
42920 {
42921 itemRectangle.X -= itemRectangle.Width;
42922 }
42923 if (gravDir == 1f)
42924 {
42925 itemRectangle.Y -= itemRectangle.Height;
42926 }
42927 if (sItem.useStyle == 1)
42928 {
42929 if ((double)itemAnimation < (double)itemAnimationMax * 0.333)
42930 {
42931 if (direction == -1)
42932 {
42933 itemRectangle.X -= (int)((double)itemRectangle.Width * 1.4 - (double)itemRectangle.Width);
42934 }
42935 itemRectangle.Width = (int)((double)itemRectangle.Width * 1.4);
42936 itemRectangle.Y += (int)((double)itemRectangle.Height * 0.5 * (double)gravDir);
42937 itemRectangle.Height = (int)((double)itemRectangle.Height * 1.1);
42938 }
42939 else if (!((double)itemAnimation < (double)itemAnimationMax * 0.666))
42940 {
42941 if (direction == 1)
42942 {
42943 itemRectangle.X -= (int)((double)itemRectangle.Width * 1.2);
42944 }
42945 itemRectangle.Width *= 2;
42946 itemRectangle.Y -= (int)(((double)itemRectangle.Height * 1.4 - (double)itemRectangle.Height) * (double)gravDir);
42947 itemRectangle.Height = (int)((double)itemRectangle.Height * 1.4);
42948 }
42949 }
42950 else if (sItem.useStyle == 3)
42951 {
42952 if ((double)itemAnimation > (double)itemAnimationMax * 0.666)
42953 {
42954 dontAttack = true;
42955 }
42956 else
42957 {
42958 if (direction == -1)
42959 {
42960 itemRectangle.X -= (int)((double)itemRectangle.Width * 1.4 - (double)itemRectangle.Width);
42961 }
42962 itemRectangle.Width = (int)((double)itemRectangle.Width * 1.4);
42963 itemRectangle.Y += (int)((double)itemRectangle.Height * 0.6);
42964 itemRectangle.Height = (int)((double)itemRectangle.Height * 0.6);
42965 if (sItem.type == 946 || sItem.type == 4707)
42966 {
42967 itemRectangle.Height += 14;
42968 itemRectangle.Width -= 10;
42969 if (direction == -1)
42970 {
42971 itemRectangle.X += 10;
42972 }
42973 }
42974 }
42975 }
42976 if (sItem.type == 1450 && Main.rand.Next(3) == 0)
42977 {
42978 int num3 = -1;
42979 float x = itemRectangle.X + Main.rand.Next(itemRectangle.Width);
42980 float y = itemRectangle.Y + Main.rand.Next(itemRectangle.Height);
42981 if (Main.rand.Next(500) == 0)
42982 {
42983 num3 = Gore.NewGore(new Vector2(x, y), default(Vector2), 415, (float)Main.rand.Next(51, 101) * 0.01f);
42984 }
42985 else if (Main.rand.Next(250) == 0)
42986 {
42987 num3 = Gore.NewGore(new Vector2(x, y), default(Vector2), 414, (float)Main.rand.Next(51, 101) * 0.01f);
42988 }
42989 else if (Main.rand.Next(80) == 0)
42990 {
42991 num3 = Gore.NewGore(new Vector2(x, y), default(Vector2), 413, (float)Main.rand.Next(51, 101) * 0.01f);
42992 }
42993 else if (Main.rand.Next(10) == 0)
42994 {
42995 num3 = Gore.NewGore(new Vector2(x, y), default(Vector2), 412, (float)Main.rand.Next(51, 101) * 0.01f);
42996 }
42997 else if (Main.rand.Next(3) == 0)
42998 {
42999 num3 = Gore.NewGore(new Vector2(x, y), default(Vector2), 411, (float)Main.rand.Next(51, 101) * 0.01f);
43000 }
43001 if (num3 >= 0)
43002 {
43003 Main.gore[num3].velocity.X += direction * 2;
43004 Main.gore[num3].velocity.Y *= 0.3f;
43005 }
43006 }
43007 if (sItem.type == 3542)
43008 {
43009 dontAttack = true;
43010 }
43011 if (sItem.type == 3779)
43012 {
43013 dontAttack = true;
43014 Vector2 vector = itemLocation + new Vector2(direction * 30, -8f);
43016 for (float num4 = 0f; num4 < 1f; num4 += 0.2f)
43017 {
43019 Dust obj = Main.dust[Dust.NewDust(vector - Vector2.One * 8f, 16, 16, 27, 0f, -2f)];
43020 obj.noGravity = true;
43021 obj.position = vector3;
43022 obj.velocity = new Vector2(0f, (0f - gravDir) * 2f);
43023 obj.scale = 1.2f;
43024 obj.alpha = 200;
43025 }
43026 }
43027 }
Vector2 oldPosition
Definition Entity.cs:18
Vector2 position
Definition Entity.cs:14
int itemAnimationMax
Definition Player.cs:2567
float GetAdjustedItemScale(Item item)
Definition Player.cs:40623
Vector2 itemLocation
Definition Player.cs:1183
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227

References Terraria.Main.dedServ, Terraria.Main.dust, Terraria.Main.gore, Microsoft.Xna.Framework.Vector2.Lerp(), Terraria.Dust.NewDust(), Terraria.Gore.NewGore(), System.obj, Microsoft.Xna.Framework.Vector2.One, Terraria.Main.rand, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.