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

◆ JumpMovement()

void Terraria.Player.JumpMovement ( )
inline

Definition at line 19912 of file Player.cs.

19913 {
19915 {
19917 rect.Offset(0, height - 1);
19918 rect.Height = 2;
19919 rect.Inflate(12, 6);
19920 for (int i = 0; i < 200; i++)
19921 {
19922 NPC nPC = Main.npc[i];
19923 if (!nPC.active || nPC.dontTakeDamage || nPC.friendly || nPC.immune[whoAmI] != 0 || !CanNPCBeHitByPlayerOrPlayerProjectile(nPC))
19924 {
19925 continue;
19926 }
19927 Rectangle rect2 = nPC.getRect();
19928 if (rect.Intersects(rect2) && (nPC.noTileCollide || Collision.CanHit(position, width, height, nPC.position, nPC.width, nPC.height)))
19929 {
19930 float num = 40f * minionDamage;
19931 float knockback = 5f;
19932 int num2 = direction;
19933 if (velocity.X < 0f)
19934 {
19935 num2 = -1;
19936 }
19937 if (velocity.X > 0f)
19938 {
19939 num2 = 1;
19940 }
19941 if (whoAmI == Main.myPlayer)
19942 {
19943 ApplyDamageToNPC(nPC, (int)num, knockback, num2, crit: false);
19944 }
19945 nPC.immune[whoAmI] = 10;
19946 velocity.Y = -10f;
19948 break;
19949 }
19950 }
19951 }
19952 if (mount.Active && mount.Type == 17 && velocity.Y > 0f)
19953 {
19955 rect3.Offset(0, height - 1);
19956 rect3.Height = 2;
19957 rect3.Inflate(12, 6);
19958 for (int j = 0; j < 200; j++)
19959 {
19960 NPC nPC2 = Main.npc[j];
19961 if (!nPC2.active || nPC2.dontTakeDamage || nPC2.friendly || nPC2.immune[whoAmI] != 0 || !CanNPCBeHitByPlayerOrPlayerProjectile(nPC2))
19962 {
19963 continue;
19964 }
19965 Rectangle rect4 = nPC2.getRect();
19966 if (rect3.Intersects(rect4) && (nPC2.noTileCollide || Collision.CanHit(position, width, height, nPC2.position, nPC2.width, nPC2.height)))
19967 {
19968 float num3 = 40f;
19969 float knockback2 = 5f;
19970 int num4 = direction;
19971 if (velocity.X < 0f)
19972 {
19973 num4 = -1;
19974 }
19975 if (velocity.X > 0f)
19976 {
19977 num4 = 1;
19978 }
19979 if (whoAmI == Main.myPlayer)
19980 {
19982 }
19983 nPC2.immune[whoAmI] = 12;
19985 break;
19986 }
19987 }
19988 }
19989 if (controlJump)
19990 {
19991 if (sliding)
19992 {
19993 autoJump = false;
19994 }
19995 bool flag = false;
19996 bool flag2 = wet && accFlipper;
19997 bool flag3 = !mount.Active || !mount.Cart;
19999 {
20000 wetSlime = 0;
20001 flag = true;
20002 }
20003 if (mount.Active && mount.Type == 43 && releaseJump && velocity.Y != 0f)
20004 {
20006 }
20007 if (jump > 0)
20008 {
20009 if (velocity.Y == 0f)
20010 {
20011 jump = 0;
20012 }
20013 else
20014 {
20015 velocity.Y = (0f - jumpSpeed) * gravDir;
20016 if (merman && (!mount.Active || !mount.Cart))
20017 {
20018 if (swimTime <= 10)
20019 {
20020 swimTime = 30;
20021 }
20022 }
20023 else
20024 {
20025 jump--;
20026 }
20027 }
20028 }
20030 {
20032 {
20033 position.Y -= 0.001f;
20034 }
20035 if (sliding || velocity.Y == 0f)
20036 {
20037 justJumped = true;
20038 }
20039 bool flag4 = false;
20040 if (wet && accFlipper)
20041 {
20042 if (swimTime == 0)
20043 {
20044 swimTime = 30;
20045 }
20046 flag4 = true;
20047 }
20048 bool flag5 = false;
20049 bool flag6 = false;
20050 bool flag7 = false;
20051 bool flag8 = false;
20052 bool flag9 = false;
20053 bool flag10 = false;
20054 bool flag11 = false;
20055 bool flag12 = false;
20056 if (!flag2 && !flag)
20057 {
20059 {
20060 flag12 = true;
20061 canJumpAgain_Basilisk = false;
20062 }
20064 {
20065 flag11 = true;
20067 }
20068 else if (canJumpAgain_Santank)
20069 {
20070 flag10 = true;
20071 canJumpAgain_Santank = false;
20072 }
20073 else if (canJumpAgain_Unicorn)
20074 {
20075 flag9 = true;
20076 canJumpAgain_Unicorn = false;
20077 }
20078 else if (canJumpAgain_Sandstorm)
20079 {
20080 flag5 = true;
20081 canJumpAgain_Sandstorm = false;
20082 }
20083 else if (canJumpAgain_Blizzard)
20084 {
20085 flag6 = true;
20086 canJumpAgain_Blizzard = false;
20087 }
20088 else if (canJumpAgain_Fart)
20089 {
20090 canJumpAgain_Fart = false;
20091 flag7 = true;
20092 }
20093 else if (canJumpAgain_Sail)
20094 {
20095 canJumpAgain_Sail = false;
20096 flag8 = true;
20097 }
20098 else
20099 {
20100 canJumpAgain_Cloud = false;
20101 }
20102 }
20103 canRocket = false;
20104 rocketRelease = false;
20105 if (velocity.Y == 0f || sliding || (autoJump && justJumped))
20106 {
20108 }
20109 if (velocity.Y == 0f || flag4 || sliding || flag)
20110 {
20111 if (mount.Active && mount.Type == 43)
20112 {
20114 }
20115 velocity.Y = (0f - jumpSpeed) * gravDir;
20116 jump = jumpHeight;
20118 {
20119 position.Y -= portableStoolInfo.HeightBoost;
20121 }
20122 if (sliding)
20123 {
20124 velocity.X = 3 * -slideDir;
20125 }
20126 }
20127 else if (flag5)
20128 {
20130 _ = height;
20131 _ = gravDir;
20132 _ = -1f;
20133 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20134 velocity.Y = (0f - jumpSpeed) * gravDir;
20135 jump = jumpHeight * 3;
20136 }
20137 else if (flag6)
20138 {
20140 _ = height;
20141 _ = gravDir;
20142 _ = -1f;
20143 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20144 velocity.Y = (0f - jumpSpeed) * gravDir;
20145 jump = (int)((double)jumpHeight * 1.5);
20146 }
20147 else if (flag8)
20148 {
20149 isPerformingJump_Sail = true;
20150 int num5 = height;
20151 if (gravDir == -1f)
20152 {
20153 num5 = 0;
20154 }
20155 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20156 velocity.Y = (0f - jumpSpeed) * gravDir;
20157 jump = (int)((double)jumpHeight * 1.25);
20158 for (int k = 0; k < 30; k++)
20159 {
20160 int num6 = Dust.NewDust(new Vector2(position.X, position.Y + (float)num5), width, 12, 253, velocity.X * 0.3f, velocity.Y * 0.3f, 100, default(Color), 1.5f);
20161 if (k % 2 == 0)
20162 {
20163 Main.dust[num6].velocity.X += (float)Main.rand.Next(30, 71) * 0.1f;
20164 }
20165 else
20166 {
20167 Main.dust[num6].velocity.X -= (float)Main.rand.Next(30, 71) * 0.1f;
20168 }
20169 Main.dust[num6].velocity.Y += (float)Main.rand.Next(-10, 31) * 0.1f;
20170 Main.dust[num6].noGravity = true;
20171 Main.dust[num6].scale += (float)Main.rand.Next(-10, 41) * 0.01f;
20172 Main.dust[num6].velocity *= Main.dust[num6].scale * 0.7f;
20173 Vector2 vector = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
20174 vector.Normalize();
20175 vector *= (float)Main.rand.Next(81) * 0.1f;
20176 }
20177 }
20178 else if (flag7)
20179 {
20180 isPerformingJump_Fart = true;
20181 int num7 = height;
20182 if (gravDir == -1f)
20183 {
20184 num7 = 0;
20185 }
20187 velocity.Y = (0f - jumpSpeed) * gravDir;
20188 jump = jumpHeight * 2;
20189 for (int l = 0; l < 10; l++)
20190 {
20191 int num8 = Dust.NewDust(new Vector2(position.X - 34f, position.Y + (float)num7 - 16f), 102, 32, 188, (0f - velocity.X) * 0.5f, velocity.Y * 0.5f, 100, default(Color), 1.5f);
20192 Main.dust[num8].velocity.X = Main.dust[num8].velocity.X * 0.5f - velocity.X * 0.1f;
20193 Main.dust[num8].velocity.Y = Main.dust[num8].velocity.Y * 0.5f - velocity.Y * 0.3f;
20194 }
20195 int num9 = Gore.NewGore(new Vector2(position.X + (float)(width / 2) - 16f, position.Y + (float)num7 - 16f), new Vector2(0f - velocity.X, 0f - velocity.Y), Main.rand.Next(435, 438));
20196 Main.gore[num9].velocity.X = Main.gore[num9].velocity.X * 0.1f - velocity.X * 0.1f;
20197 Main.gore[num9].velocity.Y = Main.gore[num9].velocity.Y * 0.1f - velocity.Y * 0.05f;
20198 num9 = Gore.NewGore(new Vector2(position.X - 36f, position.Y + (float)num7 - 16f), new Vector2(0f - velocity.X, 0f - velocity.Y), Main.rand.Next(435, 438));
20199 Main.gore[num9].velocity.X = Main.gore[num9].velocity.X * 0.1f - velocity.X * 0.1f;
20200 Main.gore[num9].velocity.Y = Main.gore[num9].velocity.Y * 0.1f - velocity.Y * 0.05f;
20201 num9 = Gore.NewGore(new Vector2(position.X + (float)width + 4f, position.Y + (float)num7 - 16f), new Vector2(0f - velocity.X, 0f - velocity.Y), Main.rand.Next(435, 438));
20202 Main.gore[num9].velocity.X = Main.gore[num9].velocity.X * 0.1f - velocity.X * 0.1f;
20203 Main.gore[num9].velocity.Y = Main.gore[num9].velocity.Y * 0.1f - velocity.Y * 0.05f;
20204 }
20205 else if (flag9)
20206 {
20208 _ = height;
20209 _ = gravDir;
20210 _ = -1f;
20211 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20212 velocity.Y = (0f - jumpSpeed) * gravDir;
20213 jump = jumpHeight * 2;
20214 Vector2 center = base.Center;
20215 Vector2 vector2 = new Vector2(50f, 20f);
20216 float num10 = (float)Math.PI * 2f * Main.rand.NextFloat();
20217 for (int m = 0; m < 5; m++)
20218 {
20219 for (float num11 = 0f; num11 < 14f; num11 += 1f)
20220 {
20221 Dust obj = Main.dust[Dust.NewDust(center, 0, 0, Utils.SelectRandom<int>(Main.rand, 176, 177, 179))];
20222 Vector2 vector3 = Vector2.UnitY.RotatedBy(num11 * ((float)Math.PI * 2f) / 14f + num10);
20223 vector3 *= 0.2f * (float)m;
20224 obj.position = center + vector3 * vector2;
20225 obj.velocity = vector3 + new Vector2(0f, gravDir * 4f);
20226 obj.noGravity = true;
20227 obj.scale = 1f + Main.rand.NextFloat() * 0.8f;
20228 obj.fadeIn = Main.rand.NextFloat() * 2f;
20229 obj.shader = GameShaders.Armor.GetSecondaryShader(cMount, this);
20230 }
20231 }
20232 }
20233 else if (flag11)
20234 {
20236 _ = height;
20237 _ = gravDir;
20238 _ = -1f;
20239 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20240 velocity.Y = (0f - jumpSpeed) * gravDir;
20241 jump = jumpHeight * 2;
20242 Vector2 center2 = base.Center;
20243 Vector2 vector4 = new Vector2(50f, 20f);
20244 float num12 = (float)Math.PI * 2f * Main.rand.NextFloat();
20245 for (int n = 0; n < 5; n++)
20246 {
20247 for (float num13 = 0f; num13 < 14f; num13 += 1f)
20248 {
20249 Dust obj2 = Main.dust[Dust.NewDust(center2, 0, 0, 6)];
20250 Vector2 vector5 = Vector2.UnitY.RotatedBy(num13 * ((float)Math.PI * 2f) / 14f + num12);
20251 vector5 *= 0.2f * (float)n;
20252 obj2.position = center2 + vector5 * vector4;
20253 obj2.velocity = vector5 + new Vector2(0f, gravDir * 4f);
20254 obj2.noGravity = true;
20255 obj2.scale = 1f + Main.rand.NextFloat() * 0.8f;
20256 obj2.fadeIn = Main.rand.NextFloat() * 2f;
20257 obj2.shader = GameShaders.Armor.GetSecondaryShader(cMount, this);
20258 }
20259 }
20260 }
20261 else if (flag12)
20262 {
20264 _ = height;
20265 _ = gravDir;
20266 _ = -1f;
20267 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20268 velocity.Y = (0f - jumpSpeed) * gravDir;
20269 jump = (int)((double)jumpHeight * 0.75);
20270 Vector2 center3 = base.Center;
20271 Vector2 vector6 = new Vector2(50f, 20f);
20272 float num14 = (float)Math.PI * 2f * Main.rand.NextFloat();
20273 for (int num15 = 0; num15 < 5; num15++)
20274 {
20275 for (float num16 = 0f; num16 < 14f; num16 += 1f)
20276 {
20277 Dust obj3 = Main.dust[Dust.NewDust(center3, 0, 0, 31)];
20278 Vector2 vector7 = Vector2.UnitY.RotatedBy(num16 * ((float)Math.PI * 2f) / 14f + num14);
20279 vector7 *= 0.2f * (float)num15;
20280 obj3.position = center3 + vector7 * vector6;
20281 obj3.velocity = vector7 + new Vector2(0f, gravDir * 4f);
20282 obj3.noGravity = true;
20283 obj3.scale = 1f + Main.rand.NextFloat() * 0.8f;
20284 obj3.fadeIn = Main.rand.NextFloat() * 2f;
20285 obj3.shader = GameShaders.Armor.GetSecondaryShader(cMount, this);
20286 }
20287 }
20288 }
20289 else if (flag10)
20290 {
20292 int num17 = height;
20293 if (gravDir == -1f)
20294 {
20295 num17 = 0;
20296 }
20297 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20298 velocity.Y = (0f - jumpSpeed) * gravDir;
20299 jump = jumpHeight * 2;
20300 for (int num18 = 0; num18 < 15; num18++)
20301 {
20302 int num19 = Dust.NewDust(new Vector2(position.X - 34f, position.Y + (float)num17 - 16f), 102, 32, 4, (0f - velocity.X) * 0.5f, velocity.Y * 0.5f, 100, new Color(250, 230, 230, 150), 1.5f);
20303 Main.dust[num19].velocity.X = Main.dust[num19].velocity.X * 0.5f - velocity.X * 0.1f;
20304 Main.dust[num19].velocity.Y = Main.dust[num19].velocity.Y * 0.5f - velocity.Y * 0.3f;
20305 Main.dust[num19].noGravity = true;
20306 num19 = Dust.NewDust(new Vector2(position.X - 34f, position.Y + (float)num17 - 16f), 102, 32, 6, (0f - velocity.X) * 0.5f, velocity.Y * 0.5f, 20, default(Color), 1.5f);
20307 Main.dust[num19].velocity.Y -= 1f;
20308 if (num18 % 2 == 0)
20309 {
20310 Main.dust[num19].fadeIn = Main.rand.NextFloat() * 2f;
20311 }
20312 }
20313 float y = base.Bottom.Y - 22f;
20314 for (int num20 = 0; num20 < 3; num20++)
20315 {
20316 Vector2 vector8 = base.Center;
20317 switch (num20)
20318 {
20319 case 0:
20320 vector8 = new Vector2(base.Center.X - 16f, y);
20321 break;
20322 case 1:
20323 vector8 = new Vector2(position.X - 36f, y);
20324 break;
20325 case 2:
20326 vector8 = new Vector2(base.Right.X + 4f, y);
20327 break;
20328 }
20329 int num21 = Gore.NewGore(vector8, new Vector2(0f - velocity.X, 0f - velocity.Y), Main.rand.Next(61, 63));
20330 Main.gore[num21].velocity *= 0.1f;
20331 Main.gore[num21].velocity.X -= velocity.X * 0.1f;
20332 Main.gore[num21].velocity.Y -= velocity.Y * 0.05f;
20333 Main.gore[num21].velocity += Main.rand.NextVector2Circular(1f, 1f) * 0.5f;
20334 }
20335 }
20336 else
20337 {
20339 int num22 = height;
20340 if (gravDir == -1f)
20341 {
20342 num22 = 0;
20343 }
20344 SoundEngine.PlaySound(16, (int)position.X, (int)position.Y);
20345 velocity.Y = (0f - jumpSpeed) * gravDir;
20346 jump = (int)((double)jumpHeight * 0.75);
20347 for (int num23 = 0; num23 < 10; num23++)
20348 {
20349 int num24 = Dust.NewDust(new Vector2(position.X - 34f, position.Y + (float)num22 - 16f), 102, 32, 16, (0f - velocity.X) * 0.5f, velocity.Y * 0.5f, 100, default(Color), 1.5f);
20350 Main.dust[num24].velocity.X = Main.dust[num24].velocity.X * 0.5f - velocity.X * 0.1f;
20351 Main.dust[num24].velocity.Y = Main.dust[num24].velocity.Y * 0.5f - velocity.Y * 0.3f;
20352 }
20353 int num25 = Gore.NewGore(new Vector2(position.X + (float)(width / 2) - 16f, position.Y + (float)num22 - 16f), new Vector2(0f - velocity.X, 0f - velocity.Y), Main.rand.Next(11, 14));
20354 Main.gore[num25].velocity.X = Main.gore[num25].velocity.X * 0.1f - velocity.X * 0.1f;
20355 Main.gore[num25].velocity.Y = Main.gore[num25].velocity.Y * 0.1f - velocity.Y * 0.05f;
20356 num25 = Gore.NewGore(new Vector2(position.X - 36f, position.Y + (float)num22 - 16f), new Vector2(0f - velocity.X, 0f - velocity.Y), Main.rand.Next(11, 14));
20357 Main.gore[num25].velocity.X = Main.gore[num25].velocity.X * 0.1f - velocity.X * 0.1f;
20358 Main.gore[num25].velocity.Y = Main.gore[num25].velocity.Y * 0.1f - velocity.Y * 0.05f;
20359 num25 = Gore.NewGore(new Vector2(position.X + (float)width + 4f, position.Y + (float)num22 - 16f), new Vector2(0f - velocity.X, 0f - velocity.Y), Main.rand.Next(11, 14));
20360 Main.gore[num25].velocity.X = Main.gore[num25].velocity.X * 0.1f - velocity.X * 0.1f;
20361 Main.gore[num25].velocity.Y = Main.gore[num25].velocity.Y * 0.1f - velocity.Y * 0.05f;
20362 }
20363 }
20364 releaseJump = false;
20365 }
20366 else
20367 {
20368 jump = 0;
20369 releaseJump = true;
20370 rocketRelease = true;
20371 }
20372 }
const double PI
Definition Math.cs:16
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static bool[] Cart
Definition MountID.cs:9
static readonly LegacySoundStyle Item16
Definition SoundID.cs:446
static readonly LegacySoundStyle Item168
Definition SoundID.cs:750
bool IsConsideredASlimeMount
Definition Mount.cs:471
bool Active
Definition Mount.cs:345
bool isPerformingJump_Sandstorm
Definition Player.cs:2239
bool canJumpAgain_Sandstorm
Definition Player.cs:2237
bool isPerformingPogostickTricks
Definition Player.cs:2283
bool canJumpAgain_Fart
Definition Player.cs:2249
bool canJumpAgain_Sail
Definition Player.cs:2255
static float jumpSpeed
Definition Player.cs:2091
bool canJumpAgain_Basilisk
Definition Player.cs:2279
bool isPerformingJump_Blizzard
Definition Player.cs:2245
bool isPerformingJump_Basilisk
Definition Player.cs:2281
bool isPerformingJump_Santank
Definition Player.cs:2269
bool CanNPCBeHitByPlayerOrPlayerProjectile(NPC npc, Projectile projectile=null)
Definition Player.cs:19902
bool canJumpAgain_Blizzard
Definition Player.cs:2243
bool canJumpAgain_Cloud
Definition Player.cs:2231
bool isPerformingJump_Cloud
Definition Player.cs:2233
bool isPerformingJump_Fart
Definition Player.cs:2251
bool canJumpAgain_Unicorn
Definition Player.cs:2261
void ApplyDamageToNPC(NPC npc, int damage, float knockback, int direction, bool crit)
Definition Player.cs:19845
bool isPerformingJump_Sail
Definition Player.cs:2257
PortableStoolUsage portableStoolInfo
Definition Player.cs:1071
Rectangle getRect()
Definition Player.cs:40162
float minionDamage
Definition Player.cs:2039
bool canJumpAgain_Santank
Definition Player.cs:2267
static int jumpHeight
Definition Player.cs:2089
bool isPerformingJump_WallOfFleshGoat
Definition Player.cs:2275
bool rocketRelease
Definition Player.cs:2319
void GiveImmuneTimeForCollisionAttack(int time)
Definition Player.cs:19883
void RefreshDoubleJumps()
Definition Player.cs:21804
bool isPerformingJump_Unicorn
Definition Player.cs:2263
bool canJumpAgain_WallOfFleshGoat
Definition Player.cs:2273

References Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.Collision.CanHit(), Terraria.ID.MountID.Sets.Cart, Terraria.Main.dust, Terraria.Main.gore, Terraria.DataStructures.PortableStoolUsage.HeightBoost, Terraria.DataStructures.PortableStoolUsage.IsInUse, Terraria.ID.SoundID.Item16, Terraria.ID.SoundID.Item168, Terraria.Main.myPlayer, Terraria.Dust.NewDust(), Terraria.Gore.NewGore(), Terraria.Main.npc, System.obj, System.Math.PI, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.rand, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.