Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Mine Speed Game Rule Implementation and World Processor Set Rule for Unit Mine Speed, and Unit Crash Damage. #10318

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ rules.unitcostmultiplier = Unit Cost Multiplier
rules.unithealthmultiplier = Unit Health Multiplier
rules.unitdamagemultiplier = Unit Damage Multiplier
rules.unitcrashdamagemultiplier = Unit Crash Damage Multiplier
rules.unitminespeedmultiplier = Unit Mine Speed Multiplier
rules.solarmultiplier = Solar Power Multiplier
rules.unitcapvariable = Cores Contribute To Unit Cap
rules.unitpayloadsexplode = Carried Payloads Explode With The Unit
Expand Down
4 changes: 2 additions & 2 deletions core/src/mindustry/entities/comp/MinerComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public boolean validMine(Tile tile){
}

public boolean canMine(){
return type.mineSpeed > 0 && type.mineTier >= 0;
return type.mineSpeed * state.rules.unitMineSpeed(team()) > 0 && type.mineTier >= 0;
}

@Override
Expand All @@ -89,7 +89,7 @@ public void update(){
mineTile = null;
mineTimer = 0f;
}else if(mining() && item != null){
mineTimer += Time.delta * type.mineSpeed;
mineTimer += Time.delta * type.mineSpeed * state.rules.unitMineSpeed(team());

if(Mathf.chance(0.06 * Time.delta)){
Fx.pulverizeSmall.at(mineTile.worldx() + Mathf.range(tilesize / 2f), mineTile.worldy() + Mathf.range(tilesize / 2f), 0f, item.color);
Expand Down
8 changes: 8 additions & 0 deletions core/src/mindustry/game/Rules.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class Rules{
public float unitHealthMultiplier = 1f;
/** How much damage unit crash damage deals. (Compounds with unitDamageMultiplier) */
public float unitCrashDamageMultiplier = 1f;
/** How fast units can mine. */
public float unitMineSpeedMultiplier = 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. */
Expand Down Expand Up @@ -262,6 +264,10 @@ public float unitCrashDamage(Team team){
return unitDamage(team) * unitCrashDamageMultiplier * teams.get(team).unitCrashDamageMultiplier;
}

public float unitMineSpeed(Team team){
return unitMineSpeedMultiplier * teams.get(team).unitMineSpeedMultiplier;
}

public float blockHealth(Team team){
return blockHealthMultiplier * teams.get(team).blockHealthMultiplier;
}
Expand Down Expand Up @@ -312,6 +318,8 @@ public static class TeamRule{
public float unitDamageMultiplier = 1f;
/** How much damage unit crash damage deals. (Compounds with unitDamageMultiplier) */
public float unitCrashDamageMultiplier = 1f;
/** How fast units can mine. */
public float unitMineSpeedMultiplier = 1f;
/** Multiplier of resources that units take to build. */
public float unitCostMultiplier = 1f;
/** How much health units start with. */
Expand Down
4 changes: 3 additions & 1 deletion core/src/mindustry/logic/LExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1515,14 +1515,16 @@ public void run(LExecutor exec){
state.rules.bannedUnits.remove(u);
}
}
case unitHealth, unitBuildSpeed, unitCost, unitDamage, blockHealth, blockDamage, buildSpeed, rtsMinSquad, rtsMinWeight -> {
case unitHealth, unitBuildSpeed, unitCrashDamage, unitMineSpeed, unitCost, unitDamage, blockHealth, blockDamage, buildSpeed, rtsMinSquad, rtsMinWeight -> {
Team team = p1.team();
if(team != null){
float num = value.numf();
switch(rule){
case buildSpeed -> team.rules().buildSpeedMultiplier = Mathf.clamp(num, 0.001f, 50f);
case unitHealth -> team.rules().unitHealthMultiplier = Math.max(num, 0.001f);
case unitBuildSpeed -> team.rules().unitBuildSpeedMultiplier = Mathf.clamp(num, 0f, 50f);
case unitCrashDamage -> team.rules().unitCrashDamageMultiplier = Math.max(num, 0f);
case unitMineSpeed -> team.rules().unitMineSpeedMultiplier = Math.max(num, 0f);
case unitCost -> team.rules().unitCostMultiplier = Math.max(num, 0f);
case unitDamage -> team.rules().unitDamageMultiplier = Math.max(num, 0f);
case blockHealth -> team.rules().blockHealthMultiplier = Math.max(num, 0.001f);
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/logic/LStatements.java
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ void rebuild(Table table){
fields(table, "w", p3, s -> p3 = s);
fields(table, "h", p4, s -> p4 = s);
}
case buildSpeed, unitHealth, unitBuildSpeed, unitCost, unitDamage, blockHealth, blockDamage, rtsMinSquad, rtsMinWeight -> {
case buildSpeed, unitHealth, unitBuildSpeed, unitCrashDamage, unitMineSpeed, unitCost, unitDamage, blockHealth, blockDamage, rtsMinSquad, rtsMinWeight -> {
if(p1.equals("0")){
p1 = "@sharded";
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/mindustry/logic/LogicRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public enum LogicRule{
buildSpeed,
unitHealth,
unitBuildSpeed,
unitCrashDamage,
unitMineSpeed,
unitCost,
unitDamage,
blockHealth,
Expand Down
1 change: 1 addition & 0 deletions core/src/mindustry/ui/dialogs/CustomRulesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ void setup(){
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.unitminespeedmultiplier", f -> rules.unitMineSpeedMultiplier = f, () -> rules.unitMineSpeedMultiplier);
number("@rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier, 0f, 50f);
number("@rules.unitcostmultiplier", f -> rules.unitCostMultiplier = f, () -> rules.unitCostMultiplier);
number("@rules.unithealthmultiplier", f -> rules.unitHealthMultiplier = f, () -> rules.unitHealthMultiplier);
Expand Down
Loading