From 87949679f1f4bc4eac1d49d4336ba69e9856557c Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Wed, 11 Jan 2023 05:56:29 -0800 Subject: [PATCH] Make crash damage a multiplier instead of a toggle (#8151) * Switch unitCrashDamage to a multiplier * Add to rules dialog --- core/assets/bundles/bundle.properties | 1 + core/src/mindustry/entities/comp/UnitComp.java | 6 +++--- core/src/mindustry/game/Rules.java | 14 ++++++++++---- .../mindustry/ui/dialogs/CustomRulesDialog.java | 2 ++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 4816475bbe..c8f06241a5 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1217,6 +1217,7 @@ rules.unitbuildspeedmultiplier = Unit Production Speed Multiplier rules.unitcostmultiplier = Unit Cost Multiplier rules.unithealthmultiplier = Unit Health Multiplier rules.unitdamagemultiplier = Unit Damage Multiplier +rules.unitcrashdamagemultiplier = Unit Crash Damage Multiplier rules.solarmultiplier = Solar Power Multiplier rules.unitcapvariable = Cores Contribute To Unit Cap rules.unitcap = Base Unit Cap diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index fb35919f71..2938c2f37e 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -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; 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{ 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(type.flying && !spawnedByCore && type.createWreck && state.rules.unitCrashDamage){ - 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); + 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.unitCrashDamage(team), true, false, true); } if(!headless && type.createScorch){ diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 86db132969..d116726c75 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -51,8 +51,6 @@ public class Rules{ public boolean damageExplosions = true; /** Whether fire (and neoplasm spread) is enabled. */ public boolean fire = true; - /** Whether unit crash damage is enabled. */ - public boolean unitCrashDamage = true; /** Whether units use and require ammo. */ public boolean unitAmmo = false; /** EXPERIMENTAL! If true, blocks will update in units and share power. */ @@ -67,8 +65,10 @@ public class Rules{ public float unitBuildSpeedMultiplier = 1f; /** Multiplier of resources that units take to build. */ public float unitCostMultiplier = 1f; - /** How much damage any other units deal. */ + /** How much damage units deal. */ 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. */ public boolean ghostBlocks = true; /** Whether to allow units to build with logic. */ @@ -224,6 +224,10 @@ public class Rules{ return unitDamageMultiplier * teams.get(team).unitDamageMultiplier; } + public float unitCrashDamage(Team team){ + return unitDamage(team) * unitCrashDamageMultiplier * teams.get(team).unitCrashDamageMultiplier; + } + public float blockHealth(Team team){ return blockHealthMultiplier * teams.get(team).blockHealthMultiplier; } @@ -266,8 +270,10 @@ public class Rules{ /** How fast unit factories build units. */ public float unitBuildSpeedMultiplier = 1f; - /** How much damage any other units deal. */ + /** How much damage units deal. */ 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. */ public float unitCostMultiplier = 1f; /** How much health blocks start with. */ diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index e2efcbd6f4..a3a99e22c2 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -196,6 +196,7 @@ public class CustomRulesDialog extends BaseDialog{ check("@rules.unitcapvariable", b -> rules.unitCapVariable = b, () -> rules.unitCapVariable); numberi("@rules.unitcap", f -> rules.unitCap = f, () -> rules.unitCap, -999, 999); 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.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.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.unitcostmultiplier", f -> teams.unitCostMultiplier = f, () -> teams.unitCostMultiplier);