diff --git a/build.gradle b/build.gradle index ce7c8060b2..2a44616829 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ allprojects{ if(!project.hasProperty("versionType")) versionType = 'official' appName = 'Mindustry' steamworksVersion = '891ed912791e01fe9ee6237a6497e5212b85c256' - rhinoVersion = 'bf4150f7add42d26c98e33c24acfd94fa87be2e1' + rhinoVersion = '8437435dab9993769d72739608580d40c5343285' loadVersionProps = { return new Properties().with{p -> p.load(file('../core/assets/version.properties').newReader()); return p } diff --git a/core/assets-raw/sprites/units/dagger-leg.png b/core/assets-raw/sprites/units/dagger-leg.png index f67d4257cf..d27c010dbc 100644 Binary files a/core/assets-raw/sprites/units/dagger-leg.png and b/core/assets-raw/sprites/units/dagger-leg.png differ diff --git a/core/assets-raw/sprites/units/mace-leg.png b/core/assets-raw/sprites/units/mace-leg.png index 82aba38b82..bb1b501dfa 100644 Binary files a/core/assets-raw/sprites/units/mace-leg.png and b/core/assets-raw/sprites/units/mace-leg.png differ diff --git a/core/assets-raw/sprites/units/reign-leg.png b/core/assets-raw/sprites/units/reign-leg.png index f4c8c27e6a..1bf212125e 100644 Binary files a/core/assets-raw/sprites/units/reign-leg.png and b/core/assets-raw/sprites/units/reign-leg.png differ diff --git a/core/assets-raw/sprites/units/scepter-leg.png b/core/assets-raw/sprites/units/scepter-leg.png index a7df74e158..80e25079bf 100644 Binary files a/core/assets-raw/sprites/units/scepter-leg.png and b/core/assets-raw/sprites/units/scepter-leg.png differ diff --git a/core/assets/sprites/fallback/sprites.png b/core/assets/sprites/fallback/sprites.png index f899d82f7f..1058af3b38 100644 Binary files a/core/assets/sprites/fallback/sprites.png and b/core/assets/sprites/fallback/sprites.png differ diff --git a/core/assets/sprites/fallback/sprites2.png b/core/assets/sprites/fallback/sprites2.png index eb90163f97..81f5eb28fe 100644 Binary files a/core/assets/sprites/fallback/sprites2.png and b/core/assets/sprites/fallback/sprites2.png differ diff --git a/core/assets/sprites/fallback/sprites3.png b/core/assets/sprites/fallback/sprites3.png index 9636f9e2a8..a56f211cd9 100644 Binary files a/core/assets/sprites/fallback/sprites3.png and b/core/assets/sprites/fallback/sprites3.png differ diff --git a/core/assets/sprites/fallback/sprites4.png b/core/assets/sprites/fallback/sprites4.png index 06aff32753..400e224dbb 100644 Binary files a/core/assets/sprites/fallback/sprites4.png and b/core/assets/sprites/fallback/sprites4.png differ diff --git a/core/assets/sprites/fallback/sprites7.png b/core/assets/sprites/fallback/sprites7.png index b618d04a0c..1e4769f803 100644 Binary files a/core/assets/sprites/fallback/sprites7.png and b/core/assets/sprites/fallback/sprites7.png differ diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index cb283ac218..57a55856db 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/assets/sprites/sprites2.png b/core/assets/sprites/sprites2.png index 5ead94a44d..12d08701a3 100644 Binary files a/core/assets/sprites/sprites2.png and b/core/assets/sprites/sprites2.png differ diff --git a/core/assets/sprites/sprites5.png b/core/assets/sprites/sprites5.png index e98962419a..284ab35a22 100644 Binary files a/core/assets/sprites/sprites5.png and b/core/assets/sprites/sprites5.png differ diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index 7408f35da7..a89b853c28 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -433,6 +433,7 @@ public class Bullets implements ContentList{ hitSize = 7f; lifetime = 18f; pierce = true; + collidesAir = false; statusDuration = 60f * 4; shootEffect = Fx.shootSmallFlame; hitEffect = Fx.hitFlameSmall; @@ -447,6 +448,7 @@ public class Bullets implements ContentList{ hitSize = 7f; lifetime = 18f; pierce = true; + collidesAir = false; statusDuration = 60f * 6; shootEffect = Fx.shootPyraFlame; hitEffect = Fx.hitFlameSmall; diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 51b6631034..8288f7d805 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -103,6 +103,7 @@ public class UnitTypes implements ContentList{ targetAir = false; health = 790; armor = 9f; + mechFrontSway = 0.55f; weapons.add(new Weapon("artillery"){{ y = 1f; @@ -131,11 +132,13 @@ public class UnitTypes implements ContentList{ speed = 0.35f; hitsize = 20f; rotateSpeed = 2.1f; - targetAir = false; health = 9000; armor = 11f; - mechLegMoveScl = 1.3f; canDrown = false; + mechFrontSway = 1f; + + mechStepParticles = true; + mechStepShake = 0.15f; weapons.add( new Weapon("scepter-weapon"){{ @@ -188,11 +191,13 @@ public class UnitTypes implements ContentList{ speed = 0.35f; hitsize = 26f; rotateSpeed = 1.65f; - targetAir = false; health = 24000; armor = 14f; - mechLegMoveScl = 1.75f; + mechStepParticles = true; + mechStepShake = 0.75f; canDrown = false; + mechFrontSway = 1.9f; + mechSideSway = 0.6f; weapons.add( new Weapon("reign-weapon"){{ @@ -201,7 +206,7 @@ public class UnitTypes implements ContentList{ shootY = 11f; reload = 9f; recoil = 5f; - shake = 4f; + shake = 2f; ejectEffect = Fx.shellEjectBig; shootSound = Sounds.artillery; @@ -319,6 +324,7 @@ public class UnitTypes implements ContentList{ landShake = 2f; commandLimit = 24; + mechFrontSway = 0.55f; speed = 0.4f; hitsize = 10f; @@ -357,7 +363,7 @@ public class UnitTypes implements ContentList{ speed = 0.85f; hitsize = 8f; health = 170; - sway = 0.25f; + mechSideSway = 0.25f; range = 40f; weapons.add(new Weapon(){{ diff --git a/core/src/mindustry/entities/EntityCollisions.java b/core/src/mindustry/entities/EntityCollisions.java index 2d8402e92c..b4e2355380 100644 --- a/core/src/mindustry/entities/EntityCollisions.java +++ b/core/src/mindustry/entities/EntityCollisions.java @@ -10,7 +10,7 @@ import static mindustry.Vars.*; public class EntityCollisions{ //range for tile collision scanning - private static final int r = 1; + private static final int r = 2; //move in 1-unit chunks private static final float seg = 1f; diff --git a/core/src/mindustry/entities/EntityGroup.java b/core/src/mindustry/entities/EntityGroup.java index 5a1be4bdc3..1157b83ff9 100644 --- a/core/src/mindustry/entities/EntityGroup.java +++ b/core/src/mindustry/entities/EntityGroup.java @@ -57,7 +57,7 @@ public class EntityGroup implements Iterable{ each(Entityc::update); } - public void copy(Seq arr){ + public void copy(Seq arr){ arr.addAll(array); } diff --git a/core/src/mindustry/entities/comp/MechComp.java b/core/src/mindustry/entities/comp/MechComp.java index d258e75406..407b256136 100644 --- a/core/src/mindustry/entities/comp/MechComp.java +++ b/core/src/mindustry/entities/comp/MechComp.java @@ -8,7 +8,7 @@ import mindustry.gen.*; @Component abstract class MechComp implements Posc, Flyingc, Hitboxc, Unitc, Mechc, ElevationMovec{ @SyncField(false) @SyncLocal float baseRotation; - transient float walkTime; + transient float walkTime, walkExtension; @Override public void update(){ diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 973fd13c6f..458d23ac6c 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -48,7 +48,6 @@ public class UnitType extends UnlockableContent{ public boolean canBoost = false; public boolean destructibleWreck = true; public float groundLayer = Layer.groundUnit; - public float sway = 1f; public float payloadCapacity = 8; public int commandLimit = 24; public float visualElevation = -1f; @@ -62,7 +61,12 @@ public class UnitType extends UnlockableContent{ public float legLength = 10f, legSpeed = 0.1f, legTrns = 1f, legBaseOffset = 0f, legMoveSpace = 1f, legExtension = 0, legPairOffset = 0, legLengthScl = 1f, kinematicScl = 1f, maxStretch = 1.75f; public float legSplashDamage = 0f, legSplashRange = 5; public boolean flipBackLegs = true; - public float mechLegMoveScl = 1f; + + public float mechSideSway = 0.54f, mechFrontSway = 0.1f; + public float mechStride = -1f; + public float mechStepShake = -1f; + public boolean mechStepParticles = false; + public Color mechLegColor = Pal.darkMetal; public int itemCapacity = -1; public int ammoCapacity = 220; @@ -133,6 +137,42 @@ public class UnitType extends UnlockableContent{ a.update(unit); } } + + if(unit instanceof Mechc){ + updateMechEffects(unit); + } + } + + public void updateMechEffects(Unit unit){ + Mechc mech = (Mechc)unit; + + float extend = walkExtend((Mechc)unit, false); + float base = walkExtend((Mechc)unit, true); + float extendScl = base % 1f; + + float lastExtend = mech.walkExtension(); + + if(extendScl < lastExtend && base % 2f > 1f){ + int side = -Mathf.sign(extend); + float width = hitsize / 2f * side, length = mechStride * 1.35f; + + float cx = unit.x + Angles.trnsx(mech.baseRotation(), length, width), + cy = unit.y + Angles.trnsy(mech.baseRotation(), length, width); + + if(mechStepShake > 0){ + Effect.shake(mechStepShake, mechStepShake, cx, cy); + } + + if(mechStepParticles){ + Tile tile = world.tileWorld(cx, cy); + if(tile != null){ + Color color = tile.floor().mapColor; + Fx.unitLand.at(cx, cy, hitsize/8f, color); + } + } + } + + mech.walkExtension(extendScl); } public void landed(Unit unit){} @@ -208,6 +248,15 @@ public class UnitType extends UnlockableContent{ } } + if(mechStride < 0){ + mechStride = 4f + (hitsize-8f)/2.1f; + } + + if(mechStepShake < 0){ + mechStepShake = Mathf.round((hitsize - 11f) / 9f); + mechStepParticles = hitsize > 15f; + } + canHeal = weapons.contains(w -> w.bullet instanceof HealBulletType); //add mirrored weapon variants @@ -286,10 +335,14 @@ public class UnitType extends UnlockableContent{ Draw.z(z - 0.02f); if(mech != null){ - drawMech((Unit & Mechc)mech); + drawMech(mech); + + //side + legOffset.trns(mech.baseRotation(), 0f, Mathf.lerp(Mathf.sin(walkExtend(mech, true), 2f/Mathf.PI, 1) * mechSideSway, 0f, unit.elevation)); + + //front + legOffset.add(Tmp.v1.trns(mech.baseRotation() + 90, 0f, Mathf.lerp(Mathf.sin(walkExtend(mech, true), 1f/Mathf.PI, 1) * mechFrontSway, 0f, unit.elevation))); - float ft = Mathf.sin(mech.walkTime(), 3f * mechLegMoveScl, 3f); - legOffset.trns(mech.baseRotation(), 0f, Mathf.lerp(ft * 0.18f * sway, 0f, unit.elevation)); unit.trns(legOffset.x, legOffset.y); } @@ -551,14 +604,15 @@ public class UnitType extends UnlockableContent{ Draw.reset(); } - public void drawMech(T unit){ + public void drawMech(Mechc mech){ + Unit unit = (Unit)mech; + Draw.reset(); - Draw.mixcol(Color.white, unit.hitTime); - float e = unit.elevation; - float sin = Mathf.lerp(Mathf.sin(unit.walkTime(), 3f * mechLegMoveScl, 1f), 0f, e); - float ft = sin*(2.5f + (unit.hitSize-8f)/2f); + + float sin = Mathf.lerp(Mathf.sin(walkExtend(mech, true), 2f / Mathf.PI, 1f), 0f, e); + float extension = walkExtend(mech, false); float boostTrns = e * 2f; Floor floor = unit.isFlying() ? Blocks.air.asFloor() : unit.floorOn(); @@ -568,25 +622,43 @@ public class UnitType extends UnlockableContent{ } for(int i : Mathf.signs){ + Draw.mixcol(Tmp.c1.set(mechLegColor).lerp(Color.white, Mathf.clamp(unit.hitTime)), Math.max(Math.max(0, i * extension / mechStride), unit.hitTime)); + Draw.rect(legRegion, - unit.x + Angles.trnsx(unit.baseRotation(), ft * i - boostTrns, -boostTrns*i), - unit.y + Angles.trnsy(unit.baseRotation(), ft * i - boostTrns, -boostTrns*i), + unit.x + Angles.trnsx(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i), + unit.y + Angles.trnsy(mech.baseRotation(), extension * i - boostTrns, -boostTrns*i), legRegion.getWidth() * i * Draw.scl, legRegion.getHeight() * Draw.scl - Math.max(-sin * i, 0) * legRegion.getHeight() * 0.5f * Draw.scl, - unit.baseRotation() - 90 + 35f*i*e); + mech.baseRotation() - 90 + 35f*i*e); } + Draw.mixcol(Color.white, unit.hitTime); + if(floor.isLiquid){ Draw.color(Color.white, floor.mapColor, unit.drownTime() * 0.4f); }else{ Draw.color(Color.white); } - Draw.rect(baseRegion, unit, unit.baseRotation() - 90); + Draw.rect(baseRegion, unit, mech.baseRotation() - 90); Draw.mixcol(); } + public float walkExtend(Mechc mech, boolean scaled){ + + //now ranges from -maxExtension to maxExtension*3 + float raw = mech.walkTime() % (mechStride * 4); + + if(scaled) return raw / mechStride; + + if(raw > mechStride*3) raw = raw - mechStride * 4; + else if(raw > mechStride*2) raw = mechStride * 2 - raw; + else if(raw > mechStride) raw = mechStride * 2 - raw; + + return raw; + } + public void applyColor(Unit unit){ Draw.color(); Draw.mixcol(Color.white, unit.hitTime); diff --git a/core/src/mindustry/ui/CoreItemsDisplay.java b/core/src/mindustry/ui/CoreItemsDisplay.java index 140723bb0b..7322f15e70 100644 --- a/core/src/mindustry/ui/CoreItemsDisplay.java +++ b/core/src/mindustry/ui/CoreItemsDisplay.java @@ -39,6 +39,7 @@ public class CoreItemsDisplay extends Table{ for(Item item : content.items()){ if(usedItems.contains(item)){ image(item.icon(Cicon.small)).padRight(3); + //TODO leaks garbage label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))).padRight(3).left(); if(++i % 4 == 0){