Support for team-specific multipliers (no UI)
This commit is contained in:
@@ -10,7 +10,6 @@ import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -33,7 +32,7 @@ public class UnitSpawnAbility extends Ability{
|
||||
|
||||
@Override
|
||||
public void update(Unit unit){
|
||||
timer += Time.delta * state.rules.unitBuildSpeedMultiplier;
|
||||
timer += Time.delta * state.rules.unitBuildSpeed(unit.team);
|
||||
|
||||
if(timer >= spawnTime && Units.canCreate(unit.team, this.unit)){
|
||||
float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX);
|
||||
|
||||
@@ -124,11 +124,13 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
||||
return;
|
||||
}
|
||||
|
||||
float bs = 1f / entity.buildCost * Time.delta * type.buildSpeed * buildSpeedMultiplier * state.rules.buildSpeed(team);
|
||||
|
||||
//otherwise, update it.
|
||||
if(current.breaking){
|
||||
entity.deconstruct(self(), core, 1f / entity.buildCost * Time.delta * type.buildSpeed * buildSpeedMultiplier * state.rules.buildSpeedMultiplier);
|
||||
entity.deconstruct(self(), core, bs);
|
||||
}else{
|
||||
entity.construct(self(), core, 1f / entity.buildCost * Time.delta * type.buildSpeed * buildSpeedMultiplier * state.rules.buildSpeedMultiplier, current.config);
|
||||
entity.construct(self(), core, bs, current.config);
|
||||
}
|
||||
|
||||
current.stuck = Mathf.equal(current.progress, entity.progress);
|
||||
|
||||
@@ -1378,10 +1378,12 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
public void damage(float damage){
|
||||
if(dead()) return;
|
||||
|
||||
if(Mathf.zero(state.rules.blockHealthMultiplier)){
|
||||
float dm = state.rules.blockHealth(team);
|
||||
|
||||
if(Mathf.zero(dm)){
|
||||
damage = health + 1;
|
||||
}else{
|
||||
damage /= state.rules.blockHealthMultiplier;
|
||||
damage /= dm;
|
||||
}
|
||||
|
||||
Call.tileDamage(self(), health - handleDamage(damage));
|
||||
|
||||
@@ -68,8 +68,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
|
||||
@Override
|
||||
public float damageMultiplier(){
|
||||
if(owner instanceof Unit u) return u.damageMultiplier() * state.rules.unitDamageMultiplier;
|
||||
if(owner instanceof Building) return state.rules.blockDamageMultiplier;
|
||||
if(owner instanceof Unit u) return u.damageMultiplier() * state.rules.unitDamage(team);
|
||||
if(owner instanceof Building) return state.rules.blockDamage(team);
|
||||
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@@ -140,6 +140,26 @@ public class Rules{
|
||||
}
|
||||
}
|
||||
|
||||
public float unitBuildSpeed(Team team){
|
||||
return unitBuildSpeedMultiplier * teams.get(team).unitBuildSpeedMultiplier;
|
||||
}
|
||||
|
||||
public float unitDamage(Team team){
|
||||
return unitDamageMultiplier * teams.get(team).unitDamageMultiplier;
|
||||
}
|
||||
|
||||
public float blockHealth(Team team){
|
||||
return blockHealthMultiplier * teams.get(team).blockHealthMultiplier;
|
||||
}
|
||||
|
||||
public float blockDamage(Team team){
|
||||
return blockDamageMultiplier * teams.get(team).blockDamageMultiplier;
|
||||
}
|
||||
|
||||
public float buildSpeed(Team team){
|
||||
return buildSpeedMultiplier * teams.get(team).buildSpeedMultiplier;
|
||||
}
|
||||
|
||||
/** A team-specific ruleset. */
|
||||
public static class TeamRule{
|
||||
/** Whether to use building AI. */
|
||||
@@ -154,6 +174,19 @@ public class Rules{
|
||||
public boolean infiniteResources;
|
||||
/** If true, this team has infinite unit ammo. */
|
||||
public boolean infiniteAmmo;
|
||||
|
||||
/** How fast unit factories build units. */
|
||||
public float unitBuildSpeedMultiplier = 1f;
|
||||
/** How much damage any other units deal. */
|
||||
public float unitDamageMultiplier = 1f;
|
||||
/** How much health blocks start with. */
|
||||
public float blockHealthMultiplier = 1f;
|
||||
/** How much damage blocks (turrets) deal. */
|
||||
public float blockDamageMultiplier = 1f;
|
||||
/** Multiplier for building speed. */
|
||||
public float buildSpeedMultiplier = 1f;
|
||||
|
||||
//build cost disabled due to technical complexity
|
||||
}
|
||||
|
||||
/** A simple map for storing TeamRules in an efficient way without hashing. */
|
||||
|
||||
@@ -197,7 +197,7 @@ public class Reconstructor extends UnitBlock{
|
||||
if(moveInPayload()){
|
||||
if(consValid()){
|
||||
valid = true;
|
||||
progress += edelta() * state.rules.unitBuildSpeedMultiplier;
|
||||
progress += edelta() * state.rules.unitBuildSpeed(team);
|
||||
}
|
||||
|
||||
//upgrade the unit
|
||||
@@ -214,7 +214,7 @@ public class Reconstructor extends UnitBlock{
|
||||
}
|
||||
|
||||
speedScl = Mathf.lerpDelta(speedScl, Mathf.num(valid), 0.05f);
|
||||
time += edelta() * speedScl * state.rules.unitBuildSpeedMultiplier;
|
||||
time += edelta() * speedScl * state.rules.unitBuildSpeed(team);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -213,8 +213,8 @@ public class UnitFactory extends UnitBlock{
|
||||
}
|
||||
|
||||
if(consValid() && currentPlan != -1){
|
||||
time += edelta() * speedScl * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
progress += edelta() * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
time += edelta() * speedScl * Vars.state.rules.unitBuildSpeed(team);
|
||||
progress += edelta() * Vars.state.rules.unitBuildSpeed(team);
|
||||
speedScl = Mathf.lerpDelta(speedScl, 1f, 0.05f);
|
||||
}else{
|
||||
speedScl = Mathf.lerpDelta(speedScl, 0f, 0.05f);
|
||||
|
||||
Reference in New Issue
Block a user