1 - Cleaned up balance rules to work with TML new damage.
2 - Removed unnecessary structs and enums.
This commit is contained in:
1 parent
24711a311d
commit
06b762eb94
5 files changed
+41
-138
No files matched your search
@@ -35,6 +35,9 @@ namespace CalamityMod.Balancing
|
||||
// into one single resist that may have to be split later.
|
||||
internal static void Load()
|
||||
{
|
||||
// Dirty shorthand for true melee resists, because they're super common and other class resists aren't.
|
||||
IBalancingRule ResistTrueMelee(float f) => new ClassResistBalancingRule(f, TrueMeleeDamageClass.Instance);
|
||||
|
||||
// Declare specific filters.
|
||||
bool DragonRageFilter(Projectile p) =>
|
||||
p.type == ProjectileType<DragonRageStaff>() || p.type == ProjectileType<DragonRageFireball>() || (p.type == ProjectileType<FuckYou>() && p.CountsAsClass<MeleeDamageClass>());
|
||||
@@ -85,17 +88,17 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region Desert Scourge
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DesertScourgeIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DesertScourgeIDs, Do(ResistTrueMelee(0.5f))));
|
||||
#endregion
|
||||
|
||||
#region Crabulon
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<Crabulon>(), new TrueMeleeResistBalancingRule(0.5f)));
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<Crabulon>(), ResistTrueMelee(0.5f)));
|
||||
#endregion
|
||||
|
||||
#region Brain of Cthulhu: Creepers
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(ResistTrueMelee(0.5f))));
|
||||
|
||||
// 50% resist to Demon Scythes.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe))));
|
||||
@@ -103,7 +106,7 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region Eater of Worlds
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.EaterofWorldsIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.EaterofWorldsIDs, Do(ResistTrueMelee(0.5f))));
|
||||
|
||||
// 50% resist to Demon Scythes.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.EaterofWorldsIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe))));
|
||||
@@ -117,12 +120,12 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region The Perforators
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.PerforatorIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.PerforatorIDs, Do(ResistTrueMelee(0.5f))));
|
||||
#endregion
|
||||
|
||||
#region Aquatic Scourge
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AquaticScourgeIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AquaticScourgeIDs, Do(ResistTrueMelee(0.5f))));
|
||||
|
||||
// 50% resist to Dormant Brimseekers.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AquaticScourgeIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType<DormantBrimseekerBab>()))));
|
||||
@@ -133,7 +136,7 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region The Destroyer
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(ResistTrueMelee(0.5f))));
|
||||
|
||||
// 50% resist to Dormant Brimseekers.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType<DormantBrimseekerBab>()))));
|
||||
@@ -147,7 +150,7 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region Ravager
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<RavagerBody>(), new TrueMeleeResistBalancingRule(0.5f)));
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<RavagerBody>(), ResistTrueMelee(0.5f)));
|
||||
#endregion
|
||||
|
||||
#region Duke Fishron
|
||||
@@ -171,7 +174,7 @@ namespace CalamityMod.Balancing
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.25f, ProjectileType<PlaguenadeBee>(), ProjectileType<PlaguenadeProj>()))));
|
||||
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(ResistTrueMelee(0.5f))));
|
||||
|
||||
// 25% resist to Resurrection Butterfly.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType<SakuraBullet>(), ProjectileType<PurpleButterfly>()))));
|
||||
@@ -184,7 +187,7 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region Profaned Guardians
|
||||
// 50% resist to true melee for the Defense Guardian's rocks.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<ProfanedRocks>(), new TrueMeleeResistBalancingRule(0.5f)));
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<ProfanedRocks>(), ResistTrueMelee(0.5f)));
|
||||
#endregion
|
||||
|
||||
#region Providence
|
||||
@@ -194,12 +197,12 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region Ceaseless Void: Dark Energies
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<DarkEnergy>(), new TrueMeleeResistBalancingRule(0.5f)));
|
||||
NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType<DarkEnergy>(), ResistTrueMelee(0.5f)));
|
||||
#endregion
|
||||
|
||||
#region Storm Weaver
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(ResistTrueMelee(0.5f))));
|
||||
|
||||
// 50% resist to Dazzling Stabbers.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType<DazzlingStabber>()))));
|
||||
@@ -244,7 +247,7 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region Exo Mechs: Ares
|
||||
// 50% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new TrueMeleeResistBalancingRule(0.5f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(ResistTrueMelee(0.5f))));
|
||||
|
||||
// 30% resist to the Spin Throw part of the Ark of the Cosmos' combo.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.7f, AotCThrowCombo))));
|
||||
@@ -276,7 +279,7 @@ namespace CalamityMod.Balancing
|
||||
|
||||
#region Exo Mechs: Thanatos
|
||||
// 65% resist to true melee.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new TrueMeleeResistBalancingRule(0.35f))));
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(ResistTrueMelee(0.35f))));
|
||||
|
||||
// 65% resist to Enforcer projectiles.
|
||||
NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType<EssenceFlame2>()))));
|
||||
@@ -385,14 +388,12 @@ namespace CalamityMod.Balancing
|
||||
|
||||
public static void ApplyFromProjectile(NPC npc, ref NPC.HitModifiers modifiers, Projectile proj)
|
||||
{
|
||||
NPCHitContext hitContext = NPCHitContext.ConstructFromProjectile(proj);
|
||||
|
||||
// Apply universal balancing rules.
|
||||
foreach (IBalancingRule[] balancingRules in UniversalBalancingChanges)
|
||||
{
|
||||
foreach (IBalancingRule balancingRule in balancingRules)
|
||||
{
|
||||
if (balancingRule.AppliesTo(npc, hitContext))
|
||||
if (balancingRule.AppliesTo(npc, modifiers, proj))
|
||||
balancingRule.ApplyBalancingChange(npc, ref modifiers);
|
||||
}
|
||||
}
|
||||
@@ -405,7 +406,7 @@ namespace CalamityMod.Balancing
|
||||
|
||||
foreach (IBalancingRule balancingRule in balanceChange.BalancingRules)
|
||||
{
|
||||
if (balancingRule.AppliesTo(npc, hitContext))
|
||||
if (balancingRule.AppliesTo(npc, modifiers, proj))
|
||||
balancingRule.ApplyBalancingChange(npc, ref modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
+22
-56
@@ -1,11 +1,13 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Balancing
|
||||
{
|
||||
public interface IBalancingRule
|
||||
{
|
||||
bool AppliesTo(NPC npc, NPCHitContext hitContext);
|
||||
bool AppliesTo(NPC npc, NPC.HitModifiers modifiers, Projectile? projectile);
|
||||
|
||||
void ApplyBalancingChange(NPC npc, ref NPC.HitModifiers modifiers);
|
||||
}
|
||||
@@ -13,16 +15,17 @@ namespace CalamityMod.Balancing
|
||||
public class ClassResistBalancingRule : IBalancingRule
|
||||
{
|
||||
public float DamageMultiplier;
|
||||
public ClassType ApplicableClass;
|
||||
public ClassResistBalancingRule(float damageMultiplier, ClassType classType)
|
||||
public DamageClass ApplicableClass;
|
||||
public ClassResistBalancingRule(float damageMultiplier, DamageClass dc)
|
||||
{
|
||||
DamageMultiplier = damageMultiplier;
|
||||
ApplicableClass = classType;
|
||||
ApplicableClass = dc;
|
||||
}
|
||||
|
||||
public bool AppliesTo(NPC npc, NPCHitContext hitContext)
|
||||
public bool AppliesTo(NPC npc, NPC.HitModifiers modifiers, Projectile? projectile)
|
||||
{
|
||||
return hitContext.Class == ApplicableClass;
|
||||
// E.g. so that a melee resist also applies to MeleeNoSpeed, TrueMelee, and TrueMeleeNoSpeed.
|
||||
return ApplicableClass.CountsAsClass(modifiers.DamageType);
|
||||
}
|
||||
|
||||
public void ApplyBalancingChange(NPC npc, ref NPC.HitModifiers modifiers)
|
||||
@@ -46,7 +49,7 @@ namespace CalamityMod.Balancing
|
||||
Requirement = npcApplicationRequirement;
|
||||
}
|
||||
|
||||
public bool AppliesTo(NPC npc, NPCHitContext hitContext) => Requirement(npc);
|
||||
public bool AppliesTo(NPC npc, NPC.HitModifiers modifiers, Projectile? projectile) => Requirement(npc);
|
||||
|
||||
// This "balancing" rule doesn't actually perform any changes. It simply serves as a means of enforcing NPC-specific requirements, and should be used only as a filter.
|
||||
// As such, this method is empty.
|
||||
@@ -58,7 +61,10 @@ namespace CalamityMod.Balancing
|
||||
public float DamageMultiplier;
|
||||
public PierceResistBalancingRule(float damageMultiplier) => DamageMultiplier = damageMultiplier;
|
||||
|
||||
public bool AppliesTo(NPC npc, NPCHitContext hitContext) => hitContext.Pierce > 1 || hitContext.Pierce == -1;
|
||||
public bool AppliesTo(NPC npc, NPC.HitModifiers modifiers, Projectile? projectile)
|
||||
{
|
||||
return projectile is not null && (projectile.maxPenetrate > 1 || projectile.maxPenetrate == -1);
|
||||
}
|
||||
|
||||
public void ApplyBalancingChange(NPC npc, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
@@ -82,14 +88,9 @@ namespace CalamityMod.Balancing
|
||||
ApplicableProjectileTypes = projTypes;
|
||||
}
|
||||
|
||||
public bool AppliesTo(NPC npc, NPCHitContext hitContext)
|
||||
public bool AppliesTo(NPC npc, NPC.HitModifiers modifiers, Projectile? projectile)
|
||||
{
|
||||
if (hitContext.DamageSource != DamageSourceType.FriendlyProjectile)
|
||||
return false;
|
||||
if (!ApplicableProjectileTypes.Contains(hitContext.ProjectileType ?? -1))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return projectile is not null && ApplicableProjectileTypes.Contains(projectile.type);
|
||||
}
|
||||
|
||||
public void ApplyBalancingChange(NPC npc, ref NPC.HitModifiers modifiers)
|
||||
@@ -115,12 +116,9 @@ namespace CalamityMod.Balancing
|
||||
Requirement = projApplicationRequirement;
|
||||
}
|
||||
|
||||
public bool AppliesTo(NPC npc, NPCHitContext hitContext)
|
||||
public bool AppliesTo(NPC npc, NPC.HitModifiers modifiers, Projectile? projectile)
|
||||
{
|
||||
if (hitContext.DamageSource != DamageSourceType.FriendlyProjectile)
|
||||
return false;
|
||||
|
||||
return Requirement(Main.projectile[hitContext.ProjectileIndex.Value]);
|
||||
return projectile is not null && Requirement(projectile);
|
||||
}
|
||||
|
||||
public void ApplyBalancingChange(NPC npc, ref NPC.HitModifiers modifiers)
|
||||
@@ -135,6 +133,7 @@ namespace CalamityMod.Balancing
|
||||
}
|
||||
}
|
||||
|
||||
// TODO -- this rule type should be deleted once stealth is finished as its own class
|
||||
public class StealthStrikeBalancingRule : IBalancingRule
|
||||
{
|
||||
public float DamageMultiplier;
|
||||
@@ -145,42 +144,9 @@ namespace CalamityMod.Balancing
|
||||
ApplicableProjectileTypes = projTypes;
|
||||
}
|
||||
|
||||
public bool AppliesTo(NPC npc, NPCHitContext hitContext)
|
||||
public bool AppliesTo(NPC npc, NPC.HitModifiers modifiers, Projectile? projectile)
|
||||
{
|
||||
if (hitContext.DamageSource != DamageSourceType.FriendlyProjectile)
|
||||
return false;
|
||||
if (!ApplicableProjectileTypes.Contains(hitContext.ProjectileType ?? -1))
|
||||
return false;
|
||||
|
||||
return hitContext.IsStealthStrike;
|
||||
}
|
||||
|
||||
public void ApplyBalancingChange(NPC npc, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
// Changed from FinalDamage to SourceDamage to ensure that resists will also apply to on-hit effects.
|
||||
// See this message in the Calamity Dev Discord for full rationale.
|
||||
// https://discord.com/channels/458428222061936650/459003706575421440/1128002932000960592
|
||||
//
|
||||
// There is one limitation to this approach. Flat bonus damage, aka whip tags, won't be reduced.
|
||||
// In the case that summons or whips need to be resisted, the best move is to consider them entirely separately.
|
||||
modifiers.SourceDamage *= DamageMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
public class TrueMeleeResistBalancingRule : IBalancingRule
|
||||
{
|
||||
public float DamageMultiplier;
|
||||
public TrueMeleeResistBalancingRule(float damageMultiplier)
|
||||
{
|
||||
DamageMultiplier = damageMultiplier;
|
||||
}
|
||||
|
||||
public bool AppliesTo(NPC npc, NPCHitContext hitContext)
|
||||
{
|
||||
if (hitContext.DamageSource == DamageSourceType.FriendlyProjectile)
|
||||
return Main.projectile[hitContext.ProjectileIndex.Value].IsTrueMelee();
|
||||
|
||||
return hitContext.DamageSource == DamageSourceType.TrueMeleeSwing;
|
||||
return projectile is not null && (modifiers.DamageType == StealthDamageClass.Instance || projectile.Calamity().stealthStrike);
|
||||
}
|
||||
|
||||
public void ApplyBalancingChange(NPC npc, ref NPC.HitModifiers modifiers)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace CalamityMod.Balancing
|
||||
{
|
||||
public enum DamageSourceType
|
||||
{
|
||||
FriendlyProjectile,
|
||||
TrueMeleeSwing,
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Balancing
|
||||
{
|
||||
public struct NPCHitContext
|
||||
{
|
||||
public int Pierce;
|
||||
public int Damage;
|
||||
public int? ProjectileIndex;
|
||||
public int? ProjectileType => ProjectileIndex.HasValue ? Main.projectile[ProjectileIndex.Value].type : (int?)null;
|
||||
public bool IsStealthStrike;
|
||||
public ClassType? Class;
|
||||
public DamageSourceType DamageSource;
|
||||
|
||||
public static NPCHitContext ConstructFromProjectile(Projectile proj)
|
||||
{
|
||||
ClassType? classType = null;
|
||||
if (proj.active)
|
||||
{
|
||||
if (proj.CountsAsClass<MeleeDamageClass>())
|
||||
classType = ClassType.Melee;
|
||||
if (proj.CountsAsClass<RangedDamageClass>())
|
||||
classType = ClassType.Ranged;
|
||||
if (proj.CountsAsClass<MagicDamageClass>())
|
||||
classType = ClassType.Magic;
|
||||
if (proj.minion)
|
||||
classType = ClassType.Summon;
|
||||
if (proj.CountsAsClass<RogueDamageClass>())
|
||||
classType = ClassType.Rogue;
|
||||
}
|
||||
|
||||
return new NPCHitContext()
|
||||
{
|
||||
Pierce = proj.penetrate,
|
||||
Damage = proj.damage,
|
||||
ProjectileIndex = proj.whoAmI,
|
||||
Class = classType,
|
||||
IsStealthStrike = proj.active && proj.Calamity().stealthStrike,
|
||||
DamageSource = DamageSourceType.FriendlyProjectile
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace CalamityMod
|
||||
{
|
||||
// TODO -- Replace all instances with references to Damage Classes, now that TML 1.4 contains those
|
||||
public enum ClassType
|
||||
{
|
||||
Melee = 0,
|
||||
Ranged = 1,
|
||||
Magic = 2,
|
||||
Summon = 3,
|
||||
Rogue = 4
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user