/// <summary> /// Weak reference, must wrap in try catch exception becase won't catch FileNotFoundException /// </summary> /// <param name="drawInfo"></param> /// <param name="item"></param> /// <param name="shader"></param> #region Hurt && Parry Methods /// <summary> /// /// </summary> /// <param name="damageSource"></param> /// <returns>True when attack is parried</returns> private bool ParryPreHurt(PlayerDeathReason damageSource) { // Caused by normal damage? if (damageSource.SourceNPCIndex >= 0 || damageSource.SourcePlayerIndex >= 0 || damageSource.SourceProjectileIndex >= 0) { // Stop this attack and parry with cooldown if (IsParryActive) { player.itemAnimation = 0; //release item lock int timeSet = parryActive; //set cooldown to prevent spam parryTime = timeSet * -3; parryActive = 0; parryTimeMax = 0; // Strike the NPC away slightly if (damageSource.SourceNPCIndex >= 0) { NPC npc = Main.npc[damageSource.SourceNPCIndex]; int hitDirection = player.direction; float knockback = 4f; if (npc.knockBackResist > 0) { knockback /= npc.knockBackResist; } npc.StrikeNPC(npc.defense, knockback, player.direction, false, false, false); if (Main.netMode != 0) { NetMessage.SendData(28, -1, -1, null, npc.whoAmI, (float)npc.defense, (float)knockback, (float)hitDirection, 0, 0, 0); } } else { Main.PlaySound(SoundID.NPCHit3, player.position); if (damageSource.SourceProjectileIndex >= 0) { ProjFX.ReflectProjectilePlayer( Main.projectile[damageSource.SourceProjectileIndex], player, this, false); } } // Add 5 sec parry buff and short invincibility Items.Weapons.UseStyles.FistStyle.provideImmunity(player, 20); player.AddBuff(ModContent.BuffType <Buffs.ParryActive>(), 300, false); if (DEBUG_PARRYFISTS) { Main.NewText(string.Concat("Parried! : ", parryTime, "/", parryActive, "/", parryTimeMax)); } CheezeMod.NetUpdateParry(mod, this); return(true); } } return(false); }
private void CustomDashMovement() { // dash = player equipped dash type // dashTime = timeWindow for double tap // dashDelay = -1 during active, counts down to 0 after dash ends (30 for SoC, 20 for tabi) // eocDash = SoC active frame time, 15 until dash ends, then count down (still active during deccel) // eocHit = registers the hit NPC for 8 frames // Reset here because reasons. if (player.pulley || player.grapCount > 0) { weaponDash = 0; } if (weaponDash > 0) { if (player.dashDelay == 0) { #region Dash Stats /* * Normal: 3 * Aglet/Anklet: 3.15, 3.3 * Hermes: 6 * Lightning: 6.75 * Fishron Air: 8 * Solar Wings: 9 */ float dashSpeed = 14.5f; switch (weaponDash) { case 1: // Guardian Knuckle dashSpeed = 10f; break; case 2: // One Punch Glove dashSpeed = 15f; break; case 3: // Boxing Gloves dashSpeed = 12f; Gore g; if (player.velocity.Y == 0f) { g = Main.gore[Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 4f), default(Vector2), Main.rand.Next(61, 64), 1f)]; } else { g = Main.gore[Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 14f), default(Vector2), Main.rand.Next(61, 64), 1f)]; } g.velocity.X = (float)Main.rand.Next(-50, 51) * 0.01f; g.velocity.Y = (float)Main.rand.Next(-50, 51) * 0.01f; g.velocity *= 0.4f; break; case 4: // Spiked Gauntlets dashSpeed = 13f; break; case 5: // Apocafist dashSpeed = 13f; break; } #endregion #region Set Dash speed // Set initial dash speed float direction = 0; /* * if (player.controlLeft && !player.controlRight) direction = -1; * if (player.controlRight && !player.controlLeft) direction = 1; * if (direction == 0) * { * direction = player.direction; * } */ direction = player.direction; player.velocity.X = dashSpeed * direction; Point point3 = (player.Center + new Vector2((float)(player.direction * player.width / 2 + 2), player.gravDir * -(float)player.height / 2f + player.gravDir * 2f)).ToTileCoordinates(); Point point4 = (player.Center + new Vector2((float)(player.direction * player.width / 2 + 2), 0f)).ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(point3.X, point3.Y) || WorldGen.SolidOrSlopedTile(point4.X, point4.Y)) { player.velocity.X = player.velocity.X / 2f; } player.dashDelay = -1; CheezeMod.NetUpdateDash(mod, this); #endregion } // Apply movement during dash, delay is managed already in DashMovement() float maxAccRunSpeed = Math.Max(player.accRunSpeed, player.maxRunSpeed); if (player.dashDelay < 0) { player.dash = 0; // Prevent vanilla dash movement #region Dash Stats float dashMaxSpeedThreshold = 12f; float dashMaxFriction = 0.992f; float dashMinFriction = 0.96f; int dashSetDelay = 30; // normally 20 but given that his ends sooner... switch (weaponDash) { case 1: // Normal short-ish dash dashMaxSpeedThreshold = 8f; dashMaxFriction = 0.98f; dashMinFriction = 0.94f; for (int i = 0; i < 3; i++) { Dust d = Main.dust[Dust.NewDust(player.position, player.width, player.height, mod.DustType("BlueLight"), 0, 0, 100, default(Color), 1.8f)]; d.velocity = d.velocity * 0.5f + player.velocity * -0.4f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; case 2: // Super quick ~12 tile dash dashMaxSpeedThreshold = 500f; dashMaxFriction = 0.995f; dashMinFriction = 0.99f; for (int i = 0; i < 3; i++) { Dust d = Main.dust[Dust.NewDust(player.position, player.width, player.height, mod.DustType("Sparkle"), 0, 0, 100, default(Color), 1.8f)]; d.velocity = d.velocity * 0.5f + player.velocity * -0.4f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; case 3: // Boxing Gloves ~ 4.5 tile step dashMaxSpeedThreshold = 3f; dashMaxFriction = 0.8f; for (int j = 0; j < 2; j++) { Dust d; if (player.velocity.Y == 0f) { d = Main.dust[Dust.NewDust(new Vector2(player.position.X, player.position.Y + (float)player.height - 4f), player.width, 8, 31, 0f, 0f, 100, default(Color), 1.4f)]; } else { d = Main.dust[Dust.NewDust(new Vector2(player.position.X, player.position.Y + (float)(player.height / 2) - 8f), player.width, 16, 31, 0f, 0f, 100, default(Color), 1.4f)]; } d.velocity *= 0.1f; d.scale *= 1f + (float)Main.rand.Next(20) * 0.01f; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; case 4: // Spiked Gauntlets dashMaxSpeedThreshold = 10f; dashMaxFriction = 0.985f; dashMinFriction = 0.95f; for (int k = 0; k < 2; k++) { Dust d; if (player.velocity.Y == 0f) { d = Main.dust[Dust.NewDust(new Vector2(player.position.X, player.position.Y + (float)player.height - 8f), player.width, 16, 39, player.velocity.X, 0f, 0, default(Color), 1.4f)]; } else { d = Main.dust[Dust.NewDust(new Vector2(player.position.X, player.position.Y + (float)(player.height / 2) - 10f), player.width, 20, 40, player.velocity.X, 0f, 0, default(Color), 1.4f)]; } d.velocity *= 0.1f; d.scale *= 1f + (float)Main.rand.Next(20) * 0.01f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; case 5: // Long range dashMaxSpeedThreshold = 7f; dashMaxFriction = 0.99f; dashMinFriction = 0.8f; for (int i = 0; i < 4; i++) { Dust d = Main.dust[Dust.NewDust(player.position, player.width, player.height, DustID.Fire, 0, 0, 100, default(Color), 2f)]; d.velocity = d.velocity * 0.5f + player.velocity * -0.4f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); d = Main.dust[Dust.NewDust(player.position, player.width, player.height, DustID.Smoke, 0, 0, 100, default(Color), 0.4f)]; d.fadeIn = 0.7f; d.velocity = d.velocity * 0.1f + player.velocity * -0.2f; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; // 10 - 19 ARE SPECIAL GAME REFERENCES case 10: // Long range // SAXTON HALE'S FIST dashMaxSpeedThreshold = 7f; dashMaxFriction = 0.99f; dashMinFriction = 0.8f; for (int i = 0; i < 4; i++) { Dust d = Main.dust[Dust.NewDust(player.position, player.width, player.height, DustID.Smoke, 0, 0, 100, default(Color), 2f)]; d.velocity = d.velocity * 0.5f + player.velocity * -0.4f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); d = Main.dust[Dust.NewDust(player.position, player.width, player.height, DustID.Smoke, 0, 0, 100, default(Color), 0.4f)]; d.fadeIn = 0.7f; d.velocity = d.velocity * 0.1f + player.velocity * -0.2f; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } for (int i = 0; i < 4; i++) { Dust d = Main.dust[Dust.NewDust(player.position, player.width, player.height, DustID.Gold, 0, 0, 100, default(Color), 2f)]; d.velocity = d.velocity * 0.5f + player.velocity * -0.4f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); d = Main.dust[Dust.NewDust(player.position, player.width, player.height, DustID.Smoke, 0, 0, 100, default(Color), 0.4f)]; d.fadeIn = 0.7f; d.velocity = d.velocity * 0.1f + player.velocity * -0.2f; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; // 20 - 29 ARE RELATED TO FLYFF case 20: // Normal short-ish dash // GUARDIAN KNUCKLE dashMaxSpeedThreshold = 8f; dashMaxFriction = 0.98f; dashMinFriction = 0.94f; for (int i = 0; i < 3; i++) { Dust d = Main.dust[Dust.NewDust(player.position, player.width, player.height, mod.DustType("BlueLight"), 0, 0, 100, default(Color), 1.8f)]; d.velocity = d.velocity * 0.5f + player.velocity * -0.4f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; case 21: // Normal short-ish dash // HISTORIC KNUCKLE dashMaxSpeedThreshold = 10f; dashMaxFriction = 0.98f; dashMinFriction = 0.94f; for (int i = 0; i < 3; i++) { Dust d = Main.dust[Dust.NewDust(player.position, player.width, player.height, 107, 0, 0, 100, default(Color), 1.8f)]; d.velocity = d.velocity * 0.5f + player.velocity * -0.4f; d.noGravity = true; d.shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } break; } #endregion #region Modify dash speeds player.vortexStealthActive = false; if (player.velocity.X > dashMaxSpeedThreshold || player.velocity.X < -dashMaxSpeedThreshold) { player.velocity.X = player.velocity.X * dashMaxFriction; } else if (player.velocity.X > maxAccRunSpeed || player.velocity.X < -maxAccRunSpeed) { player.velocity.X = player.velocity.X * dashMinFriction; } else { player.dashDelay = dashSetDelay; if (player.velocity.X < 0f) { player.velocity.X = -maxAccRunSpeed; } else if (player.velocity.X > 0f) { player.velocity.X = maxAccRunSpeed; } } #endregion } } if (player.dashDelay == 1) { weaponDash = 0; } }