Make crash damage a multiplier instead of a toggle (#8151)

* Switch unitCrashDamage to a multiplier

* Add to rules dialog
This commit is contained in:
MEEPofFaith
2023-01-11 05:56:29 -08:00
committed by GitHub
parent a9175d3ffe
commit 87949679f1
4 changed files with 16 additions and 7 deletions

View File

@@ -1217,6 +1217,7 @@ rules.unitbuildspeedmultiplier = Unit Production Speed Multiplier
rules.unitcostmultiplier = Unit Cost Multiplier rules.unitcostmultiplier = Unit Cost Multiplier
rules.unithealthmultiplier = Unit Health Multiplier rules.unithealthmultiplier = Unit Health Multiplier
rules.unitdamagemultiplier = Unit Damage Multiplier rules.unitdamagemultiplier = Unit Damage Multiplier
rules.unitcrashdamagemultiplier = Unit Crash Damage Multiplier
rules.solarmultiplier = Solar Power Multiplier rules.solarmultiplier = Solar Power Multiplier
rules.unitcapvariable = Cores Contribute To Unit Cap rules.unitcapvariable = Cores Contribute To Unit Cap
rules.unitcap = Base Unit Cap rules.unitcap = Base Unit Cap

View File

@@ -589,7 +589,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
float power = item().charge * Mathf.pow(stack().amount, 1.11f) * 160f; float power = item().charge * Mathf.pow(stack().amount, 1.11f) * 160f;
if(!spawnedByCore){ if(!spawnedByCore){
Damage.dynamicExplosion(x, y, flammability, explosiveness, power, (bounds() + type.legLength/1.7f) / 2f, state.rules.damageExplosions && state.rules.unitCrashDamage, item().flammability > 1, team, type.deathExplosionEffect); Damage.dynamicExplosion(x, y, flammability, explosiveness, power, (bounds() + type.legLength/1.7f) / 2f, state.rules.damageExplosions && state.rules.unitCrashDamage(team) > 0, item().flammability > 1, team, type.deathExplosionEffect);
}else{ }else{
type.deathExplosionEffect.at(x, y, bounds() / 2f / 8f); type.deathExplosionEffect.at(x, y, bounds() / 2f / 8f);
} }
@@ -617,8 +617,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
} }
//if this unit crash landed (was flying), damage stuff in a radius //if this unit crash landed (was flying), damage stuff in a radius
if(type.flying && !spawnedByCore && type.createWreck && state.rules.unitCrashDamage){ if(type.flying && !spawnedByCore && type.createWreck && state.rules.unitCrashDamage(team) > 0){
Damage.damage(team, x, y, Mathf.pow(hitSize, 0.94f) * 1.25f, Mathf.pow(hitSize, 0.75f) * type.crashDamageMultiplier * 5f * state.rules.unitDamage(team), true, false, true); Damage.damage(team, x, y, Mathf.pow(hitSize, 0.94f) * 1.25f, Mathf.pow(hitSize, 0.75f) * type.crashDamageMultiplier * 5f * state.rules.unitCrashDamage(team), true, false, true);
} }
if(!headless && type.createScorch){ if(!headless && type.createScorch){

View File

@@ -51,8 +51,6 @@ public class Rules{
public boolean damageExplosions = true; public boolean damageExplosions = true;
/** Whether fire (and neoplasm spread) is enabled. */ /** Whether fire (and neoplasm spread) is enabled. */
public boolean fire = true; public boolean fire = true;
/** Whether unit crash damage is enabled. */
public boolean unitCrashDamage = true;
/** Whether units use and require ammo. */ /** Whether units use and require ammo. */
public boolean unitAmmo = false; public boolean unitAmmo = false;
/** EXPERIMENTAL! If true, blocks will update in units and share power. */ /** EXPERIMENTAL! If true, blocks will update in units and share power. */
@@ -67,8 +65,10 @@ public class Rules{
public float unitBuildSpeedMultiplier = 1f; public float unitBuildSpeedMultiplier = 1f;
/** Multiplier of resources that units take to build. */ /** Multiplier of resources that units take to build. */
public float unitCostMultiplier = 1f; public float unitCostMultiplier = 1f;
/** How much damage any other units deal. */ /** How much damage units deal. */
public float unitDamageMultiplier = 1f; public float unitDamageMultiplier = 1f;
/** How much damage unit crash damage deals. (Compounds with unitDamageMultiplier) */
public float unitCrashDamageMultiplier = 1f;
/** If true, ghost blocks will appear upon destruction, letting builder blocks/units rebuild them. */ /** If true, ghost blocks will appear upon destruction, letting builder blocks/units rebuild them. */
public boolean ghostBlocks = true; public boolean ghostBlocks = true;
/** Whether to allow units to build with logic. */ /** Whether to allow units to build with logic. */
@@ -224,6 +224,10 @@ public class Rules{
return unitDamageMultiplier * teams.get(team).unitDamageMultiplier; return unitDamageMultiplier * teams.get(team).unitDamageMultiplier;
} }
public float unitCrashDamage(Team team){
return unitDamage(team) * unitCrashDamageMultiplier * teams.get(team).unitCrashDamageMultiplier;
}
public float blockHealth(Team team){ public float blockHealth(Team team){
return blockHealthMultiplier * teams.get(team).blockHealthMultiplier; return blockHealthMultiplier * teams.get(team).blockHealthMultiplier;
} }
@@ -266,8 +270,10 @@ public class Rules{
/** How fast unit factories build units. */ /** How fast unit factories build units. */
public float unitBuildSpeedMultiplier = 1f; public float unitBuildSpeedMultiplier = 1f;
/** How much damage any other units deal. */ /** How much damage units deal. */
public float unitDamageMultiplier = 1f; public float unitDamageMultiplier = 1f;
/** How much damage unit crash damage deals. (Compounds with unitDamageMultiplier) */
public float unitCrashDamageMultiplier = 1f;
/** Multiplier of resources that units take to build. */ /** Multiplier of resources that units take to build. */
public float unitCostMultiplier = 1f; public float unitCostMultiplier = 1f;
/** How much health blocks start with. */ /** How much health blocks start with. */

View File

@@ -196,6 +196,7 @@ public class CustomRulesDialog extends BaseDialog{
check("@rules.unitcapvariable", b -> rules.unitCapVariable = b, () -> rules.unitCapVariable); check("@rules.unitcapvariable", b -> rules.unitCapVariable = b, () -> rules.unitCapVariable);
numberi("@rules.unitcap", f -> rules.unitCap = f, () -> rules.unitCap, -999, 999); numberi("@rules.unitcap", f -> rules.unitCap = f, () -> rules.unitCap, -999, 999);
number("@rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier); number("@rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier);
number("@rules.unitcrashdamagemultiplier", f -> rules.unitCrashDamageMultiplier = f, () -> rules.unitCrashDamageMultiplier);
number("@rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier, 0f, 50f); number("@rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier, 0f, 50f);
number("@rules.unitcostmultiplier", f -> rules.unitCostMultiplier = f, () -> rules.unitCostMultiplier); number("@rules.unitcostmultiplier", f -> rules.unitCostMultiplier = f, () -> rules.unitCostMultiplier);
@@ -298,6 +299,7 @@ public class CustomRulesDialog extends BaseDialog{
number("@rules.buildspeedmultiplier", f -> teams.buildSpeedMultiplier = f, () -> teams.buildSpeedMultiplier, 0.001f, 50f); number("@rules.buildspeedmultiplier", f -> teams.buildSpeedMultiplier = f, () -> teams.buildSpeedMultiplier, 0.001f, 50f);
number("@rules.unitdamagemultiplier", f -> teams.unitDamageMultiplier = f, () -> teams.unitDamageMultiplier); number("@rules.unitdamagemultiplier", f -> teams.unitDamageMultiplier = f, () -> teams.unitDamageMultiplier);
number("@rules.unitcrashdamagemultiplier", f -> teams.unitCrashDamageMultiplier = f, () -> teams.unitCrashDamageMultiplier);
number("@rules.unitbuildspeedmultiplier", f -> teams.unitBuildSpeedMultiplier = f, () -> teams.unitBuildSpeedMultiplier, 0.001f, 50f); number("@rules.unitbuildspeedmultiplier", f -> teams.unitBuildSpeedMultiplier = f, () -> teams.unitBuildSpeedMultiplier, 0.001f, 50f);
number("@rules.unitcostmultiplier", f -> teams.unitCostMultiplier = f, () -> teams.unitCostMultiplier); number("@rules.unitcostmultiplier", f -> teams.unitCostMultiplier = f, () -> teams.unitCostMultiplier);