Improvements of status effects in database
This commit is contained in:
@@ -12,7 +12,7 @@ import mindustry.graphics.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class StatusEffects implements ContentList{
|
||||
public static StatusEffect none, burning, freezing, unmoving, slow, wet, muddy, melting, sapped, tarred, overdrive, overclock, shielded, shocked, blasted, corroded, boss, sporeSlowed, disarmed;
|
||||
public static StatusEffect none, burning, freezing, unmoving, slow, wet, muddy, melting, sapped, tarred, overdrive, overclock, shielded, shocked, blasted, boss, sporeSlowed, disarmed;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -20,14 +20,15 @@ public class StatusEffects implements ContentList{
|
||||
none = new StatusEffect("none");
|
||||
|
||||
burning = new StatusEffect("burning"){{
|
||||
color = Pal.lightFlame;
|
||||
color = Color.valueOf("ffc455");
|
||||
damage = 0.12f; //over 8 seconds, this would be ~60 damage
|
||||
effect = Fx.burning;
|
||||
transitionDamage = 8f;
|
||||
|
||||
init(() -> {
|
||||
opposite(wet, freezing);
|
||||
affinity(tarred, ((unit, time, newTime, result) -> {
|
||||
unit.damagePierce(8f);
|
||||
unit.damagePierce(transitionDamage);
|
||||
Fx.burning.at(unit.x + Mathf.range(unit.bounds() / 2f), unit.y + Mathf.range(unit.bounds() / 2f));
|
||||
result.set(burning, Math.min(time + newTime, 300f));
|
||||
}));
|
||||
@@ -39,12 +40,13 @@ public class StatusEffects implements ContentList{
|
||||
speedMultiplier = 0.6f;
|
||||
healthMultiplier = 0.8f;
|
||||
effect = Fx.freezing;
|
||||
transitionDamage = 18f;
|
||||
|
||||
init(() -> {
|
||||
opposite(melting, burning);
|
||||
|
||||
affinity(blasted, ((unit, time, newTime, result) -> {
|
||||
unit.damagePierce(18f);
|
||||
unit.damagePierce(transitionDamage);
|
||||
result.set(freezing, time);
|
||||
}));
|
||||
});
|
||||
@@ -65,10 +67,11 @@ public class StatusEffects implements ContentList{
|
||||
speedMultiplier = 0.94f;
|
||||
effect = Fx.wet;
|
||||
effectChance = 0.09f;
|
||||
transitionDamage = 14;
|
||||
|
||||
init(() -> {
|
||||
affinity(shocked, ((unit, time, newTime, result) -> {
|
||||
unit.damagePierce(14f);
|
||||
unit.damagePierce(transitionDamage);
|
||||
if(unit.team == state.rules.waveTeam){
|
||||
Events.fire(Trigger.shock);
|
||||
}
|
||||
@@ -169,11 +172,6 @@ public class StatusEffects implements ContentList{
|
||||
reactive = true;
|
||||
}};
|
||||
|
||||
corroded = new StatusEffect("corroded"){{
|
||||
color = Pal.plastanium;
|
||||
damage = 0.1f;
|
||||
}};
|
||||
|
||||
disarmed = new StatusEffect("disarmed"){{
|
||||
color = Color.valueOf("e9ead3");
|
||||
disarm = true;
|
||||
|
||||
@@ -139,7 +139,9 @@ public class Control implements ApplicationListener, Loadable{
|
||||
}));
|
||||
|
||||
Events.on(UnlockEvent.class, e -> {
|
||||
ui.hudfrag.showUnlock(e.content);
|
||||
if(e.content.showUnlock()){
|
||||
ui.hudfrag.showUnlock(e.content);
|
||||
}
|
||||
|
||||
checkAutoUnlocks();
|
||||
|
||||
|
||||
@@ -95,6 +95,10 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
return cicons[icon.ordinal()];
|
||||
}
|
||||
|
||||
public Cicon prefDatabaseIcon(){
|
||||
return Cicon.xlarge;
|
||||
}
|
||||
|
||||
/** Iterates through any implicit dependencies of this content.
|
||||
* For blocks, this would be the items required to build it. */
|
||||
public void getDependencies(Cons<UnlockableContent> cons){
|
||||
@@ -115,6 +119,11 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return whether to show a notification toast when this is unlocked */
|
||||
public boolean showUnlock(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Makes this piece of content unlocked; if it already unlocked, nothing happens. */
|
||||
public void unlock(){
|
||||
if(!unlocked && !alwaysUnlocked){
|
||||
|
||||
@@ -33,6 +33,11 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
void apply(StatusEffect effect, float duration){
|
||||
if(effect == StatusEffects.none || effect == null || isImmune(effect)) return; //don't apply empty or immune effects
|
||||
|
||||
//unlock status effects regardless of whether they were applied to friendly units
|
||||
if(state.isCampaign()){
|
||||
effect.unlock();
|
||||
}
|
||||
|
||||
if(statuses.size > 0){
|
||||
//check for opposite effects
|
||||
for(int i = 0; i < statuses.size; i ++){
|
||||
|
||||
@@ -208,9 +208,7 @@ public class JsonIO{
|
||||
static class CustomJson extends Json{
|
||||
private Object baseObject;
|
||||
|
||||
{
|
||||
apply(this);
|
||||
}
|
||||
{ apply(this); }
|
||||
|
||||
@Override
|
||||
public <T> T fromJson(Class<T> type, String json){
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.type;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
@@ -10,8 +9,8 @@ import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class StatusEffect extends UnlockableContent{
|
||||
/** Damage dealt by the unit with the effect. */
|
||||
@@ -24,6 +23,8 @@ public class StatusEffect extends UnlockableContent{
|
||||
public float reloadMultiplier = 1f;
|
||||
/** Unit build speed multiplier. */
|
||||
public float buildSpeedMultiplier = 1f;
|
||||
/** Damage dealt upon transition to an affinity. */
|
||||
public float transitionDamage = 0f;
|
||||
/** Unit weapon(s) disabled. */
|
||||
public boolean disarm = false;
|
||||
/** Damage per frame. */
|
||||
@@ -66,37 +67,39 @@ public class StatusEffect extends UnlockableContent{
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
if(damageMultiplier != 1){
|
||||
stats.addPercent(Stat.damageMultiplier, damageMultiplier);
|
||||
if(damageMultiplier != 1) stats.addPercent(Stat.damageMultiplier, damageMultiplier);
|
||||
if(healthMultiplier != 1) stats.addPercent(Stat.healthMultiplier, healthMultiplier);
|
||||
if(speedMultiplier != 1) stats.addPercent(Stat.speedMultiplier, speedMultiplier);
|
||||
if(reloadMultiplier != 1) stats.addPercent(Stat.reloadMultiplier, reloadMultiplier);
|
||||
if(buildSpeedMultiplier != 1) stats.addPercent(Stat.buildSpeedMultiplier, buildSpeedMultiplier);
|
||||
if(damage > 0) stats.add(Stat.damage, damage * 60f, StatUnit.perSecond);
|
||||
|
||||
var afseq = affinities.asArray().sort();
|
||||
var opseq = opposites.asArray().sort();
|
||||
|
||||
for(int i = 0; i < afseq.size; i++){
|
||||
var e = afseq.get(i);
|
||||
stats.add(Stat.affinities, e.emoji() + "" + e.toString());
|
||||
}
|
||||
|
||||
if(afseq.any() && transitionDamage != 0){
|
||||
stats.add(Stat.affinities, "/ [accent]" + (int)transitionDamage + " " + Stat.damage.localized());
|
||||
}
|
||||
|
||||
if(healthMultiplier != 1){
|
||||
stats.addPercent(Stat.healthMultiplier, healthMultiplier);
|
||||
for(int i = 0; i < opseq.size; i++){
|
||||
var e = opseq.get(i);
|
||||
stats.add(Stat.opposites, e.emoji() + "" + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if(speedMultiplier != 1){
|
||||
stats.addPercent(Stat.speedMultiplier, speedMultiplier);
|
||||
}
|
||||
@Override
|
||||
public Cicon prefDatabaseIcon(){
|
||||
return Cicon.large;
|
||||
}
|
||||
|
||||
if(reloadMultiplier != 1){
|
||||
stats.addPercent(Stat.reloadMultiplier, reloadMultiplier);
|
||||
}
|
||||
|
||||
if(buildSpeedMultiplier != 1){
|
||||
stats.addPercent(Stat.buildSpeedMultiplier, buildSpeedMultiplier);
|
||||
}
|
||||
|
||||
if(damage > 0){
|
||||
stats.add(Stat.damage, damage * 60f, StatUnit.perSecond);
|
||||
}
|
||||
|
||||
for(StatusEffect e : affinities){
|
||||
stats.add(Stat.affinities, e.toString(), StatUnit.none);
|
||||
}
|
||||
|
||||
for(StatusEffect e : opposites){
|
||||
stats.add(Stat.opposites, e.toString(), StatUnit.none);
|
||||
}
|
||||
@Override
|
||||
public boolean showUnlock(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Runs every tick on the affected unit while time is greater than 0. */
|
||||
|
||||
@@ -6,7 +6,6 @@ import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class ContentInfoDialog extends BaseDialog{
|
||||
@@ -27,9 +26,9 @@ public class ContentInfoDialog extends BaseDialog{
|
||||
content.checkStats();
|
||||
|
||||
table.table(title1 -> {
|
||||
int size = 8 * 6;
|
||||
var size = content.prefDatabaseIcon();
|
||||
|
||||
title1.image(content.icon(Cicon.xlarge)).size(size).scaling(Scaling.fit);
|
||||
title1.image(content.icon(size)).size(size.size).scaling(Scaling.fit);
|
||||
title1.add("[accent]" + content.localizedName).padLeft(5);
|
||||
});
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ public class MessageBlock extends Block{
|
||||
for(int i = 0; i < text.length(); i++){
|
||||
char c = text.charAt(i);
|
||||
if(c == '\n'){
|
||||
count ++;
|
||||
if(count <= maxNewlines){
|
||||
if(count++ <= maxNewlines){
|
||||
tile.message.append('\n');
|
||||
}
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user