Moved most mundane melee speed boosts to their own files.
This commit is contained in:
1 parent
c8fe47cb0b
commit
162c7587b7
12 files changed
+79
-102
No files matched your search
@@ -1,4 +1,4 @@
|
||||
using Terraria;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace CalamityMod.Buffs.Alcohol
|
||||
public override void Update(Player player, ref int buffIndex)
|
||||
{
|
||||
player.Calamity().bloodyMary = true;
|
||||
if (Main.bloodMoon)
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.15f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Terraria;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Buffs.DamageOverTime
|
||||
@@ -17,6 +17,7 @@ namespace CalamityMod.Buffs.DamageOverTime
|
||||
public override void Update(Player player, ref int buffIndex)
|
||||
{
|
||||
player.Calamity().bBlood = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.025f;
|
||||
}
|
||||
|
||||
public override void Update(NPC npc, ref int buffIndex)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Terraria;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Buffs.Potions
|
||||
@@ -17,6 +17,7 @@ namespace CalamityMod.Buffs.Potions
|
||||
public override void Update(Player player, ref int buffIndex)
|
||||
{
|
||||
player.Calamity().yPower = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.05f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Terraria;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Buffs.StatBuffs
|
||||
@@ -17,6 +17,7 @@ namespace CalamityMod.Buffs.StatBuffs
|
||||
public override void Update(Player player, ref int buffIndex)
|
||||
{
|
||||
player.Calamity().rRage = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.05f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -437,8 +437,6 @@ namespace CalamityMod.CalPlayer
|
||||
public bool badgeOfBravery = false;
|
||||
public bool warbannerOfTheSun = false;
|
||||
public float warBannerBonus = 0f;
|
||||
private const float maxWarBannerBonus = 0.2f;
|
||||
private const float maxWarBannerDistance = 480f;
|
||||
public bool cryogenSoul = false;
|
||||
public bool yInsignia = false;
|
||||
public bool eGauntlet = false;
|
||||
@@ -3400,90 +3398,8 @@ namespace CalamityMod.CalPlayer
|
||||
// Increase wall placement speed to speed up early game a bit and make building more fun
|
||||
Player.wallSpeed += 0.5f;
|
||||
|
||||
// TODO -- Melee speed boosts can all go back into their own files.
|
||||
#region MeleeSpeed
|
||||
#region Melee Speed for Projectile Melee Weapons
|
||||
float meleeSpeedMult = 0f;
|
||||
if (bBlood)
|
||||
{
|
||||
meleeSpeedMult += 0.025f;
|
||||
}
|
||||
if (rRage)
|
||||
{
|
||||
meleeSpeedMult += 0.05f;
|
||||
}
|
||||
if (yPower)
|
||||
{
|
||||
meleeSpeedMult += 0.05f;
|
||||
}
|
||||
if (darkSunRing)
|
||||
{
|
||||
meleeSpeedMult += 0.12f;
|
||||
}
|
||||
if (badgeOfBravery)
|
||||
{
|
||||
meleeSpeedMult += 0.15f;
|
||||
}
|
||||
if (warbannerOfTheSun)
|
||||
{
|
||||
int closestNPC = -1;
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
NPC nPC = Main.npc[i];
|
||||
if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage)
|
||||
{
|
||||
closestNPC = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
float distance = -1f;
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
{
|
||||
NPC nPC = Main.npc[j];
|
||||
if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage)
|
||||
{
|
||||
float distance2 = Math.Abs(nPC.position.X + (float)(nPC.width / 2) - (Player.position.X + (float)(Player.width / 2))) + Math.Abs(nPC.position.Y + (float)(nPC.height / 2) - (Player.position.Y + (float)(Player.height / 2)));
|
||||
if (distance == -1f || distance2 < distance)
|
||||
{
|
||||
distance = distance2;
|
||||
closestNPC = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closestNPC != -1)
|
||||
{
|
||||
NPC actualClosestNPC = Main.npc[closestNPC];
|
||||
|
||||
float generousHitboxWidth = Math.Max(actualClosestNPC.Hitbox.Width / 2f, actualClosestNPC.Hitbox.Height / 2f);
|
||||
float hitboxEdgeDist = actualClosestNPC.Distance(Player.Center) - generousHitboxWidth;
|
||||
|
||||
if (hitboxEdgeDist < 0)
|
||||
hitboxEdgeDist = 0;
|
||||
|
||||
if (hitboxEdgeDist < maxWarBannerDistance)
|
||||
{
|
||||
warBannerBonus = MathHelper.Lerp(0f, maxWarBannerBonus, 1f - (hitboxEdgeDist / maxWarBannerDistance));
|
||||
|
||||
if (warBannerBonus > maxWarBannerBonus)
|
||||
warBannerBonus = maxWarBannerBonus;
|
||||
}
|
||||
|
||||
meleeSpeedMult += warBannerBonus;
|
||||
}
|
||||
}
|
||||
if (eGauntlet)
|
||||
{
|
||||
meleeSpeedMult += 0.15f;
|
||||
}
|
||||
if (yInsignia)
|
||||
{
|
||||
meleeSpeedMult += 0.1f;
|
||||
}
|
||||
if (bloodyMary)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
meleeSpeedMult += 0.15f;
|
||||
}
|
||||
if (community)
|
||||
{
|
||||
float floatTypeBoost = 0.05f +
|
||||
@@ -3504,22 +3420,14 @@ namespace CalamityMod.CalPlayer
|
||||
(DownedBossSystem.downedYharon ? 0.01f : 0f); // 0.2
|
||||
meleeSpeedMult += floatTypeBoost * 0.25f;
|
||||
}
|
||||
if (eArtifact)
|
||||
{
|
||||
meleeSpeedMult += 0.1f;
|
||||
}
|
||||
if (bloodyWormTooth)
|
||||
{
|
||||
meleeSpeedMult += 0.07f;
|
||||
}
|
||||
|
||||
// Nerfs the effectiveness of Beetle Scale Mail.
|
||||
if (Player.beetleOffense && Player.beetleOrbs > 0)
|
||||
{
|
||||
meleeSpeedMult -= 0.1f * Player.beetleOrbs;
|
||||
}
|
||||
|
||||
if (CalamityConfig.Instance.Proficiency)
|
||||
{
|
||||
meleeSpeedMult += GetMeleeSpeedBonus();
|
||||
}
|
||||
|
||||
if (GemTechSet && GemTechState.IsYellowGemActive)
|
||||
meleeSpeedMult += GemTechHeadgear.MeleeSpeedBoost;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace CalamityMod.Items.Accessories
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.badgeOfBravery = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.15f;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace CalamityMod.Items.Accessories
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.bloodyWormTooth = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.07f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ namespace CalamityMod.Items.Accessories
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.darkSunRing = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.12f;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace CalamityMod.Items.Accessories
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.eArtifact = true;
|
||||
player.buffImmune[ModContent.BuffType<WhisperingDeath>()] = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.1f;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace CalamityMod.Items.Accessories
|
||||
modPlayer.eGauntlet = true;
|
||||
player.autoReuseGlove = true;
|
||||
player.meleeScaleGlove = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.15f;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using CalamityMod.CalPlayer;
|
||||
using System;
|
||||
using CalamityMod.CalPlayer;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
@@ -9,6 +11,9 @@ namespace CalamityMod.Items.Accessories
|
||||
[AutoloadEquip(EquipType.Balloon)]
|
||||
public class WarbanneroftheSun : ModItem
|
||||
{
|
||||
internal const float MaxBonus = 0.2f;
|
||||
internal const float MaxDistance = 480f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
SacrificeTotal = 1;
|
||||
@@ -31,6 +36,59 @@ namespace CalamityMod.Items.Accessories
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.warbannerOfTheSun = true;
|
||||
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += CalculateMeleeSpeedBonus(player);
|
||||
}
|
||||
|
||||
private static float CalculateMeleeSpeedBonus(Player player)
|
||||
{
|
||||
float bonus = 0f;
|
||||
|
||||
int closestNPC = -1;
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
NPC nPC = Main.npc[i];
|
||||
if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage)
|
||||
{
|
||||
closestNPC = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
float distance = -1f;
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
{
|
||||
NPC nPC = Main.npc[j];
|
||||
if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage)
|
||||
{
|
||||
float distance2 = Math.Abs(nPC.position.X + (float)(nPC.width / 2) - (player.position.X + (float)(player.width / 2))) + Math.Abs(nPC.position.Y + (float)(nPC.height / 2) - (player.position.Y + (float)(player.height / 2)));
|
||||
if (distance == -1f || distance2 < distance)
|
||||
{
|
||||
distance = distance2;
|
||||
closestNPC = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closestNPC != -1)
|
||||
{
|
||||
NPC actualClosestNPC = Main.npc[closestNPC];
|
||||
|
||||
float generousHitboxWidth = Math.Max(actualClosestNPC.Hitbox.Width / 2f, actualClosestNPC.Hitbox.Height / 2f);
|
||||
float hitboxEdgeDist = actualClosestNPC.Distance(player.Center) - generousHitboxWidth;
|
||||
|
||||
if (hitboxEdgeDist < 0)
|
||||
hitboxEdgeDist = 0;
|
||||
|
||||
if (hitboxEdgeDist < MaxDistance)
|
||||
{
|
||||
bonus = MathHelper.Lerp(0f, MaxBonus, 1f - (hitboxEdgeDist / MaxDistance));
|
||||
|
||||
if (bonus > MaxBonus)
|
||||
bonus = MaxBonus;
|
||||
}
|
||||
}
|
||||
|
||||
return bonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ namespace CalamityMod.Items.Accessories
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.yInsignia = true;
|
||||
player.GetAttackSpeed<MeleeDamageClass>() += 0.1f;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
Reference in new issue
Block a user