Changed how Cobalt and Mythril weapon effects are handled

* Both effects are now temporary, handled by timers. They last 10 seconds.
* This also fixes Mythril weapons making enemies deal contact damage for 1 frame.
This commit is contained in:
CongratsIsTrash committed 2024-05-13 23:16:16 -04:00
1 parent 7d8ed11cfb
commit ca03ac7db8
2 files changed
+29 -26

No files matched your search

+4 -18
View File
@@ -87,8 +87,7 @@ namespace CalamityMod.CalPlayer
switch (item.type)
{
case ItemID.CobaltSword:
target.Calamity().miscDefenseLoss = (int)(target.defense * 0.25);
target.Calamity().isNerfedByCobalt = true;
target.Calamity().cobaltNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime;
break;
case ItemID.PalladiumSword:
@@ -98,13 +97,7 @@ namespace CalamityMod.CalPlayer
break;
case ItemID.MythrilSword:
if (target.damage > 0)
{
target.damage = (int)(target.defDamage * 0.9);
target.Calamity().isNerfedByMythril = true;
}
target.Calamity().mythrilNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime;
break;
case ItemID.OrichalcumSword:
@@ -226,8 +219,7 @@ namespace CalamityMod.CalPlayer
switch (proj.type)
{
case ProjectileID.CobaltNaginata:
target.Calamity().miscDefenseLoss = (int)(target.defense * 0.25);
target.Calamity().isNerfedByCobalt = true;
target.Calamity().cobaltNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime;
break;
case ProjectileID.PalladiumPike:
@@ -237,13 +229,7 @@ namespace CalamityMod.CalPlayer
break;
case ProjectileID.MythrilHalberd:
if (target.damage > 0)
{
target.damage = (int)(target.defDamage * 0.9);
target.Calamity().isNerfedByMythril = true;
}
target.Calamity().mythrilNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime;
break;
case ProjectileID.OrichalcumHalberd:
+25 -8
View File
@@ -226,9 +226,10 @@ namespace CalamityMod.NPCs
public const int knockbackResistanceMin = 180;
public int knockbackResistanceTimer = 0;
// Used for particle drawing on NPCs affected by vanilla Cobalt/Mythril weapons
public bool isNerfedByCobalt = false;
public bool isNerfedByMythril = false;
// Used for NPCs affected by vanilla Cobalt/Mythril weapons
public const int cobaltAndMythrilNerfTime = 600;
public int cobaltNerfTimer = 0;
public int mythrilNerfTimer = 0;
// Debuffs
public int vaporfied = 0;
@@ -447,8 +448,8 @@ namespace CalamityMod.NPCs
myClone.bossCanBeKnockedBack = bossCanBeKnockedBack;
myClone.knockbackResistanceTimer = knockbackResistanceTimer;
myClone.isNerfedByCobalt = isNerfedByCobalt;
myClone.isNerfedByMythril = isNerfedByMythril;
myClone.cobaltNerfTimer = cobaltNerfTimer;
myClone.mythrilNerfTimer = mythrilNerfTimer;
myClone.vaporfied = vaporfied;
myClone.timeSlow = timeSlow;
@@ -5083,6 +5084,11 @@ namespace CalamityMod.NPCs
if (RancorBurnTime > 0)
RancorBurnTime--;
if (cobaltNerfTimer > 0)
cobaltNerfTimer--;
if (mythrilNerfTimer > 0)
mythrilNerfTimer--;
if (veriumDoomTimer > 0)
veriumDoomTimer--;
if (veriumDoomTimer == 0 && veriumDoomMarked)
@@ -6378,9 +6384,12 @@ namespace CalamityMod.NPCs
}
}
// Cobalt and Mythril weapon particle effects
if (isNerfedByCobalt)
// Cobalt weapons reduce NPC defense
if (cobaltNerfTimer > 0)
{
miscDefenseLoss = (int)(npc.defense * 0.25);
// Particle effects
if (Main.rand.NextBool(5))
{
Vector2 spawnLocation = new Vector2(Main.rand.NextFloat(npc.position.X, npc.position.X + npc.width), Main.rand.NextFloat(npc.position.Y, npc.position.Y + npc.height));
@@ -6391,8 +6400,16 @@ namespace CalamityMod.NPCs
}
}
if (isNerfedByMythril)
// Mythril weapons reduce NPC contact damage
if (mythrilNerfTimer > 0)
{
// Ensure that it isn't trying to set a non-zero damage value if the NPC's damage is currently 0
if (npc.damage == 0)
npc.damage = 0;
else
npc.damage = (int)(npc.defDamage * 0.9);
// Particle effects
if (Main.rand.NextBool(5))
{
Vector2 spawnLocation = new Vector2(Main.rand.NextFloat(npc.position.X, npc.position.X + npc.width), Main.rand.NextFloat(npc.position.Y, npc.position.Y + npc.height));