Fixed TechGuns nuclear rocket oversized explosion strength

This commit is contained in:
LemADEC 2020-06-25 01:32:24 +02:00
parent cc52c13fa2
commit 1f0b083092
2 changed files with 29 additions and 2 deletions

View file

@ -479,6 +479,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
}
double strength = explosion.size;
float factorResistance = 1.0F;
// Typical size/strength values
// Vanilla
@ -517,6 +518,19 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
// ICBM Classic Conventional/Incendiary/Repulsive grenade
// icbm.classic.content.entity.EntityGrenade 3.0 tbc
// TechGuns
// note: that mod is sharing a Vanilla explosion with the player as exploder, so we don't see the mod itself directly
// Rocket 5.0
// Rocket (High Velocity) 3.75
// Tactical Nuke 25.0
if ( explosion.getClass().equals(Explosion.class)
&& strength > WarpDriveConfig.FORCE_FIELD_EXPLOSION_STRENGTH_VANILLA_CAP) {
// assuming its TechGuns, we caps it to be in par with ICBM Nuclear which actually simulate the shockwave
factorResistance = (float) (strength / WarpDriveConfig.FORCE_FIELD_EXPLOSION_STRENGTH_VANILLA_CAP);
strength = Math.min(WarpDriveConfig.FORCE_FIELD_EXPLOSION_STRENGTH_VANILLA_CAP, strength);
}
if (strength == 0.0D) {// (explosion with no size defined, let's check the explosion itself)
final String nameExplosion = explosion.getClass().toString();
switch (nameExplosion) {
@ -536,6 +550,13 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
blockPos.getY() + 0.5D - vExplosion.y,
blockPos.getZ() + 0.5D - vExplosion.z );
final double magnitude = Math.max(1.0D, vDirection.getMagnitude());
if (magnitude > strength) {
if (isFirstHit) {
WarpDrive.logger.error(String.format("Blocking out of range explosion instance %s %s at %.1f m",
vExplosion, explosion, magnitude ));
}
return Float.MAX_VALUE;
}
if (magnitude != 0) {// normalize
vDirection.scale(1 / magnitude);
}
@ -553,7 +574,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
vExplosion,
strength, magnitude, damageLevel, damageLeft));
}
return super.getExplosionResistance(world, blockPos, exploder, explosion);
return factorResistance * super.getExplosionResistance(world, blockPos, exploder, explosion);
}
@Override

View file

@ -548,10 +548,11 @@ public class WarpDriveConfig {
public static float[] ENAN_REACTOR_EXPLOSION_STRENGTH_MIN_BY_TIER = { 4.0F, 4.0F, 5.0F, 6.0F };
public static float[] ENAN_REACTOR_EXPLOSION_STRENGTH_MAX_BY_TIER = { 7.0F, 7.0F, 9.0F, 11.0F };
// Enantiomorphic power reactor
// Force field setup
public static int[] FORCE_FIELD_PROJECTOR_MAX_ENERGY_STORED_BY_TIER = { 20000000, 30000, 90000, 150000 }; // 30000 * (1 + 2 * tier)
public static double FORCE_FIELD_PROJECTOR_EXPLOSION_SCALE = 1000.0D;
public static double FORCE_FIELD_PROJECTOR_MAX_LASER_REQUIRED = 10.0D;
public static double FORCE_FIELD_EXPLOSION_STRENGTH_VANILLA_CAP = 15.0D;
// Subspace capacitor
public static int[] CAPACITOR_MAX_ENERGY_STORED_BY_TIER = { 20000000, 800000, 4000000, 20000000 };
@ -1355,6 +1356,11 @@ public class WarpDriveConfig {
config.get("force_field", "projector_max_laser_required", FORCE_FIELD_PROJECTOR_MAX_LASER_REQUIRED,
"Number of maxed out laser cannons required to break a superior force field.").getDouble(FORCE_FIELD_PROJECTOR_MAX_LASER_REQUIRED));
FORCE_FIELD_EXPLOSION_STRENGTH_VANILLA_CAP = Commons.clamp(3.0D, 1000.0D,
config.get("force_field", "explosion_strength_vanilla_cap", FORCE_FIELD_EXPLOSION_STRENGTH_VANILLA_CAP,
"Maximum strength for vanilla explosion object used by simple explosives like TechGuns rockets.").getDouble(FORCE_FIELD_EXPLOSION_STRENGTH_VANILLA_CAP));
// Subspace capacitor
CAPACITOR_MAX_ENERGY_STORED_BY_TIER = config.get("capacitor", "max_energy_stored_by_tier", CAPACITOR_MAX_ENERGY_STORED_BY_TIER, "Maximum energy stored for each subspace capacitor tier").getIntList();
clampByTier(0, Integer.MAX_VALUE, CAPACITOR_MAX_ENERGY_STORED_BY_TIER);