Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ DashMovement()

void Terraria.Player.DashMovement ( )
inline

Definition at line 20374 of file Player.cs.

20375 {
20376 if (dashDelay == 0)
20377 {
20378 dash = dashType;
20379 }
20380 if (dash == 0)
20381 {
20382 dashTime = 0;
20383 dashDelay = 0;
20384 }
20385 if (dash == 2 && eocDash > 0)
20386 {
20387 if (eocHit < 0)
20388 {
20389 Rectangle rectangle = new Rectangle((int)((double)position.X + (double)velocity.X * 0.5 - 4.0), (int)((double)position.Y + (double)velocity.Y * 0.5 - 4.0), width + 8, height + 8);
20390 for (int i = 0; i < 200; i++)
20391 {
20392 NPC nPC = Main.npc[i];
20393 if (!nPC.active || nPC.dontTakeDamage || nPC.friendly || (nPC.aiStyle == 112 && !(nPC.ai[2] <= 1f)) || !CanNPCBeHitByPlayerOrPlayerProjectile(nPC))
20394 {
20395 continue;
20396 }
20397 Rectangle rect = nPC.getRect();
20398 if (rectangle.Intersects(rect) && (nPC.noTileCollide || CanHit(nPC)))
20399 {
20400 float num = 30f * meleeDamage;
20401 float num2 = 9f;
20402 bool crit = false;
20403 if (kbGlove)
20404 {
20405 num2 *= 2f;
20406 }
20407 if (kbBuff)
20408 {
20409 num2 *= 1.5f;
20410 }
20411 if (Main.rand.Next(100) < meleeCrit)
20412 {
20413 crit = true;
20414 }
20415 int num3 = direction;
20416 if (velocity.X < 0f)
20417 {
20418 num3 = -1;
20419 }
20420 if (velocity.X > 0f)
20421 {
20422 num3 = 1;
20423 }
20424 if (whoAmI == Main.myPlayer)
20425 {
20426 ApplyDamageToNPC(nPC, (int)num, num2, num3, crit);
20427 }
20428 eocDash = 10;
20429 dashDelay = 30;
20430 velocity.X = -num3 * 9;
20431 velocity.Y = -4f;
20433 eocHit = i;
20434 }
20435 }
20436 }
20437 else if ((!controlLeft || !(velocity.X < 0f)) && (!controlRight || !(velocity.X > 0f)))
20438 {
20439 velocity.X *= 0.95f;
20440 }
20441 }
20442 if (dash == 3 && dashDelay < 0 && whoAmI == Main.myPlayer)
20443 {
20444 Rectangle rectangle2 = new Rectangle((int)((double)position.X + (double)velocity.X * 0.5 - 4.0), (int)((double)position.Y + (double)velocity.Y * 0.5 - 4.0), width + 8, height + 8);
20445 for (int j = 0; j < 200; j++)
20446 {
20447 NPC nPC2 = Main.npc[j];
20448 if (!nPC2.active || nPC2.dontTakeDamage || nPC2.friendly || nPC2.immune[whoAmI] > 0 || (nPC2.aiStyle == 112 && !(nPC2.ai[2] <= 1f)) || !CanNPCBeHitByPlayerOrPlayerProjectile(nPC2))
20449 {
20450 continue;
20451 }
20452 Rectangle rect2 = nPC2.getRect();
20453 if (rectangle2.Intersects(rect2) && (nPC2.noTileCollide || CanHit(nPC2)))
20454 {
20456 {
20459 }
20460 float num4 = 150f * meleeDamage;
20461 float num5 = 9f;
20462 bool crit2 = false;
20463 if (kbGlove)
20464 {
20465 num5 *= 2f;
20466 }
20467 if (kbBuff)
20468 {
20469 num5 *= 1.5f;
20470 }
20471 if (Main.rand.Next(100) < meleeCrit)
20472 {
20473 crit2 = true;
20474 }
20475 int num6 = direction;
20476 if (velocity.X < 0f)
20477 {
20478 num6 = -1;
20479 }
20480 if (velocity.X > 0f)
20481 {
20482 num6 = 1;
20483 }
20484 if (whoAmI == Main.myPlayer)
20485 {
20487 int num7 = Projectile.NewProjectile(GetProjectileSource_OnHit(nPC2, 2), base.Center.X, base.Center.Y, 0f, 0f, 608, (int)num4, 15f, Main.myPlayer);
20488 Main.projectile[num7].Kill();
20489 }
20490 nPC2.immune[whoAmI] = 6;
20492 }
20493 }
20494 }
20495 if (dashDelay > 0)
20496 {
20497 if (eocDash > 0)
20498 {
20499 eocDash--;
20500 }
20501 if (eocDash == 0)
20502 {
20503 eocHit = -1;
20504 }
20505 dashDelay--;
20506 }
20507 else if (dashDelay < 0)
20508 {
20510 float num8 = 12f;
20511 float num9 = 0.992f;
20513 float num11 = 0.96f;
20514 int num12 = 20;
20515 if (dash == 1)
20516 {
20517 for (int k = 0; k < 2; k++)
20518 {
20519 int num13 = ((velocity.Y != 0f) ? Dust.NewDust(new Vector2(position.X, position.Y + (float)(height / 2) - 8f), width, 16, 31, 0f, 0f, 100, default(Color), 1.4f) : Dust.NewDust(new Vector2(position.X, position.Y + (float)height - 4f), width, 8, 31, 0f, 0f, 100, default(Color), 1.4f));
20520 Main.dust[num13].velocity *= 0.1f;
20521 Main.dust[num13].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20522 }
20523 }
20524 else if (dash == 2)
20525 {
20526 for (int l = 0; l < 0; l++)
20527 {
20528 int num14 = ((velocity.Y != 0f) ? Dust.NewDust(new Vector2(position.X, position.Y + (float)(height / 2) - 8f), width, 16, 31, 0f, 0f, 100, default(Color), 1.4f) : Dust.NewDust(new Vector2(position.X, position.Y + (float)height - 4f), width, 8, 31, 0f, 0f, 100, default(Color), 1.4f));
20529 Main.dust[num14].velocity *= 0.1f;
20530 Main.dust[num14].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20531 }
20532 num9 = 0.985f;
20533 num11 = 0.94f;
20534 num12 = 30;
20535 }
20536 else if (dash == 3)
20537 {
20538 for (int m = 0; m < 4; m++)
20539 {
20540 int num15 = Dust.NewDust(new Vector2(position.X, position.Y + 4f), width, height - 8, 6, 0f, 0f, 100, default(Color), 1.7f);
20541 Main.dust[num15].velocity *= 0.1f;
20542 Main.dust[num15].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20543 Main.dust[num15].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
20544 Main.dust[num15].noGravity = true;
20545 if (Main.rand.Next(2) == 0)
20546 {
20547 Main.dust[num15].fadeIn = 0.5f;
20548 }
20549 }
20550 num8 = 14f;
20551 num9 = 0.985f;
20552 num11 = 0.94f;
20553 num12 = 20;
20554 }
20555 else if (dash == 4)
20556 {
20557 for (int n = 0; n < 2; n++)
20558 {
20559 int num16 = Dust.NewDust(new Vector2(position.X, position.Y + 4f), width, height - 8, 229, 0f, 0f, 100, default(Color), 1.2f);
20560 Main.dust[num16].velocity *= 0.1f;
20561 Main.dust[num16].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20562 Main.dust[num16].noGravity = true;
20563 if (Main.rand.Next(2) == 0)
20564 {
20565 Main.dust[num16].fadeIn = 0.3f;
20566 }
20567 }
20568 num9 = 0.985f;
20569 num11 = 0.94f;
20570 num12 = 20;
20571 }
20572 if (dash == 5)
20573 {
20574 for (int num17 = 0; num17 < 2; num17++)
20575 {
20576 int type = Main.rand.NextFromList(new short[3] { 68, 69, 70 });
20577 int num18 = ((velocity.Y != 0f) ? Dust.NewDust(new Vector2(position.X, position.Y + (float)(height / 2) - 8f), width, 16, type, 0f, 0f, 100) : Dust.NewDust(new Vector2(position.X, position.Y + (float)height - 4f), width, 8, type, 0f, 0f, 100));
20578 Main.dust[num18].velocity *= 0.2f;
20579 Main.dust[num18].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20580 Main.dust[num18].fadeIn = 0.5f + (float)Main.rand.Next(20) * 0.01f;
20581 Main.dust[num18].noGravity = true;
20582 Main.dust[num18].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
20583 }
20584 }
20585 if (dash <= 0)
20586 {
20587 return;
20588 }
20590 vortexStealthActive = false;
20591 if (velocity.X > num8 || velocity.X < 0f - num8)
20592 {
20593 velocity.X *= num9;
20594 return;
20595 }
20596 if (velocity.X > num10 || velocity.X < 0f - num10)
20597 {
20598 velocity.X *= num11;
20599 return;
20600 }
20601 dashDelay = num12;
20602 if (velocity.X < 0f)
20603 {
20604 velocity.X = 0f - num10;
20605 }
20606 else if (velocity.X > 0f)
20607 {
20608 velocity.X = num10;
20609 }
20610 }
20611 else
20612 {
20613 if (dash <= 0 || mount.Active)
20614 {
20615 return;
20616 }
20617 if (dash == 1)
20618 {
20620 if (dashing)
20621 {
20622 velocity.X = 16.9f * (float)dir;
20623 Point point = (base.Center + new Vector2(dir * width / 2 + 2, gravDir * (float)(-height) / 2f + gravDir * 2f)).ToTileCoordinates();
20624 Point point2 = (base.Center + new Vector2(dir * width / 2 + 2, 0f)).ToTileCoordinates();
20625 if (WorldGen.SolidOrSlopedTile(point.X, point.Y) || WorldGen.SolidOrSlopedTile(point2.X, point2.Y))
20626 {
20627 velocity.X /= 2f;
20628 }
20629 dashDelay = -1;
20630 for (int num19 = 0; num19 < 20; num19++)
20631 {
20632 int num20 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 31, 0f, 0f, 100, default(Color), 2f);
20633 Main.dust[num20].position.X += Main.rand.Next(-5, 6);
20634 Main.dust[num20].position.Y += Main.rand.Next(-5, 6);
20635 Main.dust[num20].velocity *= 0.2f;
20636 Main.dust[num20].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20637 }
20638 int num21 = Gore.NewGore(new Vector2(position.X + (float)(width / 2) - 24f, position.Y + (float)(height / 2) - 34f), default(Vector2), Main.rand.Next(61, 64));
20639 Main.gore[num21].velocity.X = (float)Main.rand.Next(-50, 51) * 0.01f;
20640 Main.gore[num21].velocity.Y = (float)Main.rand.Next(-50, 51) * 0.01f;
20641 Main.gore[num21].velocity *= 0.4f;
20642 num21 = Gore.NewGore(new Vector2(position.X + (float)(width / 2) - 24f, position.Y + (float)(height / 2) - 14f), default(Vector2), Main.rand.Next(61, 64));
20643 Main.gore[num21].velocity.X = (float)Main.rand.Next(-50, 51) * 0.01f;
20644 Main.gore[num21].velocity.Y = (float)Main.rand.Next(-50, 51) * 0.01f;
20645 Main.gore[num21].velocity *= 0.4f;
20646 }
20647 }
20648 else if (dash == 2)
20649 {
20651 if (dashing2)
20652 {
20653 velocity.X = 14.5f * (float)dir2;
20654 Point point3 = (base.Center + new Vector2(dir2 * width / 2 + 2, gravDir * (float)(-height) / 2f + gravDir * 2f)).ToTileCoordinates();
20655 Point point4 = (base.Center + new Vector2(dir2 * width / 2 + 2, 0f)).ToTileCoordinates();
20656 if (WorldGen.SolidOrSlopedTile(point3.X, point3.Y) || WorldGen.SolidOrSlopedTile(point4.X, point4.Y))
20657 {
20658 velocity.X /= 2f;
20659 }
20660 dashDelay = -1;
20661 eocDash = 15;
20662 for (int num22 = 0; num22 < 0; num22++)
20663 {
20664 int num23 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 31, 0f, 0f, 100, default(Color), 2f);
20665 Main.dust[num23].position.X += Main.rand.Next(-5, 6);
20666 Main.dust[num23].position.Y += Main.rand.Next(-5, 6);
20667 Main.dust[num23].velocity *= 0.2f;
20668 Main.dust[num23].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20669 }
20670 }
20671 }
20672 else if (dash == 3)
20673 {
20675 if (dashing3)
20676 {
20677 velocity.X = 21.9f * (float)dir3;
20678 Point point5 = (base.Center + new Vector2(dir3 * width / 2 + 2, gravDir * (float)(-height) / 2f + gravDir * 2f)).ToTileCoordinates();
20679 Point point6 = (base.Center + new Vector2(dir3 * width / 2 + 2, 0f)).ToTileCoordinates();
20680 if (WorldGen.SolidOrSlopedTile(point5.X, point5.Y) || WorldGen.SolidOrSlopedTile(point6.X, point6.Y))
20681 {
20682 velocity.X /= 2f;
20683 }
20684 dashDelay = -1;
20685 for (int num24 = 0; num24 < 20; num24++)
20686 {
20687 int num25 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 6, 0f, 0f, 100, default(Color), 2f);
20688 Main.dust[num25].position.X += Main.rand.Next(-5, 6);
20689 Main.dust[num25].position.Y += Main.rand.Next(-5, 6);
20690 Main.dust[num25].velocity *= 0.2f;
20691 Main.dust[num25].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20692 Main.dust[num25].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
20693 Main.dust[num25].noGravity = true;
20694 Main.dust[num25].fadeIn = 0.5f;
20695 }
20696 }
20697 }
20698 if (dash != 5)
20699 {
20700 return;
20701 }
20703 if (dashing4)
20704 {
20705 velocity.X = 16.9f * (float)dir4;
20706 Point point7 = (base.Center + new Vector2(dir4 * width / 2 + 2, gravDir * (float)(-height) / 2f + gravDir * 2f)).ToTileCoordinates();
20707 Point point8 = (base.Center + new Vector2(dir4 * width / 2 + 2, 0f)).ToTileCoordinates();
20708 if (WorldGen.SolidOrSlopedTile(point7.X, point7.Y) || WorldGen.SolidOrSlopedTile(point8.X, point8.Y))
20709 {
20710 velocity.X /= 2f;
20711 }
20712 dashDelay = -1;
20713 for (int num26 = 0; num26 < 20; num26++)
20714 {
20715 int type2 = Main.rand.NextFromList(new short[3] { 68, 69, 70 });
20716 int num27 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, type2, 0f, 0f, 100, default(Color), 1.5f);
20717 Main.dust[num27].position.X += Main.rand.Next(-5, 6);
20718 Main.dust[num27].position.Y += Main.rand.Next(-5, 6);
20719 Main.dust[num27].velocity = DirectionTo(Main.dust[num27].position) * 2f;
20720 Main.dust[num27].scale *= 1f + (float)Main.rand.Next(20) * 0.01f;
20721 Main.dust[num27].fadeIn = 0.5f + (float)Main.rand.Next(20) * 0.01f;
20722 Main.dust[num27].noGravity = true;
20723 Main.dust[num27].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
20724 }
20725 }
20726 }
20727 }
static byte Max(byte val1, byte val2)
Definition Math.cs:738
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
void AllowOpeningDoorsByVelocityAloneForATime(int timeInFramesToAllow)
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
bool Active
Definition Mount.cs:345
bool controlRight
Definition Player.cs:1383
DoorOpeningHelper doorHelper
Definition Player.cs:2471
IEntitySource GetProjectileSource_OnHit(Entity victim, int projectileSourceId)
Definition Player.cs:9302
bool ConsumeSolarFlare()
Definition Player.cs:53348
void SolarDashStart(int dashDirection)
Definition Player.cs:20729
int ArmorSetDye()
Definition Player.cs:9255
float accRunSpeed
Definition Player.cs:821
bool CanNPCBeHitByPlayerOrPlayerProjectile(NPC npc, Projectile projectile=null)
Definition Player.cs:19902
bool vortexStealthActive
Definition Player.cs:2411
bool CanHit(Entity ent)
Definition Player.cs:40596
float meleeDamage
Definition Player.cs:2023
void ApplyDamageToNPC(NPC npc, int damage, float knockback, int direction, bool crit)
Definition Player.cs:19845
bool solarDashConsumedFlare
Definition Player.cs:699
void StopVanityActions(bool multiplayerBroadcast=true)
Definition Player.cs:31204
float maxRunSpeed
Definition Player.cs:2097
void DoCommonDashHandle(out int dir, out bool dashing, DashStartAction dashStartAction=null)
Definition Player.cs:20735
void GiveImmuneTimeForCollisionAttack(int time)
Definition Player.cs:19883

References Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.Main.dust, Terraria.Main.gore, System.Math.Max(), Terraria.Main.myPlayer, Terraria.Dust.NewDust(), Terraria.Gore.NewGore(), Terraria.Projectile.NewProjectile(), Terraria.Main.npc, Terraria.Main.projectile, Terraria.Main.rand, Terraria.WorldGen.SolidOrSlopedTile(), System.type, Microsoft.Xna.Framework.Point.X, and Microsoft.Xna.Framework.Point.Y.