Percentage modifier stat for status effects (#10306)
* Percentage modifier stat for status effects * Merge true by default Make percentage symbol inherit the color as well * Multipliers instead of percentages
This commit is contained in:
@@ -1165,6 +1165,7 @@ unit.minutes = mins
|
|||||||
unit.persecond = /sec
|
unit.persecond = /sec
|
||||||
unit.perminute = /min
|
unit.perminute = /min
|
||||||
unit.timesspeed = x speed
|
unit.timesspeed = x speed
|
||||||
|
unit.multiplier = x
|
||||||
unit.percent = %
|
unit.percent = %
|
||||||
unit.shieldhealth = shield health
|
unit.shieldhealth = shield health
|
||||||
unit.items = items
|
unit.items = items
|
||||||
|
|||||||
@@ -90,11 +90,11 @@ public class StatusEffect extends UnlockableContent{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStats(){
|
public void setStats(){
|
||||||
if(damageMultiplier != 1) stats.addPercent(Stat.damageMultiplier, damageMultiplier);
|
if(damageMultiplier != 1) stats.addMultModifier(Stat.damageMultiplier, damageMultiplier);
|
||||||
if(healthMultiplier != 1) stats.addPercent(Stat.healthMultiplier, healthMultiplier);
|
if(healthMultiplier != 1) stats.addMultModifier(Stat.healthMultiplier, healthMultiplier);
|
||||||
if(speedMultiplier != 1) stats.addPercent(Stat.speedMultiplier, speedMultiplier);
|
if(speedMultiplier != 1) stats.addMultModifier(Stat.speedMultiplier, speedMultiplier);
|
||||||
if(reloadMultiplier != 1) stats.addPercent(Stat.reloadMultiplier, reloadMultiplier);
|
if(reloadMultiplier != 1) stats.addMultModifier(Stat.reloadMultiplier, reloadMultiplier);
|
||||||
if(buildSpeedMultiplier != 1) stats.addPercent(Stat.buildSpeedMultiplier, buildSpeedMultiplier);
|
if(buildSpeedMultiplier != 1) stats.addMultModifier(Stat.buildSpeedMultiplier, buildSpeedMultiplier);
|
||||||
if(damage > 0) stats.add(Stat.damage, damage * 60f, StatUnit.perSecond);
|
if(damage > 0) stats.add(Stat.damage, damage * 60f, StatUnit.perSecond);
|
||||||
if(damage < 0) stats.add(Stat.healing, -damage * 60f, StatUnit.perSecond);
|
if(damage < 0) stats.add(Stat.healing, -damage * 60f, StatUnit.perSecond);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class StatUnit{
|
|||||||
perMinute = new StatUnit("perMinute", false),
|
perMinute = new StatUnit("perMinute", false),
|
||||||
perShot = new StatUnit("perShot", false),
|
perShot = new StatUnit("perShot", false),
|
||||||
timesSpeed = new StatUnit("timesSpeed", false),
|
timesSpeed = new StatUnit("timesSpeed", false),
|
||||||
|
multiplier = new StatUnit("multiplier", false),
|
||||||
percent = new StatUnit("percent", false),
|
percent = new StatUnit("percent", false),
|
||||||
shieldHealth = new StatUnit("shieldHealth"),
|
shieldHealth = new StatUnit("shieldHealth"),
|
||||||
none = new StatUnit("none"),
|
none = new StatUnit("none"),
|
||||||
|
|||||||
@@ -69,6 +69,48 @@ public class StatValues{
|
|||||||
return number(value, unit, false);
|
return number(value, unit, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StatValue multiplierModifier(float value, StatUnit unit, boolean merge){
|
||||||
|
return table -> {
|
||||||
|
String l1 = (unit.icon == null ? "" : unit.icon + " ") + multStat(value), l2 = (unit.space ? " " : "") + unit.localized();
|
||||||
|
|
||||||
|
if(merge){
|
||||||
|
table.add(l1 + l2).left();
|
||||||
|
}else{
|
||||||
|
table.add(l1).left();
|
||||||
|
table.add(l2).left();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatValue multiplierModifier(float value, StatUnit unit){
|
||||||
|
return multiplierModifier(value, unit, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatValue multiplierModifier(float value){
|
||||||
|
return multiplierModifier(value, StatUnit.multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatValue percentModifier(float value, StatUnit unit, boolean merge){
|
||||||
|
return table -> {
|
||||||
|
String l1 = (unit.icon == null ? "" : unit.icon + " ") + ammoStat((value - 1) * 100), l2 = (unit.space ? " " : "") + unit.localized();
|
||||||
|
|
||||||
|
if(merge){
|
||||||
|
table.add(l1 + l2).left();
|
||||||
|
}else{
|
||||||
|
table.add(l1).left();
|
||||||
|
table.add(l2).left();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatValue percentModifier(float value, StatUnit unit){
|
||||||
|
return percentModifier(value, unit, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatValue percentModifier(float value){
|
||||||
|
return percentModifier(value, StatUnit.percent);
|
||||||
|
}
|
||||||
|
|
||||||
public static StatValue liquid(Liquid liquid, float amount, boolean perSecond){
|
public static StatValue liquid(Liquid liquid, float amount, boolean perSecond){
|
||||||
return table -> table.add(displayLiquid(liquid, amount, perSecond));
|
return table -> table.add(displayLiquid(liquid, amount, perSecond));
|
||||||
}
|
}
|
||||||
@@ -691,6 +733,10 @@ public class StatValues{
|
|||||||
return (val > 0 ? "[stat]+" : "[negstat]") + Strings.autoFixed(val, 1);
|
return (val > 0 ? "[stat]+" : "[negstat]") + Strings.autoFixed(val, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String multStat(float val){
|
||||||
|
return (val >= 1 ? "[stat]" : "[negstat]") + Strings.autoFixed(val, 2);
|
||||||
|
}
|
||||||
|
|
||||||
private static TextureRegion icon(UnlockableContent t){
|
private static TextureRegion icon(UnlockableContent t){
|
||||||
return t.uiIcon;
|
return t.uiIcon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ public class Stats{
|
|||||||
add(stat, StatValues.number((int)(value * 100), StatUnit.percent));
|
add(stat, StatValues.number((int)(value * 100), StatUnit.percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Adds a multiplicative modifier stat value. Value is assumed to be in the 0-1 range. */
|
||||||
|
public void addMultModifier(Stat stat, float value){
|
||||||
|
add(stat, StatValues.multiplierModifier(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds an percent modifier stat value. Value is assumed to be in the 0-1 range. */
|
||||||
|
public void addPercentModifier(Stat stat, float value){
|
||||||
|
add(stat, StatValues.percentModifier(value));
|
||||||
|
}
|
||||||
|
|
||||||
/** Adds a single y/n boolean value. */
|
/** Adds a single y/n boolean value. */
|
||||||
public void add(Stat stat, boolean value){
|
public void add(Stat stat, boolean value){
|
||||||
add(stat, StatValues.bool(value));
|
add(stat, StatValues.bool(value));
|
||||||
|
|||||||
Reference in New Issue
Block a user