diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 465d83a44c..5ec95a64bd 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -635,6 +635,8 @@ stat.memorycapacity = Memory Capacity stat.basepowergeneration = Base Power Generation stat.productiontime = Production Time stat.repairtime = Block Full Repair Time +stat.weapons = Weapons +stat.bullet = Bullet stat.speedincrease = Speed Increase stat.range = Range stat.drilltier = Drillables @@ -704,12 +706,14 @@ units.processorcontrol = [lightgray]Processor Controlled bullet.damage = [stat]{0}[lightgray] damage bullet.splashdamage = [stat]{0}[lightgray] area dmg ~[stat] {1}[lightgray] tiles bullet.incendiary = [stat]incendiary +bullet.sapping = [stat]sapping bullet.homing = [stat]homing bullet.shock = [stat]shock bullet.frag = [stat]frag bullet.knockback = [stat]{0}[lightgray] knockback bullet.pierce = [stat]{0}[lightgray]x pierce bullet.infinitepierce = [stat]pierce +bullet.healpercent = [stat]{0}[lightgray]% healing bullet.freezing = [stat]freezing bullet.tarred = [stat]tarred bullet.multiplier = [stat]{0}[lightgray]x ammo multiplier diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 0decd0539a..4a0949a17a 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -337,6 +337,8 @@ public class UnitTypes implements ContentList{ lightningLength = 7; lightningLengthRand = 7; shootEffect = Fx.shootHeal; + //Does not actually do anything; Just here to make stats work + healPercent = 2f; lightningType = new BulletType(0.0001f, 0f){{ lifetime = Fx.lightning.lifetime; diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 35368f47c3..2f48e6bf91 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -231,6 +231,8 @@ public class UnitType extends UnlockableContent{ if(inst instanceof Payloadc){ stats.add(Stat.payloadCapacity, (payloadCapacity / (tilesize * tilesize)), StatUnit.blocksSquared); } + + stats.add(Stat.weapons, new WeaponListValue(this, weapons)); } @CallSuper diff --git a/core/src/mindustry/world/meta/Stat.java b/core/src/mindustry/world/meta/Stat.java index 718dbb8f2d..8f1d23820b 100644 --- a/core/src/mindustry/world/meta/Stat.java +++ b/core/src/mindustry/world/meta/Stat.java @@ -55,6 +55,9 @@ public enum Stat{ linkRange(StatCat.crafting), instructions(StatCat.crafting), + weapons(StatCat.function), + bullet(StatCat.function), + speedIncrease(StatCat.function), repairTime(StatCat.function), range(StatCat.function), diff --git a/core/src/mindustry/world/meta/values/AmmoListValue.java b/core/src/mindustry/world/meta/values/AmmoListValue.java index ba6a0d8a50..9cd89b18d9 100644 --- a/core/src/mindustry/world/meta/values/AmmoListValue.java +++ b/core/src/mindustry/world/meta/values/AmmoListValue.java @@ -1,6 +1,7 @@ package mindustry.world.meta.values; import arc.*; +import arc.func.*; import arc.graphics.g2d.*; import arc.math.*; import arc.scene.ui.layout.*; @@ -10,6 +11,7 @@ import mindustry.content.*; import mindustry.ctype.*; import mindustry.entities.bullet.*; import mindustry.gen.*; +import mindustry.type.*; import mindustry.ui.*; import mindustry.world.meta.*; @@ -28,9 +30,12 @@ public class AmmoListValue implements StatValue{ table.row(); for(T t : map.keys()){ BulletType type = map.get(t); - table.image(icon(t)).size(3 * 8).padRight(4).right().top(); - table.add(t.localizedName).padRight(10).left().top(); - table.table(Tex.underline, bt -> { + //no point in displaying unit icon twice + if(!(t instanceof UnitType)){ + table.image(icon(t)).size(3 * 8).padRight(4).right().top(); + table.add(t.localizedName).padRight(10).left().top(); + } + Cons tableCons = bt -> { bt.left().defaults().padRight(3).left(); if(type.damage > 0 && (type.collides || type.splashDamage <= 0)){ @@ -41,7 +46,7 @@ public class AmmoListValue implements StatValue{ sep(bt, Core.bundle.format("bullet.splashdamage", (int)type.splashDamage, Strings.fixed(type.splashDamageRadius / tilesize, 1))); } - if(!Mathf.equal(type.ammoMultiplier, 1f) && !(type instanceof LiquidBulletType)){ + if(!(t instanceof UnitType) && !Mathf.equal(type.ammoMultiplier, 1f) && !(type instanceof LiquidBulletType)){ sep(bt, Core.bundle.format("bullet.multiplier", (int)type.ammoMultiplier)); } @@ -53,10 +58,15 @@ public class AmmoListValue implements StatValue{ sep(bt, Core.bundle.format("bullet.knockback", Strings.fixed(type.knockback, 1))); } - if(type.pierce || type.pierceCap != -1){ + //sap bullets don't really have pierce + if((type.pierce || type.pierceCap != -1) && !(type instanceof SapBulletType)){ sep(bt, type.pierceCap == -1 ? "@bullet.infinitepierce" : Core.bundle.format("bullet.pierce", type.pierceCap)); } + if((type.healPercent > 0f)){ + sep(bt, Core.bundle.format("bullet.healpercent", (int)type.healPercent)); + } + if((type.status == StatusEffects.burning || type.status == StatusEffects.melting) || type.incendAmount > 0){ sep(bt, "@bullet.incendiary"); } @@ -69,6 +79,10 @@ public class AmmoListValue implements StatValue{ sep(bt, "@bullet.tarred"); } + if(type.status == StatusEffects.sapped){ + sep(bt, "@bullet.sapping"); + } + if(type.homingPower > 0.01f){ sep(bt, "@bullet.homing"); } @@ -80,7 +94,12 @@ public class AmmoListValue implements StatValue{ if(type.fragBullet != null){ sep(bt, "@bullet.frag"); } - }).left().padTop(-9); + }; + if(t instanceof UnitType){ + table.table(tableCons); + }else{ + table.table(Tex.underline, tableCons).left().padTop(-9); + } table.row(); } } diff --git a/core/src/mindustry/world/meta/values/WeaponListValue.java b/core/src/mindustry/world/meta/values/WeaponListValue.java new file mode 100644 index 0000000000..be50d94c29 --- /dev/null +++ b/core/src/mindustry/world/meta/values/WeaponListValue.java @@ -0,0 +1,57 @@ +package mindustry.world.meta.values; + +import arc.*; +import arc.util.*; +import arc.scene.ui.layout.*; +import arc.struct.*; +import mindustry.gen.*; +import mindustry.type.*; +import mindustry.ui.*; +import mindustry.world.meta.*; + +import static mindustry.Vars.*; + +public class WeaponListValue implements StatValue{ + private final Seq weapons; + private final UnitType unit; + + public WeaponListValue(UnitType unit, Seq weapons){ + this.weapons = weapons; + this.unit = unit; + } + + @Override + public void display(Table table){ + table.row(); + for(int i = 0;i < weapons.size;i ++){ + Weapon weapon = weapons.get(i); + + if(weapon.flipSprite){ + //fliped weapons are not given stats + continue; + } + + if(weapon.outlineRegion.found()){ + table.image(weapon.outlineRegion).size(10 * 8).scaling(Scaling.fit).right().top(); + }else{ + table.image(unit.icon(Cicon.full)).size(10 * 8).scaling(Scaling.fit).right().top(); + } + table.table(Tex.underline, w -> { + w.left().defaults().padRight(3).left(); + + sep(w, "[lightgray]" + Stat.inaccuracy.localized() + ": [white]" + (int)weapon.inaccuracy + " " + StatUnit.degrees.localized()); + sep(w, "[lightgray]" + Stat.reload.localized() + ": " + (weapon.mirror ? "2x " : "") + "[white]" + Strings.autoFixed(60f / weapon.reload * weapon.shots, 1)); + sep(w, "[lightgray]" + Stat.bullet.localized() + ":"); + + AmmoListValue bullet = new AmmoListValue(OrderedMap.of(unit, weapon.bullet)); + bullet.display(w); + }).left().padTop(-9); + table.row(); + } + } + + void sep(Table table, String text){ + table.row(); + table.add(text); + } +} diff --git a/tools/src/mindustry/tools/Generators.java b/tools/src/mindustry/tools/Generators.java index 2b56d76a4e..1350a0ff24 100644 --- a/tools/src/mindustry/tools/Generators.java +++ b/tools/src/mindustry/tools/Generators.java @@ -504,7 +504,6 @@ public class Generators{ scaled.save(type.name + "-icon-logic"); } } - }catch(IllegalArgumentException e){ Log.err("WARNING: Skipping unit @: @", type.name, e.getMessage()); }